Class
NumCosmoMathMatrix
Description [src]
class NumCosmoMath.Matrix : GObject.Object
{
/* No available fields */
}
Matrix object representing an array of doubles.
This object defines the functions for allocating and accessing matrices. Also includes several matrix operations.
Constructors
ncm_matrix_const_new_data
This function returns a constant NcmMatrix of the array d.
The memory allocated is kept during all time life of the object and
must not be freed during this period.
ncm_matrix_new
This function allocates memory for a new NcmMatrix of doubles
with nrows rows and ncols columns.
ncm_matrix_new_array
The number of rows is defined dividing the lenght of a by ncols.
This function saves a internally and frees it when it is no longer necessary.
The GArray a must not be freed.
ncm_matrix_new_data_malloc
This function returns a NcmMatrix of the array d allocated using malloc.
It saves d internally and frees it when it is no longer necessary.
ncm_matrix_new_data_slice
This function returns a NcmMatrix of the array d allocated using g_slice function.
It saves d internally and frees it when it is no longer necessary.
The matrix has nrows rows and ncols columns.
The physical number of columns in memory is also given by ncols.
ncm_matrix_new_data_static
This function returns a NcmMatrix of the array d.
The memory allocated is kept during all time life of the object and
must not be freed during this period.
ncm_matrix_new_data_static_tda
This function returns a NcmMatrix of the array d with a physical number of columns tda which may differ
from the corresponding dimension of the matrix. The matrix has nrows rows and ncols columns, and the physical
number of columns in memory is given by tda.
ncm_matrix_new_full
This function allocates memory for a new NcmMatrix of doubles
with nrows rows and ncols columns.
ncm_matrix_new_gsl
This function saves gm internally and frees it when it is no longer necessary.
The gm matrix must not be freed.
ncm_matrix_new_gsl_static
This function saves gm internally and does not frees it.
The gm matrix must be valid during the life of the created NcmMatrix.
Functions
ncm_matrix_clear
Atomically decrements the reference count of cm by one. If the reference count drops to 0,
all memory allocated by cm is released. The pointer is set to NULL.
ncm_matrix_new0
This function allocates memory for a new NcmMatrix of doubles
with nrows rows and ncols columns and sets all elements to zero.
ncm_matrix_substitute
Substitute the matrix cm by nm, first it unref cm if it is not NULL.
If check_size is TRUE then check if the two matrix have the same size.
Instance methods
ncm_matrix_add
This function adds the elements of the matrices cm1 and cm2.
The two matrices must have the same size.
ncm_matrix_add_constant
This function adds the the constant factor val to the elements of the matrix cm.
The result is stored in cm.
ncm_matrix_as_vector
Creates a vector containing the row-wise concatenation
of the matrix cm. It requires a matrix with tda==ncols.
ncm_matrix_cholesky_decomp
Calculates in-place the Cholesky decomposition for a symmetric positive definite matrix.
ncm_matrix_cholesky_inverse
Calculates inplace the inverse of cm that has been previously decomposed by
the Cholesky decomposition ncm_matrix_cholesky_decomp().
ncm_matrix_cholesky_lndet
Calculates determinant of a symmetric positive definite matrix, that was previously decomposed using ncm_matrix_cholesky_decomp().
ncm_matrix_cholesky_solve
Calculates in-place the Cholesky decomposition for a symmetric positive
definite matrix and solve the system $A x = B$ where $A=$cm and $B$=b.
ncm_matrix_cholesky_solve2
Using a previously computed Cholesky decomposition in cm, through
ncm_matrix_cholesky_decomp(), solves the system $A x = B$ where
$A=$cm and $B$=b.
ncm_matrix_cmp
This function performes a comparison, component-wise, of the two matrices, given by $\left| \right. ($cm1 $-$ cm2 $)/($scale $+$ cm2$)\left. \right|$ and returns its maximum value.
ncm_matrix_cmp_diag
This function is similar to ncm_matrix_cmp(), but now only the diagonal elements are compared.
ncm_matrix_col_len
This function returns the number of elements in a column of the matrix cm. The columns length.
ncm_matrix_const_free
Atomically decrements the reference count of cv by one. If the reference count drops to 0,
all memory allocated by cv is released.
ncm_matrix_const_gsl
This function returns a constant pointer to the #gsl_matrix associated to the matrix cm.
ncm_matrix_copy_triangle
If UL == ‘U’ copy the upper triangle over the lower.
If UL == ‘L’ copy the lower triangle over the upper.
ncm_matrix_cov2cor
Convert a covariance matrix cov to a correlation
matrix cor. The matrices cor and cov can be the same object.
ncm_matrix_div_elements
This function divides the elements of the matrices cm1 and cm2.
The two matrices must have the same size.
ncm_matrix_fast_get
This function returns the value of the cm[i,j] element by direct access of its base data. Where ij = i $\times$ tda $+$ j.
ncm_matrix_fast_set
This function sets the value of the cm[i,j] element to val by direct access of its base data. Where ij = i $\times$ tda $+$ j.
ncm_matrix_fill_rand_cor
Overwrite cm with a random correlation matrix, the
parameter cor_level controls the correlation between
entries the lower cor_level more correlated the entries are.
ncm_matrix_fill_rand_cov
Overwrite cm with a random covariance matrix, the
parameter cor_level controls the correlation between
entries the lower cor_level more correlated the entries are.
ncm_matrix_fill_rand_cov2
Overwrite cm with a random covariance matrix, the
parameter cor_level controls the correlation between
entries the lower cor_level more correlated the entries are.
ncm_matrix_free
Atomically decrements the reference count of cm by one. If the reference count drops to 0,
all memory allocated by cm is released.
ncm_matrix_get_array
This function returns the array of cv. It is only applied if the matrix cm was created with ncm_matrix_new_array().
ncm_matrix_get_col
This function returns the elements of the col column of the matrix cm
into a NcmVector.
ncm_matrix_get_row
This function returns the elements of the row row of the matrix cm
into a NcmVector.
ncm_matrix_get_submatrix
This function returns a submatrix NcmMatrix of the matrix cm.
The upper-left element of the submatrix is the element (k1,k2) of the original matrix.
The submatrix has nrows rows and ncols columns.
ncm_matrix_memcpy
This function copies the elements of the matrix cm2 into the matrix cm1.
The two matrices must have the same size.
ncm_matrix_memcpy_to_colmajor
This function copies the elements of the matrix cm2 into the matrix cm1.
The two matrices must have the same size. The elements are written in cm1
in column-major order order.
ncm_matrix_mul_elements
This function multiplies the elements of the matrices cm1 and cm2.
The two matrices must have the same size.
ncm_matrix_nearPD
Assuming that cm is a symmetric matrix with data on UL
side, computes the nearest positive definite matrix
in the Frobenius norm. See [Higham (2002)][XHigham2002].
The iterations stop when the Cholesky decomposition is valid.
ncm_matrix_peek_variant
This function gets a variant of values taken from cm using the same memory.
The matrix cm should not be modified during the variant existance.
ncm_matrix_row_len
This function returns the number of elements in a row of the matrix cm. The rows length.
ncm_matrix_scale
This function multiplies the elements of the matrix cm by the constant factor val.
The result is stored in cm.
ncm_matrix_set_col
This function copies the elements of the vector cv into the n-th column of the matrix cm.
The length of the vector must be the same as the length of the column.
ncm_matrix_set_colmajor
This function sets the value of the (i,j)-th element of the matrix cm to val
considering it being in the column-major order.
ncm_matrix_set_diag
This function copies de the elements of the vector diag to the diagonal elements of the matrix cm.
ncm_matrix_set_from_array
This function sets the valuus of cm using data. Data
must have the same size as NcmMatrix.
ncm_matrix_set_from_data
This function sets the valuus of cm using data. Data
must have the same size as NcmMatrix.
ncm_matrix_set_identity
This function sets the elements of the matrix cm to the corresponding elements of the identity matrix,
i.e. a unit diagonal with all off-diagonal elements zero. This applies to both square and rectangular matrices.
ncm_matrix_set_row
This function copies the elements of the vector cv into the n-th row of the matrix cm.
The length of the vector must be the same as the length of the row.
ncm_matrix_square_to_sym
Computes the symmetric matrix $M^\intercal \times M$ if
NT == ‘T’ or $M\times M^\intercal$ if NT == ‘N’. The result
is stored in the upper/lower triangle if UL=’U’/’L’.
ncm_matrix_sub
This function subtracts the elements of the matrices cm1 and cm2.
The two matrices must have the same size.
ncm_matrix_sym_exp_cholesky
Assuming that cm is a symmetric matrix with data on UL
side, computes the matrix exponential of cm and its cholesky decomposition.
ncm_matrix_sym_posdef_log
Assuming that cm is a symmetric matrix with data on UL
side, computes the matrix logarithm of cm.
ncm_matrix_sym_update_vector
Computes the matrix - vector product $u = \alpha M v + \beta u$
if NT == ‘N’ or $u = M^\intercal v$ if NT == ‘T’
and stores the result in u. This function assumes
that $M$ is symmetric and it´s stored in the Upper/Lower
triangle if UL == ‘U’/’L’.
ncm_matrix_transpose
This function replaces the matrix cm by its transpose by copying the elements of the matrix in-place.
The matrix must be square for this operation to be possible.
ncm_matrix_triang_to_sym
Assuming that cm is a triangular square matrix with data on UL
side, computes the symmetric matrix $M^\intercal \times M$ if
cm is upper triangular or $M\times M^\intercal$ if it is
lower triangular.
ncm_matrix_update_vector
Computes the matrix - vector product $u = \alpha M v + \beta u$
if NT == ‘N’ or $u = \alpha M^\intercal v + u$ if NT == ‘T’
and stores the result in u.
Signals
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.