Go to the first, previous, next, last section, table of contents.

Copying rows and columns

The functions described in this section copy a row or column of a matrix into a vector. This allows the elements of the vector and the matrix to be modified independently. Note that if the matrix and the vector point to overlapping regions of memory then the result will be undefined. The same effect can be achieved with more generality using gsl_vector_memcpy with vector views of rows and columns.

Function: int gsl_matrix_get_row (gsl_vector * v, const gsl_matrix * m, size_t i)
This function copies the elements of the i-th row of the matrix m into the vector v. The length of the vector must be the same as the length of the row.

Function: int gsl_matrix_get_col (gsl_vector * v, const gsl_matrix * m, size_t j)
This function copies the elements of the i-th column of the matrix m into the vector v. The length of the vector must be the same as the length of the column.

Function: int gsl_matrix_set_row (gsl_matrix * m, size_t i, const gsl_vector * v)
This function copies the elements of the vector v into the i-th row of the matrix m. The length of the vector must be the same as the length of the row.

Function: int gsl_matrix_set_col (gsl_matrix * m, size_t j, const gsl_vector * v)
This function copies the elements of the vector v into the i-th column of the matrix m. The length of the vector must be the same as the length of the column.


Go to the first, previous, next, last section, table of contents.