c++ - Assigning elements in a numeric matrix very slow in Rcpp -


I am new to RCPP and C ++ programming in general, so I hope this question is not even basic < / P>

I am trying to write some code which will return a numerical matrix with some inputs. The code includes many edges, see below. Unfortunately it is currently very slow. However, if we run the code without specifying the counting numbers in the matrix, the program runs immediately. Similarly, if we change the counting number slightly to exclude "TMP" below (see the comment below), it runs immediately (see the comments below).

Any suggestion about how to make this race more quickly is greatly appreciated! Sorry if this poorly written code insults you

Code:

  // [[RCP :: Exports]] Numeric matrix lenaltime (numeric matrix infatt, numeric matrix D, Integrator Times, Numeric Vector Theta, Numeric Vector Pop) {Ent Enro = Infmat.nrow (); Int ncol = infmat.ncol (); Numerical matrix ll (nrow, ncol); Int tmax; Double PJ; Double LaminateJet; Double PI; Double Dies; Double tmp; Double PK; Double DJK; For (int j = 0; j and lt; enro; j ++) {tmx = times [j]; PJ = log (pop [j]) * theta [0]; For (int t = 0; t  


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -