Top | ![]() |
![]() |
![]() |
![]() |
Functions
Description
This object defines the functions for allocating and accessing matrices. Also includes serveral matrix operations.
Functions
ncm_matrix_new ()
NcmMatrix * ncm_matrix_new (const guint nrows
,const guint ncols
);
This function allocates memory for a new NcmMatrix of doubles
with nrows
rows and ncols
columns.
ncm_matrix_new_full ()
NcmMatrix * ncm_matrix_new_full (gdouble *d
,guint nrows
,guint ncols
,guint tda
,gpointer pdata
,GDestroyNotify pfree
);
This function allocates memory for a new NcmMatrix of doubles
with nrows
rows and ncols
columns.
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_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_array ()
NcmMatrix * ncm_matrix_new_array (GArray *a
,const guint 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.
Parameters
a |
GArray of doubles to be converted into a NcmMatrix. |
[element-type double] |
ncols |
number of columns. |
ncm_matrix_new_data_slice ()
NcmMatrix * ncm_matrix_new_data_slice (gdouble *d
,const guint nrows
,const guint 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
.
ncm_matrix_new_data_malloc ()
NcmMatrix * ncm_matrix_new_data_malloc (gdouble *d
,const guint nrows
,const guint 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.
ncm_matrix_new_data_static ()
NcmMatrix * ncm_matrix_new_data_static (gdouble *d
,const guint nrows
,const guint 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.
ncm_matrix_new_data_static_tda ()
NcmMatrix * ncm_matrix_new_data_static_tda (gdouble *d
,const guint nrows
,const guint ncols
,const guint 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_variant ()
NcmMatrix *
ncm_matrix_new_variant (GVariant *var
);
Creates a new matrix using the values from var
.
ncm_matrix_const_new_data ()
const NcmMatrix * ncm_matrix_const_new_data (const gdouble *d
,guint nrows
,guint ncols
);
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_const_new_variant ()
const NcmMatrix *
ncm_matrix_const_new_variant (GVariant *var
);
Creates a new constant matrix using the same memory of var
.
ncm_matrix_get_submatrix ()
NcmMatrix * ncm_matrix_get_submatrix (NcmMatrix *cm
,const guint k1
,const guint k2
,const guint nrows
,const guint 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.
Parameters
cm |
a NcmMatrix. |
|
k1 |
row index of the original matrix |
|
k2 |
column index of the original matrix |
|
nrows |
number of rows of the submatrix. |
|
ncols |
number of columns of the submatrix. |
ncm_matrix_get_col ()
NcmVector * ncm_matrix_get_col (NcmMatrix *cm
,const guint 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 guint row
);
This function returns the elements of the row
row of the matrix cm
into a NcmVector.
ncm_matrix_set_from_variant ()
void ncm_matrix_set_from_variant (NcmMatrix *cm
,GVariant *var
);
This function sets the values of cm
using the variant var
.
ncm_matrix_get_variant ()
GVariant *
ncm_matrix_get_variant (NcmMatrix *cm
);
This function gets a variant of values taken from cm
.
ncm_matrix_peek_variant ()
GVariant *
ncm_matrix_peek_variant (NcmMatrix *cm
);
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_set_from_data ()
void ncm_matrix_set_from_data (NcmMatrix *cm
,gdouble *data
);
This function sets the valuus of cm
using data
. Data
must have the same size as NcmMatrix.
ncm_matrix_set_from_array ()
void ncm_matrix_set_from_array (NcmMatrix *cm
,GArray *a
);
This function sets the valuus of cm
using data
. Data
must have the same size as NcmMatrix.
ncm_matrix_new_gsl_const ()
const NcmMatrix *
ncm_matrix_new_gsl_const (gsl_matrix *m
);
This function converts m
into a constant NcmMatrix.
ncm_matrix_ref ()
NcmMatrix *
ncm_matrix_ref (NcmMatrix *cm
);
Increase the reference count of cm
by one.
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
.
ncm_matrix_transpose ()
void
ncm_matrix_transpose (NcmMatrix *cm
);
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_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.
ncm_matrix_set_zero ()
void
ncm_matrix_set_zero (NcmMatrix *cm
);
This function sets all the elements of the matrix cm
to zero.
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
.
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_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_fast_set ()
void ncm_matrix_fast_set (NcmMatrix *cm
,const guint ij
,const gdouble val
);
FIXME
ncm_matrix_size ()
guint
ncm_matrix_size (const NcmMatrix *cm
);
Calculates the total size of the matrix, ncols * nrows.
ncm_matrix_dup ()
NcmMatrix *
ncm_matrix_dup (const NcmMatrix *cm
);
Duplicates cm
setting the same values of the original propertities.
ncm_matrix_add_mul ()
void ncm_matrix_add_mul (NcmMatrix *cm
,const gdouble alpha
,NcmMatrix *b
);
FIXME
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.
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.
ncm_matrix_const_free ()
void
ncm_matrix_const_free (const NcmMatrix *cm
);
Atomically decrements the reference count of cv
by one. If the reference count drops to 0,
all memory allocated by cv
is released.
Property Details
The “values”
property
“values” GVariant *
values.
Flags: Read / Write
Allowed values: GVariant<a*>
Default value: NULL