get values from dolfin::Matrix
I'm Valerio and I'm using FEniCS fenics/2016.1.0 in C++. I need something that extracts the coefficients in a row of a dolfin::Matrix and allocates them in a std::vector<double> or in a pointer to double. Is there a simple way to do it? something like:
with A object of the class dolfin::Matrix, my_vector a pointer to double or a object of the class vector, and row an int value that identifies the row. I know that there is the function:
but i don't understand what it takes as input. Could you give me a practical example?
void get(double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const
virtual void getrow(std::size_t row, std::vector<std::size_t>& columns, std::vector<double>& values) const
In order to find out what the arguments mean have look at some implementation of the method, e.g. in file PETScMatrix.cpp. You'll find out it calls
MatGetRow of petsc library. There
row is the index of the row you are interested in,
values will be filled with columns indices and actual values in that row respectively.