Class

NumCosmoMathVector

Description [src]

class NumCosmoMath.Vector : GObject.Object
{
  /* No available fields */
}

Vector object representing arrays of doubles.

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

Ancestors

Constructors

ncm_vector_const_new_data

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.

ncm_vector_const_new_gsl

This function converts the #gsl_vector gv into a new constant NcmVector.

ncm_vector_const_new_variant

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

ncm_vector_new

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

ncm_vector_new_array

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

ncm_vector_new_data_dup

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

ncm_vector_new_data_malloc

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.

ncm_vector_new_data_slice

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.

ncm_vector_new_data_static

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.

ncm_vector_new_fftw

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.

ncm_vector_new_full

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.

ncm_vector_new_gsl

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

ncm_vector_new_gsl_static

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

ncm_vector_new_variant

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

Functions

ncm_vector_clear

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.

ncm_vector_substitute

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.

Instance methods

ncm_vector_add

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

ncm_vector_add_constant

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

ncm_vector_addto

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

ncm_vector_axpy

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

ncm_vector_between

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

ncm_vector_cmp

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

ncm_vector_cmp2

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

ncm_vector_const_data

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

ncm_vector_const_free

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.

ncm_vector_const_gsl

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

ncm_vector_const_ptr
No description available.

ncm_vector_const_ref

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

ncm_vector_data

This function returns a pointer to the vector cv data.

ncm_vector_div

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

ncm_vector_dnrm2

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

ncm_vector_dot

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

ncm_vector_dup

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

ncm_vector_dup_array

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

ncm_vector_fast_addto

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

ncm_vector_fast_get
No description available.

ncm_vector_fast_mulby

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

ncm_vector_fast_ptr
No description available.

ncm_vector_fast_set

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

ncm_vector_fast_subfrom

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

ncm_vector_find_closest_index

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}$.

ncm_vector_free

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

ncm_vector_get
No description available.

ncm_vector_get_absminmax

Gets the minimum/maximum absolute value of cv components.

ncm_vector_get_array

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

ncm_vector_get_max

Gets the maximum value of the vector components.

ncm_vector_get_max_index

Gets the index of the maximal vector component.

ncm_vector_get_min

Gets the minimum value of the vector components.

ncm_vector_get_min_index

Gets the index of the minimal vector component.

ncm_vector_get_minmax

Gets the minimum/maximum value of the vector components.

ncm_vector_get_subvector

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.

ncm_vector_get_subvector2

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.

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

ncm_vector_get_variant

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

ncm_vector_gsl

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

ncm_vector_hypot

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.

ncm_vector_is_finite

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

ncm_vector_len

Computes the number of components in the NcmVector cv.

ncm_vector_log_vals

Log the values of cv using prestr and format.

ncm_vector_log_vals_avpb

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

ncm_vector_log_vals_func

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

ncm_vector_lt

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

ncm_vector_lteq

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

ncm_vector_mean

Calculates the mean of the components.

ncm_vector_memcpy

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

ncm_vector_memcpy2

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.

ncm_vector_mul

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

ncm_vector_mulby

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

ncm_vector_peek_variant

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

ncm_vector_ptr
No description available.

ncm_vector_reciprocal

Calculates the reciprocal of cv.

ncm_vector_ref

Increases the reference count of cv by one atomically.

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

ncm_vector_replace_data_full

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.

ncm_vector_scale

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

ncm_vector_set

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

ncm_vector_set_all

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

ncm_vector_set_array

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

ncm_vector_set_data

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

ncm_vector_set_from_variant

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

ncm_vector_set_zero

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

ncm_vector_sqrt

Calculates the term-wise square-root of cv.

ncm_vector_square

Calculates the term-wise square of cv.

ncm_vector_stride

This function returns the stride of NcmVector cv.

ncm_vector_sub

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

ncm_vector_sub_round_off

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

ncm_vector_subfrom

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

ncm_vector_sum_cpts

Calculates the sum of the components.

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Properties

NumCosmoMath.Vector:values

GVariant representation of the vector used to serialize the object.

Signals

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct NumCosmoMathVectorClass {
  GObjectClass parent_class;
  
}

No description available.

Class members
parent_class: GObjectClass

No description available.