![]() |
![]() |
![]() |
NumCosmo Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
Synopsis
#define NCM_MATRIX_COL_LEN (cm) #define NCM_MATRIX_DATA (cm) #define NCM_MATRIX_GSL (cm) #define NCM_MATRIX_NCOLS (cm) #define NCM_MATRIX_NROWS (cm) #define NCM_MATRIX_ROW_LEN (cm) struct NcmMatrix; struct NcmMatrixClass; enum NcmMatrixInternal; void ncm_matrix_add_mul (NcmMatrix *cm
,const gdouble alpha
,NcmMatrix *b
); void ncm_matrix_clear (NcmMatrix **cm
); NcmMatrix * ncm_matrix_dup (const NcmMatrix *cm
); void ncm_matrix_free (NcmMatrix *cm
); gdouble ncm_matrix_get (const NcmMatrix *cm
,const guint i
,const guint j
); GArray * ncm_matrix_get_array (NcmMatrix *cm
); NcmVector * ncm_matrix_get_col (NcmMatrix *cm
,const gsize col
); NcmVector * ncm_matrix_get_row (NcmMatrix *cm
,const gsize row
); NcmMatrix * ncm_matrix_get_submatrix (NcmMatrix *cm
,const gsize k1
,const gsize k2
,const gsize nrows
,const gsize ncols
); void ncm_matrix_memcpy (NcmMatrix *cm1
,const NcmMatrix *cm2
); NcmMatrix * ncm_matrix_new (const gsize nrows
,const gsize ncols
); NcmMatrix * ncm_matrix_new_array (GArray *a
,const gsize ncols
); NcmMatrix * ncm_matrix_new_data_malloc (gdouble *d
,const gsize nrows
,const gsize ncols
); NcmMatrix * ncm_matrix_new_data_slice (gdouble *d
,const gsize nrows
,const gsize ncols
); NcmMatrix * ncm_matrix_new_data_static (gdouble *d
,const gsize nrows
,const gsize ncols
); NcmMatrix * ncm_matrix_new_data_static_tda (gdouble *d
,const gsize nrows
,const gsize ncols
,const gsize tda
); NcmMatrix * ncm_matrix_new_gsl (gsl_matrix *gm
); const NcmMatrix * ncm_matrix_new_gsl_const (gsl_matrix *m
); NcmMatrix * ncm_matrix_new_gsl_static (gsl_matrix *gm
); NcmMatrix * ncm_matrix_new_sunk (const gsize nrows
,const gsize ncols
); gdouble * ncm_matrix_ptr (NcmMatrix *cm
,const guint i
,const guint j
); NcmMatrix * ncm_matrix_ref (NcmMatrix *cm
); void ncm_matrix_scale (NcmMatrix *cm
,const gdouble val
); void ncm_matrix_set (NcmMatrix *cm
,const guint i
,const guint j
,const gdouble val
); void ncm_matrix_set_col (NcmMatrix *cm
,const guint n
,const NcmVector *cv
); void ncm_matrix_set_identity (NcmMatrix *cm
); void ncm_matrix_set_zero (NcmMatrix *cm
); void ncm_matrix_transpose (NcmMatrix *cm
);
Description
This object defines the functions for allocating and accessing matrices. Also includes serveral matrix operations.
Details
enum NcmMatrixInternal
typedef enum { NCM_MATRIX_SLICE = 0, NCM_MATRIX_GSL_MATRIX, NCM_MATRIX_MALLOC, NCM_MATRIX_GARRAY, NCM_MATRIX_DERIVED, } NcmMatrixInternal;
FIXME
ncm_matrix_add_mul ()
void ncm_matrix_add_mul (NcmMatrix *cm
,const gdouble alpha
,NcmMatrix *b
);
FIXME
|
FIXME |
|
FIXME |
|
FIXME |
ncm_matrix_clear ()
void ncm_matrix_clear (NcmMatrix **cm
);
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.
|
a NcmMatrix. |
ncm_matrix_dup ()
NcmMatrix * ncm_matrix_dup (const NcmMatrix *cm
);
Duplicates cm
setting the same values of the original propertities.
ncm_matrix_free ()
void ncm_matrix_free (NcmMatrix *cm
);
Atomically decrements the reference count of cm
by one. If the reference count drops to 0,
all memory allocated by cm
is released.
|
a NcmMatrix. |
ncm_matrix_get ()
gdouble ncm_matrix_get (const NcmMatrix *cm
,const guint i
,const guint j
);
|
a constant NcmMatrix. |
|
row index. |
|
column index. |
Returns : |
The (i ,j )-th element of the matrix cm . |
ncm_matrix_get_array ()
GArray * ncm_matrix_get_array (NcmMatrix *cm
);
FIXME
|
a NcmMatrix. |
Returns : |
FIXME. [transfer container][element-type double] |
ncm_matrix_get_col ()
NcmVector * ncm_matrix_get_col (NcmMatrix *cm
,const gsize col
);
This function returns the elements of the col
column of the matrix cm
into a NcmVector.
ncm_matrix_get_row ()
NcmVector * ncm_matrix_get_row (NcmMatrix *cm
,const gsize row
);
This function returns the elements of the row
row of the matrix cm
into a NcmVector.
ncm_matrix_get_submatrix ()
NcmMatrix * ncm_matrix_get_submatrix (NcmMatrix *cm
,const gsize k1
,const gsize k2
,const gsize nrows
,const gsize ncols
);
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 ()
void ncm_matrix_memcpy (NcmMatrix *cm1
,const NcmMatrix *cm2
);
This function copies the elements of the matrix cm1
into the matrix cm2
.
The two matrices must have the same size.
ncm_matrix_new ()
NcmMatrix * ncm_matrix_new (const gsize nrows
,const gsize ncols
);
This function allocates memory for a new NcmMatrix of doubles
with nrows
rows and ncols
columns.
|
number of rows. |
|
number of columns. |
Returns : |
A new NcmMatrix. |
ncm_matrix_new_array ()
NcmMatrix * ncm_matrix_new_array (GArray *a
,const gsize ncols
);
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 ()
NcmMatrix * ncm_matrix_new_data_malloc (gdouble *d
,const gsize nrows
,const gsize ncols
);
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.
|
pointer to the first double allocated. |
|
number of rows. |
|
number of columns. |
Returns : |
A new NcmMatrix. |
ncm_matrix_new_data_slice ()
NcmMatrix * ncm_matrix_new_data_slice (gdouble *d
,const gsize nrows
,const gsize ncols
);
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
.
|
pointer to the first double allocated. |
|
number of rows. |
|
number of columns. |
Returns : |
A new NcmMatrix. |
ncm_matrix_new_data_static ()
NcmMatrix * ncm_matrix_new_data_static (gdouble *d
,const gsize nrows
,const gsize ncols
);
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.
|
pointer to the first double allocated. |
|
number of rows. |
|
number of columns. |
Returns : |
A new NcmMatrix. |
ncm_matrix_new_data_static_tda ()
NcmMatrix * ncm_matrix_new_data_static_tda (gdouble *d
,const gsize nrows
,const gsize ncols
,const gsize 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.
|
pointer to the first double allocated. |
|
number of rows. |
|
number of columns. |
|
physical number of columns which may differ from the corresponding dimension of the matrix. |
Returns : |
A new NcmMatrix. |
ncm_matrix_new_gsl ()
NcmMatrix * ncm_matrix_new_gsl (gsl_matrix *gm
);
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_const ()
const NcmMatrix * ncm_matrix_new_gsl_const (gsl_matrix *m
);
This function converts m
into a constant NcmMatrix.
|
matrix from GNU Scientific Library (GSL). |
Returns : |
A new constant NcmMatrix. |
ncm_matrix_new_gsl_static ()
NcmMatrix * ncm_matrix_new_gsl_static (gsl_matrix *gm
);
This function saves gm
internally and does not frees it.
The gm
matrix must be valid during the life of the created NcmMatrix.
ncm_matrix_new_sunk ()
NcmMatrix * ncm_matrix_new_sunk (const gsize nrows
,const gsize ncols
);
This function allocates memory for a new NcmMatrix of doubles
with nrows
rows and ncols
columns. Returns a sunk reference.
|
number of rows. |
|
number of columns. |
Returns : |
A new NcmMatrix. |
ncm_matrix_ptr ()
gdouble * ncm_matrix_ptr (NcmMatrix *cm
,const guint i
,const guint j
);
|
a NcmMatrix. |
|
row index. |
|
column index. |
Returns : |
A pointer to the (i ,j )-th element of the matrix cm . |
ncm_matrix_ref ()
NcmMatrix * ncm_matrix_ref (NcmMatrix *cm
);
Increase the reference count of cm
by one.
|
a NcmMatrix. |
Returns : |
cm . [transfer full]
|
ncm_matrix_scale ()
void ncm_matrix_scale (NcmMatrix *cm
,const gdouble val
);
This function multiplies the elements of the matrix cm
by the constant factor val
.
The result is stored in cm
.
|
a NcmMatrix. |
|
a double. |
ncm_matrix_set ()
void ncm_matrix_set (NcmMatrix *cm
,const guint i
,const guint j
,const gdouble val
);
This function sets the value of the (i
,j
)-th element of the matrix cm
to val
.
|
a NcmMatrix. |
|
row index. |
|
column index. |
|
a double. |
ncm_matrix_set_col ()
void ncm_matrix_set_col (NcmMatrix *cm
,const guint n
,const NcmVector *cv
);
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_identity ()
void ncm_matrix_set_identity (NcmMatrix *cm
);
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.
|
a NcmMatrix. |
ncm_matrix_set_zero ()
void ncm_matrix_set_zero (NcmMatrix *cm
);
This function sets all the elements of the matrix cm
to zero.
|
a NcmMatrix. |