vectors.texi

来自「math library from gnu」· TEXI 代码 · 共 1,492 行 · 第 1/5 页

TEXI
1,492
字号
@comment @comment @deftypefun int gsl_matrix_view_from_matrix (gsl_matrix * @var{m}, gsl_matrix * @var{mm}, const size_t @var{k1}, const size_t @var{k2}, const size_t @var{n1}, const size_t @var{n2})@comment This function modifies and existing matrix view @var{m} to form a new@comment view of a matrix @var{mm}, starting from element (@var{k1},@var{k2}).@comment The matrix view has @var{n1} rows and @var{n2} columns.  Any existing@comment view in @var{m} will be lost as a result of this function.@comment @end deftypefun@comment @comment @deftypefun int gsl_matrix_view_from_vector (gsl_matrix * @var{m}, gsl_vector * @var{v}, const size_t @var{offset}, const size_t @var{n1}, const size_t @var{n2})@comment This function modifies and existing matrix view @var{m} to form a new@comment view of a vector @var{v}, starting from element @var{offset}.  The@comment vector has @var{n1} rows and @var{n2} columns.  Any@comment existing view in @var{m} will be lost as a result of this function.@comment @end deftypefun@comment @comment @deftypefun int gsl_matrix_view_from_array (gsl_matrix * @var{m}, double * @var{base}, const size_t @var{offset}, const size_t @var{n1}, const size_t @var{n2})@comment This function modifies and existing matrix view @var{m} to form a new@comment view of an array @var{base}, starting from element @var{offset}.  The@comment matrix has @var{n1} rows and @var{n2} columns.  Any@comment existing view in @var{m} will be lost as a result of this function.@comment @end deftypefun@comment @comment @deftypefun {gsl_matrix *} gsl_matrix_alloc_from_block (gsl_block * @var{b}, size_t @var{offset}, size_t @var{n1}, size_t @var{n2}, size_t @var{tda})@comment This function creates a matrix as a slice of the block @var{b},@comment returning a pointer to a newly initialized matrix struct.  The start of@comment the matrix is offset by @var{offset} elements from the start of the@comment block.  The matrix has @var{n1} rows and @var{n2} columns, with the@comment physical number of columns in memory given by @var{tda}.@comment Mathematically, the (@var{i},@var{j})-th element of the matrix is given by,@comment @comment @example@comment m(i,j) = b->data[offset + i*tda + j]@comment @end example@comment @noindent@comment where the index @var{i} runs from 0 to @code{n1-1} and the index @var{j}@comment runs from 0 to @code{n2-1}.@comment @comment A null pointer is returned if the combined parameters@comment (@var{offset},@var{n1},@var{n2},@var{tda}) overrun the end of the block@comment or if insufficient memory is available to store the matrix.@comment @comment The matrix is only a view of the block @var{b}, and the block is not@comment owned by the matrix.  When the matrix is deallocated the block @var{b}@comment will continue to exist.  This memory can only be deallocated by freeing@comment the block itself.  Of course, this block should not be deallocated while@comment the matrix is still in use.@comment @end deftypefun@comment @comment @deftypefun {gsl_matrix *} gsl_matrix_alloc_from_matrix (gsl_matrix * @var{m}, size_t @var{k1}, size_t @var{k2}, size_t @var{n1}, size_t @var{n2})@comment @comment This function creates a matrix as a submatrix of the matrix @var{m},@comment returning a pointer to a newly initialized matrix struct.  The upper-left@comment element of the submatrix is the element (@var{k1},@var{k2}) of the@comment original matrix.  The submatrix has @var{n1} rows and @var{n2} columns.@comment The physical number of columns in memory given by @var{tda} is@comment unchanged.  Mathematically, the (@var{i},@var{j})-th element of the@comment new matrix is given by,@comment @comment @example@comment m'(i,j) = m->data[(k1*m->tda + k2) + i*m->tda + j]@comment @end example@comment @noindent@comment where the index @var{i} runs from 0 to @code{n1-1} and the index @var{j}@comment runs from 0 to @code{n2-1}.@comment @comment A null pointer is returned if the combined parameters@comment (@var{k1},@var{k2},@var{n1},@var{n2},@var{tda}) overrun the end of the@comment original matrix or if insufficient memory is available to store the matrix.@comment @comment The new matrix is only a view of the block underlying the existing@comment matrix, @var{m}.  The block is not owned by the new matrix.  When the new@comment matrix is deallocated the original matrix @var{m} and its block will@comment continue to exist.  The original memory can only be deallocated by@comment freeing the original matrix.  Of course, the original matrix should not@comment be deallocated while the new matrix is still in use.@comment @end deftypefun@node Creating row and column views@subsection Creating row and column viewsIn general there are two ways to access an object, by reference or bycopying.  The functions described in this section create vector viewswhich allow access to a row or column of a matrix by reference.Modifying elements of the view is equivalent to modifying the matrix,since both the vector view and the matrix point to the same memoryblock.@deftypefun gsl_vector_view gsl_matrix_row (gsl_matrix * @var{m}, size_t @var{i})@deftypefunx {gsl_vector_const_view} gsl_matrix_const_row (const gsl_matrix * @var{m}, size_t @var{i})These functions return a vector view of the @var{i}-th row of the matrix@var{m}.  The @code{data} pointer of the new vector is set to null if@var{i} is out of range.The function @code{gsl_vector_const_row} is equivalent to@code{gsl_matrix_row} but can be used for matrices which are declared@code{const}.@end deftypefun@deftypefun gsl_vector_view gsl_matrix_column (gsl_matrix * @var{m}, size_t @var{j})@deftypefunx {gsl_vector_const_view} gsl_matrix_const_column (const gsl_matrix * @var{m}, size_t @var{j})These functions return a vector view of the @var{j}-th column of thematrix @var{m}.  The @code{data} pointer of the new vector is set tonull if @var{j} is out of range.The function @code{gsl_vector_const_column} is equivalent to@code{gsl_matrix_column} but can be used for matrices which are declared@code{const}.@end deftypefun@deftypefun gsl_vector_view gsl_matrix_subrow (gsl_matrix * @var{m}, size_t @var{i}, size_t @var{offset}, size_t @var{n})@deftypefunx {gsl_vector_const_view} gsl_matrix_const_subrow (const gsl_matrix * @var{m}, size_t @var{i}, size_t @var{offset}, size_t @var{n})These functions return a vector view of the @var{i}-th row of the matrix@var{m} beginning at @var{offset} elements past the first column andcontaining @var{n} elements. The @code{data} pointer of the new vectoris set to null if @var{i}, @var{offset}, or @var{n} are out of range.The function @code{gsl_vector_const_subrow} is equivalent to@code{gsl_matrix_subrow} but can be used for matrices which are declared@code{const}.@end deftypefun@deftypefun gsl_vector_view gsl_matrix_subcolumn (gsl_matrix * @var{m}, size_t @var{j}, size_t @var{offset}, size_t @var{n})@deftypefunx {gsl_vector_const_view} gsl_matrix_const_subcolumn (const gsl_matrix * @var{m}, size_t @var{j}, size_t @var{offset}, size_t @var{n})These functions return a vector view of the @var{j}-th column of the matrix@var{m} beginning at @var{offset} elements past the first row andcontaining @var{n} elements. The @code{data} pointer of the new vectoris set to null if @var{j}, @var{offset}, or @var{n} are out of range.The function @code{gsl_vector_const_subcolumn} is equivalent to@code{gsl_matrix_subcolumn} but can be used for matrices which are declared@code{const}.@end deftypefun@cindex matrix diagonal@cindex diagonal, of a matrix@deftypefun gsl_vector_view gsl_matrix_diagonal (gsl_matrix * @var{m})@deftypefunx {gsl_vector_const_view} gsl_matrix_const_diagonal (const gsl_matrix * @var{m})These functions returns a vector view of the diagonal of the matrix@var{m}. The matrix @var{m} is not required to be square. For arectangular matrix the length of the diagonal is the same as the smallerdimension of the matrix.The function @code{gsl_matrix_const_diagonal} is equivalent to@code{gsl_matrix_diagonal} but can be used for matrices which aredeclared @code{const}.@end deftypefun@cindex matrix subdiagonal@cindex subdiagonal, of a matrix@deftypefun gsl_vector_view gsl_matrix_subdiagonal (gsl_matrix * @var{m}, size_t @var{k}) @deftypefunx {gsl_vector_const_view} gsl_matrix_const_subdiagonal (const gsl_matrix * @var{m}, size_t @var{k})These functions return a vector view of the @var{k}-th subdiagonal ofthe matrix @var{m}. The matrix @var{m} is not required to be square.The diagonal of the matrix corresponds to @math{k = 0}.The function @code{gsl_matrix_const_subdiagonal} is equivalent to@code{gsl_matrix_subdiagonal} but can be used for matrices which aredeclared @code{const}.@end deftypefun@cindex matrix superdiagonal@cindex superdiagonal, matrix@deftypefun gsl_vector_view gsl_matrix_superdiagonal (gsl_matrix * @var{m}, size_t @var{k}) @deftypefunx {gsl_vector_const_view} gsl_matrix_const_superdiagonal (const gsl_matrix * @var{m}, size_t @var{k})These functions return a vector view of the @var{k}-th superdiagonal ofthe matrix @var{m}. The matrix @var{m} is not required to be square. Thediagonal of the matrix corresponds to @math{k = 0}.The function @code{gsl_matrix_const_superdiagonal} is equivalent to@code{gsl_matrix_superdiagonal} but can be used for matrices which aredeclared @code{const}.@end deftypefun@comment @deftypefun {gsl_vector *} gsl_vector_alloc_row_from_matrix (gsl_matrix * @var{m}, size_t @var{i})@comment This function allocates a new @code{gsl_vector} struct which points to@comment the @var{i}-th row of the matrix @var{m}.@comment @end deftypefun@comment @comment @deftypefun {gsl_vector *} gsl_vector_alloc_col_from_matrix (gsl_matrix * @var{m}, size_t @var{j})@comment This function allocates a new @code{gsl_vector} struct which points to@comment the @var{j}-th column of the matrix @var{m}.@comment @end deftypefun@node Copying matrices@subsection Copying matrices@deftypefun int gsl_matrix_memcpy (gsl_matrix * @var{dest}, const gsl_matrix * @var{src})This function copies the elements of the matrix @var{src} into thematrix @var{dest}.  The two matrices must have the same size.@end deftypefun@deftypefun int gsl_matrix_swap (gsl_matrix * @var{m1}, gsl_matrix * @var{m2})This function exchanges the elements of the matrices @var{m1} and@var{m2} by copying.  The two matrices must have the same size.@end deftypefun@node Copying rows and columns@subsection Copying rows and columnsThe functions described in this section copy a row or column of a matrixinto a vector.  This allows the elements of the vector and the matrix tobe modified independently.  Note that if the matrix and the vector pointto overlapping regions of memory then the result will be undefined.  Thesame effect can be achieved with more generality using@code{gsl_vector_memcpy} with vector views of rows and columns.@deftypefun int gsl_matrix_get_row (gsl_vector * @var{v}, const gsl_matrix * @var{m}, size_t @var{i})This function copies the elements of the @var{i}-th row of the matrix@var{m} into the vector @var{v}.  The length of the vector must be thesame as the length of the row.@end deftypefun@deftypefun int gsl_matrix_get_col (gsl_vector * @var{v}, const gsl_matrix * @var{m}, size_t @var{j})This function copies the elements of the @var{j}-th column of the matrix@var{m} into the vector @var{v}.  The length of the vector must be thesame as the length of the column.@end deftypefun@deftypefun int gsl_matrix_set_row (gsl_matrix * @var{m}, size_t @var{i}, const gsl_vector * @var{v})This function copies the elements of the vector @var{v} into the@var{i}-th row of the matrix @var{m}.  The length of the vector must bethe same as the length of the row.@end deftypefun@deftypefun int gsl_matrix_set_col (gsl_matrix * @var{m}, size_t @var{j}, const gsl_vector * @var{v})This function copies the elements of the vector @var{v} into the@var{j}-th column of the matrix @var{m}.  The length of the vector must bethe same as the length of the column.@end deftypefun@node Exchanging rows and columns@subsection Exchanging rows and columnsThe following functions can be used to exchange the rows and columns ofa matrix.@deftypefun int gsl_matrix_swap_rows (gsl_matrix * @var{m}, size_t @var{i}, size_t @var{j})This function exchanges the @var{i}-th and @var{j}-th rows of the matrix@var{m} in-place.@end deftypefun@deftypefun int gsl_matrix_swap_columns (gsl_matrix * @var{m}, size_t @var{i}, size_t @var{j})This function exchanges the @var{i}-th and @var{j}-th columns of thematrix @var{m} in-place.@end deftypefun@deftypefun int gsl_matrix_swap_rowcol (gsl_matrix * @var{m}, size_t @var{i}, size_t @var{j})This function exchanges the @var{i}-th row and @var{j}-th column of thematrix @var{m} in-place.  The matrix must be square for this operation tobe possible.@end deftypefun@deftypefun int gsl_matrix_transpose_memcpy (gsl_matrix * @var{dest}, const gsl_matrix * @var{src})This function makes the matrix @var{dest} the transpose of the matrix@var{src} by copying the elements of @var{src} into @var{dest}.  Thisfunction works for all matrices provided that the dimensions of the matrix@var{dest} match the transposed dimensions of the matrix @var{src}.@end deftypefun@deftypefun int gsl_matrix_transpose (gsl_matrix * @var{m})This function replaces the matrix @var{m} by its transpose by copyingthe elements of the matrix in-place.  The matrix must be square for thisoperation to be possible.@end deftypefun@node Matrix operations@subsection Matrix operationsThe following operations are defined for real and complex matrices.@deftypefun int gsl_matrix_add (gsl_matrix * @var{a}, const gsl_matrix * @var{b})This function adds the elements of matrix @var{b} to the elements ofmatrix @var{a}, @math{a'(i,j) = a(i,j) + b(i,j)}. The two matrices must have thesame dimensions.@end deftypefun@deftypefun int gsl_matrix_sub (gsl_matrix * @var{a}, const gsl_matrix * @var{b})This function subtracts the elements of matrix @var{b} from the elements ofmatrix @var{a}, @math{a'(i,j) = a(i,j) - b(i,j)}. The two matrices must have thesame dimensions.@end deftypefun@deftypefun int gsl_matrix_mul_elements (gsl_matrix * @var{a}, const gsl_matrix * @var{b})This function multiplies the elements of matrix @var{a} by the elements ofmatrix @var{b}, @math{a'(i,j) = a(i,j) * b(i,j)}. The two matrices must have thesame dimensions.@end deftypefun@deftypefun int gsl_matrix_div_elements (gsl_matrix * @var{a}, const gsl_matrix * @var{b})This function divides the elements of matrix @var{a} by the elements ofmatrix @var{b}, @math{a'(i,j) = a(i,j) / b(i,j)}. The two matrices must have thesame dimensions.@end deftypefun@deftypefun int gsl_matrix_scale (gsl_matrix * @var{a}, const double @var{x})This function multiplies the elements of matrix @var{a

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?