Hi
I'm trying to write a cpp11 code for an assignment and I have a problem that doesn't happen with Rcpp.
First I tried
doubles cpp_partialDerivative_other(int iterMax, integers Q, int N, double epsDeriv,
double ll_d2, double dx_dother, double init,
integers_matrix<> dumMat, int nbCluster){
// takes in:
// dumMat: the matrix of dummies (n X c) each obs => cluster // must be in cpp index!!!
// init: the initialisation of the sum of derivatives vector
// ll_d2: the second derivative
// dx_dother: the vector of dx_dother
int iter;
writable::integers i, q, c;
writable::integers index;
writable::integers sum_cases=0;
writable::logicals ok;
writable::doubles new_value;
writable::integers start(Q), end(Q);
for(q=0 ; q<Q ; q++){
// the total number of clusters (eg if man/woman and 10 countries: total of 12 cases)
sum_cases += nbCluster(q);
etc...
in the "for" statement, I get an error: no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive]
if I put the cursor over the line, it says: "cannot increment the value of type 'writable::integers'"
Then I tried
int iter;
int i, q, c;
int index;
int sum_cases=0;
bool ok;
double new_value;
writable::integers start(Q), end(Q);
for(q=0 ; q<Q ; q++) {
// the total number of clusters (eg if man/woman and 10 countries: total of 12 cases)
sum_cases += nbCluster(q);
if(q == 0){
start(q) = 0;
end(q) = nbCluster(q);
} else {
start(q) = start(q-1) + nbCluster(q-1);
end(q) = end(q-1) + nbCluster(q);
}
}
but now I see this error for sum_cases += nbCluster(q);
: expression cannot be used as a function
I'm adapting from fixest/misc_funs.cpp at master · lrberge/fixest · GitHub besides separate Stan codes