H2Lib
3.0
|
Representation of a vector as an array for real coefficients. More...
Data Structures | |
struct | _realavector |
Typedefs | |
typedef struct _realavector | realavector |
typedef realavector * | prealavector |
typedef const realavector * | pcrealavector |
Functions | |
prealavector | init_realavector (prealavector v, uint dim) |
Initialize an realavector object. More... | |
prealavector | init_sub_realavector (prealavector v, prealavector src, uint dim, uint off) |
Initialize an realavector object to represent a subvector. More... | |
prealavector | init_pointer_realavector (prealavector v, preal src, uint dim) |
Initialize an realavector object using a given array for the coefficients. More... | |
void | uninit_realavector (prealavector v) |
Uninitialize an realavector object. More... | |
prealavector | new_realavector (uint dim) |
Create a new realavector object. More... | |
prealavector | new_sub_realavector (prealavector src, uint dim, uint off) |
Create a new realavector object representing a subvector. More... | |
prealavector | new_pointer_realavector (preal src, uint dim) |
Create a new realavector object using a given array for the coefficients. More... | |
void | del_realavector (prealavector v) |
Delete an realavector object. More... | |
void | resize_realavector (prealavector v, uint dim) |
Change the dimension of an realavector object without preserving its coefficients. More... | |
void | shrink_realavector (prealavector v, uint dim) |
Reduce the dimension of an realavector object without reallocating storage, preserving its coefficients. More... | |
real | getentry_realavector (pcrealavector v, uint i) |
Read a vector entry . More... | |
void | setentry_realavector (prealavector v, uint i, real x) |
Set a vector entry, . More... | |
real | addentry_realavector (prealavector v, uint i, real x) |
Add to a vector entry, . More... | |
uint | getactives_realavector () |
Get number of currently initialized realavector objects. More... | |
size_t | getsize_realavector (pcrealavector v) |
Get size of a given realavector object. More... | |
size_t | getsize_heap_realavector (pcrealavector v) |
Get heap size of a given realavector object. More... | |
void | clear_realavector (prealavector v) |
Set a vector to zero. More... | |
void | fill_realavector (prealavector v, real x) |
Set all coefficients in a vector to the same value. More... | |
void | random_realavector (prealavector v) |
Fill a vector with random values. More... | |
void | copy_realavector (pcrealavector v, prealavector w) |
Copy a vector into another vector, . More... | |
void | copy_sub_realavector (pcrealavector v, prealavector w) |
Copy a vector into another vector, . More... | |
void | print_realavector (pcrealavector v) |
Print a vector. More... | |
void | scale_realavector (real alpha, prealavector v) |
Scale a vector by a factor , . More... | |
real | norm2_realavector (pcrealavector v) |
Compute the Euclidean norm of a vector . More... | |
real | dotprod_realavector (pcrealavector x, pcrealavector y) |
Compute the Euclidean innner product of two vectors and . More... | |
void | add_realavector (real alpha, pcrealavector x, prealavector y) |
Add two vectors, . More... | |
Representation of a vector as an array for real coefficients.
The realavector class is used to handle standard linear algebra operations like adding, scaling and multiplying vectors for real valued vectors.
typedef const realavector* pcrealavector |
Pointer to a constant avector object.
typedef realavector* prealavector |
Pointer to a avector object.
typedef struct _realavector realavector |
Representation of a vector as an array.
void add_realavector | ( | real | alpha, |
pcrealavector | x, | ||
prealavector | y | ||
) |
Add two vectors, .
alpha | Scaling factor . |
x | Source vector . |
y | Target vector . |
real addentry_realavector | ( | prealavector | v, |
uint | i, | ||
real | x | ||
) |
Add to a vector entry, .
v | Vector . |
i | Index . |
x | Summand. |
void clear_realavector | ( | prealavector | v | ) |
Set a vector to zero.
v | Target vector. |
void copy_realavector | ( | pcrealavector | v, |
prealavector | w | ||
) |
Copy a vector into another vector, .
Both vectors have to be of the same dimension.
v | Source vector. |
w | Target vector. |
void copy_sub_realavector | ( | pcrealavector | v, |
prealavector | w | ||
) |
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_realavector | ( | prealavector | v | ) |
Delete an realavector object.
Releases the storage corresponding to the object.
v | Object to be deleted. |
real dotprod_realavector | ( | pcrealavector | x, |
pcrealavector | y | ||
) |
Compute the Euclidean innner product of two vectors and .
The Euclidean inner product is given by .
x | Vector . |
y | Vector . |
void fill_realavector | ( | prealavector | v, |
real | x | ||
) |
Set all coefficients in a vector to the same value.
v | Target vector. |
x | Fill value. |
uint getactives_realavector | ( | ) |
Get number of currently initialized realavector objects.
Calls to initialization functions like init_realavector and constructors like new_realavector increase an internal counter, while uninit_realavector and del_realavector decrease it.
real getentry_realavector | ( | pcrealavector | v, |
uint | i | ||
) |
Read a vector entry .
v | Vector . |
i | Index . |
size_t getsize_heap_realavector | ( | pcrealavector | v | ) |
Get heap size of a given realavector object.
Computes the size of storage allocated for the coefficients on the heap, but not for the realavector object itself. If the object uses the coefficients of another object (e.g., if it was created using new_sub_realavector), no storage is required.
v | Vector object. |
size_t getsize_realavector | ( | pcrealavector | v | ) |
Get size of a given realavector object.
Computes the size of the realavector 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_realavector), no coefficient storage is added.
v | Vector object. |
prealavector init_pointer_realavector | ( | prealavector | v, |
preal | src, | ||
uint | dim | ||
) |
Initialize an realavector 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. |
prealavector init_realavector | ( | prealavector | v, |
uint | dim | ||
) |
Initialize an realavector 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. |
prealavector init_sub_realavector | ( | prealavector | v, |
prealavector | src, | ||
uint | dim, | ||
uint | off | ||
) |
Initialize an realavector object to represent a subvector.
Sets up the components of the object and uses part of the storage of another realavector 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 . |
prealavector new_pointer_realavector | ( | preal | src, |
uint | dim | ||
) |
Create a new realavector object using a given array for the coefficients.
src | Source array, should contain at least dim elements. |
dim | Dimension of the new vector. |
prealavector new_realavector | ( | uint | dim | ) |
Create a new realavector object.
Allocates storage for the object an sets up its components.
dim | Dimension of the new vector. |
prealavector new_sub_realavector | ( | prealavector | src, |
uint | dim, | ||
uint | off | ||
) |
Create a new realavector object representing a subvector.
Allocates storage for the object, but uses part of the storage of another realavector 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 . |
real norm2_realavector | ( | pcrealavector | v | ) |
Compute the Euclidean norm of a vector .
v | Vector . |
void print_realavector | ( | pcrealavector | v | ) |
Print a vector.
v | Vector . |
void random_realavector | ( | prealavector | v | ) |
Fill a vector with random values.
v | Target vector. |
void resize_realavector | ( | prealavector | v, |
uint | dim | ||
) |
Change the dimension of an realavector 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. |
void scale_realavector | ( | real | alpha, |
prealavector | v | ||
) |
Scale a vector by a factor , .
alpha | Scaling factor . |
v | Target vector . |
void setentry_realavector | ( | prealavector | v, |
uint | i, | ||
real | x | ||
) |
Set a vector entry, .
v | Vector . |
i | Index . |
x | New value of . |
void shrink_realavector | ( | prealavector | v, |
uint | dim | ||
) |
Reduce the dimension of an realavector object without reallocating storage, preserving its coefficients.
v | Vector to be resized. |
dim | New vector dimension, not greater than v->dim . |
void uninit_realavector | ( | prealavector | v | ) |
Uninitialize an realavector object.
Invalidates pointers, freeing corresponding storage if appropriate, and prepares the object for deletion.
v | Object to be uninitialized. |