NcmVector

NcmVector — Vector object representing arrays of doubles.

Stability Level

Stable, unless otherwise indicated

Functions

gdouble (*NcmVectorCompFunc) ()
#define NCM_N2VECTOR()
NcmVector * ncm_vector_new ()
NcmVector * ncm_vector_new_full ()
NcmVector * ncm_vector_new_fftw ()
NcmVector * ncm_vector_new_gsl ()
NcmVector * ncm_vector_new_gsl_static ()
NcmVector * ncm_vector_new_array ()
NcmVector * ncm_vector_new_data_slice ()
NcmVector * ncm_vector_new_data_malloc ()
NcmVector * ncm_vector_new_data_static ()
NcmVector * ncm_vector_new_data_dup ()
NcmVector * ncm_vector_new_variant ()
NcmVector * ncm_vector_ref ()
const NcmVector * ncm_vector_const_ref ()
const NcmVector * ncm_vector_const_new_variant ()
const NcmVector * ncm_vector_const_new_data ()
NcmVector * ncm_vector_get_subvector ()
void ncm_vector_get_subvector2 ()
NcmVector * ncm_vector_get_subvector_stride ()
GVariant * ncm_vector_get_variant ()
GVariant * ncm_vector_peek_variant ()
void ncm_vector_log_vals ()
void ncm_vector_log_vals_avpb ()
void ncm_vector_log_vals_func ()
void ncm_vector_set_from_variant ()
gdouble ncm_vector_dnrm2 ()
void ncm_vector_axpy ()
void ncm_vector_cmp ()
gint ncm_vector_cmp2 ()
void ncm_vector_sub_round_off ()
void ncm_vector_reciprocal ()
void ncm_vector_square ()
void ncm_vector_sqrt ()
void ncm_vector_hypot ()
gdouble ncm_vector_sum_cpts ()
gdouble ncm_vector_mean ()
const NcmVector * ncm_vector_const_new_gsl ()
gdouble ncm_vector_get ()
gdouble ncm_vector_fast_get ()
gdouble * ncm_vector_ptr ()
gdouble * ncm_vector_fast_ptr ()
const gdouble * ncm_vector_const_ptr ()
void ncm_vector_set ()
void ncm_vector_fast_set ()
void ncm_vector_addto ()
void ncm_vector_fast_addto ()
void ncm_vector_subfrom ()
void ncm_vector_fast_subfrom ()
void ncm_vector_mulby ()
void ncm_vector_fast_mulby ()
void ncm_vector_set_all ()
void ncm_vector_set_data ()
void ncm_vector_set_array ()
void ncm_vector_scale ()
void ncm_vector_add_constant ()
void ncm_vector_mul ()
void ncm_vector_div ()
void ncm_vector_add ()
void ncm_vector_sub ()
void ncm_vector_set_zero ()
void ncm_vector_memcpy ()
void ncm_vector_memcpy2 ()
GArray * ncm_vector_get_array ()
GArray * ncm_vector_dup_array ()
gdouble * ncm_vector_data ()
const gdouble * ncm_vector_const_data ()
void ncm_vector_replace_data ()
gsl_vector * ncm_vector_gsl ()
const gsl_vector * ncm_vector_const_gsl ()
gdouble ncm_vector_dot ()
guint ncm_vector_len ()
guint ncm_vector_stride ()
gdouble ncm_vector_get_max ()
gdouble ncm_vector_get_min ()
gsize ncm_vector_get_max_index ()
gsize ncm_vector_get_min_index ()
void ncm_vector_get_minmax ()
gboolean ncm_vector_is_finite ()
gboolean ncm_vector_lt ()
gboolean ncm_vector_lteq ()
gboolean ncm_vector_between ()
void ncm_vector_get_absminmax ()
guint ncm_vector_find_closest_index ()
NcmVector * ncm_vector_dup ()
void ncm_vector_substitute ()
void ncm_vector_free ()
void ncm_vector_clear ()
void ncm_vector_const_free ()

Properties

GVariant * values Read / Write

Types and Values

Object Hierarchy

    GEnum
    ╰── NcmVectorInternal
    GObject
    ╰── NcmVector

Includes

#include <numcosmo/math/ncm_vector.h>

Description

This object defines the functions for allocating and accessing vectors. Also includes several vector operations.

Functions

NcmVectorCompFunc ()

gdouble
(*NcmVectorCompFunc) (gdouble v_i,
                      guint i,
                      gpointer user_data);

NCM_N2VECTOR()

#define NCM_N2VECTOR(v) ((NcmVector *) ((v)->content))

ncm_vector_new ()

NcmVector *
ncm_vector_new (gsize n);

This function allocates memory for a new NcmVector of doubles with n components.

Parameters

n

defines the size of the vector

 

Returns

A new NcmVector.


ncm_vector_new_full ()

NcmVector *
ncm_vector_new_full (gdouble *d,
                     gsize size,
                     gsize stride,
                     gpointer pdata,
                     GDestroyNotify pfree);

This function returns a NcmVector of the array d . This function saves userdata internally and frees it using free when it is no longer necessary.

Parameters

d

pointer to the first double allocated.

[array][element-type double]

size

number of doubles allocated

 

stride

the step-size from one element to the next in physical memory, measured in units of double

 

pdata

descending data pointer.

[allow-none]

pfree

free function to be called when destroying the vector.

[scope notified][allow-none]

Returns

A new NcmVector.


ncm_vector_new_fftw ()

NcmVector *
ncm_vector_new_fftw (guint size);

This function allocates memory for a new NcmVector of double with n components. It uses fftw_alloc_real in order to be used by fftw* functions.

Parameters

size

number of doubles allocated

 

Returns

A new NcmVector.


ncm_vector_new_gsl ()

NcmVector *
ncm_vector_new_gsl (gsl_vector *gv);

This function saves gv internally and frees it when it is no longer necessary. The gv vector must not be freed.

[skip]

Parameters

gv

vector from GNU Scientific Library (GSL) to be converted into a NcmVector

 

Returns

A new NcmVector.


ncm_vector_new_gsl_static ()

NcmVector *
ncm_vector_new_gsl_static (gsl_vector *gv);

This function saves gv internally and does not frees. The gv vector must be valid during the life of the created NcmVector.

[skip]

Parameters

gv

vector from GNU Scientific Library (GSL) to be converted into a NcmVector

 

Returns

A new NcmVector.


ncm_vector_new_array ()

NcmVector *
ncm_vector_new_array (GArray *a);

This function saves a internally and frees it when it is no longer necessary. The a array must not be freed.

Parameters

a

array of doubles to be converted into a NcmVector.

[array][element-type double]

Returns

A new NcmVector.

[transfer full]


ncm_vector_new_data_slice ()

NcmVector *
ncm_vector_new_data_slice (gdouble *d,
                           const gsize size,
                           const gsize stride);

This function returns a NcmVector of the array d allocated using g_slice function. This function saves d internally and frees it when it is no longer necessary. The d vector must not be freed.

Parameters

d

pointer to the first double allocated.

[array][element-type double]

size

number of doubles allocated

 

stride

the step-size from one element to the next in physical memory, measured in units of double

 

Returns

A new NcmVector.


ncm_vector_new_data_malloc ()

NcmVector *
ncm_vector_new_data_malloc (gdouble *d,
                            const gsize size,
                            const gsize stride);

This function returns a NcmVector of the array d allocated using malloc. It saves d internally and frees it when it is no longer necessary. The d vector must not be freed.

Parameters

d

pointer to the first double allocated.

[array][element-type double]

size

number of doubles allocated

 

stride

the step-size from one element to the next in physical memory, measured in units of double

 

Returns

A new NcmVector.


ncm_vector_new_data_static ()

NcmVector *
ncm_vector_new_data_static (gdouble *d,
                            const gsize size,
                            const gsize stride);

This function returns a NcmVector 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.

[array][element-type double]

size

number of doubles allocated

 

stride

the step-size from one element to the next in physical memory, measured in units of double

 

Returns

A new NcmVector.


ncm_vector_new_data_dup ()

NcmVector *
ncm_vector_new_data_dup (gdouble *d,
                         const gsize size,
                         const gsize stride);

This function returns a NcmVector of the array d . It allocate a new vector and copy the contents of d into it.

Parameters

d

pointer to the first double allocated.

[array][element-type double]

size

number of doubles allocated

 

stride

the step-size from one element to the next in physical memory, measured in units of double

 

Returns

A new NcmVector.

[transfer full]


ncm_vector_new_variant ()

NcmVector *
ncm_vector_new_variant (GVariant *var);

This function convert a GVariant array to a NcmVector allocating new memory for the vector.

Parameters

var

a GVariant of the type "ad"

 

Returns

A new NcmVector.


ncm_vector_ref ()

NcmVector *
ncm_vector_ref (NcmVector *cv);

Increases the reference count of cv by one atomically.

Parameters

cv

a NcmVector

 

Returns

cv .

[transfer full]


ncm_vector_const_ref ()

const NcmVector *
ncm_vector_const_ref (const NcmVector *cv);

Increases the reference count of the constant cv by one atomically.

Parameters

cv

a constant NcmVector

 

Returns

cv .

[transfer full]


ncm_vector_const_new_variant ()

const NcmVector *
ncm_vector_const_new_variant (GVariant *var);

This function convert a GVariant array to a NcmVector. Since it returns a constant NcmVector it uses the same memory of var .

Parameters

var

a GVariant of the type "ad"

 

Returns

A new NcmVector.

[transfer full]


ncm_vector_const_new_data ()

const NcmVector *
ncm_vector_const_new_data (const gdouble *d,
                           const gsize size,
                           const gsize stride);

This function returns a constant NcmVector 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.

[array][element-type double]

size

number of doubles allocated

 

stride

the step-size from one element to the next in physical memory, measured in units of double

 

Returns

A new constant NcmVector.


ncm_vector_get_subvector ()

NcmVector *
ncm_vector_get_subvector (NcmVector *cv,
                          const gsize k,
                          const gsize size);

This function returns a new NcmVector which is a subvector of the vector cv . The start of the new vector is the component k from the original vector cv . The new vector has size elements.

Parameters

cv

a NcmVector

 

k

component index of the original vector

 

size

number of components of the subvector

 

Returns

A NcmVector.

[transfer full]


ncm_vector_get_subvector2 ()

void
ncm_vector_get_subvector2 (NcmVector *sub_cv,
                           NcmVector *cv,
                           const gsize k,
                           const gsize size);

This function sets sub_cv to be a subvector of the vector cv . The start of the new vector is the component k from the original vector cv . The new vector has size elements.

It is assumed that sub_cv is a static vector allocated with ncm_vector_new_data_static(). If a different type of vector is passed then the function will lead to a memory leak.

Parameters

sub_cv

a NcmVector

 

cv

a NcmVector

 

k

component index of the original vector

 

size

number of components of the subvector

 

ncm_vector_get_subvector_stride ()

NcmVector *
ncm_vector_get_subvector_stride (NcmVector *cv,
                                 const gsize k,
                                 const gsize size,
                                 const gsize stride);

This function returns a new NcmVector which is a subvector of the vector cv . The start of the new vector is the component k from the original vector cv . The new vector has size elements.

Parameters

cv

a NcmVector

 

k

component index of the original vector

 

size

number of components of the subvector

 

stride

the step-size from one element to the next in physical memory, measured in units of double

 

Returns

A NcmVector.

[transfer full]


ncm_vector_get_variant ()

GVariant *
ncm_vector_get_variant (const NcmVector *cv);

Convert cv to a GVariant of the type "ad" without destroying the original vector cv .

Parameters

cv

a constant NcmVector

 

Returns

A GVariant of the type "ad".

[transfer full]


ncm_vector_peek_variant ()

GVariant *
ncm_vector_peek_variant (const NcmVector *cv);

Convert cv to a GVariant of the type "ad" using the same memory space. The vector cv should not be modified during the variant existance. If the vector has stride != 1 then ncm_vector_get_variant() is called.

Parameters

cv

a constant NcmVector

 

Returns

A GVariant of the type "ad".

[transfer full]


ncm_vector_log_vals ()

void
ncm_vector_log_vals (const NcmVector *cv,
                     const gchar *prestr,
                     const gchar *format,
                     gboolean cr);

Log the values of cv using prestr and format .

Parameters

cv

a constant NcmVector

 

prestr

initial string

 

format

float format

 

cr

whether to include a cariage return

 

ncm_vector_log_vals_avpb ()

void
ncm_vector_log_vals_avpb (const NcmVector *cv,
                          const gchar *prestr,
                          const gchar *format,
                          const gdouble a,
                          const gdouble b);

Log the values of (a $\times$ cv $+$ b ) using prestr and format .

Parameters

cv

a constant NcmVector

 

prestr

initial string

 

format

float format

 

a

a double

 

b

a double

 

ncm_vector_log_vals_func ()

void
ncm_vector_log_vals_func (const NcmVector *cv,
                          const gchar *prestr,
                          const gchar *format,
                          NcmVectorCompFunc f,
                          gpointer user_data);

Log the values of f (cv ) using prestr and format .

Parameters

cv

a constant NcmVector

 

prestr

initial string

 

format

float format

 

f

a NcmVectorCompFunc.

[scope notified]

user_data

user data used in f

 

ncm_vector_set_from_variant ()

void
ncm_vector_set_from_variant (NcmVector *cv,
                             GVariant *var);

Sets the values of cv using the variant var . This function fails if cv and var differ in size.

Parameters

cv

a NcmVector

 

var

a GVariant of type ad

 

ncm_vector_dnrm2 ()

gdouble
ncm_vector_dnrm2 (const NcmVector *cv);

Calculates the Euclidean norm of the vector cv , i.e., $\vert\text{cv}\vert_2$.

Parameters

cv

a constant NcmVector

 

Returns

$\vert\text{cv}\vert_2$.


ncm_vector_axpy ()

void
ncm_vector_axpy (NcmVector *cv1,
                 const gdouble alpha,
                 const NcmVector *cv2);

Performs the operation: cv1 $=\alpha\times$ cv2 $+$ cv1 .

Parameters

cv1

a NcmVector

 

alpha

a constant double $\alpha$

 

cv2

a constant NcmVector

 

ncm_vector_cmp ()

void
ncm_vector_cmp (NcmVector *cv1,
                const NcmVector *cv2);

Performs a comparison, component-wise, of the two vectors and puts the weighted difference in cv1 .

Parameters

cv1

a NcmVector

 

cv2

a constant NcmVector

 

ncm_vector_cmp2 ()

gint
ncm_vector_cmp2 (const NcmVector *cv1,
                 const NcmVector *cv2,
                 const gdouble reltol,
                 const gdouble abstol);

Performs a comparison, component-wise, of the two vectors and returns the number of components that do not match.

Parameters

cv1

a constant NcmVector

 

cv2

a constant NcmVector

 

reltol

the relative tolerance

 

abstol

the absolute tolerance

 

Returns

the number of components that do not match.


ncm_vector_sub_round_off ()

void
ncm_vector_sub_round_off (NcmVector *cv1,
                          const NcmVector *cv2);

Estimate the round-off error component wise in the subtraction of cv1 by cv2 .

Parameters

cv1

a NcmVector

 

cv2

a constant NcmVector

 

ncm_vector_reciprocal ()

void
ncm_vector_reciprocal (NcmVector *cv);

Calculates the reciprocal of cv .

Parameters

cv

a NcmVector

 

ncm_vector_square ()

void
ncm_vector_square (NcmVector *cv);

Calculates the term-wise square of cv .

Parameters

cv

a NcmVector

 

ncm_vector_sqrt ()

void
ncm_vector_sqrt (NcmVector *cv);

Calculates the term-wise square-root of cv .

Parameters

cv

a NcmVector

 

ncm_vector_hypot ()

void
ncm_vector_hypot (NcmVector *cv1,
                  const gdouble a,
                  const NcmVector *cv2);

Performs the operation: $x^i_1 = \sqrt{(x^i_1)^2+(\alpha x^i_2)^2}$ where $x_1^i$ and $x_2^i$ are the components of cv1 and cv2 respectively.

Parameters

cv1

a NcmVector

 

a

a constant gdouble

 

cv2

a constant NcmVector

 

ncm_vector_sum_cpts ()

gdouble
ncm_vector_sum_cpts (const NcmVector *cv);

Calculates the sum of the components.

Parameters

cv

a constant NcmVector

 

Returns

the sum of the vector cv components.


ncm_vector_mean ()

gdouble
ncm_vector_mean (const NcmVector *cv);

Calculates the mean of the components.

Parameters

cv

a constant NcmVector

 

Returns

the mean of the vector cv components.


ncm_vector_const_new_gsl ()

const NcmVector *
ncm_vector_const_new_gsl (const gsl_vector *gv);

This function converts the gsl_vetor gv into a new constant NcmVector.

[skip]

Parameters

Returns

A new constant NcmVector.


ncm_vector_get ()

gdouble
ncm_vector_get (const NcmVector *cv,
                const guint i);

Parameters

cv

a constant NcmVector

 

i

component index

 

Returns

The i -th component of the vector cv .


ncm_vector_fast_get ()

gdouble
ncm_vector_fast_get (const NcmVector *cv,
                     const guint i);

Parameters

cv

a constant NcmVector

 

i

component index

 

Returns

The i -th component of the vector cv assuming stride == 1.


ncm_vector_ptr ()

gdouble *
ncm_vector_ptr (NcmVector *cv,
                const guint i);

Parameters

cv

a NcmVector

 

i

component index

 

Returns

A pointer to the i -th component of the vector cv .


ncm_vector_fast_ptr ()

gdouble *
ncm_vector_fast_ptr (NcmVector *cv,
                     const guint i);

Parameters

cv

a NcmVector

 

i

component index

 

Returns

A pointer to the i -th component of the vector cv assuming stride == 1.


ncm_vector_const_ptr ()

const gdouble *
ncm_vector_const_ptr (const NcmVector *cv,
                      const guint i);

Parameters

cv

a constant NcmVector

 

i

component index

 

Returns

A constant pointer to the i -th component of the vector cv .


ncm_vector_set ()

void
ncm_vector_set (NcmVector *cv,
                const guint i,
                const gdouble val);

This function sets the value of the i -th component of the vector cv to val .

Parameters

cv

a NcmVector

 

i

component index

 

val

a constant double

 

ncm_vector_fast_set ()

void
ncm_vector_fast_set (NcmVector *cv,
                     const guint i,
                     const gdouble val);

This function sets the value of the i -th component of the vector cv to val assuming stride == 1.

Parameters

cv

a NcmVector

 

i

component index

 

val

a constant double

 

ncm_vector_addto ()

void
ncm_vector_addto (NcmVector *cv,
                  const guint i,
                  const gdouble val);

This function adds val to the value of the i -th component of the vector cv .

Parameters

cv

a NcmVector

 

i

component index

 

val

a constant double

 

ncm_vector_fast_addto ()

void
ncm_vector_fast_addto (NcmVector *cv,
                       const guint i,
                       const gdouble val);

This function adds val to the value of the i -th component of cv assuming stride == 1.

Parameters

cv

a NcmVector

 

i

component index

 

val

a constant double

 

ncm_vector_subfrom ()

void
ncm_vector_subfrom (NcmVector *cv,
                    const guint i,
                    const gdouble val);

This function subtracts val from the value of the i -th component of the vector cv .

Parameters

cv

a NcmVector

 

i

component index

 

val

a constant double

 

ncm_vector_fast_subfrom ()

void
ncm_vector_fast_subfrom (NcmVector *cv,
                         const guint i,
                         const gdouble val);

This function subtracts val from the value of the i -th component of the vector cv assuming stride == 1.

Parameters

cv

a NcmVector

 

i

component index

 

val

a constant double

 

ncm_vector_mulby ()

void
ncm_vector_mulby (NcmVector *cv,
                  const guint i,
                  const gdouble val);

This function multiplies the i -th component of the vector cv by val .

Parameters

cv

a NcmVector

 

i

component index

 

val

a constant double

 

ncm_vector_fast_mulby ()

void
ncm_vector_fast_mulby (NcmVector *cv,
                       const guint i,
                       const gdouble val);

This function multiplies the i -th component of the vector by val assuming stride == 1.

Parameters

cv

a NcmVector

 

i

component index

 

val

a constant double

 

ncm_vector_set_all ()

void
ncm_vector_set_all (NcmVector *cv,
                    const gdouble val);

This function sets all the components of the vector cv to the value val .

Parameters

cv

a NcmVector

 

val

a constant double

 

ncm_vector_set_data ()

void
ncm_vector_set_data (NcmVector *cv,
                     const gdouble *array,
                     guint size);

This function sets all the components of the vector cv using the data array . size must match the vector size.

Parameters

cv

a NcmVector

 

array

a pointer to a double array.

[array length=size][element-type double]

size

data array size

 

ncm_vector_set_array ()

void
ncm_vector_set_array (NcmVector *cv,
                      GArray *array);

This function sets all the components of the vector cv using the data array array . array->len must match the vector size.

Parameters

cv

a NcmVector

 

array

a pointer to a double GArray.

[array][element-type double]

ncm_vector_scale ()

void
ncm_vector_scale (NcmVector *cv,
                  const gdouble val);

This function multiplies the components of the vector cv by the constant factor val .

Parameters

cv

a NcmVector

 

val

a constant double

 

ncm_vector_add_constant ()

void
ncm_vector_add_constant (NcmVector *cv,
                         const gdouble val);

This function adds the constant val to all components of the vector cv .

Parameters

cv

a NcmVector

 

val

a constant double

 

ncm_vector_mul ()

void
ncm_vector_mul (NcmVector *cv1,
                const NcmVector *cv2);

This function multiplies the components of the vector cv1 by the components of the vector cv2 . The two vectors must have the same length.

Parameters

cv1

a NcmVector

 

cv2

a constant NcmVector

 

ncm_vector_div ()

void
ncm_vector_div (NcmVector *cv1,
                const NcmVector *cv2);

This function divides the components of the vector cv1 by the components of the vector cv2 . The two vectors must have the same length.

Parameters

cv1

a NcmVector, numerator

 

cv2

a NcmVector, denominator

 

ncm_vector_add ()

void
ncm_vector_add (NcmVector *cv1,
                const NcmVector *cv2);

This function adds the components of the vector cv2 to the components of the vector cv1 . The two vectors must have the same length.

Parameters

cv1

a NcmVector

 

cv2

a constant NcmVector

 

ncm_vector_sub ()

void
ncm_vector_sub (NcmVector *cv1,
                const NcmVector *cv2);

This function subtracts the components of the vector cv2 to the components of the vector cv1 . The two vectors must have the same length.

Parameters

cv1

a NcmVector

 

cv2

a constant NcmVector

 

ncm_vector_set_zero ()

void
ncm_vector_set_zero (NcmVector *cv);

This function sets all the components of the vector cv to zero.

Parameters

cv

a NcmVector

 

ncm_vector_memcpy ()

void
ncm_vector_memcpy (NcmVector *cv1,
                   const NcmVector *cv2);

This function copies the components of the vector cv2 into the vector cv1 . The two vectors must have the same length.

Parameters

cv1

a NcmVector

 

cv2

a constant NcmVector

 

ncm_vector_memcpy2 ()

void
ncm_vector_memcpy2 (NcmVector *cv1,
                    const NcmVector *cv2,
                    const guint cv1_start,
                    const guint cv2_start,
                    const guint size);

This function copies size components of the vector cv2 , counting from cv2_start , to the vector cv1 , starting from the cv1_start component. It is useful for vectors with different sizes.

Parameters

cv1

a NcmVector

 

cv2

a constant NcmVector

 

cv1_start

component of cv1

 

cv2_start

component of cv2

 

size

number of components

 

ncm_vector_get_array ()

GArray *
ncm_vector_get_array (NcmVector *cv);

This function returns the array of cv . It is only applied if the vector cv was created with ncm_vector_new_array().

Parameters

cv

a NcmVector

 

Returns

A pointer to a double GArray.

[transfer container][element-type double]


ncm_vector_dup_array ()

GArray *
ncm_vector_dup_array (NcmVector *cv);

This function allocates a new array and copy the contents of the vector cv into it. The array must not be freed.

Parameters

cv

a NcmVector

 

Returns

A new pointer to a double GArray.

[transfer full][element-type double]


ncm_vector_data ()

gdouble *
ncm_vector_data (NcmVector *cv);

This function returns a pointer to the vector cv data.

Parameters

cv

a NcmVector

 

Returns

A pointer to cv data.

[transfer none]


ncm_vector_const_data ()

const gdouble *
ncm_vector_const_data (const NcmVector *cv);

This function returns a constant pointer to the vector cv data.

Parameters

cv

a constant NcmVector

 

Returns

A constant pointer to the vector cv data.

[transfer none]


ncm_vector_replace_data ()

void
ncm_vector_replace_data (NcmVector *cv,
                         gdouble *data);

This function replaces the data of the vector cv by data . It does not make any check on the size of the new data. It assumes that the new data has the same size of the vector cv and that the original data was statically allocated.

It is useful when one needs to convert a data pointer to a NcmVector.

[skip]

Parameters

cv

a NcmVector

 

data

a pointer to the new data

 

ncm_vector_gsl ()

gsl_vector *
ncm_vector_gsl (NcmVector *cv);

This function returns a pointer to the gsl_vector associated to the vector cv .

[skip]

Parameters

cv

a NcmVector

 

Returns

a pointer to a gsl_vector.


ncm_vector_const_gsl ()

const gsl_vector *
ncm_vector_const_gsl (const NcmVector *cv);

This function returns a constant pointer to the gsl_vector associated to the vector cv .

[skip]

Parameters

cv

a constant NcmVector

 

Returns

a constant pointer to a gsl_vector.


ncm_vector_dot ()

gdouble
ncm_vector_dot (const NcmVector *cv1,
                const NcmVector *cv2);

This function returns the dot product of the NcmVector cv1 and cv2 .

Parameters

cv1

a constant NcmVector

 

cv2

a constant NcmVector

 

Returns

$\vec{v}_1 \cdot \vec{v}_2$.


ncm_vector_len ()

guint
ncm_vector_len (const NcmVector *cv);

Computes the number of components in the NcmVector cv .

Parameters

cv

a constant NcmVector

 

Returns

the number of components in cv .


ncm_vector_stride ()

guint
ncm_vector_stride (const NcmVector *cv);

This function returns the stride of NcmVector cv .

Parameters

cv

a constant NcmVector

 

Returns

the stride of cv .


ncm_vector_get_max ()

gdouble
ncm_vector_get_max (const NcmVector *cv);

Gets the maximum value of the vector components.

Parameters

cv

a constant NcmVector

 

Returns

the maximum value of the vector components.


ncm_vector_get_min ()

gdouble
ncm_vector_get_min (const NcmVector *cv);

Gets the minimum value of the vector components.

Parameters

cv

a constant NcmVector

 

Returns

the minimum value of the vector components.


ncm_vector_get_max_index ()

gsize
ncm_vector_get_max_index (const NcmVector *cv);

Gets the index of the maximal vector component.

Parameters

cv

a constant NcmVector

 

Returns

the index of the maximal component.


ncm_vector_get_min_index ()

gsize
ncm_vector_get_min_index (const NcmVector *cv);

Gets the index of the minimal vector component.

Parameters

cv

a constant NcmVector

 

Returns

the index of the minimal component.


ncm_vector_get_minmax ()

void
ncm_vector_get_minmax (const NcmVector *cv,
                       gdouble *min,
                       gdouble *max);

Gets the minimum/maximum value of the vector components.

Parameters

cv

a constant NcmVector

 

min

minimum component value of cv .

[out]

max

maximum component value of cv .

[out]

ncm_vector_is_finite ()

gboolean
ncm_vector_is_finite (const NcmVector *cv);

Tests all entries, if one or more are not finite return FALSE. Otherwise returns TRUE.

Parameters

cv

a constant NcmVector

 

Returns

whether all components of cv are finite.


ncm_vector_lt ()

gboolean
ncm_vector_lt (const NcmVector *cv1,
               const NcmVector *cv2);

Compare cv1 and cv2 and returns TRUE if all components of cv1 are less than cv2 's.

Parameters

cv1

a constant NcmVector

 

cv2

a constant NcmVector

 

Returns

whether cv1 < cv2 .


ncm_vector_lteq ()

gboolean
ncm_vector_lteq (const NcmVector *cv1,
                 const NcmVector *cv2);

Compare cv1 and cv2 and returns TRUE if all components of cv1 are less than or equal to cv2 's.

Parameters

cv1

a constant NcmVector

 

cv2

a constant NcmVector

 

Returns

whether cv1 <= cv2 .


ncm_vector_between ()

gboolean
ncm_vector_between (const NcmVector *cv,
                    const NcmVector *cv_lb,
                    const NcmVector *cv_ub,
                    gint type);

Check whether all components of cv are between components of cv_lb and cv_ub . If type == 0, compare using cv_lb <= cv < cv_ub ; If type == 1, compare using cv_lb < cv <= cv_ub ;

Parameters

cv

a constant NcmVector

 

cv_lb

a constant NcmVector

 

cv_ub

a constant NcmVector

 

type

an int

 

Returns

whether cv is between cv_lb and cv_ub .


ncm_vector_get_absminmax ()

void
ncm_vector_get_absminmax (const NcmVector *cv,
                          gdouble *absmin,
                          gdouble *absmax);

Gets the minimum/maximum absolute value of cv components.

Parameters

cv

a constant NcmVector

 

absmin

minimum component absolute value of cv .

[out]

absmax

maximum component absolute value of cv .

[out]

ncm_vector_find_closest_index ()

guint
ncm_vector_find_closest_index (const NcmVector *cv,
                               const gdouble x);

Assuming that cv elements are in increasing order ($x_i < x_{i+1}$) finds the largest index $i$ such the $x_i < x$. It also assumes that $x_0 < x < x_{\mathrm{len} - 1}$.

Parameters

cv

a NcmVector .

 

x

a gdouble $x$

 

ncm_vector_dup ()

NcmVector *
ncm_vector_dup (const NcmVector *cv);

This function copies the elements of the constant vector cv into the new NcmVector.

Parameters

cv

a constant NcmVector

 

Returns

A NcmVector.

[transfer full]


ncm_vector_substitute ()

void
ncm_vector_substitute (NcmVector **cv1,
                       NcmVector *cv2,
                       gboolean check_size);

This function substitute the vector *cv1 by cv2 , it will unref *cv1 first. If check_size is TRUE then the function asserts that both vectors have the same size.

Parameters

cv1

a NcmVector

 

cv2

a NcmVector

 

check_size

whether to check vector size

 

ncm_vector_free ()

void
ncm_vector_free (NcmVector *cv);

Atomically decrements the reference count of cv by one. If the reference count drops to 0, all memory allocated by cv is released.

Parameters

cv

a NcmVector

 

ncm_vector_clear ()

void
ncm_vector_clear (NcmVector **cv);

If cv is different from NULL, atomically decrements the reference count of cv by one. If the reference count drops to 0, all memory allocated by cv is released and cv is set to NULL.

Parameters

cv

a NcmVector

 

ncm_vector_const_free ()

void
ncm_vector_const_free (const NcmVector *cv);

Atomically decrements the reference count of the constant cv by one. If the reference count drops to 0, all memory allocated by cv is released.

Parameters

cv

a constant NcmVector

 

Types and Values

NCM_TYPE_VECTOR

#define NCM_TYPE_VECTOR (ncm_vector_get_type ())

enum NcmVectorInternal

This enumerator is only used internally. Only by developers.

Members

NCM_VECTOR_SLICE

Uses g_slice_* family functions from Glib to alloc and free memory segments.

 

NCM_VECTOR_GSL_VECTOR

Uses gsl_vector from GSL as the base object.

 

NCM_VECTOR_MALLOC

Uses malloc for memory allocation and free functions.

 

NCM_VECTOR_ARRAY

Uses g_array from Glib as base.

 

NCM_VECTOR_DERIVED

Uses another NcmVector (for example, if it is getting a subvector from a NcmVector).

 

struct NcmVector

struct NcmVector;

Property Details

The “values” property

  “values”                   GVariant *

GVariant representation of the vector used to serialize the object.

Owner: NcmVector

Flags: Read / Write

Allowed values: GVariant<ad>

Default value: NULL