Giter VIP home page Giter VIP logo

Comments (5)

bgoodri avatar bgoodri commented on May 28, 2024

I think it is a parser issue. Last I heard, it was not possible to assign a row vector to a row of a matrix. Also, when you declare a matrix, in C++ it is an Eigen::Matrix so [i] assigns to the i-th element in column-major order, rather than to the i-th row. And assigning anything to the i-th element other than a scalar shouldn't work.

from stan.

mbrubake avatar mbrubake commented on May 28, 2024

A matrix row/column is not a valid L-value in the modelling language, as the transformed C++ for row/column extraction produces a copy of the data, as opposed to a reference to it. Ideally this should be caught by the parser right now. I'm not sure hard that would be to implement.

from stan.

jrnold avatar jrnold commented on May 28, 2024

I didn't think that I could do it, but I had forgot to change a few lines of code before compiling. If the row_vectors are changed to vectors, then the parser catches the error.

INVALID COMMAND-LINE ARGUMENT
EXPECTATION FAILURE LOCATION: file=foo.stan; line=11, column=3

  alpha_beta[1] <- alpha;
  ^-- here


DIAGNOSTIC(S) FROM PARSER:
base type mismatch in assignment; left variable=alpha_beta; left base type=row vector; right base type=vector
binary infix operator <= with functional interpretation logical_lt requires arguments or primitive type (int or real), found left type=row vector, right arg type=vector; no matches for function name="logical_lt"
    arg 0 type=row vector
    arg 1 type=vector
Parser expecting: "}"

from stan.

bob-carpenter avatar bob-carpenter commented on May 28, 2024

This is definitely a bug. My intention (which was reflected
in the doc and the parser, but not the assignment implementation)
was for the following to be valid:

matass.stan

transformed data {
matrix[2,2] X;
row_vector[2] y;

X[1] <- y;
X[2] <- y;
print("X=",X);
}
model {

}

Right now, during compilation, the issue is this:

/Users/carp/temp2/matass.cpp:48:9: error: no matching function for call to 'assign'
assign(get_base1(X,1,"X",1), y);

I'll patch the code so that (a) get_base1(...) returns a reference
to a view of a row of X, and (b) assign does the right thing with
it.

  • Bob

On 2/12/13 2:25 PM, Marcus Brubaker wrote:

A matrix row/column is not a valid L-value in the modelling language, as the transformed C++ for row/column extraction
produces a copy of the data, as opposed to a reference to it. Ideally this should be caught by the parser right now. I'm
not sure hard that would be to implement.


Reply to this email directly or view it on GitHub #12 (comment).

from stan.

bob-carpenter avatar bob-carpenter commented on May 28, 2024

[master 034ac1c] resolved issue #12: allowing matrix row assignments on LHS with vars

from stan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.