Comments (5)
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.
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.
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.
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.
[master 034ac1c] resolved issue #12: allowing matrix row assignments on LHS with vars
from stan.
Related Issues (20)
- Allow drawing from the Laplace approximation and Pathfinder without evaluating log_p HOT 4
- Pathfinder warning message is misleading HOT 4
- Infinite loop in `WolfLSZoom` when using stan for optimization HOT 8
- Print statements inside a model are buffered into a stringstream and only printed when log_prob returns
- Typo on wiki: prior choice recommendation for correlation HOT 2
- Pathfinder run not reproducible from seed
- Underflow in psis_weights leads to uniform sampling from multi-pathfinder draws
- Add resampling options for multi-Pathfinder HOT 5
- min:max indexing does not support SoA but does not prevent this at compile time? HOT 5
- `install-tbb.bat` fails on windows
- Write metric as JSON - add field "metric_type" HOT 1
- How to use stan::math::hypergeometric_2F1 in stan? HOT 1
- Move away from the `boost::ecuyer1988` pRNG HOT 3
- Remove places where exceptions are unconditionally swallowed.
- Add an argument to write Hessian from Laplace algorithm to a file
- CompileError: command '/usr/bin/gcc' failed with exit code 1 HOT 6
- Pathfinder: unexpected behavior when num_draws < num_elbo_draws
- Implementation of improved Rhat for assessing convergence of MCMC
- Exception: In serializer: Storage capacity [763] exceeded while writing value of size [16] from position [759] HOT 6
- Too loose ASSERT_NEAR and wrong test values in compute_potential_scale_reduction_test.cpp HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stan.