⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vectors.texi

📁 该文件为c++的数学函数库!是一个非常有用的编程工具.它含有各种数学函数,为科学计算、工程应用等程序编写提供方便!
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
@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} 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_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@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@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} by the constantfactor @var{x}, @math{a'(i,j) = x a(i,j)}.@end deftypefun@deftypefun int gsl_matrix_add_constant (gsl_matrix * @var{a}, const double @var{x})This function adds the constant value @var{x} to the elements of thematrix @var{a}, @math{a'(i,j) = a(i,j) + x}.@end deftypefun@node  Finding maximum and minimum elements of matrices@subsection Finding maximum and minimum elements of matricesThe following operations are only defined for real matrices.@deftypefun double gsl_matrix_max (const gsl_matrix * @var{m})This function returns the maximum value in the matrix @var{m}.@end deftypefun@deftypefun double gsl_matrix_min (const gsl_matrix * @var{m})This function returns the minimum value in the matrix @var{m}.@end deftypefun@deftypefun void gsl_matrix_minmax (const gsl_matrix * @var{m}, double * @var{min_out}, double * @var{max_out})This function returns the minimum and maximum values in the matrix@var{m}, storing them in @var{min_out} and @var{max_out}.@end deftypefun@deftypefun void gsl_matrix_max_index (const gsl_matrix * @var{m}, size_t * @var{imax}, size_t * @var{jmax})This function returns the indices of the maximum value in the matrix@var{m}, storing them in @var{imax} and @var{jmax}.  When there areseveral equal maximum elements then the first element found is returned,searching in row-major order.@end deftypefun@deftypefun void gsl_matrix_min_index (const gsl_matrix * @var{m}, size_t * @var{imax}, size_t * @var{jmax})This function returns the indices of the minimum value in the matrix@var{m}, storing them in @var{imax} and @var{jmax}.  When there areseveral equal minimum elements then the first element found is returned,searching in row-major order.@end deftypefun@deftypefun void gsl_matrix_minmax_index (const gsl_matrix * @var{m}, size_t * @var{imin}, size_t * @var{imax})This function returns the indices of the minimum and maximum values inthe matrix @var{m}, storing them in (@var{imin},@var{jmin}) and(@var{imax},@var{jmax}). When there are several equal minimum or maximumelements then the first elements found are returned, searching inrow-major order.@end deftypefun@node Matrix properties@subsection Matrix properties@deftypefun int gsl_matrix_isnull (const gsl_matrix * @var{m})This function returns 1 if all the elements of the matrix @var{m} arezero, and 0 otherwise.@end deftypefun@node Example programs for matrices@subsection Example programs for matricesThe program below shows how to allocate, initialize and read from a matrixusing the functions @code{gsl_matrix_alloc}, @code{gsl_matrix_set} and@code{gsl_matrix_get}.@example@verbatiminclude examples/matrix.c@end example@comment@noindentHere is the output from the program.  The final loop attempts to readoutside the range of the matrix @code{m}, and the error is trapped bythe range-checking code in @code{gsl_matrix_get}.@examplem(0,0) = 0.23m(0,1) = 1.23m(0,2) = 2.23m(1,0) = 100.23m(1,1) = 101.23m(1

⌨️ 快捷键说明

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