C3E: Complex Compute Core Engine v1.0
An engine for handling complex computational tasks
|
Vector operations and utilities for the C3E library. More...
Go to the source code of this file.
Functions | |
c3e_vector * | c3e_vector_init (size_t size) |
Initializes a vector with a specified size. | |
c3e_vector * | c3e_vector_create (size_t size, c3e_number *data) |
Creates a new c3e_vector instance with the specified size and data. | |
void | c3e_vector_free (c3e_vector *vector) |
Frees the memory allocated for a vector. | |
c3e_number | c3e_vector_length (c3e_matrix *matrix, int col) |
Computes the length of a column vector extracted from a matrix. | |
c3e_number | c3e_vector_get (c3e_vector *vector, size_t index) |
Retrieves an element from the vector at a specified index. | |
void | c3e_vector_set (c3e_vector *vector, size_t index, c3e_number value) |
Sets the value of an element in the vector at a specified index. | |
void | c3e_vector_set_elements (c3e_vector *vector, c3e_number *values) |
Sets multiple elements in the vector with specified values. | |
c3e_vector * | c3e_vector_add (c3e_vector *vector, c3e_vector *subject) |
Adds two vectors element-wise. | |
c3e_vector * | c3e_vector_sub (c3e_vector *vector, c3e_vector *subject) |
Subtracts one vector from another element-wise. | |
c3e_vector * | c3e_vector_mul (c3e_vector *vector, c3e_vector *subject) |
Multiplies two vectors element-wise. | |
c3e_vector * | c3e_vector_div (c3e_vector *vector, c3e_vector *subject) |
Divides one vector by another element-wise. | |
c3e_vector * | c3e_vector_exp (c3e_vector *vector) |
Computes the element-wise exponential of a vector. | |
c3e_vector * | c3e_vector_scale (c3e_vector *vector, int x) |
Scales the elements of a vector by a specified factor. | |
c3e_number | c3e_vector_sum (c3e_vector *vector) |
Computes the sum of all elements in a vector. | |
c3e_number | c3e_vector_norm (c3e_vector *vector) |
Computes the Euclidean norm (magnitude) of a vector. | |
c3e_number | c3e_vector_angle (c3e_vector *vector, c3e_vector *subject) |
Calculates the angle between two vectors. | |
c3e_number | c3e_vector_cross (c3e_vector *vector, c3e_vector *subject) |
Computes the cross product of two vectors. | |
c3e_number | c3e_vector_projection (c3e_vector *vector, c3e_vector *subject) |
Computes the projection of one vector onto another. | |
c3e_number | c3e_vector_dot (c3e_vector *vector, c3e_vector *subject) |
Computes the dot product of two vectors. | |
c3e_number | c3e_vector_dot_cols (c3e_matrix *matrix, int col1, c3e_matrix *subject, int col2) |
Computes the dot product of two columns in matrices. | |
c3e_vector * | c3e_vector_normalize (c3e_vector *vector) |
Normalizes a vector to unit length. | |
c3e_vector * | c3e_vector_transform (c3e_vector *vector, c3e_matrix *matrix) |
Transforms a vector by multiplying it with a matrix. | |
c3e_vector * | c3e_vector_copy (c3e_vector *vector) |
Creates a copy of a vector. | |
c3e_vector * | c3e_vector_zeros (size_t size) |
Creates a vector of zeros. | |
c3e_vector * | c3e_vector_ones (size_t size) |
Creates a vector of ones. | |
c3e_vector * | c3e_vector_fill (size_t size, c3e_number values) |
Creates a vector filled with a specific value. | |
c3e_vector * | c3e_vector_random (size_t size, int seed) |
Creates a vector with random values. | |
c3e_vector * | c3e_vector_random_bound (size_t size, int seed, c3e_number min, c3e_number max) |
Creates a vector with random values within a specified range. | |
bool | c3e_vector_equals (c3e_vector *vector, c3e_vector *subject) |
Compares two vectors for equality. | |
bool | c3e_vector_all_close (c3e_vector *vector, c3e_vector *subject) |
Checks if all elements of one vector are close to another vector's elements within a tolerance. | |
c3e_vector * | c3e_vector_arc_sin (c3e_vector *vector) |
Computes the arc sine of each element in the vector. | |
c3e_vector * | c3e_vector_arc_sinh (c3e_vector *vector) |
Computes the arc hyperbolic sine of each element in the vector. | |
c3e_vector * | c3e_vector_sin (c3e_vector *vector) |
Computes the sine of each element in the vector. | |
c3e_vector * | c3e_vector_sinh (c3e_vector *vector) |
Computes the hyperbolic sine of each element in the vector. | |
c3e_vector * | c3e_vector_arc_cos (c3e_vector *vector) |
Computes the arc cosine of each element in the vector. | |
c3e_vector * | c3e_vector_arc_cosh (c3e_vector *vector) |
Computes the arc hyperbolic cosine of each element in the vector. | |
c3e_vector * | c3e_vector_cos (c3e_vector *vector) |
Computes the cosine of each element in the vector. | |
c3e_vector * | c3e_vector_cosh (c3e_vector *vector) |
Computes the hyperbolic cosine of each element in the vector. | |
c3e_vector * | c3e_vector_arc_tan (c3e_vector *vector) |
Computes the arc tangent of each element in the vector. | |
c3e_vector * | c3e_vector_arc_tanh (c3e_vector *vector) |
Computes the arc hyperbolic tangent of each element in the vector. | |
c3e_vector * | c3e_vector_tan (c3e_vector *vector) |
Computes the tangent of each element in the vector. | |
c3e_vector * | c3e_vector_tanh (c3e_vector *vector) |
Computes the hyperbolic tangent of each element in the vector. | |
c3e_vector * | c3e_vector_abs (c3e_vector *vector) |
Computes the absolute value of each element in the vector. | |
c3e_vector * | c3e_vector_log (c3e_vector *vector) |
Computes the natural logarithm of each element in the vector. | |
c3e_vector * | c3e_vector_log10 (c3e_vector *vector) |
Computes the base-10 logarithm of each element in the vector. | |
c3e_vector * | c3e_vector_log2 (c3e_vector *vector) |
Computes the base-2 logarithm of each element in the vector. | |
c3e_vector * | c3e_vector_log1p (c3e_vector *vector) |
Computes the natural logarithm of (1 + each element in the vector). | |
c3e_vector * | c3e_vector_pow (c3e_vector *vector, c3e_number exp) |
Computes each element of the vector raised to the given power. | |
c3e_vector * | c3e_vector_rsqrt (c3e_vector *vector) |
Computes the reciprocal square root of each element in the vector. | |
c3e_vector * | c3e_vector_sqrt (c3e_vector *vector) |
Computes the square root of each element in the vector. | |
This file provides functions for creating and manipulating vectors. Operations include initialization, modification, arithmetic operations, and various vector-specific calculations.
c3e_vector * c3e_vector_abs | ( | c3e_vector * | vector | ) |
This function applies the absolute value function to each element of the input vector. The resulting vector contains the absolute values of the original elements.
vector | Pointer to the input vector on which the absolute value function will be applied. |
c3e_vector * c3e_vector_add | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
vector | A pointer to the first vector. |
subject | A pointer to the second vector. |
bool c3e_vector_all_close | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
Useful for comparing vectors in numerical computations where exact equality is not feasible.
vector | A pointer to the first vector. |
subject | A pointer to the second vector. |
c3e_number c3e_vector_angle | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
vector | A pointer to the first vector. |
subject | A pointer to the second vector. |
c3e_vector * c3e_vector_arc_cos | ( | c3e_vector * | vector | ) |
This function applies the arc cosine function (inverse of cosine) to each element of the input vector. The resulting vector contains the arc cosine values of the original elements.
vector | Pointer to the input vector on which the arc cosine function will be applied. |
c3e_vector * c3e_vector_arc_cosh | ( | c3e_vector * | vector | ) |
This function applies the arc hyperbolic cosine function (inverse of hyperbolic cosine) to each element of the input vector. The resulting vector contains the arc hyperbolic cosine values of the original elements.
vector | Pointer to the input vector on which the arc hyperbolic cosine function will be applied. |
c3e_vector * c3e_vector_arc_sin | ( | c3e_vector * | vector | ) |
This function applies the arc sine function (inverse of sine) to each element of the input vector. The resulting vector contains the arc sine values of the original elements.
vector | Pointer to the input vector on which the arc sine function will be applied. |
c3e_vector * c3e_vector_arc_sinh | ( | c3e_vector * | vector | ) |
This function applies the arc hyperbolic sine function (inverse of hyperbolic sine) to each element of the input vector. The resulting vector contains the arc hyperbolic sine values of the original elements.
vector | Pointer to the input vector on which the arc hyperbolic sine function will be applied. |
c3e_vector * c3e_vector_arc_tan | ( | c3e_vector * | vector | ) |
This function applies the arc tangent function (inverse of tangent) to each element of the input vector. The resulting vector contains the arc tangent values of the original elements.
vector | Pointer to the input vector on which the arc tangent function will be applied. |
c3e_vector * c3e_vector_arc_tanh | ( | c3e_vector * | vector | ) |
This function applies the arc hyperbolic tangent function (inverse of hyperbolic tangent) to each element of the input vector. The resulting vector contains the arc hyperbolic tangent values of the original elements.
vector | Pointer to the input vector on which the arc hyperbolic tangent function will be applied. |
c3e_vector * c3e_vector_copy | ( | c3e_vector * | vector | ) |
vector | A pointer to the vector to be copied. |
c3e_vector * c3e_vector_cos | ( | c3e_vector * | vector | ) |
This function applies the cosine function to each element of the input vector. The resulting vector contains the cosine values of the original elements.
vector | Pointer to the input vector on which the cosine function will be applied. |
c3e_vector * c3e_vector_cosh | ( | c3e_vector * | vector | ) |
This function applies the hyperbolic cosine function to each element of the input vector. The resulting vector contains the hyperbolic cosine values of the original elements.
vector | Pointer to the input vector on which the hyperbolic cosine function will be applied. |
c3e_vector * c3e_vector_create | ( | size_t | size, |
c3e_number * | data | ||
) |
This function allocates memory for a new c3e_vector
and initializes it with the provided size and data. The data
array should contain size
elements that are copied into the newly created vector's data array.
size | The number of elements in the vector. |
data | Pointer to an array of c3e_number containing the initial values for the vector. The data is copied into the new vector. |
c3e_vector
structure, or NULL
if memory allocation fails. c3e_number c3e_vector_cross | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
Only valid for 3-dimensional vectors.
vector | A pointer to the first vector. |
subject | A pointer to the second vector. |
c3e_vector * c3e_vector_div | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
vector | A pointer to the numerator vector. |
subject | A pointer to the denominator vector. |
c3e_number c3e_vector_dot | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
vector | A pointer to the first vector. |
subject | A pointer to the second vector. |
c3e_number c3e_vector_dot_cols | ( | c3e_matrix * | matrix, |
int | col1, | ||
c3e_matrix * | subject, | ||
int | col2 | ||
) |
matrix | A pointer to the first matrix. |
col1 | The index of the column in the first matrix. |
subject | A pointer to the second matrix. |
col2 | The index of the column in the second matrix. |
bool c3e_vector_equals | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
Determines if two vectors have identical elements.
vector | A pointer to the first vector. |
subject | A pointer to the second vector. |
c3e_vector * c3e_vector_exp | ( | c3e_vector * | vector | ) |
vector | A pointer to the vector. |
c3e_vector * c3e_vector_fill | ( | size_t | size, |
c3e_number | values | ||
) |
size | The number of elements in the vector. |
values | The value to fill each element of the vector. |
void c3e_vector_free | ( | c3e_vector * | vector | ) |
Releases the memory occupied by the vector and its elements.
vector | A pointer to the vector to be freed. |
c3e_number c3e_vector_get | ( | c3e_vector * | vector, |
size_t | index | ||
) |
vector | A pointer to the vector. |
index | The index of the element to retrieve. |
c3e_vector * c3e_vector_init | ( | size_t | size | ) |
Allocates memory for a vector with the given size and initializes its elements to zero.
size | The number of elements in the vector. |
c3e_number c3e_vector_length | ( | c3e_matrix * | matrix, |
int | col | ||
) |
Calculates the Euclidean norm (length) of a column vector from a matrix.
matrix | The matrix from which the column vector is extracted. |
col | The index of the column to be used as the vector. |
c3e_vector * c3e_vector_log | ( | c3e_vector * | vector | ) |
This function applies the natural logarithm function to each element of the input vector. The resulting vector contains the natural logarithm values of the original elements.
vector | Pointer to the input vector on which the natural logarithm function will be applied. |
c3e_vector * c3e_vector_log10 | ( | c3e_vector * | vector | ) |
This function applies the base-10 logarithm function to each element of the input vector. The resulting vector contains the base-10 logarithm values of the original elements.
vector | Pointer to the input vector on which the base-10 logarithm function will be applied. |
c3e_vector * c3e_vector_log1p | ( | c3e_vector * | vector | ) |
This function applies the natural logarithm function to (1 + each element) of the input vector. The resulting vector contains the natural logarithm values of the modified elements.
vector | Pointer to the input vector on which the natural logarithm of (1 + element) function will be applied. |
c3e_vector * c3e_vector_log2 | ( | c3e_vector * | vector | ) |
This function applies the base-2 logarithm function to each element of the input vector. The resulting vector contains the base-2 logarithm values of the original elements.
vector | Pointer to the input vector on which the base-2 logarithm function will be applied. |
c3e_vector * c3e_vector_mul | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
vector | A pointer to the first vector. |
subject | A pointer to the second vector. |
c3e_number c3e_vector_norm | ( | c3e_vector * | vector | ) |
vector | A pointer to the vector. |
c3e_vector * c3e_vector_normalize | ( | c3e_vector * | vector | ) |
vector | A pointer to the vector to be normalized. |
c3e_vector * c3e_vector_ones | ( | size_t | size | ) |
size | The number of elements in the vector. |
c3e_vector * c3e_vector_pow | ( | c3e_vector * | vector, |
c3e_number | exp | ||
) |
This function applies the power function to each element of the input vector, raising each element to the specified exponent.
vector | Pointer to the input vector on which the power function will be applied. |
exp | The exponent to which each element of the vector will be raised. |
c3e_number c3e_vector_projection | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
vector | A pointer to the vector to be projected. |
subject | A pointer to the vector onto which projection is done. |
c3e_vector * c3e_vector_random | ( | size_t | size, |
int | seed | ||
) |
size | The number of elements in the vector. |
seed | The seed value for the random number generator. |
c3e_vector * c3e_vector_random_bound | ( | size_t | size, |
int | seed, | ||
c3e_number | min, | ||
c3e_number | max | ||
) |
size | The number of elements in the vector. |
seed | The seed value for the random number generator. |
min | The minimum value in the range. |
max | The maximum value in the range. |
c3e_vector * c3e_vector_rsqrt | ( | c3e_vector * | vector | ) |
This function applies the reciprocal square root function (1 / sqrt(x)) to each element of the input vector. The resulting vector contains the reciprocal square root values of the original elements.
vector | Pointer to the input vector on which the reciprocal square root function will be applied. |
c3e_vector * c3e_vector_scale | ( | c3e_vector * | vector, |
int | x | ||
) |
vector | A pointer to the vector. |
x | The scaling factor. |
void c3e_vector_set | ( | c3e_vector * | vector, |
size_t | index, | ||
c3e_number | value | ||
) |
vector | A pointer to the vector. |
index | The index of the element to set. |
value | The value to be assigned to the element at the specified index. |
void c3e_vector_set_elements | ( | c3e_vector * | vector, |
c3e_number * | values | ||
) |
vector | A pointer to the vector. |
values | An array of values to set in the vector. |
c3e_vector * c3e_vector_sin | ( | c3e_vector * | vector | ) |
This function applies the sine function to each element of the input vector. The resulting vector contains the sine values of the original elements.
vector | Pointer to the input vector on which the sine function will be applied. |
c3e_vector * c3e_vector_sinh | ( | c3e_vector * | vector | ) |
This function applies the hyperbolic sine function to each element of the input vector. The resulting vector contains the hyperbolic sine values of the original elements.
vector | Pointer to the input vector on which the hyperbolic sine function will be applied. |
c3e_vector * c3e_vector_sqrt | ( | c3e_vector * | vector | ) |
This function applies the square root function to each element of the input vector. The resulting vector contains the square root values of the original elements.
vector | Pointer to the input vector on which the square root function will be applied. |
c3e_vector * c3e_vector_sub | ( | c3e_vector * | vector, |
c3e_vector * | subject | ||
) |
vector | A pointer to the first vector. |
subject | A pointer to the second vector to be subtracted. |
c3e_number c3e_vector_sum | ( | c3e_vector * | vector | ) |
vector | A pointer to the vector. |
c3e_vector * c3e_vector_tan | ( | c3e_vector * | vector | ) |
This function applies the tangent function to each element of the input vector. The resulting vector contains the tangent values of the original elements.
vector | Pointer to the input vector on which the tangent function will be applied. |
c3e_vector * c3e_vector_tanh | ( | c3e_vector * | vector | ) |
This function applies the hyperbolic tangent function to each element of the input vector. The resulting vector contains the hyperbolic tangent values of the original elements.
vector | Pointer to the input vector on which the hyperbolic tangent function will be applied. |
c3e_vector * c3e_vector_transform | ( | c3e_vector * | vector, |
c3e_matrix * | matrix | ||
) |
vector | A pointer to the vector. |
matrix | A pointer to the matrix used for transformation. |
c3e_vector * c3e_vector_zeros | ( | size_t | size | ) |
size | The number of elements in the vector. |