NcmMatrix

NcmMatrix — Matrix object representing an array of doubles.

Functions

NcmMatrix * ncm_matrix_new ()
NcmMatrix * ncm_matrix_new0 ()
NcmMatrix * ncm_matrix_new_full ()
NcmMatrix * ncm_matrix_new_gsl ()
NcmMatrix * ncm_matrix_new_gsl_static ()
NcmMatrix * ncm_matrix_new_array ()
NcmMatrix * ncm_matrix_new_data_slice ()
NcmMatrix * ncm_matrix_new_data_malloc ()
NcmMatrix * ncm_matrix_new_data_static ()
NcmMatrix * ncm_matrix_new_data_static_tda ()
NcmMatrix * ncm_matrix_new_variant ()
const NcmMatrix * ncm_matrix_const_new_data ()
const NcmMatrix * ncm_matrix_const_new_variant ()
NcmMatrix * ncm_matrix_get_submatrix ()
NcmVector * ncm_matrix_get_col ()
NcmVector * ncm_matrix_get_row ()
void ncm_matrix_set_from_variant ()
GVariant * ncm_matrix_get_variant ()
GVariant * ncm_matrix_peek_variant ()
void ncm_matrix_set_from_data ()
void ncm_matrix_set_from_array ()
const NcmMatrix * ncm_matrix_new_gsl_const ()
gdouble ncm_matrix_get ()
gdouble * ncm_matrix_ptr ()
const gdouble * ncm_matrix_const_ptr ()
NcmMatrix * ncm_matrix_ref ()
GArray * ncm_matrix_get_array ()
void ncm_matrix_set ()
void ncm_matrix_set_colmajor ()
void ncm_matrix_addto ()
void ncm_matrix_transpose ()
void ncm_matrix_set_identity ()
void ncm_matrix_set_zero ()
void ncm_matrix_set_all ()
void ncm_matrix_scale ()
void ncm_matrix_memcpy ()
void ncm_matrix_set_col ()
gdouble ncm_matrix_fast_get ()
void ncm_matrix_fast_set ()
gsl_matrix * ncm_matrix_gsl ()
const gsl_matrix * ncm_matrix_const_gsl ()
guint ncm_matrix_col_len ()
guint ncm_matrix_row_len ()
guint ncm_matrix_nrows ()
guint ncm_matrix_ncols ()
guint ncm_matrix_size ()
guint ncm_matrix_tda ()
gdouble * ncm_matrix_data ()
const gdouble * ncm_matrix_const_data ()
NcmMatrix * ncm_matrix_dup ()
void ncm_matrix_substitute ()
void ncm_matrix_add_mul ()
void ncm_matrix_free ()
void ncm_matrix_clear ()
void ncm_matrix_const_free ()
void ncm_matrix_copy_triangle ()
void ncm_matrix_dsymm ()
gint ncm_matrix_cholesky_decomp ()
gint ncm_matrix_cholesky_inverse ()
void ncm_matrix_log_vals ()

Properties

GVariant * values Read / Write

Types and Values

Object Hierarchy

    GEnum
    ╰── NcmMatrixInternal
    GObject
    ╰── NcmMatrix

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.

Parameters

nrows

number of rows

 

ncols

number of columns

 

Returns

A new NcmMatrix.


ncm_matrix_new0 ()

NcmMatrix *
ncm_matrix_new0 (const guint nrows,
                 const guint ncols);

This function allocates memory for a new NcmMatrix of doubles with nrows rows and ncols columns and sets all elements to zero.

Parameters

nrows

number of rows

 

ncols

number of columns

 

Returns

A new NcmMatrix.

[transfer full]


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.

Parameters

d

pointer to the data

 

nrows

number of rows

 

ncols

number of columns

 

tda

row trailing dimension

 

pdata

descending data pointer.

[allow-none]

pfree

free function to be called when destroying the matrix.

[scope notified][allow-none]

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.

[skip]

Parameters

gm

matrix from GNU Scientific Library (GSL) to be converted into a NcmMatrix

 

Returns

A new 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.

[skip]

Parameters

gm

matrix from GNU Scientific Library (GSL) to be converted into a NcmMatrix

 

Returns

A new 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

 

Returns

A new NcmMatrix.


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 .

[skip]

Parameters

d

pointer to the first double allocated

 

nrows

number of rows

 

ncols

number of columns

 

Returns

A new NcmMatrix.


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.

[skip]

Parameters

d

pointer to the first double allocated

 

nrows

number of rows

 

ncols

number of columns

 

Returns

A new NcmMatrix.


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.

[skip]

Parameters

d

pointer to the first double allocated

 

nrows

number of rows

 

ncols

number of columns

 

Returns

A new NcmMatrix.


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.

[skip]

Parameters

d

pointer to the first double allocated

 

nrows

number of rows

 

ncols

number of columns

 

tda

physical number of columns which may differ from the corresponding dimension of the matrix

 

Returns

A new NcmMatrix.


ncm_matrix_new_variant ()

NcmMatrix *
ncm_matrix_new_variant (GVariant *var);

Creates a new matrix using the values from var .

Parameters

var

a variant of type "aad"

 

Returns

(transfer full) :a NcmMatrix with 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.

Parameters

d

pointer to the first double allocated

 

nrows

number of rows

 

ncols

number of cols

 

Returns

A new constant NcmMatrix.


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 .

Parameters

var

a variant of type "aad"

 

Returns

(transfer full) :a NcmMatrix with the values from 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 cm

 

k2

column index of the original matrix cm

 

nrows

number of rows of the submatrix

 

ncols

number of columns of the submatrix

 

Returns

A NcmMatrix.

[transfer full]


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.

Parameters

cm

a NcmMatrix

 

col

column index

 

Returns

A NcmVector.

[transfer full]


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.

Parameters

cm

a NcmMatrix

 

row

row index

 

Returns

A NcmVector.

[transfer full]


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 .

Parameters

cm

a NcmMatrix

 

var

a GVariant of type "aad"

 

ncm_matrix_get_variant ()

GVariant *
ncm_matrix_get_variant (NcmMatrix *cm);

This function gets a variant of values taken from cm .

Parameters

cm

a NcmMatrix

 

Returns

the newly created GVariant.

[transfer full]


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.

Parameters

cm

a NcmMatrix

 

Returns

the newly created GVariant.

[transfer full]


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.

Parameters

cm

a NcmMatrix

 

data

Array of doubles.

[array][element-type double]

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.

Parameters

cm

a NcmMatrix

 

a

Array of doubles.

[array][element-type double]

ncm_matrix_new_gsl_const ()

const NcmMatrix *
ncm_matrix_new_gsl_const (gsl_matrix *m);

This function converts m into a constant NcmMatrix.

[skip]

Parameters

m

matrix from GNU Scientific Library (GSL)

 

Returns

A new constant NcmMatrix.


ncm_matrix_get ()

gdouble
ncm_matrix_get (const NcmMatrix *cm,
                const guint i,
                const guint j);

Parameters

cm

a constant NcmMatrix

 

i

row index

 

j

column index

 

Returns

The (i ,j )-th element of the matrix cm .


ncm_matrix_ptr ()

gdouble *
ncm_matrix_ptr (NcmMatrix *cm,
                const guint i,
                const guint j);

Parameters

cm

a NcmMatrix

 

i

row index

 

j

column index

 

Returns

A pointer to the (i ,j )-th element of the matrix cm .


ncm_matrix_const_ptr ()

const gdouble *
ncm_matrix_const_ptr (const NcmMatrix *cm,
                      const guint i,
                      const guint j);

Parameters

cm

a NcmMatrix

 

i

row index

 

j

column index

 

Returns

A constant 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.

Parameters

cm

a NcmMatrix

 

Returns

cm .

[transfer full]


ncm_matrix_get_array ()

GArray *
ncm_matrix_get_array (NcmMatrix *cm);

FIXME

Parameters

cm

a NcmMatrix

 

Returns

FIXME.

[transfer container][element-type 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 .

Parameters

cm

a NcmMatrix

 

i

row index

 

j

column index

 

val

a double

 

ncm_matrix_set_colmajor ()

void
ncm_matrix_set_colmajor (NcmMatrix *cm,
                         const guint i,
                         const guint j,
                         gdouble val);

ncm_matrix_addto ()

void
ncm_matrix_addto (NcmMatrix *cm,
                  const guint i,
                  const guint j,
                  const gdouble val);

This function adds the value val to the (i ,j )-th element of the matrix cm .

Parameters

cm

a NcmMatrix

 

i

row index

 

j

column index

 

val

a double

 

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.

Parameters

cm

a NcmMatrix

 

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.

Parameters

cm

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.

Parameters

cm

a NcmMatrix

 

ncm_matrix_set_all ()

void
ncm_matrix_set_all (NcmMatrix *cm,
                    const gdouble val);

This function sets all the elements of the matrix cm to val .

Parameters

cm

a NcmMatrix

 

val

a double

 

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 .

Parameters

cm

a NcmMatrix

 

val

a double

 

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.

Parameters

cm1

a NcmMatrix

 

cm2

a NcmMatrix

 

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.

Parameters

cm

a NcmMatrix

 

n

column index

 

cv

a constant NcmVector

 

ncm_matrix_fast_get ()

gdouble
ncm_matrix_fast_get (NcmMatrix *cm,
                     const guint ij);

FIXME

Parameters

cm

a NcmMatrix

 

ij

FIXME

 

Returns

FIXME


ncm_matrix_fast_set ()

void
ncm_matrix_fast_set (NcmMatrix *cm,
                     const guint ij,
                     const gdouble val);

FIXME

Parameters

cm

a NcmMatrix

 

ij

FIXME

 

val

FIXME

 

ncm_matrix_gsl ()

gsl_matrix *
ncm_matrix_gsl (NcmMatrix *cm);

FIXME

[skip]

Parameters

cm

a NcmMatrix

 

Returns

FIXME


ncm_matrix_const_gsl ()

const gsl_matrix *
ncm_matrix_const_gsl (const NcmMatrix *cm);

FIXME

[skip]

Parameters

cm

a NcmMatrix

 

Returns

FIXME


ncm_matrix_col_len ()

guint
ncm_matrix_col_len (const NcmMatrix *cm);

FIXME

Parameters

cm

a NcmMatrix

 

Returns

FIXME


ncm_matrix_row_len ()

guint
ncm_matrix_row_len (const NcmMatrix *cm);

FIXME

Parameters

cm

a NcmMatrix

 

Returns

FIXME


ncm_matrix_nrows ()

guint
ncm_matrix_nrows (const NcmMatrix *cm);

FIXME

Parameters

cm

a NcmMatrix

 

Returns

FIXME


ncm_matrix_ncols ()

guint
ncm_matrix_ncols (const NcmMatrix *cm);

FIXME

Parameters

cm

a NcmMatrix

 

Returns

FIXME


ncm_matrix_size ()

guint
ncm_matrix_size (const NcmMatrix *cm);

Calculates the total size of the matrix, ncols * nrows.

Parameters

cm

a NcmMatrix

 

Returns

Total size of the matrix.


ncm_matrix_tda ()

guint
ncm_matrix_tda (const NcmMatrix *cm);

Parameters

cm

a NcmMatrix

 

Returns

The matrix tda.


ncm_matrix_data ()

gdouble *
ncm_matrix_data (NcmMatrix *cm);

FIXME

Parameters

cm

a NcmMatrix

 

Returns

FIXME.

[transfer none]


ncm_matrix_const_data ()

const gdouble *
ncm_matrix_const_data (const NcmMatrix *cm);

FIXME

Parameters

cm

a NcmMatrix

 

Returns

FIXME.

[transfer none]


ncm_matrix_dup ()

NcmMatrix *
ncm_matrix_dup (const NcmMatrix *cm);

Duplicates cm setting the same values of the original propertities.

Parameters

cm

a constant NcmMatrix

 

Returns

A NcmMatrix.

[transfer full]


ncm_matrix_substitute ()

void
ncm_matrix_substitute (NcmMatrix **cm,
                       NcmMatrix *nm,
                       gboolean check_size);

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.

Parameters

cm

a NcmMatrix

 

nm

a NcmMatrix.

[allow-none]

check_size

a boolean

 

ncm_matrix_add_mul ()

void
ncm_matrix_add_mul (NcmMatrix *cm,
                    const gdouble alpha,
                    NcmMatrix *b);

FIXME

Parameters

cm

FIXME

 

alpha

FIXME

 

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.

Parameters

cm

a NcmMatrix

 

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.

Parameters

cm

a NcmMatrix

 

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.

Parameters

cm

a constant NcmMatrix

 

ncm_matrix_copy_triangle ()

void
ncm_matrix_copy_triangle (NcmMatrix *cm,
                          gchar UL);

If UL == 'U' copy the upper triangle over the lower. If UL == 'L' copy the lower triangle over the lower.

Parameters

cm

a NcmMatrix

 

UL

char indicating 'U'pper or 'L'ower matrix

 

ncm_matrix_dsymm ()

void
ncm_matrix_dsymm (NcmMatrix *cm,
                  gchar UL,
                  const gdouble alpha,
                  NcmMatrix *b,
                  const gdouble beta,
                  NcmMatrix *c);

FIXME

Parameters

cm

a NcmMatrix

 

UL

char indicating 'U'pper or 'L'ower matrix

 

alpha

FIXME

 

b

FIXME

 

beta

FIXME

 

c

FIXME

 

ncm_matrix_cholesky_decomp ()

gint
ncm_matrix_cholesky_decomp (NcmMatrix *cm,
                            gchar UL);

Calculates inplace the Cholesky decomposition for a symmetric positive definite matrix.

Parameters

cm

a NcmMatrix

 

UL

char indicating 'U'pper or 'L'ower matrix

 

ncm_matrix_cholesky_inverse ()

gint
ncm_matrix_cholesky_inverse (NcmMatrix *cm,
                             gchar UL);

Calculates inplace the inverse of cm that has been previously decomposed by the Cholesky decomposition ncm_matrix_cholesky_decomp().

Parameters

cm

a NcmMatrix

 

UL

char indicating 'U'pper or 'L'ower matrix

 

ncm_matrix_log_vals ()

void
ncm_matrix_log_vals (NcmMatrix *cm,
                     gchar *prefix,
                     gchar *format);

Prints to the log the values of cm .

Parameters

cm

a NcmMatrix

 

prefix

the prefixed text

 

format

double format

 

Types and Values

enum NcmMatrixInternal

FIXME

Members

NCM_MATRIX_SLICE

FIXME

 

NCM_MATRIX_GSL_MATRIX

FIXME

 

NCM_MATRIX_MALLOC

FIXME

 

NCM_MATRIX_GARRAY

FIXME

 

NCM_MATRIX_DERIVED

FIXME

 

struct NcmMatrix

struct NcmMatrix;

FIXME

Property Details

The “values” property

  “values”                   GVariant *

values.

Flags: Read / Write

Allowed values: GVariant<a*>

Default value: NULL