compilation error related to ifelse operator

61 views
Skip to first unread message

Charles Driver

unread,
Nov 1, 2016, 9:57:01 AM11/1/16
to Stan users mailing list
I haven't worked out what is wrong yet, but here is an R script to generate a compilation error. The problem is related to the conditional operator here:
mcholcor[rowi,coli] * (rowi==coli ? 0 : mat[rowi,coli-1]) * sqrt(1-square(mcholcor[rowi,coli-1]));
I have fixed my logic and script but so far as I understand you like these reported.


require(rstan)
sm2 <- '
functions{

row_vector vecpower(row_vector vec, real power){
row_vector[num_elements(vec)] out;
for(i in 1:num_elements(vec)){
out[i] = vec[i]^power;
}
return out;
}

vector vecsqrt(vector vec){
vector[num_elements(vec)] out;
for(i in 1:num_elements(vec)){
out[i]=sqrt(vec[i]);
}
return out;
}

matrix sdpcorr2cov_lp(matrix mat,int chol, real eta){ //converts from lower pcor and diag sd to chol or cov matrix
int ndim;
matrix[rows(mat),cols(mat)] mscale;
matrix[rows(mat),cols(mat)] mcholcor;
matrix[rows(mat),cols(mat)] out;
real tempsum;
real betad;

ndim = cols(mat);
mcholcor=diag_matrix(rep_vector(0,ndim));
mscale = diag_matrix(diagonal(mat));
betad = eta + (ndim-1)/2;

if(ndim > 1){
for(coli in 1:(ndim-1)){
betad = betad - 1/2;
for(rowi in coli:ndim){

if(rowi > coli){
mat[rowi,coli]/2+.5 ~ beta(betad,betad);
mcholcor[rowi,coli] =  mat[rowi,coli];
mcholcor[coli,rowi] = 0;
}
if(coli > 1){
mcholcor[rowi,coli] = mcholcor[rowi,coli] * (rowi==coli ? 0 : mat[rowi,coli-1]) * sqrt(1-square(mcholcor[rowi,coli-1]));
}

}
}
}



//out = mscale * mcholcor; //cholesky

//if(chol == 0) out=multiply_lower_tri_self_transpose(out); //cov
return mcholcor;
} //end sdpcorr2cov

}

data{
int ndim;
real eta;
}

parameters{
vector<lower=-1,upper=1>[(ndim*ndim-ndim)/2] pcorrvec;
real dummy;
}

transformed parameters{
vector[ndim] scalevec;
matrix[ndim,ndim] sdpcorrmat;
matrix[ndim,ndim] cholcorrmat;
scalevec=rep_vector(1,ndim);

{
  int counter;
  counter=0;
  sdpcorrmat=diag_matrix(scalevec);
 
  for(rowi in 2:ndim){ // fill lower tri of sdpcorrmat
  for(coli in 1:(rowi-1)){
  counter=counter+1;
  sdpcorrmat[rowi,coli]=pcorrvec[counter];
  }
  }
}

cholcorrmat = sdpcorr2cov_lp(sdpcorrmat,1,eta); //convert sd and lower tri partial cor matrix to cholesky factor cov


}
model{
dummy~normal(0,1); //just putting something here...
//pcorrvec~normal(0,1);
}
generated quantities{
matrix[ndim,ndim] corrmat_out;
corrmat_out = cholcorrmat * cholcorrmat\'; //the matrix of actual interest
}
'



ndim=6
eta=1
fit=stan(model_code=sm2,data=list(ndim=ndim,eta=eta),warmup=10,iter=150000,chains=3,cores=3)

Daniel Lee

unread,
Nov 1, 2016, 10:22:32 AM11/1/16
to stan-...@googlegroups.com
Can you include the error? I can't tell if the program is not compiling or if the generated code is not compiling. 
--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Charles Driver

unread,
Nov 1, 2016, 11:38:55 AM11/1/16
to Stan users mailing list
DIAGNOSTIC(S) FROM PARSER:
Warning: integer division implicitly rounds to integer. Found int division: (ndim - 1) / 2
 Positive values rounded down, negative values rounded up or down in platform-dependent way.
Warning: integer division implicitly rounds to integer. Found int division: 1 / 2
 Positive values rounded down, negative values rounded up or down in platform-dependent way.
Warning: integer division implicitly rounds to integer. Found int division: ((ndim * ndim) - ndim) / 2
 Positive values rounded down, negative values rounded up or down in platform-dependent way.

In file included from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/mat/fun/promote_scalar.hpp:4:0,
                 from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/mat.hpp:133,
                 from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/rev/mat.hpp:9,
                 from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math.hpp:4,
                 from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file21e0675830d8.cpp:8:
C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/scal/fun/promote_scalar.hpp: In instantiation of 'static T stan::math::promote_scalar_struct<T, S>::apply(S) [with T = double; S = stan::math::var]':
C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/scal/fun/promote_scalar.hpp:68:50:   required from 'typename stan::math::promote_scalar_type<T, S>::type stan::math::promote_scalar(const S&) [with T = double; S = stan::math::var; typename stan::math::promote_scalar_type<T, S>::type = double]'
file21e0675830d8.cpp:165:281:   required from 'Eigen::Matrix<typename boost::math::tools::promote_args<RT1, RT2, A>::type, -1, -1> model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::sdpcorr2cov_lp(const Eigen::Matrix<LhsScalar, -1, -1, 0>&, const int&, const T2__&, T_lp__&, T_lp_accum__&, std::ostream*) [with T0__ = stan::math::var; T2__ = double; T_lp__ = stan::math::var; T_lp_accum__ = stan::math::accumulator<stan::math::var>; typename boost::math::tools::promote_args<RT1, RT2, A>::type = stan::math::var; std::ostream = std::basic_ostream<char>]'
file21e0675830d8.cpp:380:105:   required from 'T__ model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343::log_prob(std::vector<T2>&, std::vector<int>&, std::ostream*) const [with bool propto__ = true; bool jacobian__ = true; T__ = stan::math::var; std::ostream = std::basic_ostream<char>]'
C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/src/stan/model/util.hpp:93:39:   required from 'double stan::model::log_prob_grad(const M&, std::vector<double>&, std::vector<int>&, std::vector<double>&, std::ostream*) [with bool propto = true; bool jacobian_adjust_transform = true; M = model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343; std::ostream = std::basic_ostream<char>]'
C:/Users/driver/Documents/R/win-library/3.3/rstan/include/rstan/stan_fit.hpp:1464:101:   required from 'SEXPREC* rstan::stan_fit<Model, RNG_t>::grad_log_prob(SEXP, SEXP) [with Model = model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343; RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >; SEXP = SEXPREC*]'
file21e0675830d8.cpp:736:172:   required from here
C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/scal/fun/promote_scalar.hpp:32:19: error: invalid cast from type 'stan::math::var' to type 'double'
         return T(x);
                   ^
C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/scal/fun/promote_scalar.hpp: In static member function 'static T stan::math::promote_scalar_struct<T, S>::apply(S) [with T = double; S = stan::math::var]':
C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/scal/fun/promote_scalar.hpp:33:7: warning: control reaches end of non-void function [-Wreturn-type]
       }
       ^
make: *** [file21e0675830d8.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-33~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.0/share/make/winshlib.mk" -f "C:/Users/driver/Documents/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file21e0675830d8.dll" WIN=64 TCLBIN=64 OBJECTS="file21e0675830d8.o"' had status 2 

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: 
  2: // includes from the plugin
  3: 
  4: 
  5: // user includes
  6: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.12
  7: 
  8: #include <stan/model/model_header.hpp>
  9: 
 10: namespace model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace {
 11: 
 12: using std::istream;
 13: using std::string;
 14: using std::stringstream;
 15: using std::vector;
 16: using stan::io::dump;
 17: using stan::math::lgamma;
 18: using stan::model::prob_grad;
 19: using namespace stan::math;
 20: 
 21: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
 22: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
 23: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
 24: 
 25: static int current_statement_begin__;
 26: 
 27: template <typename T0__, typename T1__>
 28: inline
 29: Eigen::Matrix<typename boost::math::tools::promote_args<T0__, T1__>::type, 1,Eigen::Dynamic>
 30: vecpower(const Eigen::Matrix<T0__, 1,Eigen::Dynamic>& vec,
 31:              const T1__& power, std::ostream* pstream__) {
 32:     typedef typename boost::math::tools::promote_args<T0__, T1__>::type fun_scalar_t__;
 33:     typedef fun_scalar_t__ fun_return_scalar_t__;
 34:     const static bool propto__ = true;
 35:     (void) propto__;
 36:     int current_statement_begin__ = -1;
 37:     try {
 38:         {
 39:             Eigen::Matrix<fun_scalar_t__,1,Eigen::Dynamic>  out(static_cast<Eigen::VectorXd::Index>(num_elements(vec)));
 40:             (void) out;  // dummy to suppress unused var warning
 41:             stan::math::initialize(out, std::numeric_limits<double>::quiet_NaN());
 42:             current_statement_begin__ = 6;
 43:             for (int i = 1; i <= num_elements(vec); ++i) {
 44:                 current_statement_begin__ = 7;
 45:                 stan::math::assign(get_base1_lhs(out,i,"out",1), pow(get_base1(vec,i,"vec",1),power));
 46:             }
 47:             current_statement_begin__ = 9;
 48:             return stan::math::promote_scalar<fun_return_scalar_t__>(out);
 49:         }
 50:     } catch (const std::exception& e) {
 51:         stan::lang::rethrow_located(e,current_statement_begin__);
 52:         // Next line prevents compiler griping about no return
 53:         throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 54:     }
 55: }
 56: 
 57: 
 58: struct vecpower_functor__ {
 59:     template <typename T0__, typename T1__>
 60:     inline
 61:     Eigen::Matrix<typename boost::math::tools::promote_args<T0__, T1__>::type, 1,Eigen::Dynamic>
 62:     operator()(const Eigen::Matrix<T0__, 1,Eigen::Dynamic>& vec,
 63:              const T1__& power, std::ostream* pstream__) const {
 64:         return vecpower(vec, power, pstream__);
 65:     }
 66: };
 67: 
 68: template <typename T0__>
 69: inline
 70: Eigen::Matrix<typename boost::math::tools::promote_args<T0__>::type, Eigen::Dynamic,1>
 71: vecsqrt(const Eigen::Matrix<T0__, Eigen::Dynamic,1>& vec, std::ostream* pstream__) {
 72:     typedef typename boost::math::tools::promote_args<T0__>::type fun_scalar_t__;
 73:     typedef fun_scalar_t__ fun_return_scalar_t__;
 74:     const static bool propto__ = true;
 75:     (void) propto__;
 76:     int current_statement_begin__ = -1;
 77:     try {
 78:         {
 79:             Eigen::Matrix<fun_scalar_t__,Eigen::Dynamic,1>  out(static_cast<Eigen::VectorXd::Index>(num_elements(vec)));
 80:             (void) out;  // dummy to suppress unused var warning
 81:             stan::math::initialize(out, std::numeric_limits<double>::quiet_NaN());
 82:             current_statement_begin__ = 14;
 83:             for (int i = 1; i <= num_elements(vec); ++i) {
 84:                 current_statement_begin__ = 15;
 85:                 stan::math::assign(get_base1_lhs(out,i,"out",1), sqrt(get_base1(vec,i,"vec",1)));
 86:             }
 87:             current_statement_begin__ = 17;
 88:             return stan::math::promote_scalar<fun_return_scalar_t__>(out);
 89:         }
 90:     } catch (const std::exception& e) {
 91:         stan::lang::rethrow_located(e,current_statement_begin__);
 92:         // Next line prevents compiler griping about no return
 93:         throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 94:     }
 95: }
 96: 
 97: 
 98: struct vecsqrt_functor__ {
 99:     template <typename T0__>
100:     inline
101:     Eigen::Matrix<typename boost::math::tools::promote_args<T0__>::type, Eigen::Dynamic,1>
102:     operator()(const Eigen::Matrix<T0__, Eigen::Dynamic,1>& vec, std::ostream* pstream__) const {
103:         return vecsqrt(vec, pstream__);
104:     }
105: };
106: 
107: template <typename T0__, typename T2__, typename T_lp__, typename T_lp_accum__>
108: inline
109: Eigen::Matrix<typename boost::math::tools::promote_args<T0__, T2__, T_lp__>::type, Eigen::Dynamic,Eigen::Dynamic>
110: sdpcorr2cov_lp(const Eigen::Matrix<T0__, Eigen::Dynamic,Eigen::Dynamic>& mat,
111:                    const int& chol,
112:                    const T2__& eta, T_lp__& lp__, T_lp_accum__& lp_accum__, std::ostream* pstream__) {
113:     typedef typename boost::math::tools::promote_args<T0__, T2__, T_lp__>::type fun_scalar_t__;
114:     typedef fun_scalar_t__ fun_return_scalar_t__;
115:     const static bool propto__ = true;
116:     (void) propto__;
117:     int current_statement_begin__ = -1;
118:     try {
119:         {
120:             int ndim(0);
121:             (void) ndim;  // dummy to suppress unused var warning
122:             Eigen::Matrix<fun_scalar_t__,Eigen::Dynamic,Eigen::Dynamic>  mscale(static_cast<Eigen::VectorXd::Index>(rows(mat)),static_cast<Eigen::VectorXd::Index>(cols(mat)));
123:             (void) mscale;  // dummy to suppress unused var warning
124:             Eigen::Matrix<fun_scalar_t__,Eigen::Dynamic,Eigen::Dynamic>  mcholcor(static_cast<Eigen::VectorXd::Index>(rows(mat)),static_cast<Eigen::VectorXd::Index>(cols(mat)));
125:             (void) mcholcor;  // dummy to suppress unused var warning
126:             Eigen::Matrix<fun_scalar_t__,Eigen::Dynamic,Eigen::Dynamic>  out(static_cast<Eigen::VectorXd::Index>(rows(mat)),static_cast<Eigen::VectorXd::Index>(cols(mat)));
127:             (void) out;  // dummy to suppress unused var warning
128:             fun_scalar_t__ tempsum;
129:             (void) tempsum;  // dummy to suppress unused var warning
130:             fun_scalar_t__ betad;
131:             (void) betad;  // dummy to suppress unused var warning
132:             stan::math::initialize(mscale, std::numeric_limits<double>::quiet_NaN());
133:             stan::math::initialize(mcholcor, std::numeric_limits<double>::quiet_NaN());
134:             stan::math::initialize(out, std::numeric_limits<double>::quiet_NaN());
135:             stan::math::initialize(tempsum, std::numeric_limits<double>::quiet_NaN());
136:             stan::math::initialize(betad, std::numeric_limits<double>::quiet_NaN());
137:             current_statement_begin__ = 28;
138:             stan::math::assign(ndim, cols(mat));
139:             current_statement_begin__ = 29;
140:             stan::math::assign(mcholcor, diag_matrix(rep_vector(0,ndim)));
141:             current_statement_begin__ = 30;
142:             stan::math::assign(mscale, diag_matrix(diagonal(mat)));
143:             current_statement_begin__ = 31;
144:             stan::math::assign(betad, (eta + divide((ndim - 1),2)));
145:             current_statement_begin__ = 33;
146:             if (as_bool(logical_gt(ndim,1))) {
147:                 current_statement_begin__ = 34;
148:                 for (int coli = 1; coli <= (ndim - 1); ++coli) {
149:                     current_statement_begin__ = 35;
150:                     stan::math::assign(betad, (betad - divide(1,2)));
151:                     current_statement_begin__ = 36;
152:                     for (int rowi = coli; rowi <= ndim; ++rowi) {
153:                         current_statement_begin__ = 38;
154:                         if (as_bool(logical_gt(rowi,coli))) {
155:                             current_statement_begin__ = 39;
156:                             lp_accum__.add(beta_log<propto__>(((get_base1(mat,rowi,coli,"mat",1) / 2) + 0.5), betad, betad));
157:                             current_statement_begin__ = 40;
158:                             stan::math::assign(get_base1_lhs(mcholcor,rowi,coli,"mcholcor",1), get_base1(mat,rowi,coli,"mat",1));
159:                             current_statement_begin__ = 41;
160:                             stan::math::assign(get_base1_lhs(mcholcor,coli,rowi,"mcholcor",1), 0);
161:                         }
162:                         current_statement_begin__ = 43;
163:                         if (as_bool(logical_gt(coli,1))) {
164:                             current_statement_begin__ = 44;
165:                             stan::math::assign(get_base1_lhs(mcholcor,rowi,coli,"mcholcor",1), ((get_base1(mcholcor,rowi,coli,"mcholcor",1) * (logical_eq(rowi,coli) ? stan::math::promote_scalar<double>(0) : stan::math::promote_scalar<double>(get_base1(mat,rowi,(coli - 1),"mat",1)) )) * sqrt((1 - square(get_base1(mcholcor,rowi,(coli - 1),"mcholcor",1))))));
166:                         }
167:                     }
168:                 }
169:             }
170:             current_statement_begin__ = 56;
171:             return stan::math::promote_scalar<fun_return_scalar_t__>(mcholcor);
172:         }
173:     } catch (const std::exception& e) {
174:         stan::lang::rethrow_located(e,current_statement_begin__);
175:         // Next line prevents compiler griping about no return
176:         throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
177:     }
178: }
179: 
180: 
181: struct sdpcorr2cov_lp_functor__ {
182:     template <typename T0__, typename T2__, typename T_lp__, typename T_lp_accum__>
183:     inline
184:     Eigen::Matrix<typename boost::math::tools::promote_args<T0__, T2__, T_lp__>::type, Eigen::Dynamic,Eigen::Dynamic>
185:     operator()(const Eigen::Matrix<T0__, Eigen::Dynamic,Eigen::Dynamic>& mat,
186:                    const int& chol,
187:                    const T2__& eta, T_lp__& lp__, T_lp_accum__& lp_accum__, std::ostream* pstream__) const {
188:         return sdpcorr2cov_lp(mat, chol, eta, lp__, lp_accum__, pstream__);
189:     }
190: };
191: 
192: class model21e05f842a3d_668201f656fa56a40310f15ffd0f7343 : public prob_grad {
193: private:
194:     int ndim;
195:     double eta;
196: public:
197:     model21e05f842a3d_668201f656fa56a40310f15ffd0f7343(stan::io::var_context& context__,
198:         std::ostream* pstream__ = 0)
199:         : prob_grad(0) {
200:         typedef boost::ecuyer1988 rng_t;
201:         rng_t base_rng(0);  // 0 seed default
202:         ctor_body(context__, base_rng, pstream__);
203:     }
204: 
205:     template <class RNG>
206:     model21e05f842a3d_668201f656fa56a40310f15ffd0f7343(stan::io::var_context& context__,
207:         RNG& base_rng__,
208:         std::ostream* pstream__ = 0)
209:         : prob_grad(0) {
210:         ctor_body(context__, base_rng__, pstream__);
211:     }
212: 
213:     template <class RNG>
214:     void ctor_body(stan::io::var_context& context__,
215:                    RNG& base_rng__,
216:                    std::ostream* pstream__) {
217:         current_statement_begin__ = -1;
218: 
219:         static const char* function__ = "model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343";
220:         (void) function__; // dummy call to supress warning
221:         size_t pos__;
222:         (void) pos__; // dummy call to supress warning
223:         std::vector<int> vals_i__;
224:         std::vector<double> vals_r__;
225:         context__.validate_dims("data initialization", "ndim", "int", context__.to_vec());
226:         ndim = int(0);
227:         vals_i__ = context__.vals_i("ndim");
228:         pos__ = 0;
229:         ndim = vals_i__[pos__++];
230:         context__.validate_dims("data initialization", "eta", "double", context__.to_vec());
231:         eta = double(0);
232:         vals_r__ = context__.vals_r("eta");
233:         pos__ = 0;
234:         eta = vals_r__[pos__++];
235: 
236:         // validate data
237: 
238:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
239:         (void) DUMMY_VAR__;  // suppress unused var warning
240: 
241: 
242:         // initialize transformed variables to avoid seg fault on val access
243: 
244:         try {
245:         } catch (const std::exception& e) {
246:             stan::lang::rethrow_located(e,current_statement_begin__);
247:             // Next line prevents compiler griping about no return
248:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
249:         }
250: 
251:         // validate transformed data
252: 
253:         // set parameter ranges
254:         num_params_r__ = 0U;
255:         param_ranges_i__.clear();
256:         num_params_r__ += divide(((ndim * ndim) - ndim),2);
257:         ++num_params_r__;
258:     }
259: 
260:     ~model21e05f842a3d_668201f656fa56a40310f15ffd0f7343() { }
261: 
262: 
263:     void transform_inits(const stan::io::var_context& context__,
264:                          std::vector<int>& params_i__,
265:                          std::vector<double>& params_r__,
266:                          std::ostream* pstream__) const {
267:         stan::io::writer<double> writer__(params_r__,params_i__);
268:         size_t pos__;
269:         (void) pos__; // dummy call to supress warning
270:         std::vector<double> vals_r__;
271:         std::vector<int> vals_i__;
272: 
273:         if (!(context__.contains_r("pcorrvec")))
274:             throw std::runtime_error("variable pcorrvec missing");
275:         vals_r__ = context__.vals_r("pcorrvec");
276:         pos__ = 0U;
277:         context__.validate_dims("initialization", "pcorrvec", "vector_d", context__.to_vec(divide(((ndim * ndim) - ndim),2)));
278:         vector_d pcorrvec(static_cast<Eigen::VectorXd::Index>(divide(((ndim * ndim) - ndim),2)));
279:         for (int j1__ = 0U; j1__ < divide(((ndim * ndim) - ndim),2); ++j1__)
280:             pcorrvec(j1__) = vals_r__[pos__++];
281:         try {
282:             writer__.vector_lub_unconstrain(-(1),1,pcorrvec);
283:         } catch (const std::exception& e) { 
284:             throw std::runtime_error(std::string("Error transforming variable pcorrvec: ") + e.what());
285:         }
286: 
287:         if (!(context__.contains_r("dummy")))
288:             throw std::runtime_error("variable dummy missing");
289:         vals_r__ = context__.vals_r("dummy");
290:         pos__ = 0U;
291:         context__.validate_dims("initialization", "dummy", "double", context__.to_vec());
292:         double dummy(0);
293:         dummy = vals_r__[pos__++];
294:         try {
295:             writer__.scalar_unconstrain(dummy);
296:         } catch (const std::exception& e) { 
297:             throw std::runtime_error(std::string("Error transforming variable dummy: ") + e.what());
298:         }
299: 
300:         params_r__ = writer__.data_r();
301:         params_i__ = writer__.data_i();
302:     }
303: 
304:     void transform_inits(const stan::io::var_context& context,
305:                          Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
306:                          std::ostream* pstream__) const {
307:       std::vector<double> params_r_vec;
308:       std::vector<int> params_i_vec;
309:       transform_inits(context, params_i_vec, params_r_vec, pstream__);
310:       params_r.resize(params_r_vec.size());
311:       for (int i = 0; i < params_r.size(); ++i)
312:         params_r(i) = params_r_vec[i];
313:     }
314: 
315: 
316:     template <bool propto__, bool jacobian__, typename T__>
317:     T__ log_prob(vector<T__>& params_r__,
318:                  vector<int>& params_i__,
319:                  std::ostream* pstream__ = 0) const {
320: 
321:         T__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
322:         (void) DUMMY_VAR__;  // suppress unused var warning
323: 
324:         T__ lp__(0.0);
325:         stan::math::accumulator<T__> lp_accum__;
326: 
327:         // model parameters
328:         stan::io::reader<T__> in__(params_r__,params_i__);
329: 
330:         Eigen::Matrix<T__,Eigen::Dynamic,1>  pcorrvec;
331:         (void) pcorrvec;  // dummy to suppress unused var warning
332:         if (jacobian__)
333:             pcorrvec = in__.vector_lub_constrain(-(1),1,divide(((ndim * ndim) - ndim),2),lp__);
334:         else
335:             pcorrvec = in__.vector_lub_constrain(-(1),1,divide(((ndim * ndim) - ndim),2));
336: 
337:         T__ dummy;
338:         (void) dummy;  // dummy to suppress unused var warning
339:         if (jacobian__)
340:             dummy = in__.scalar_constrain(lp__);
341:         else
342:             dummy = in__.scalar_constrain();
343: 
344: 
345:         // transformed parameters
346:         Eigen::Matrix<T__,Eigen::Dynamic,1>  scalevec(static_cast<Eigen::VectorXd::Index>(ndim));
347:         (void) scalevec;  // dummy to suppress unused var warning
348:         Eigen::Matrix<T__,Eigen::Dynamic,Eigen::Dynamic>  sdpcorrmat(static_cast<Eigen::VectorXd::Index>(ndim),static_cast<Eigen::VectorXd::Index>(ndim));
349:         (void) sdpcorrmat;  // dummy to suppress unused var warning
350:         Eigen::Matrix<T__,Eigen::Dynamic,Eigen::Dynamic>  cholcorrmat(static_cast<Eigen::VectorXd::Index>(ndim),static_cast<Eigen::VectorXd::Index>(ndim));
351:         (void) cholcorrmat;  // dummy to suppress unused var warning
352: 
353:         // initialize transformed variables to avoid seg fault on val access
354:         stan::math::fill(scalevec,DUMMY_VAR__);
355:         stan::math::fill(sdpcorrmat,DUMMY_VAR__);
356:         stan::math::fill(cholcorrmat,DUMMY_VAR__);
357: 
358:         try {
359:             current_statement_begin__ = 75;
360:             stan::math::assign(scalevec, rep_vector(1,ndim));
361:             {
362:                 int counter(0);
363:                 (void) counter;  // dummy to suppress unused var warning
364:                 current_statement_begin__ = 79;
365:                 stan::math::assign(counter, 0);
366:                 current_statement_begin__ = 80;
367:                 stan::math::assign(sdpcorrmat, diag_matrix(scalevec));
368:                 current_statement_begin__ = 82;
369:                 for (int rowi = 2; rowi <= ndim; ++rowi) {
370:                     current_statement_begin__ = 83;
371:                     for (int coli = 1; coli <= (rowi - 1); ++coli) {
372:                         current_statement_begin__ = 84;
373:                         stan::math::assign(counter, (counter + 1));
374:                         current_statement_begin__ = 85;
375:                         stan::math::assign(get_base1_lhs(sdpcorrmat,rowi,coli,"sdpcorrmat",1), get_base1(pcorrvec,counter,"pcorrvec",1));
376:                     }
377:                 }
378:             }
379:             current_statement_begin__ = 90;
380:             stan::math::assign(cholcorrmat, sdpcorr2cov_lp(sdpcorrmat,1,eta, lp__, lp_accum__, pstream__));
381:         } catch (const std::exception& e) {
382:             stan::lang::rethrow_located(e,current_statement_begin__);
383:             // Next line prevents compiler griping about no return
384:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
385:         }
386: 
387:         // validate transformed parameters
388:         for (int i0__ = 0; i0__ < ndim; ++i0__) {
389:             if (stan::math::is_uninitialized(scalevec(i0__))) {
390:                 std::stringstream msg__;
391:                 msg__ << "Undefined transformed parameter: scalevec" << '[' << i0__ << ']';
392:                 throw std::runtime_error(msg__.str());
393:             }
394:         }
395:         for (int i0__ = 0; i0__ < ndim; ++i0__) {
396:             for (int i1__ = 0; i1__ < ndim; ++i1__) {
397:                 if (stan::math::is_uninitialized(sdpcorrmat(i0__,i1__))) {
398:                     std::stringstream msg__;
399:                     msg__ << "Undefined transformed parameter: sdpcorrmat" << '[' << i0__ << ']' << '[' << i1__ << ']';
400:                     throw std::runtime_error(msg__.str());
401:                 }
402:             }
403:         }
404:         for (int i0__ = 0; i0__ < ndim; ++i0__) {
405:             for (int i1__ = 0; i1__ < ndim; ++i1__) {
406:                 if (stan::math::is_uninitialized(cholcorrmat(i0__,i1__))) {
407:                     std::stringstream msg__;
408:                     msg__ << "Undefined transformed parameter: cholcorrmat" << '[' << i0__ << ']' << '[' << i1__ << ']';
409:                     throw std::runtime_error(msg__.str());
410:                 }
411:             }
412:         }
413: 
414:         const char* function__ = "validate transformed params";
415:         (void) function__;  // dummy to suppress unused var warning
416: 
417:         // model body
418:         try {
419:             current_statement_begin__ = 95;
420:             lp_accum__.add(normal_log<propto__>(dummy, 0, 1));
421:         } catch (const std::exception& e) {
422:             stan::lang::rethrow_located(e,current_statement_begin__);
423:             // Next line prevents compiler griping about no return
424:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
425:         }
426: 
427:         lp_accum__.add(lp__);
428:         return lp_accum__.sum();
429: 
430:     } // log_prob()
431: 
432:     template <bool propto, bool jacobian, typename T_>
433:     T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
434:                std::ostream* pstream = 0) const {
435:       std::vector<T_> vec_params_r;
436:       vec_params_r.reserve(params_r.size());
437:       for (int i = 0; i < params_r.size(); ++i)
438:         vec_params_r.push_back(params_r(i));
439:       std::vector<int> vec_params_i;
440:       return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
441:     }
442: 
443: 
444:     void get_param_names(std::vector<std::string>& names__) const {
445:         names__.resize(0);
446:         names__.push_back("pcorrvec");
447:         names__.push_back("dummy");
448:         names__.push_back("scalevec");
449:         names__.push_back("sdpcorrmat");
450:         names__.push_back("cholcorrmat");
451:         names__.push_back("corrmat_out");
452:     }
453: 
454: 
455:     void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
456:         dimss__.resize(0);
457:         std::vector<size_t> dims__;
458:         dims__.resize(0);
459:         dims__.push_back(divide(((ndim * ndim) - ndim),2));
460:         dimss__.push_back(dims__);
461:         dims__.resize(0);
462:         dimss__.push_back(dims__);
463:         dims__.resize(0);
464:         dims__.push_back(ndim);
465:         dimss__.push_back(dims__);
466:         dims__.resize(0);
467:         dims__.push_back(ndim);
468:         dims__.push_back(ndim);
469:         dimss__.push_back(dims__);
470:         dims__.resize(0);
471:         dims__.push_back(ndim);
472:         dims__.push_back(ndim);
473:         dimss__.push_back(dims__);
474:         dims__.resize(0);
475:         dims__.push_back(ndim);
476:         dims__.push_back(ndim);
477:         dimss__.push_back(dims__);
478:     }
479: 
480:     template <typename RNG>
481:     void write_array(RNG& base_rng__,
482:                      std::vector<double>& params_r__,
483:                      std::vector<int>& params_i__,
484:                      std::vector<double>& vars__,
485:                      bool include_tparams__ = true,
486:                      bool include_gqs__ = true,
487:                      std::ostream* pstream__ = 0) const {
488:         vars__.resize(0);
489:         stan::io::reader<double> in__(params_r__,params_i__);
490:         static const char* function__ = "model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::write_array";
491:         (void) function__; // dummy call to supress warning
492:         // read-transform, write parameters
493:         vector_d pcorrvec = in__.vector_lub_constrain(-(1),1,divide(((ndim * ndim) - ndim),2));
494:         double dummy = in__.scalar_constrain();
495:         for (int k_0__ = 0; k_0__ < divide(((ndim * ndim) - ndim),2); ++k_0__) {
496:             vars__.push_back(pcorrvec[k_0__]);
497:         }
498:         vars__.push_back(dummy);
499: 
500:         if (!include_tparams__) return;
501:         // declare and define transformed parameters
502:         double lp__ = 0.0;
503:         (void) lp__; // dummy call to supress warning
504:         stan::math::accumulator<double> lp_accum__;
505: 
506:         vector_d scalevec(static_cast<Eigen::VectorXd::Index>(ndim));
507:         (void) scalevec;  // dummy to suppress unused var warning
508:         matrix_d sdpcorrmat(static_cast<Eigen::VectorXd::Index>(ndim),static_cast<Eigen::VectorXd::Index>(ndim));
509:         (void) sdpcorrmat;  // dummy to suppress unused var warning
510:         matrix_d cholcorrmat(static_cast<Eigen::VectorXd::Index>(ndim),static_cast<Eigen::VectorXd::Index>(ndim));
511:         (void) cholcorrmat;  // dummy to suppress unused var warning
512: 
513:         try {
514:             current_statement_begin__ = 75;
515:             stan::math::assign(scalevec, rep_vector(1,ndim));
516:             {
517:                 int counter(0);
518:                 (void) counter;  // dummy to suppress unused var warning
519:                 current_statement_begin__ = 79;
520:                 stan::math::assign(counter, 0);
521:                 current_statement_begin__ = 80;
522:                 stan::math::assign(sdpcorrmat, diag_matrix(scalevec));
523:                 current_statement_begin__ = 82;
524:                 for (int rowi = 2; rowi <= ndim; ++rowi) {
525:                     current_statement_begin__ = 83;
526:                     for (int coli = 1; coli <= (rowi - 1); ++coli) {
527:                         current_statement_begin__ = 84;
528:                         stan::math::assign(counter, (counter + 1));
529:                         current_statement_begin__ = 85;
530:                         stan::math::assign(get_base1_lhs(sdpcorrmat,rowi,coli,"sdpcorrmat",1), get_base1(pcorrvec,counter,"pcorrvec",1));
531:                     }
532:                 }
533:             }
534:             current_statement_begin__ = 90;
535:             stan::math::assign(cholcorrmat, sdpcorr2cov_lp(sdpcorrmat,1,eta, lp__, lp_accum__, pstream__));
536:         } catch (const std::exception& e) {
537:             stan::lang::rethrow_located(e,current_statement_begin__);
538:             // Next line prevents compiler griping about no return
539:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
540:         }
541: 
542:         // validate transformed parameters
543: 
544:         // write transformed parameters
545:         for (int k_0__ = 0; k_0__ < ndim; ++k_0__) {
546:             vars__.push_back(scalevec[k_0__]);
547:         }
548:         for (int k_1__ = 0; k_1__ < ndim; ++k_1__) {
549:             for (int k_0__ = 0; k_0__ < ndim; ++k_0__) {
550:                 vars__.push_back(sdpcorrmat(k_0__, k_1__));
551:             }
552:         }
553:         for (int k_1__ = 0; k_1__ < ndim; ++k_1__) {
554:             for (int k_0__ = 0; k_0__ < ndim; ++k_0__) {
555:                 vars__.push_back(cholcorrmat(k_0__, k_1__));
556:             }
557:         }
558: 
559:         if (!include_gqs__) return;
560:         // declare and define generated quantities
561:         matrix_d corrmat_out(static_cast<Eigen::VectorXd::Index>(ndim),static_cast<Eigen::VectorXd::Index>(ndim));
562:         (void) corrmat_out;  // dummy to suppress unused var warning
563: 
564:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
565:         (void) DUMMY_VAR__;  // suppress unused var warning
566: 
567: 
568:         // initialize transformed variables to avoid seg fault on val access
569:         stan::math::fill(corrmat_out,DUMMY_VAR__);
570: 
571:         try {
572:             current_statement_begin__ = 100;
573:             stan::math::assign(corrmat_out, multiply(cholcorrmat,transpose(cholcorrmat)));
574:         } catch (const std::exception& e) {
575:             stan::lang::rethrow_located(e,current_statement_begin__);
576:             // Next line prevents compiler griping about no return
577:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
578:         }
579: 
580:         // validate generated quantities
581: 
582:         // write generated quantities
583:         for (int k_1__ = 0; k_1__ < ndim; ++k_1__) {
584:             for (int k_0__ = 0; k_0__ < ndim; ++k_0__) {
585:                 vars__.push_back(corrmat_out(k_0__, k_1__));
586:             }
587:         }
588: 
589:     }
590: 
591:     template <typename RNG>
592:     void write_array(RNG& base_rng,
593:                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
594:                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
595:                      bool include_tparams = true,
596:                      bool include_gqs = true,
597:                      std::ostream* pstream = 0) const {
598:       std::vector<double> params_r_vec(params_r.size());
599:       for (int i = 0; i < params_r.size(); ++i)
600:         params_r_vec[i] = params_r(i);
601:       std::vector<double> vars_vec;
602:       std::vector<int> params_i_vec;
603:       write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
604:       vars.resize(vars_vec.size());
605:       for (int i = 0; i < vars.size(); ++i)
606:         vars(i) = vars_vec[i];
607:     }
608: 
609:     static std::string model_name() {
610:         return "model21e05f842a3d_668201f656fa56a40310f15ffd0f7343";
611:     }
612: 
613: 
614:     void constrained_param_names(std::vector<std::string>& param_names__,
615:                                  bool include_tparams__ = true,
616:                                  bool include_gqs__ = true) const {
617:         std::stringstream param_name_stream__;
618:         for (int k_0__ = 1; k_0__ <= divide(((ndim * ndim) - ndim),2); ++k_0__) {
619:             param_name_stream__.str(std::string());
620:             param_name_stream__ << "pcorrvec" << '.' << k_0__;
621:             param_names__.push_back(param_name_stream__.str());
622:         }
623:         param_name_stream__.str(std::string());
624:         param_name_stream__ << "dummy";
625:         param_names__.push_back(param_name_stream__.str());
626: 
627:         if (!include_gqs__ && !include_tparams__) return;
628:         for (int k_0__ = 1; k_0__ <= ndim; ++k_0__) {
629:             param_name_stream__.str(std::string());
630:             param_name_stream__ << "scalevec" << '.' << k_0__;
631:             param_names__.push_back(param_name_stream__.str());
632:         }
633:         for (int k_1__ = 1; k_1__ <= ndim; ++k_1__) {
634:             for (int k_0__ = 1; k_0__ <= ndim; ++k_0__) {
635:                 param_name_stream__.str(std::string());
636:                 param_name_stream__ << "sdpcorrmat" << '.' << k_0__ << '.' << k_1__;
637:                 param_names__.push_back(param_name_stream__.str());
638:             }
639:         }
640:         for (int k_1__ = 1; k_1__ <= ndim; ++k_1__) {
641:             for (int k_0__ = 1; k_0__ <= ndim; ++k_0__) {
642:                 param_name_stream__.str(std::string());
643:                 param_name_stream__ << "cholcorrmat" << '.' << k_0__ << '.' << k_1__;
644:                 param_names__.push_back(param_name_stream__.str());
645:             }
646:         }
647: 
648:         if (!include_gqs__) return;
649:         for (int k_1__ = 1; k_1__ <= ndim; ++k_1__) {
650:             for (int k_0__ = 1; k_0__ <= ndim; ++k_0__) {
651:                 param_name_stream__.str(std::string());
652:                 param_name_stream__ << "corrmat_out" << '.' << k_0__ << '.' << k_1__;
653:                 param_names__.push_back(param_name_stream__.str());
654:             }
655:         }
656:     }
657: 
658: 
659:     void unconstrained_param_names(std::vector<std::string>& param_names__,
660:                                    bool include_tparams__ = true,
661:                                    bool include_gqs__ = true) const {
662:         std::stringstream param_name_stream__;
663:         for (int k_0__ = 1; k_0__ <= divide(((ndim * ndim) - ndim),2); ++k_0__) {
664:             param_name_stream__.str(std::string());
665:             param_name_stream__ << "pcorrvec" << '.' << k_0__;
666:             param_names__.push_back(param_name_stream__.str());
667:         }
668:         param_name_stream__.str(std::string());
669:         param_name_stream__ << "dummy";
670:         param_names__.push_back(param_name_stream__.str());
671: 
672:         if (!include_gqs__ && !include_tparams__) return;
673:         for (int k_0__ = 1; k_0__ <= ndim; ++k_0__) {
674:             param_name_stream__.str(std::string());
675:             param_name_stream__ << "scalevec" << '.' << k_0__;
676:             param_names__.push_back(param_name_stream__.str());
677:         }
678:         for (int k_1__ = 1; k_1__ <= ndim; ++k_1__) {
679:             for (int k_0__ = 1; k_0__ <= ndim; ++k_0__) {
680:                 param_name_stream__.str(std::string());
681:                 param_name_stream__ << "sdpcorrmat" << '.' << k_0__ << '.' << k_1__;
682:                 param_names__.push_back(param_name_stream__.str());
683:             }
684:         }
685:         for (int k_1__ = 1; k_1__ <= ndim; ++k_1__) {
686:             for (int k_0__ = 1; k_0__ <= ndim; ++k_0__) {
687:                 param_name_stream__.str(std::string());
688:                 param_name_stream__ << "cholcorrmat" << '.' << k_0__ << '.' << k_1__;
689:                 param_names__.push_back(param_name_stream__.str());
690:             }
691:         }
692: 
693:         if (!include_gqs__) return;
694:         for (int k_1__ = 1; k_1__ <= ndim; ++k_1__) {
695:             for (int k_0__ = 1; k_0__ <= ndim; ++k_0__) {
696:                 param_name_stream__.str(std::string());
697:                 param_name_stream__ << "corrmat_out" << '.' << k_0__ << '.' << k_1__;
698:                 param_names__.push_back(param_name_stream__.str());
699:             }
700:         }
701:     }
702: 
703: }; // model
704: 
705: } // namespace
706: 
707: typedef model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343 stan_model;
708: 
709: #include <rstan/rstaninc.hpp>
710: /**
711:  * Define Rcpp Module to expose stan_fit's functions to R.
712:  */
713: RCPP_MODULE(stan_fit4model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_mod){
714:   Rcpp::class_<rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343,
715:                boost::random::ecuyer1988> >("stan_fit4model21e05f842a3d_668201f656fa56a40310f15ffd0f7343")
716:     // .constructor<Rcpp::List>()
717:     .constructor<SEXP, SEXP>()
718:     // .constructor<SEXP, SEXP>()
719:     .method("call_sampler",
720:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::call_sampler)
721:     .method("param_names",
722:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::param_names)
723:     .method("param_names_oi",
724:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::param_names_oi)
725:     .method("param_fnames_oi",
726:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::param_fnames_oi)
727:     .method("param_dims",
728:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::param_dims)
729:     .method("param_dims_oi",
730:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::param_dims_oi)
731:     .method("update_param_oi",
732:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::update_param_oi)
733:     .method("param_oi_tidx",
734:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::param_oi_tidx)
735:     .method("grad_log_prob",
736:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::grad_log_prob)
737:     .method("log_prob",
738:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::log_prob)
739:     .method("unconstrain_pars",
740:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::unconstrain_pars)
741:     .method("constrain_pars",
742:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::constrain_pars)
743:     .method("num_pars_unconstrained",
744:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::num_pars_unconstrained)
745:     .method("unconstrained_param_names",
746:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::unconstrained_param_names)
747:     .method("constrained_param_names",
748:             &rstan::stan_fit<model21e05f842a3d_668201f656fa56a40310f15ffd0f7343_namespace::model21e05f842a3d_668201f656fa56a40310f15ffd0f7343, boost::random::ecuyer1988>::constrained_param_names)
749:     ;
750: }
751: 
752: // declarations
753: extern "C" {
754: SEXP file21e0675830d8( ) ;
755: }
756: 
757: // definition
758: 
759: SEXP file21e0675830d8(  ){
760:  return Rcpp::wrap("668201f656fa56a40310f15ffd0f7343");
761: }
762: 
763: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/mat/fun/promote_scalar.hpp:4:0,
                 from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/mat.hpp:133,
                 from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/rev/mat.hpp:9,
                 from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math.hpp:4,
                 from C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file21e0675830d8.cpp:8:
C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/scal/fun/promote_scalar.hpp: In instantiation of 'static T stan::math::promote_scalar_struct<T, S>::apply(S) [with T = double; S = stan::math::var]':
C:/Users/driver/Documents/R/win-library/3.3/StanHeaders/include/stan/math/prim/
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-33~1.0/bin/x64/R CMD SHLIB file21e0675830d8.cpp 2> file21e0675830d8.cpp.err.txt' had status 1 

Daniel Lee

unread,
Nov 1, 2016, 2:21:55 PM11/1/16
to stan-...@googlegroups.com
Thanks. What version of RStan? That looks like a bug that was fixed for 2.12. (I'm replying on my phone underground.... I'd try to find the actual issue if I had reliable internet.)


Daniel

Daniel Lee

unread,
Nov 1, 2016, 2:29:46 PM11/1/16
to stan-...@googlegroups.com

It was fixed for 2.12. If you're using 2.12 and it's still broken, I'll get it fixed for our next release. 


Daniel
Message has been deleted

Charles Driver

unread,
Nov 1, 2016, 3:03:03 PM11/1/16
to Stan users mailing list
You made me wonder, but I checked on my laptop which is definitely 2.12 and it's also broken.
...
Reply all
Reply to author
Forward
0 new messages