A matrix view is a temporary object, stored on the stack, which can be
used to operate on a subset of matrix elements. Matrix views can be
defined for both constant and non-constant matrices using separate types
that preserve constness. A matrix view has the type
gsl_matrix_view
and a constant matrix view has the type
gsl_matrix_const_view
. In both cases the elements of the view
can by accessed using the matrix
component of the view object. A
pointer gsl_matrix *
or const gsl_matrix *
can be obtained
by taking the address of the matrix
component with the &
operator. In addition to matrix views it is also possible to create
vector views of a matrix, such as row or column views.
m'(i,j) = m->data[(k1*m->tda + k2) + i*m->tda + j]
where the index i runs from 0 to n1-1
and the index j
runs from 0 to n2-1
.
The data
pointer of the returned matrix struct is set to null if
the combined parameters (k1,k2,n1,n2,tda)
overrun the ends of the original matrix.
The new matrix view is only a view of the block underlying the existing matrix, m. The block containing the elements of m is not owned by the new matrix view. When the view goes out of scope the original matrix m and its block will continue to exist. The original memory can only be deallocated by freeing the original matrix. Of course, the original matrix should not be deallocated while the view is still in use.
The function gsl_matrix_const_submatrix
is equivalent to
gsl_matrix_submatrix
but can be used for matrices which are
declared const
.
m'(i,j) = base[i*n2 + j]
where the index i runs from 0 to n1-1
and the index j
runs from 0 to n2-1
.
The new matrix is only a view of the array base. When the view goes out of scope the original array base will continue to exist. The original memory can only be deallocated by freeing the original array. Of course, the original array should not be deallocated while the view is still in use.
The function gsl_matrix_const_view_array
is equivalent to
gsl_matrix_view_array
but can be used for matrices which are
declared const
.
m'(i,j) = base[i*tda + j]
where the index i runs from 0 to n1-1
and the index j
runs from 0 to n2-1
.
The new matrix is only a view of the array base. When the view goes out of scope the original array base will continue to exist. The original memory can only be deallocated by freeing the original array. Of course, the original array should not be deallocated while the view is still in use.
The function gsl_matrix_const_view_array_with_tda
is equivalent
to gsl_matrix_view_array_with_tda
but can be used for matrices
which are declared const
.
m'(i,j) = v->data[i*n2 + j]
where the index i runs from 0 to n1-1
and the index j
runs from 0 to n2-1
.
The new matrix is only a view of the vector v. When the view goes out of scope the original vector v will continue to exist. The original memory can only be deallocated by freeing the original vector. Of course, the original vector should not be deallocated while the view is still in use.
The function gsl_matrix_const_view_vector
is equivalent to
gsl_matrix_view_vector
but can be used for matrices which are
declared const
.
m'(i,j) = v->data[i*tda + j]
where the index i runs from 0 to n1-1
and the index j
runs from 0 to n2-1
.
The new matrix is only a view of the vector v. When the view goes out of scope the original vector v will continue to exist. The original memory can only be deallocated by freeing the original vector. Of course, the original vector should not be deallocated while the view is still in use.
The function gsl_matrix_const_view_vector_with_tda
is equivalent
to gsl_matrix_view_vector_with_tda
but can be used for matrices
which are declared const
.