c++ - Find number of rows/columns in a GSL matrix? -
say have gsl_matrix * a
. want write function retrieves e.g. number of rows in matrix, without having access else besides object itself.
example:
int num_rows(gsl_matrix * a){ //some operation(s) on find number of rows in matrix //store number in int r return r; }
what write me?
from https://www.gnu.org/software/gsl/manual/html_node/matrices.html
gsl_matrix
defined as:
typedef struct { size_t size1; size_t size2; size_t tda; double * data; gsl_block * block; int owner; } gsl_matrix;
and
the number of rows size1. range of valid row indices runs 0 size1-1. size2 number of columns. range of valid column indices runs 0 size2-1. physical row dimension tda, or trailing dimension, specifies size of row of matrix laid out in memory.
so if want number of rows in a
use:
int num_rows(gsl_matrix * a){ int r = a->size1; return r; }
Comments
Post a Comment