armstrtw/CppBugs — Issue #5: Using vectorized uniform distributions
Author: yasirs
Created: 2012-01-11 01:38:37+00:00
State: open

I tried to modify the linear example test to have `b` as a uniform variable. Declaring ` Uniform b;` on line 16, and then updating as ` b.dunif(-10, 10);` on line 39, I get compile time errors:
```$ make linear.model.test
g++ -I.. -Wall -O2 -llapack -larmadillo linear.model.test.cpp -o linear.model.test
In file included from ../cppbugs/cppbugs.hpp:27:0,
from linear.model.test.cpp:4:
../cppbugs/mcmc.model.hpp: In member function 'void cppbugs::MCModel::sample(int, int, int, int)':
../cppbugs/mcmc.model.hpp:137:14: warning: unused variable 'ideal_scale' [-Wunused-variable]
dune:test yasir$ vi linear.model.test.cpp
dune:test yasir$ make linear.model.test
g++ -I.. -Wall -O2 -llapack -larmadillo linear.model.test.cpp -o linear.model.test
In file included from ../cppbugs/cppbugs.hpp:27:0,
from linear.model.test.cpp:4:
../cppbugs/mcmc.model.hpp: In member function 'void cppbugs::MCModel::sample(int, int, int, int)':
../cppbugs/mcmc.model.hpp:137:14: warning: unused variable 'ideal_scale' [-Wunused-variable]
In file included from ../cppbugs/cppbugs.hpp:23:0,
from linear.model.test.cpp:4:
../cppbugs/mcmc.uniform.hpp: In member function 'void cppbugs::Uniform::dunif(double, double) [with T = arma::Col]':
linear.model.test.cpp:39:20: instantiated from here
../cppbugs/mcmc.uniform.hpp:33:7: error: no match for 'operator||' in 'arma::operator<(const arma::Base::result, T1>&, typename arma::arma_not_cx::result) [with T1 = arma::Mat, typename arma::arma_not_cx::result = double](lower) || arma::operator>(const arma::Base::result, T1>&, typename arma::arma_not_cx::result) [with T1 = arma::Mat, typename arma::arma_not_cx::result = double](upper)'
../cppbugs/mcmc.uniform.hpp:33:7: note: candidate is:
../cppbugs/mcmc.uniform.hpp:33:7: note: operator||(bool, bool)
../cppbugs/mcmc.uniform.hpp:33:7: note: no known conversion for argument 2 from 'const arma::mtOp, arma::op_rel_gt_post>' to 'bool'
make: *** [linear.model.test] Error 1```

If, on the other hand I try to use vector limits as ` b.dunif(-10 * arma::ones(X.n_cols), 10 * arma::ones(X.n_cols));`, it gives me the compile time errors:
```$ make linear.model.test
g++ -I.. -Wall -O2 -llapack -larmadillo linear.model.test.cpp -o linear.model.test
In file included from ../cppbugs/cppbugs.hpp:27:0,
from linear.model.test.cpp:4:
../cppbugs/mcmc.model.hpp: In member function 'void cppbugs::MCModel::sample(int, int, int, int)':
../cppbugs/mcmc.model.hpp:137:14: warning: unused variable 'ideal_scale' [-Wunused-variable]
linear.model.test.cpp: In member function 'virtual void TestModel::update()':
linear.model.test.cpp:39:88: error: no matching function for call to 'cppbugs::Uniform >::dunif(const arma::eOp, arma::eop_scalar_times>, const arma::eOp, arma::eop_scalar_times>)'
linear.model.test.cpp:39:88: note: candidate is:
../cppbugs/mcmc.uniform.hpp:32:10: note: void cppbugs::Uniform::dunif(double, double) [with T = arma::Col]
../cppbugs/mcmc.uniform.hpp:32:10: note: no known conversion for argument 1 from 'const arma::eOp, arma::eop_scalar_times>' to 'double'
make: *** [linear.model.test] Error 1```