#include using namespace arma; // [[Rcpp::depends(RcppArmadillo)]] // [[Rcpp::export]] // Rcpp::List multistate_ddt(mat P, cube Pu, cube Q, cube Qu) { RcppExport SEXP multistate_ddt(SEXP P_, SEXP Pu_, SEXP Q_, SEXP Qu_) { // P(nstates,nobs), Pu(nstates,ncoef,nobs), Q(nstates,nstates,nobs), Qu(nstates*nstates,ncoef,nobs) mat P = Rcpp::as(P_); cube Pu = Rcpp::as(Pu_); cube Q = Rcpp::as(Q_); cube Qu = Rcpp::as(Qu_); int nstates = P.n_rows; int nobs=P.n_cols; int ncoef=Pu.n_cols; mat dPdt = P*0.0; // nstates,nobs cube dPudt = Pu*0.0; // nstates,ncoef,nobs for(int i=0; i::from(P.col(i)); vec rs = sum(Qi,1); for (int j=0; j::from(Pi*Qi); // is this valid? cube Qui = Qu(span::all, span::all, span(i,i)); Qui.reshape(nstates,nstates,ncoef); mat Pui = Pu.slice(i); for (int j=0; j