Class Vector
Represents a vector.
#include <Vector.hpp>
Public Attributes
| Type | Name |
|---|---|
| Comm & | comm |
Public Functions
| Type | Name |
|---|---|
| Vector (Comm & comm, unsigned int blocks, unsigned int block_size, std::string row_or_col, bool global_sizes=false, bool SOTI_ordering=true) Constructor for the Vector class. |
|
| Vector (Vector & vec, bool deep_copy) Copy constructor for the Vector class. |
|
| Vector (Vector & vec) Copy constructor for the Vector class. |
|
| Vector (Vector && vec) noexcept Move constructor for the Vector class. |
|
| Vector | add_scalar (double scalar) Adds a scalar to each element of this vector. |
| void | add_scalar_inplace (double scalar) Performs an in-place scalar addition (x_i = x_i + scalar). |
| void | axpby (double alpha, double beta, Vector & x) Computes the operation y = alpha * x + beta * y. |
| void | axpy (double alpha, Vector & x) Computes the operation y = alpha * x + y. |
| void | copy_to (Vector & x) Copies a vector to another vector. |
| double | dot (Vector & x) Computes the dot product of the vector with another vector. |
| Vector | elementwise_abs () Computes the element-wise absolute value of this vector. |
| void | elementwise_abs_inplace () Performs an in-place element-wise absolute value operation. |
| Vector | elementwise_divide (Vector & other) Computes the element-wise division of this vector by another. |
| void | elementwise_divide_inplace (Vector & other) Performs an in-place element-wise division by another vector. |
| Vector | elementwise_inverse () Computes the element-wise inverse (1.0 / x_i) of this vector. |
| void | elementwise_inverse_inplace () Performs an in-place element-wise inversion (x_i = 1.0 / x_i). |
| Vector | elementwise_max (Vector & other) Computes the element-wise maximum of this vector and another. |
| void | elementwise_max_inplace (Vector & other) Performs an in-place element-wise maximum with another vector. |
| Vector | elementwise_min (Vector & other) Computes the element-wise minimum of this vector and another. |
| void | elementwise_min_inplace (Vector & other) Performs an in-place element-wise minimum with another vector. |
| Vector | elementwise_multiply (Vector & other) Computes the element-wise product of this vector and another. |
| Vector | elementwise_multiply_add (Vector & y, Vector & z) Computes the fused element-wise multiply-add: this_i * y_i + z_i. |
| void | elementwise_multiply_add_inplace (Vector & y, Vector & z) Performs an in-place fused element-wise multiply-add: this_i = this_i * y_i + z_i. |
| void | elementwise_multiply_inplace (Vector & other) Performs an in-place element-wise multiplication with another vector. |
| Vector | elementwise_sign () Computes the element-wise sign of this vector. |
| void | elementwise_sign_inplace () Performs an in-place element-wise sign operation. |
| Vector | extend (int new_block_size) Extends the vector to a new block size. |
| void | extend (Vector & out) Extends the vector to a new block size. |
| unsigned int | get_block_size () Gets the size of each block without padding. |
| int | get_checksum () |
| double * | get_d_vec () Gets the pointer to the vector data. |
| unsigned int | get_glob_num_blocks () Gets the global number of blocks. |
| unsigned int | get_num_blocks () Gets the number of blocks. |
| unsigned int | get_padded_size () Gets the size of each block with padding. |
| std::string | get_row_or_col () Gets the row or column descriptor. |
| double | global_max () Computes the global maximum element across the distributed vector. |
| double | global_min () Computes the global minimum element across the distributed vector. |
| void | init_vec () Initializes the vector. |
| void | init_vec_consecutive () Initializes the vector with consecutive integers. |
| void | init_vec_doubles () Initializes the vector with double precision floating point numbers (used for precision testing). |
| void | init_vec_from_file (std::string filename, int checksum=0, bool QoI=false) Initializes the vector from a file. |
| void | init_vec_ones () Initializes the vector with all ones. |
| void | init_vec_zeros () Initializes the vector with all zeros. |
| bool | is_SOTI_ordered () Checks if the vector is using SOTI ordering. |
| bool | is_initialized () Checks if the vector data is initialized. |
| Vector | max_scalar (double scalar) Computes the element-wise maximum of this vector and a scalar. |
| void | max_scalar_inplace (double scalar) Performs an in-place element-wise maximum with a scalar. |
| Vector | min_scalar (double scalar) Computes the element-wise minimum of this vector and a scalar. |
| void | min_scalar_inplace (double scalar) Performs an in-place element-wise minimum with a scalar. |
| double | norm (int order=2, std::string name="") Computes the norm of the vector. |
| bool | on_grid () Checks if the calling process has the vector data. |
| Vector | operator* (double alpha) Scalar multiplication operator for the Vector class. |
| Vector | operator* (Vector & other) Element-wise multiplication operator for the Vector class. |
| Vector | operator* (Vector && other) R-value overload to allow chaining (e.g., y * (1.0 / x)) |
| Vector & | operator*= (double alpha) Scalar Multiplicative assignment operator for the Vector class. |
| Vector & | operator*= (Vector & other) Element-wise multiplicative assignment operator for the Vector class. |
| Vector | operator+ (Vector & x) Addition operator for the Vector class. |
| Vector | operator+ (double scalar) Scalar addition operator ( Vector + scalar). |
| Vector & | operator+= (Vector & x) Additive assignment operator for the Vector class. |
| Vector & | operator+= (double scalar) In-place scalar addition operator ( Vector += scalar). |
| Vector | operator- (Vector & x) Subtraction operator for the Vector class. |
| Vector | operator- (double scalar) Scalar subtraction operator ( Vector - scalar). |
| Vector & | operator-= (Vector & x) Subtractive assignment operator for the Vector class. |
| Vector & | operator-= (double scalar) In-place scalar subtraction operator ( Vector -= scalar). |
| Vector | operator/ (double alpha) Scalar division operator for the Vector class. |
| Vector | operator/ (Vector & other) Element-wise division operator for the Vector class. |
| Vector | operator/ (Vector && other) R-value overload to allow chaining (e.g., y / (1.0 / x)) |
| Vector & | operator/= (double alpha) Scalar Division assignment operator for the Vector class. |
| Vector & | operator/= (Vector & other) Element-wise division assignment operator for the Vector class. |
| Vector & | operator= (Vector & vec) Copy assignment operator for the Vector class. |
| Vector & | operator= (Vector && vec) Move assignment operator for the Vector class. |
| Vector | pow (double exponent) Computes the element-wise power (x_i ^ p) of this vector. |
| void | pow_inplace (double exponent) Performs an in-place element-wise power operation (x_i = x_i ^ p). |
| void | print (std::string name="") Prints the vector. |
| Vector | resize (int new_block_size) Resizes the vector to a new block size. |
| void | resize (Vector & out) Resizes the vector to a new block size. |
| void | save (std::string filename, bool QoI=false) Saves the vector to a file (HDF5 format). |
| void | scale (double alpha) Scales the vector by a constant (in-place). |
| void | set_checksum (int checksum) |
| void | set_d_vec (double * vec) Sets the pointer to the vector data. |
| Vector | shrink (int new_block_size) Shrinks the vector to a new block size. |
| void | shrink (Vector & out) Shrinks the vector to a new block size. |
| Vector | waxpby (double alpha, double beta, Vector & x) Computes the operation w = alpha * x + beta * y. |
| Vector | waxpy (double alpha, Vector & x) Computes the operation w = alpha * x + y. |
| Vector | wscale (double alpha) Scales the vector by a constant (out-of-place). |
| ~Vector () Destructor for the Vector class. Frees the memory allocated for the vector data. |
Public Attributes Documentation
variable comm
Reference to the communication object.
Public Functions Documentation
function Vector [1/4]
Constructor for the Vector class.
Vector::Vector (
Comm & comm,
unsigned int blocks,
unsigned int block_size,
std::string row_or_col,
bool global_sizes=false,
bool SOTI_ordering=true
)
Parameters:
commThe Comm object (passed as reference).blocksThe number of blocks (local or global based on value of global_sizes).block_sizeThe size of each block without padding.row_or_colIndicates whether the vector is row or column.global_sizesFlag indicating whether the sizes are global.SOTI_orderingFlag indicating whether to use SOTI ordering.
function Vector [2/4]
Copy constructor for the Vector class.
Parameters:
vecThe Vector object to be copied.deep_copyFlag indicating whether to perform a deep copy.
function Vector [3/4]
Copy constructor for the Vector class.
Parameters:
vecThe Vector object to be copied.
function Vector [4/4]
Move constructor for the Vector class.
Parameters:
vecThe Vector object to be moved.
function add_scalar
Adds a scalar to each element of this vector.
Parameters:
scalarThe scalar value to add.
Returns:
A new vector containing the shifted elements.
function add_scalar_inplace
Performs an in-place scalar addition (x_i = x_i + scalar).
Parameters:
scalarThe scalar value to add.
function axpby
Computes the operation y = alpha * x + beta * y.
Parameters:
alphaThe constant by which to scale the vector x.betaThe constant by which to scale the vector y.xThe vector to be added.
function axpy
Computes the operation y = alpha * x + y.
Parameters:
alphaThe constant by which to scale the vector x.xThe vector to be added.
function copy_to
Copies a vector to another vector.
Parameters:
xThe vector to be copied to.
function dot
Computes the dot product of the vector with another vector.
Parameters:
xThe vector with which to compute the dot product.
Returns:
The dot product of the two vectors. All ranks have the global dot product.
function elementwise_abs
Computes the element-wise absolute value of this vector.
Returns:
A new vector containing |x_i|.
function elementwise_abs_inplace
Performs an in-place element-wise absolute value operation.
function elementwise_divide
Computes the element-wise division of this vector by another.
Parameters:
otherThe vector to divide by.
Returns:
A new vector containing the element-wise quotient.
function elementwise_divide_inplace
Performs an in-place element-wise division by another vector.
Parameters:
otherThe vector to divide by.
function elementwise_inverse
Computes the element-wise inverse (1.0 / x_i) of this vector.
Returns:
A new vector containing the inverted elements.
function elementwise_inverse_inplace
Performs an in-place element-wise inversion (x_i = 1.0 / x_i).
function elementwise_max
Computes the element-wise maximum of this vector and another.
Parameters:
otherThe vector to compare against.
Returns:
A new vector containing max(x_i, y_i).
function elementwise_max_inplace
Performs an in-place element-wise maximum with another vector.
Parameters:
otherThe vector to compare against.
function elementwise_min
Computes the element-wise minimum of this vector and another.
Parameters:
otherThe vector to compare against.
Returns:
A new vector containing min(x_i, y_i).
function elementwise_min_inplace
Performs an in-place element-wise minimum with another vector.
Parameters:
otherThe vector to compare against.
function elementwise_multiply
Computes the element-wise product of this vector and another.
Parameters:
otherThe vector to multiply with.
Returns:
A new vector containing the element-wise product.
function elementwise_multiply_add
Computes the fused element-wise multiply-add: this_i * y_i + z_i.
Parameters:
yThe vector to multiply with.zThe vector to add.
Returns:
A new vector containing the result.
function elementwise_multiply_add_inplace
Performs an in-place fused element-wise multiply-add: this_i = this_i * y_i + z_i.
Parameters:
yThe vector to multiply with.zThe vector to add.
function elementwise_multiply_inplace
Performs an in-place element-wise multiplication with another vector.
Parameters:
otherThe vector to multiply with.
function elementwise_sign
Computes the element-wise sign of this vector.
Returns:
A new vector containing sign(d_in[i]) in {-1, 0, 1}.
function elementwise_sign_inplace
Performs an in-place element-wise sign operation.
function extend [1/2]
Extends the vector to a new block size.
Parameters:
new_block_sizeThe new block size.
Returns:
The extended vector.
function extend [2/2]
Extends the vector to a new block size.
Parameters:
outThe vector to be extended.
function get_block_size
Gets the size of each block without padding.
Returns:
The size of each block without padding.
function get_checksum
Returns the checksum for the vector.
function get_d_vec
Gets the pointer to the vector data.
Returns:
The pointer to the vector data.
function get_glob_num_blocks
Gets the global number of blocks.
Returns:
The global number of blocks.
function get_num_blocks
Gets the number of blocks.
Returns:
The number of blocks.
function get_padded_size
Gets the size of each block with padding.
Returns:
The size of each block with padding.
function get_row_or_col
Gets the row or column descriptor.
Returns:
The row or column descriptor.
function global_max
Computes the global maximum element across the distributed vector.
Returns:
The maximum value over all local and remote elements.
function global_min
Computes the global minimum element across the distributed vector.
Returns:
The minimum value over all local and remote elements.
function init_vec
Initializes the vector.
function init_vec_consecutive
Initializes the vector with consecutive integers.
function init_vec_doubles
Initializes the vector with double precision floating point numbers (used for precision testing).
function init_vec_from_file
Initializes the vector from a file.
Parameters:
filenameThe name of the file.checksumChecksum for the vector (if applicable).QoIFlag indicating whether the vector is a quantity of interest or regular observation (if applicable).
function init_vec_ones
Initializes the vector with all ones.
function init_vec_zeros
Initializes the vector with all zeros.
function is_SOTI_ordered
Checks if the vector is using SOTI ordering.
Returns:
True if the vector is using SOTI ordering, false otherwise.
function is_initialized
Checks if the vector data is initialized.
Returns:
True if the vector data is initialized, false otherwise.
function max_scalar
Computes the element-wise maximum of this vector and a scalar.
Parameters:
scalarThe scalar value broadcast to each element.
Returns:
A new vector containing max(x_i, scalar).
function max_scalar_inplace
Performs an in-place element-wise maximum with a scalar.
Parameters:
scalarThe scalar value broadcast to each element.
function min_scalar
Computes the element-wise minimum of this vector and a scalar.
Parameters:
scalarThe scalar value broadcast to each element.
Returns:
A new vector containing min(x_i, scalar).
function min_scalar_inplace
Performs an in-place element-wise minimum with a scalar.
Parameters:
scalarThe scalar value broadcast to each element.
function norm
Computes the norm of the vector.
Parameters:
orderThe order of the norm (e.g., "2" for the 2-norm, "1" for the 1-norm, "-1" for the infinity norm).nameThe name of the vector. Prints the norm if name is not empty.
Returns:
The norm of the vector. All ranks have the global norm.
function on_grid
Checks if the calling process has the vector data.
Returns:
True if the calling process has the vector data, false otherwise.
function operator*
Scalar multiplication operator for the Vector class.
Parameters:
alphaThe constant by which to scale the vector.
Returns:
The scaled vector.
function operator*
Element-wise multiplication operator for the Vector class.
Parameters:
otherThe Vector object to multiply with.
Returns:
A new vector containing the element-wise product.
function operator*
R-value overload to allow chaining (e.g., y * (1.0 / x))
function operator*=
Scalar Multiplicative assignment operator for the Vector class.
Parameters:
alphaThe constant by which to scale the vector.
Returns:
The scaled vector.
function operator*=
Element-wise multiplicative assignment operator for the Vector class.
Parameters:
otherThe Vector object to multiply with.
Returns:
The modified vector.
function operator+
Addition operator for the Vector class.
Parameters:
xThe Vector object to be added.
Returns:
The sum of the two vectors.
function operator+
Scalar addition operator ( Vector + scalar).
function operator+=
Additive assignment operator for the Vector class.
Parameters:
xThe Vector object to be added.
Returns:
The sum of the two vectors.
function operator+=
In-place scalar addition operator ( Vector += scalar).
function operator-
Subtraction operator for the Vector class.
Parameters:
xThe Vector object to be subtracted.
Returns:
The difference of the two vectors.
function operator-
Scalar subtraction operator ( Vector - scalar).
function operator-=
Subtractive assignment operator for the Vector class.
Parameters:
xThe Vector object to be subtracted.
Returns:
The difference of the two vectors.
function operator-=
In-place scalar subtraction operator ( Vector -= scalar).
function operator/
Scalar division operator for the Vector class.
Parameters:
alphaThe constant by which to divide the vector.
Returns:
The scaled vector.
function operator/
Element-wise division operator for the Vector class.
Parameters:
otherThe Vector object to divide by.
Returns:
A new vector containing the element-wise quotient.
function operator/
R-value overload to allow chaining (e.g., y / (1.0 / x))
function operator/=
Scalar Division assignment operator for the Vector class.
Parameters:
alphaThe constant by which to divide the vector.
Returns:
The scaled vector.
function operator/=
Element-wise division assignment operator for the Vector class.
Parameters:
otherThe Vector object to divide by.
Returns:
The modified vector.
function operator=
Copy assignment operator for the Vector class.
Parameters:
vecThe Vector object to be copied.
Returns:
The copied Vector object.
function operator=
Move assignment operator for the Vector class.
Parameters:
vecThe Vector object to be moved.
Returns:
The moved Vector object.
function pow
Computes the element-wise power (x_i ^ p) of this vector.
Parameters:
exponentThe power to raise the elements to.
Returns:
A new vector containing the powered elements.
function pow_inplace
Performs an in-place element-wise power operation (x_i = x_i ^ p).
Parameters:
exponentThe power to raise the elements to.
function print
Prints the vector.
Parameters:
nameThe name of the vector.
function resize [1/2]
Resizes the vector to a new block size.
Parameters:
new_block_sizeThe new block size.
Returns:
The resized vector.
function resize [2/2]
Resizes the vector to a new block size.
Parameters:
outThe vector to be resized.
function save
Saves the vector to a file (HDF5 format).
Parameters:
filenameThe name of the file.QoIFlag indicating whether the vector is a quantity of interest vector.
function scale
Scales the vector by a constant (in-place).
Parameters:
alphaThe constant by which to scale the vector.
function set_checksum
Sets the checksum for the vector.
function set_d_vec
Sets the pointer to the vector data.
Parameters:
vecThe pointer to the vector data. Must be allocated on the GPU.
function shrink [1/2]
Shrinks the vector to a new block size.
Parameters:
new_block_sizeThe new block size.
Returns:
The shrunken vector.
function shrink [2/2]
Shrinks the vector to a new block size.
Parameters:
outThe vector to be shrunken.
function waxpby
Computes the operation w = alpha * x + beta * y.
Parameters:
alphaThe constant by which to scale the vector x.betaThe constant by which to scale the vector y.xThe vector to be added.
function waxpy
Computes the operation w = alpha * x + y.
Parameters:
alphaThe constant by which to scale the vector x.xThe vector to be added.
function wscale
Scales the vector by a constant (out-of-place).
Parameters:
alphaThe constant by which to scale the vector.
Returns:
The scaled vector.
function ~Vector
Destructor for the Vector class. Frees the memory allocated for the vector data.
Friends Documentation
friend operator*
friend operator+
Scalar addition operator (scalar + Vector ).
friend operator+
friend operator-
Scalar subtraction operator (scalar - Vector ). Calculates: scalar - x_i.
friend operator-
friend operator/
R-value overload to allow chaining (e.g., 1.0 / (x * y))
friend operator/
Allows the syntax: Vector y = 1.0 / x;.
Parameters:
numeratorThe scalar numerator (typically 1.0).vThe Vector object to invert.
Returns:
A new vector containing (numerator / v_i).
The documentation for this class was generated from the following file src/Vector.hpp