{"action":"created","issue":{"url":"https://api.github.com/repos/alashworth/test-issue-import/issues/65","repository_url":"https://api.github.com/repos/alashworth/test-issue-import","labels_url":"https://api.github.com/repos/alashworth/test-issue-import/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/alashworth/test-issue-import/issues/65/comments","events_url":"https://api.github.com/repos/alashworth/test-issue-import/issues/65/events","html_url":"https://github.com/alashworth/test-issue-import/issues/65","id":419883288,"node_id":"MDU6SXNzdWU0MTk4ODMyODg=","number":65,"title":"ragged array assignment (not declaration)","user":{"login":"alashworth","id":3664221,"node_id":"MDQ6VXNlcjM2NjQyMjE=","avatar_url":"https://avatars3.githubusercontent.com/u/3664221?v=4","gravatar_id":"","url":"https://api.github.com/users/alashworth","html_url":"https://github.com/alashworth","followers_url":"https://api.github.com/users/alashworth/followers","following_url":"https://api.github.com/users/alashworth/following{/other_user}","gists_url":"https://api.github.com/users/alashworth/gists{/gist_id}","starred_url":"https://api.github.com/users/alashworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alashworth/subscriptions","organizations_url":"https://api.github.com/users/alashworth/orgs","repos_url":"https://api.github.com/users/alashworth/repos","events_url":"https://api.github.com/users/alashworth/events{/privacy}","received_events_url":"https://api.github.com/users/alashworth/received_events","type":"User","site_admin":false},"labels":[{"id":1269293423,"node_id":"MDU6TGFiZWwxMjY5MjkzNDIz","url":"https://api.github.com/repos/alashworth/test-issue-import/labels/feature","name":"feature","color":"84b6eb","default":false},{"id":1269293438,"node_id":"MDU6TGFiZWwxMjY5MjkzNDM4","url":"https://api.github.com/repos/alashworth/test-issue-import/labels/language","name":"language","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/alashworth/test-issue-import/milestones/1","html_url":"https://github.com/alashworth/test-issue-import/milestone/1","labels_url":"https://api.github.com/repos/alashworth/test-issue-import/milestones/1/labels","id":4132534,"node_id":"MDk6TWlsZXN0b25lNDEzMjUzNA==","number":1,"title":"Future","description":"For tasks and features not scheduled for the next release.","creator":{"login":"alashworth","id":3664221,"node_id":"MDQ6VXNlcjM2NjQyMjE=","avatar_url":"https://avatars3.githubusercontent.com/u/3664221?v=4","gravatar_id":"","url":"https://api.github.com/users/alashworth","html_url":"https://github.com/alashworth","followers_url":"https://api.github.com/users/alashworth/followers","following_url":"https://api.github.com/users/alashworth/following{/other_user}","gists_url":"https://api.github.com/users/alashworth/gists{/gist_id}","starred_url":"https://api.github.com/users/alashworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alashworth/subscriptions","organizations_url":"https://api.github.com/users/alashworth/orgs","repos_url":"https://api.github.com/users/alashworth/repos","events_url":"https://api.github.com/users/alashworth/events{/privacy}","received_events_url":"https://api.github.com/users/alashworth/received_events","type":"User","site_admin":false},"open_issues":59,"closed_issues":0,"state":"open","created_at":"2019-03-12T09:12:12Z","updated_at":"2019-03-12T09:31:35Z","due_on":null,"closed_at":null},"comments":18,"created_at":"2019-03-12T09:31:35Z","updated_at":"2019-03-12T09:32:10Z","closed_at":null,"author_association":"OWNER","body":"<a href=\"https://github.com/bob-carpenter\"><img src=\"https://avatars1.githubusercontent.com/u/3383807?v=4\" align=\"left\" width=\"96\" height=\"96\" hspace=\"10\"></img></a> **Issue by [bob-carpenter](https://github.com/bob-carpenter)**\n_Saturday Mar 14, 2015 at 03:59 GMT_\n_Originally opened as https://github.com/stan-dev/stan/issues/1369_\n\n----\n\nFrom Ben Goodrich on stan-dev:\n\nOK. I invented a new rule (locally): You are allowed to assign anything to a matrix with 0 rows and 0 columns. So, this now works:\n\n```\nmodel {\n  matrix[0,0] X[2];\n  vector[4] ones;\n  ones[1] <- 1;\n  ones[2] <- 1;\n  ones[3] <- 1;\n  ones[4] <- 1;\n  X[1] <- diag_matrix(ones);\n  theta ~ normal(0,1);\n}\n```\n\nBut it would probably be better to support (outside of the data and parameters blocks)\n\n```\nmatrix X[2]; \n// parse to vector<Eigen::Matrix<T__,Eigen::Dynamic,Eigen::Dynamic> > X(2);\n// i.e. no fill value after the 2\n```\n\nrather than making users declare\n\n```\nmatrix[0,0] X[2];\n```\n\nI think we're good in that case in the sense that this runs so I guess the column vector gets promoted:\n\n```\n#include <vector>\n#include <Eigen/Dense>\n\nint main() {\n  std::vector<Eigen::Matrixd> > x(2);\n  Eigen::MatrixXd m(2,2);\n  m(0,0) = 3;\n  m(1,0) = 2.5;\n  m(0,1) = -1;\n  m(1,1) = m(1,0) + m(0,1);\n  x[0] = m;\n  x[1] = m.col(1);\n  return 0;\n}\n```\n\nHowever, the comment in `src/stan/math/prim/mat/fun/assign.hpp` does not seem to match what the code does. I had to do trial and error to figure out that this was being called rather than the one above it that allegedly fires when the dimensions do not match. \n\n```\n/** \n * Copy the right-hand side's value to the left-hand side \n * variable. \n * \n * The <code>assign()</code> function is overloaded.  This \n * instance will be called for arguments that are both \n * <code>Eigen::Matrix</code> types and whose shapes match.  The \n * shapes are specified in the row and column template parameters. \n * \n * @tparam LHS Type of left-hand side matrix elements. \n * @tparam RHS Type of right-hand side matrix elements. \n * @tparam R Row shape of both matrices. \n * @tparam C Column shape of both mtarices. \n * @param x Left-hand side matrix. \n * @param y Right-hand side matrix. \n * @throw std::invalid_argument if sizes do not match. \n */ \ntemplate <typename LHS, typename RHS, int R, int C> \ninline void \nassign(Eigen::Matrix<LHS,R,C>& x, \n       const Eigen::Matrix<RHS,R,C>& y) { \n  if(x.rows() == 0 && x.cols() == 0) { \n    x = y; \n    return ; \n  } \n  stan::math::check_matching_dims(\"assign\", \n                                            \"x\", x, \n                                            \"y\", y); \n  for (int i = 0; i < x.size(); ++i) \n    assign(x(i),y(i)); \n} \n```\n\n"},"comment":{"url":"https://api.github.com/repos/alashworth/test-issue-import/issues/comments/471923294","html_url":"https://github.com/alashworth/test-issue-import/issues/65#issuecomment-471923294","issue_url":"https://api.github.com/repos/alashworth/test-issue-import/issues/65","id":471923294,"node_id":"MDEyOklzc3VlQ29tbWVudDQ3MTkyMzI5NA==","user":{"login":"alashworth","id":3664221,"node_id":"MDQ6VXNlcjM2NjQyMjE=","avatar_url":"https://avatars3.githubusercontent.com/u/3664221?v=4","gravatar_id":"","url":"https://api.github.com/users/alashworth","html_url":"https://github.com/alashworth","followers_url":"https://api.github.com/users/alashworth/followers","following_url":"https://api.github.com/users/alashworth/following{/other_user}","gists_url":"https://api.github.com/users/alashworth/gists{/gist_id}","starred_url":"https://api.github.com/users/alashworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alashworth/subscriptions","organizations_url":"https://api.github.com/users/alashworth/orgs","repos_url":"https://api.github.com/users/alashworth/repos","events_url":"https://api.github.com/users/alashworth/events{/privacy}","received_events_url":"https://api.github.com/users/alashworth/received_events","type":"User","site_admin":false},"created_at":"2019-03-12T09:32:10Z","updated_at":"2019-03-12T09:32:10Z","author_association":"OWNER","body":"<a href=\"https://github.com/betanalpha\"><img src=\"https://avatars0.githubusercontent.com/u/1527190?v=4\" align=\"left\" width=\"48\" height=\"48\" hspace=\"10\"></img></a> **Comment by [betanalpha](https://github.com/betanalpha)**\n_Friday Mar 20, 2015 at 16:00 GMT_\n\n----\n\nYeah, I’m just thinking about the users — the\nunderlying code can be exactly the same.\n\nOn Mar 20, 2015, at 3:58 PM, bgoodri notifications@github.com wrote:\n\n> Do you mean, just for users to remind themselves that it is resizeable?\n> \n> resizeable matrix X;\n> X <- rep_matrix(0, 2, 2);\n> print(X[1,2]);\n> \n> That's fine by me, but how would it be different on the C++ as\n> \n> matrix[0,0] X;\n> X <- rep_matrix(0, 2, 2);\n> print(X[1,2]);\n> \n> On Fri, Mar 20, 2015 at 11:49 AM, Michael Betancourt <\n> notifications@github.com> wrote:\n> \n> > I agree that if a type is meant to be resizable\n> > we should make that explicit. I think most\n> > people assume that their matrix sizes are\n> > constant, and that’s a good thing.\n> > \n> > On Mar 20, 2015, at 3:25 PM, bgoodri notifications@github.com wrote:\n> > \n> > > This wouldn't limit the ability to use a size zero matrix as a\n> > > placeholder\n> > > in the model. If you don't resize it, then it stays size zero.\n> > > \n> > > I'm not sure what the code is almost ready to do with regards to error\n> > > messages. I think what would happen is whatever would happen if someone\n> > > declared a size zero matrix and then did something buggy:\n> > > \n> > > matrix[0,0] X;\n> > > print(X[1,2]); // error\n> > > \n> > > matrix X; // equivalent to matrix[0,0] X;\n> > > print(X[1,2]); // error\n> > > \n> > > matrix X; // equivalent to matrix[0,0] X;\n> > > X <- rep_matrix(0, 2, 2); // resized to 2x2\n> > > print(X[1,2]); // prints 0 correctly\n> > > \n> > > I don't think adding the Stan keyword dynamic would hurt anything but how\n> > > it help if the construct gets parsed to an\n> > > Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> in C++? Are you thinking\n> > > of\n> > > subclassing from Eigen::Matrix?\n> > > \n> > > On Fri, Mar 20, 2015 at 10:46 AM, Daniel Lee notifications@github.com\n> > > wrote:\n> > > \n> > > > Sorry for taking so long to catch up.\n> > > > \n> > > > First off, I disagree with allowing matrix[0,0] stand for a resizable\n> > > > matrix. Hopefully Stan is now compatible with 0 x 0 matrices, 0-length\n> > > > vectors, and 0-length row vectors. Early on, I found myself wanting to\n> > > > draw\n> > > > from priors and would intentionally write models with size 0 to allow\n> > > > for\n> > > > this. Perhaps the behavior to use this functionality within the Stan\n> > > > language wouldn't be affected, but I think this might allow users (me)\n> > > > to\n> > > > write models that behaved differently than intended.\n> > > > \n> > > > Regarding matrix without sizes representing a resizable matrix, it does\n> > > > make some sense, but I'm afraid it'll make the user experience a little\n> > > > worse. The problem is when people forget to size matrices, we'll lose\n> > > > the\n> > > > power to write better error messages due to the strict typing at that\n> > > > point. Yes, I know, we don't proactively stop now, but the code is\n> > > > almost\n> > > > ready to do so.\n> > > > \n> > > > Rather than just saying no, my suggestion would be to create a new\n> > > > type,\n> > > > something called dynamic_matrix. (I was inspired by Eigen's naming...\n> > > > and\n> > > > this is just a suggestion, we can call it whatever makes sense.) I'm\n> > > > really\n> > > > trying not to get ahead of myself and thinking about implementation\n> > > > because\n> > > > the C++ types would be the same (Eigen::Matrix), but we would want to\n> > > > do\n> > > > different checking. Perhaps we would need to have another set of assign\n> > > > calls or something like that? Not sure.\n> > > > \n> > > > In short: I don't like matrix[0,0] or just matrix, but would prefer\n> > > > dynamic_matrix.\n> > > > \n> > > > —\n> > > > Reply to this email directly or view it on GitHub\n> > > > https://github.com/stan-dev/stan/issues/1369#issuecomment-84034932.\n> > > > \n> > > > —\n> > > > Reply to this email directly or view it on GitHub.\n> > \n> > —\n> > Reply to this email directly or view it on GitHub\n> > https://github.com/stan-dev/stan/issues/1369#issuecomment-84053543.\n> > \n> > —\n> > Reply to this email directly or view it on GitHub.\n\n"}}
{"actor":{"display_login":"alashworth"}}