functions {
matrix Foo() {
return [ [1,2,3,4,5,6,7,8,9,10]
, [1,2,3,4,5,6,7,8,9,10]
, [1,2,3,4,5,6,7,8,9,10] ];
}
}
model {
}
on cmdstan 2.20.0 release with OCAML v1.0.0-rc1 compiler downloaded binary produces:
andre@ubuntu:~/cmdstan-2.20.0$ make models/test1
--- Translating Stan model to C++ code ---
bin/stanc --o=models/test1.hpp models/test1.stan
--- Compiling, linking C++ code ---
g++ -std=c++1y -pthread -Wno-sign-compare -O3 -I src -I stan/src -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -c -x c++ -o models/test1.o models/test1.hpp
models/test1.hpp: In function ‘Eigen::Matrix<double, -1, -1> test1_model_namespace::Foo(std::ostream*)’:
models/test1.hpp:49:74: error: no matching function for call to ‘to_row_vector(<brace-enclosed initializer list>)’
9, 10})});
^
In file included from stan/lib/stan_math/stan/math/prim/mat.hpp:237:0,
from stan/lib/stan_math/stan/math/rev/mat.hpp:12,
from stan/lib/stan_math/stan/math.hpp:4,
from stan/src/stan/model/model_header.hpp:4,
from models/test1.hpp:3:
stan/lib/stan_math/stan/math/prim/mat/fun/to_row_vector.hpp:15:44: note: candidate: template<class T, int R, int C> Eigen::Matrix<T, 1, -1> stan::math::to_row_vector(const Eigen::Matrix<T, R, C>&)
inline Eigen::Matrix<T, 1, Eigen::Dynamic> to_row_vector(
^
stan/lib/stan_math/stan/math/prim/mat/fun/to_row_vector.hpp:15:44: note: template argument deduction/substitution failed:
models/test1.hpp:49:74: note: couldn't deduce template parameter ‘T’
9, 10})});
^
In file included from stan/lib/stan_math/stan/math/prim/mat.hpp:237:0,
from stan/lib/stan_math/stan/math/rev/mat.hpp:12,
from stan/lib/stan_math/stan/math.hpp:4,
from stan/src/stan/model/model_header.hpp:4,
from models/test1.hpp:3:
stan/lib/stan_math/stan/math/prim/mat/fun/to_row_vector.hpp:23:44: note: candidate: template<class T> Eigen::Matrix<T, 1, -1> stan::math::to_row_vector(const std::vector<_RealType>&)
inline Eigen::Matrix<T, 1, Eigen::Dynamic> to_row_vector(
^
stan/lib/stan_math/stan/math/prim/mat/fun/to_row_vector.hpp:23:44: note: template argument deduction/substitution failed:
models/test1.hpp:49:74: note: couldn't deduce template parameter ‘T’
9, 10})});
^
In file included from stan/lib/stan_math/stan/math/prim/mat.hpp:237:0,
from stan/lib/stan_math/stan/math/rev/mat.hpp:12,
from stan/lib/stan_math/stan/math.hpp:4,
from stan/src/stan/model/model_header.hpp:4,
from models/test1.hpp:3:
stan/lib/stan_math/stan/math/prim/mat/fun/to_row_vector.hpp:29:49: note: candidate: Eigen::Matrix<double, 1, -1> stan::math::to_row_vector(const std::vector<int>&)
inline Eigen::Matrix<double, 1, Eigen::Dynamic> to_row_vector(
^
stan/lib/stan_math/stan/math/prim/mat/fun/to_row_vector.hpp:29:49: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::vector<int>&’
make/program:38: recipe for target 'models/test1' failed
make: *** [models/test1] Error 1
on
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.11' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)
test1.hpp (8.7 KB)
Model 2
functions {
vector Foo() {
return [1,2,3,4,5,6,7,8,9,10]';
}
vector bar(real mu) {
vector[10] l = mu * Foo();
return l;
}
}
model {
}
produces:
--- Compiling, linking C++ code ---
g++ -std=c++1y -pthread -Wno-sign-compare -O3 -I src -I stan/src -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -c -x c++ -o models/test2.o models/test2.hpp
models/test2.hpp: In function ‘Eigen::Matrix<typename boost::math::tools::promote_args<T>::type, -1, 1> test2_model_namespace::bar(const T0__&, std::ostream*)’:
models/test2.hpp:77:50: error: expected primary-expression before ‘,’ token
assign(l, nil_index_list(), multiply(mu, Foo(, pstream__)), "assigning variable l");
^
make/program:38: recipe for target 'models/test2' failed
make: *** [models/test2] Error 1
Model 3
functions {
vector bar(real mu) {
vector[10] l = mu * [1,2,3,4,5,6,7,8,9,10]';
return l[{1,2,3,4,5}];
}
}
model {
}
Produces a linking problem:
--- Translating Stan model to C++ code ---
bin/stanc --o=models/test3.hpp models/test3.stan
--- Compiling, linking C++ code ---
g++ -std=c++1y -pthread -Wno-sign-compare -O3 -I src -I stan/src -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -c -x c++ -o models/test3.o models/test3.hpp
g++ -std=c++1y -pthread -Wno-sign-compare -O3 -I src -I stan/src -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION src/cmdstan/main.o stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_idas.a models/test3.o -o models/test3
src/cmdstan/main.o: In function `cmdstan::command(int, char const**)':
main.cpp:(.text+0x612c): undefined reference to `new_model(stan::io::var_context&, unsigned int, std::ostream*)'
collect2: error: ld returned 1 exit status
make/program:38: recipe for target 'models/test3' failed