// version 1.0.0 14Feb2018 // source file for MyMatrix class #include #include #include "mymatrix.h" #include "stplugin.h" #define M(i,j) *(mat+(i)*c+j) // Constructor // creates matrix and and initializes elements to zero // Notes: matrices are long vectors with row-major storage // The i,j element of an r x c matrix is // the (i-1)*r + (j-1) element of the of the vector // under C-style zero-base indexing // MyMatrix::MyMatrix(ST_int rows, ST_int cols) : r(rows), c(cols) { ST_int i, j, TotalSize ; TotalSize = r * c ; try { mat = new ST_double[TotalSize]; for(i=0; i0) { sprintf(msg, "cannot access Stata matrix %s\n", smname) ; SF_error(msg) ; return(rc_st) ; } } } return(rc_st) ; } #undef M