H2Lib
3.0
|
Representation of a vector as an array. More...
Data Structures | |
struct | _avector |
Typedefs | |
typedef struct _avector | avector |
typedef avector * | pavector |
typedef const avector * | pcavector |
Functions | |
pavector | init_avector (pavector v, uint dim) |
Initialize an avector object. More... | |
pavector | init_sub_avector (pavector v, pavector src, uint dim, uint off) |
Initialize an avector object to represent a subvector. More... | |
pavector | init_zero_avector (pavector v, uint dim) |
Initialize an avector object and set it to zero. More... | |
pavector | init_column_avector (pavector v, pamatrix src, uint col) |
Initialize an avector object to represent a column vector of a given matrix. More... | |
pavector | init_pointer_avector (pavector v, pfield src, uint dim) |
Initialize an avector object using a given array for the coefficients. More... | |
void | uninit_avector (pavector v) |
Uninitialize an avector object. More... | |
pavector | new_avector (uint dim) |
Create a new avector object. More... | |
pavector | new_sub_avector (pavector src, uint dim, uint off) |
Create a new avector object representing a subvector. More... | |
pavector | new_zero_avector (uint dim) |
Create a new avector object representing a zero vector. More... | |
pavector | new_pointer_avector (pfield src, uint dim) |
Create a new avector object using a given array for the coefficients. More... | |
void | del_avector (pavector v) |
Delete an avector object. More... | |
void | resize_avector (pavector v, uint dim) |
Change the dimension of an avector object without preserving its coefficients. More... | |
void | shrink_avector (pavector v, uint dim) |
Reduce the dimension of an avector object without reallocating storage, preserving its coefficients. More... | |
field | getentry_avector (pcavector v, uint i) |
Read a vector entry . More... | |
void | setentry_avector (pavector v, uint i, field x) |
Set a vector entry, . More... | |
field | addentry_avector (pavector v, uint i, field x) |
Add to a vector entry, . More... | |
uint | getactives_avector () |
Get number of currently initialized avector objects. More... | |
size_t | getsize_avector (pcavector v) |
Get size of a given avector object. More... | |
size_t | getsize_heap_avector (pcavector v) |
Get heap size of a given avector object. More... | |
void | clear_avector (pavector v) |
Set a vector to zero. More... | |
void | fill_avector (pavector v, field x) |
Set all coefficients in a vector to the same value. More... | |
void | random_avector (pavector v) |
Fill a vector with random values. More... | |
void | random_real_avector (pavector v) |
Fill a vector with real valued random values. More... | |
void | copy_avector (pcavector v, pavector w) |
Copy a vector into another vector, . More... | |
void | copy_sub_avector (pcavector v, pavector w) |
Copy a vector into another vector, . More... | |
void | print_avector (pcavector v) |
Print a vector. More... | |
void | scale_avector (field alpha, pavector v) |
Scale a vector by a factor , . More... | |
real | norm2_avector (pcavector v) |
Compute the Euclidean norm of a vector . More... | |
field | dotprod_avector (pcavector x, pcavector y) |
Compute the Euclidean innner product of two vectors and . More... | |
void | add_avector (field alpha, pcavector x, pavector y) |
Add two vectors, . More... | |
Representation of a vector as an array.
The avector class is used to handle standard linear algebra operations like adding, scaling and multiplying vectors.
Add two vectors, .
alpha | Scaling factor . |
x | Source vector . |
y | Target vector . |
Add to a vector entry, .
v | Vector . |
i | Index . |
x | Summand. |
void clear_avector | ( | pavector | v | ) |
Set a vector to zero.
v | Target vector. |
Copy a vector into another vector, .
Both vectors have to be of the same dimension.
v | Source vector. |
w | Target vector. |
Copy a vector into another vector, .
If is smaller than , only the first coefficients of are copied. If is smaller than , only the first coefficients of are filled.
v | Source vector. |
w | Target vector. |
void del_avector | ( | pavector | v | ) |
Delete an avector object.
Releases the storage corresponding to the object.
v | Object to be deleted. |
Compute the Euclidean innner product of two vectors and .
The Euclidean inner product is given by .
x | Vector . |
y | Vector . |
Set all coefficients in a vector to the same value.
v | Target vector. |
x | Fill value. |
uint getactives_avector | ( | ) |
Get number of currently initialized avector objects.
Calls to initialization functions like init_avector and constructors like new_avector increase an internal counter, while uninit_avector and del_avector decrease it.
Read a vector entry .
v | Vector . |
i | Index . |
size_t getsize_avector | ( | pcavector | v | ) |
Get size of a given avector object.
Computes the size of the avector object and the storage allocated for the coefficients. If the object uses the coefficients of another object (e.g., if it was created using new_sub_avector), no coefficient storage is added.
v | Vector object. |
size_t getsize_heap_avector | ( | pcavector | v | ) |
Get heap size of a given avector object.
Computes the size of storage allocated for the coefficients on the heap, but not for the avector object itself. If the object uses the coefficients of another object (e.g., if it was created using new_sub_avector), no storage is required.
v | Vector object. |
Initialize an avector object.
Sets up the components of the object and allocates storage for the coefficient array.
v | Object to be initialized. |
dim | Dimension of the new vector. |
Initialize an avector object to represent a column vector of a given matrix.
Sets up the components of the object and uses part of the storage of an amatrix corresponding to one of its columns. Changes to the coefficients of the new vector also change the column of the source matrix.
v | Object to be initialized. |
src | Source matrix. |
col | Column of the source matrix that will be used for the vector. |
Initialize an avector object using a given array for the coefficients.
Sets up the components of the object and uses the given array to represent the coefficients.
v | Object to be initialized. |
src | Source array, should contain at least dim elements. |
dim | Dimension of the new vector. |
Initialize an avector object to represent a subvector.
Sets up the components of the object and uses part of the storage of another avector for the coefficient array, leading to a new vector representing a subvector of the source. Changes to the coefficients of the new vector also change coefficients of the source vector.
v | Object to be initialized. |
src | Source vector. |
dim | Dimension of the new vector. |
off | Offset in the source vector, should satisfy dim+off<=src->dim . |
Create a new avector object.
Allocates storage for the object an sets up its components.
dim | Dimension of the new vector. |
Create a new avector object representing a subvector.
Allocates storage for the object, but uses part of the storage of another avector for the coefficient array, leading to a new vector representing a subvector of the source. Changes to the coefficients of the new vector also change coefficients of the source vector.
src | Source vector. |
dim | Dimension of the new vector. |
off | Offset in the source vector, should satisfy dim+off<=src->dim . |
Create a new avector object representing a zero vector.
Allocates storage for the object and sets all coefficients to zero.
dim | Dimension of the new vector. |
Compute the Euclidean norm of a vector .
v | Vector . |
void print_avector | ( | pcavector | v | ) |
Print a vector.
v | Vector . |
void random_avector | ( | pavector | v | ) |
Fill a vector with random values.
v | Target vector. |
void random_real_avector | ( | pavector | v | ) |
Fill a vector with real valued random values.
v | Target vector. |
Change the dimension of an avector object without preserving its coefficients.
Allocates new storage for the coefficients and releases the old storage.
v | Vector to be resized. |
dim | New vector dimension. |
Scale a vector by a factor , .
alpha | Scaling factor . |
v | Target vector . |
Set a vector entry, .
v | Vector . |
i | Index . |
x | New value of . |
Reduce the dimension of an avector object without reallocating storage, preserving its coefficients.
v | Vector to be resized. |
dim | New vector dimension, not greater than v->dim . |