Vector Object

Vector Object — Vector object representing arrays of doubles

Synopsis

#define             NCM_N2VECTOR                        (v)
#define             NCM_VECTOR_DATA                     (cv)
struct              NcmVector;
struct              NcmVectorClass;
enum                NcmVectorInternal;
void                ncm_vector_add                      (NcmVector *cv1,
                                                         const NcmVector *cv2);
void                ncm_vector_addto                    (NcmVector *cv,
                                                         const guint i,
                                                         const gdouble val);
void                ncm_vector_clear                    (NcmVector **cv);
void                ncm_vector_const_free               (const NcmVector *cv);
const gsl_vector *  ncm_vector_const_gsl                (const NcmVector *cv);
void                ncm_vector_div                      (NcmVector *cv1,
                                                         const NcmVector *cv2);
NcmVector *         ncm_vector_dup                      (const NcmVector *cv);
GArray *            ncm_vector_dup_array                (NcmVector *cv);
gdouble             ncm_vector_fast_get                 (const NcmVector *cv,
                                                         const guint i);
void                ncm_vector_fast_set                 (NcmVector *cv,
                                                         const guint i,
                                                         const gdouble val);
void                ncm_vector_fast_subfrom             (NcmVector *cv,
                                                         const guint i,
                                                         const gdouble val);
void                ncm_vector_free                     (NcmVector *cv);
gdouble             ncm_vector_get                      (const NcmVector *cv,
                                                         const guint i);
GArray *            ncm_vector_get_array                (NcmVector *cv);
NcmVector *         ncm_vector_get_subvector            (NcmVector *cv,
                                                         const gsize k,
                                                         const gsize size);
GVariant *          ncm_vector_get_variant              (NcmVector *v);
gsl_vector *        ncm_vector_gsl                      (NcmVector *cv);
guint               ncm_vector_len                      (const NcmVector *cv);
void                ncm_vector_memcpy                   (NcmVector *cv1,
                                                         const NcmVector *cv2);
void                ncm_vector_memcpy2                  (NcmVector *cv1,
                                                         const NcmVector *cv2,
                                                         const guint cv1_start,
                                                         const guint cv2_start,
                                                         const guint size);
NcmVector *         ncm_vector_new                      (gsize n);
NcmVector *         ncm_vector_new_array                (GArray *a);
const NcmVector *   ncm_vector_new_data_const           (const gdouble *d,
                                                         const gsize size,
                                                         const gsize stride);
NcmVector *         ncm_vector_new_data_malloc          (gdouble *d,
                                                         const gsize size,
                                                         const gsize stride);
NcmVector *         ncm_vector_new_data_slice           (gdouble *d,
                                                         const gsize size,
                                                         const gsize stride);
NcmVector *         ncm_vector_new_data_static          (gdouble *d,
                                                         const gsize size,
                                                         const gsize stride);
NcmVector *         ncm_vector_new_gsl                  (gsl_vector *gv);
const NcmVector *   ncm_vector_new_gsl_const            (const gsl_vector *v);
NcmVector *         ncm_vector_new_gsl_static           (gsl_vector *gv);
NcmVector *         ncm_vector_new_variant              (GVariant *var);
N_Vector            ncm_vector_nvector                  (NcmVector *cv);
gdouble *           ncm_vector_ptr                      (NcmVector *cv,
                                                         const guint i);
NcmVector *         ncm_vector_ref                      (NcmVector *cv);
void                ncm_vector_scale                    (NcmVector *cv,
                                                         const gdouble val);
void                ncm_vector_set                      (NcmVector *cv,
                                                         const guint i,
                                                         const gdouble val);
void                ncm_vector_set_all                  (NcmVector *cv,
                                                         const gdouble val);
void                ncm_vector_set_zero                 (NcmVector *cv);
guint               ncm_vector_stride                   (const NcmVector *cv);
void                ncm_vector_sub                      (NcmVector *cv1,
                                                         const NcmVector *cv2);
void                ncm_vector_subfrom                  (NcmVector *cv,
                                                         const guint i,
                                                         const gdouble val);

Object Hierarchy

  GObject
   +----NcmVector

Description

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

Details

NCM_N2VECTOR()

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

NCM_VECTOR_DATA()

#define NCM_VECTOR_DATA(cv) ((cv)->vv.vector.data)

struct NcmVector

struct NcmVector;

struct NcmVectorClass

struct NcmVectorClass {
};

enum NcmVectorInternal

typedef enum {
  NCM_VECTOR_SLICE = 0,
  NCM_VECTOR_GSL_VECTOR,
  NCM_VECTOR_MALLOC,
  NCM_VECTOR_ARRAY,
  NCM_VECTOR_DERIVED,
} NcmVectorInternal;

FIXME

NCM_VECTOR_SLICE

FIXME

NCM_VECTOR_GSL_VECTOR

FIXME

NCM_VECTOR_MALLOC

FIXME

NCM_VECTOR_ARRAY

FIXME

NCM_VECTOR_DERIVED

FIXME

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.

cv1 :

a NcmVector.

cv2 :

a NcmVector.

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 cv.

cv :

a NcmVector.

i :

component index.

val :

a constant double.

ncm_vector_clear ()

void                ncm_vector_clear                    (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. The pointer is set to NULL.

cv :

a NcmVector.

ncm_vector_const_free ()

void                ncm_vector_const_free               (const 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.

cv :

a constant NcmVector.

ncm_vector_const_gsl ()

const gsl_vector *  ncm_vector_const_gsl                (const NcmVector *cv);

FIXME

cv :

a NcmVector.

Returns :

FIXME

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.

cv1 :

a NcmVector, numerator.

cv2 :

a NcmVector, denominator.

ncm_vector_dup ()

NcmVector *         ncm_vector_dup                      (const NcmVector *cv);

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

cv :

a constant NcmVector.

Returns :

A NcmVector. [transfer full]

ncm_vector_dup_array ()

GArray *            ncm_vector_dup_array                (NcmVector *cv);

FIXME

cv :

a NcmVector.

Returns :

FIXME. [transfer full][element-type double]

ncm_vector_fast_get ()

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

cv :

a constant NcmVector.

i :

component index.

Returns :

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

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.

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 cv assuming stride == 1.

cv :

a NcmVector.

i :

component index.

val :

a cosntant double.

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.

cv :

a NcmVector.

ncm_vector_get ()

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

cv :

a constant NcmVector.

i :

component index.

Returns :

The i-th component of the vector cv.

ncm_vector_get_array ()

GArray *            ncm_vector_get_array                (NcmVector *cv);

FIXME

cv :

a NcmVector.

Returns :

FIXME. [transfer container][element-type double]

ncm_vector_get_subvector ()

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

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

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_variant ()

GVariant *          ncm_vector_get_variant              (NcmVector *v);

Convert v to a GVariant of the type "ad" without destroying the original vector v;

v :

a NcmVector.

Returns :

A GVariant of the type "ad". [transfer full]

ncm_vector_gsl ()

gsl_vector *        ncm_vector_gsl                      (NcmVector *cv);

FIXME

cv :

a NcmVector.

Returns :

FIXME

ncm_vector_len ()

guint               ncm_vector_len                      (const NcmVector *cv);

FIXME

cv :

a NcmVector.

Returns :

FIXME

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.

cv1 :

a NcmVector.

cv2 :

a 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 cv2, counting from cv2_start, to the vector cv1, starting from the cv1_start component. It is useful for vectors with different sizes.

cv1 :

a NcmVector.

cv2 :

a NcmVector.

cv1_start :

component of cv1.

cv2_start :

component of cv2.

size :

number of components.

ncm_vector_new ()

NcmVector *         ncm_vector_new                      (gsize n);

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

n :

defines the size of the vector.

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.

a :

array of doubles to be converted into a NcmVector. [array][element-type double][transfer full]

Returns :

A new NcmVector.

ncm_vector_new_data_const ()

const NcmVector *   ncm_vector_new_data_const           (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.

d :

pointer to the first double allocated.

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_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.

d :

pointer to the first double allocated.

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_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 a internally and frees it when it is no longer necessary. The a vector must not be freed.

d :

pointer to the first double allocated.

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.

d :

pointer to the first double allocated.

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_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.

gv :

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

Returns :

A new NcmVector.

ncm_vector_new_gsl_const ()

const NcmVector *   ncm_vector_new_gsl_const            (const gsl_vector *v);

This function converts v into a constant NcmVector.

v :

vector from GNU Scientific Library (GSL).

Returns :

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

gv :

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

Returns :

A new NcmVector.

ncm_vector_new_variant ()

NcmVector *         ncm_vector_new_variant              (GVariant *var);

This function convert a GVariant array to a NcmVector.

var :

a GVariant of the type "ad".

Returns :

A new NcmVector.

ncm_vector_nvector ()

N_Vector            ncm_vector_nvector                  (NcmVector *cv);

FIXME

cv :

a NcmVector.

Returns :

FIXME

ncm_vector_ptr ()

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

cv :

a NcmVector.

i :

component index.

Returns :

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

ncm_vector_ref ()

NcmVector *         ncm_vector_ref                      (NcmVector *cv);

This function increses the reference count of cv the object.

cv :

a NcmVector.

Returns :

cv. [transfer full]

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.

cv :

a NcmVector.

val :

a cosntant double.

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.

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.

cv :

a NcmVector.

val :

a cosntant double.

ncm_vector_set_zero ()

void                ncm_vector_set_zero                 (NcmVector *cv);

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

cv :

a NcmVector.

ncm_vector_stride ()

guint               ncm_vector_stride                   (const NcmVector *cv);

FIXME

cv :

a NcmVector.

Returns :

FIXME

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.

cv1 :

a NcmVector.

cv2 :

a NcmVector.

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 cv.

cv :

a NcmVector.

i :

component index.

val :

a cosntant double.