# File numerics/src/tools/NumericsVector.h¶

Go to the source code of this file

Structure definition and functions related to vector storage in Numerics.

Functions

void NV_display(const double *const m, int n)

Screen display of the vector content stored as a double * array.

Parameters
• m – the vector to be displayed

• n – the size of the vector

void NV_copy(const double *const vec, unsigned int vecSize, double *out)
void NV_write_in_file_python(double *m, int nRow, FILE *file)
bool NV_equal(double *x, double *y, int nRow, double tol)

Test if two vectors are equal up to a given tolerance.

Parameters
• x – the vector to be tested

• y – the vector to be tested

• n – the size of the vector

• tol – the tolerance

Returns

1 is equal

void NV_insert(double *x, const unsigned int xSize, const double *const y, const unsigned int ySize, unsigned int i)

Insert the vector y into the vector x starting from position i.

Parameters
• x – the vector

• size_x – the size of the vector x

• y – the vector to be inserted

• size_y – the size of the vector y

• i – the position of insertion

void NV_power2(const double *const vec, const unsigned int vecSize, double *out)

Put all elements of vector to the suqre (element by element)

Parameters
• vec – is the vector

• vecSize – the size of the vector vec

• out – is the result power2 vector

double NV_reduce(const double *const vec, const unsigned int vecSize)

Sum all the elements in vector.

Parameters
• vec – is the vector

• vecSize – the size of the vector vec

Returns

sum of all the elements in vector

void NV_prod(const double *const vec1, const double *const vec2, const unsigned int vecSize, double *out)

Element by element product of two vectors.

Parameters
• vec1 – is the vector

• vec2 – is the vector

• vecSize – the size of the vector vec

• out – is the result product vector

double *NV_div(const double *const x, const double *const y, const unsigned int vecSize)

Element by element division of two vectors.

Parameters
• x – is the vector

• y – is the vector

• vecSize – the size of the vector vec

Returns

product vector

double NV_min(const double *const vec, const unsigned int vecSize)

Find a minimum value of vertor.

Parameters
• vec – is the vector

• vecSize – the size of the vector vec

Returns

a minimum value of vertor

double NV_max(const double *const vec, const unsigned int vecSize)

Find a maximum value of vertor.

Parameters
• vec – is the vector

• vecSize – the size of the vector vec

Returns

a minimum value of vertor

double *NV_abs(const double *const vec, const unsigned int vecSize)

Compute abs vector.

Parameters
• vec – is the vector

• vecSize – the size of the vector vec

Returns

elemet by element abs vector

void NV_add(const double *const vec1, const double *const vec2, const unsigned int vecSize, double *out)

Compute element by element by element sum.

Parameters
• vec1 – is the vector

• vec2 – is the vector

• vecSize – the size of the vector vec

• out – is the sum vector

void NV_const_add(const double *const vec, const unsigned int vecSize, const double alpha, const double beta, double *out)

Compute y = alpha * x + beta.

Parameters
• x – is the vector

• vecSize – the size of the vector vec

• alpha – is a scalar

• beta – is a scalar

• out – is y = alpha * x + beta

void NV_sub(const double *const vec1, const double *const vec2, const unsigned int vecSize, double *out)

Compute element by element by element subtraction.

Parameters
• vec1 – is the vector

• vec2 – is the vector

• vecSize – the size of the vector vec

Returns

subtract vector

double NV_norm_inf(const double *const vec, const unsigned int vecSize)

Find a L-inf norm of vertor ( max(abs(vec)) )

Parameters
• vec – is the vector

• vecSize – the size of the vector vec

Returns

a minimum value of vertor

double NV_norm_2(const double *const vec, const unsigned int vecSize)

Find a L-2 norm of vertor ( sqrt(sum(vec^2)) )

Parameters
• vec – is the vector

• vecSize – the size of the vector vec

Returns

a minimum value of vertor

void NV_sqrt(const double *const vec, const unsigned int vecSize, double *out)

Compute element by element square root.

Parameters
• vec – is the vector

• vecSize – is the size of the vector vec

• out – is the sqrt vector

void NV_dott(const double *const vec1, const double *const vec2, const unsigned int vecSize, NumericsMatrix *out)

Compute scalar product x x^T which is a matrix of rank 1.

Parameters
• vec1 – is the vector

• vec2 – is the vector

• vecSize – is the size of the vector vec

• out – is the resut matrix of rank 1.

int NV_isnan(const double *const vec, const unsigned int vecSize)