[−][src]Module optimization_engine::matrix_operations
matrix_operations
Simple algebraic operations used by Optimization Engine
Examples
use optimization_engine::matrix_operations::*; fn main() { let a = [1.0, 2.0, 3.0]; let b = [4.0, 5.0, 6.0]; // inner product let a_dot_b = inner_product(&a, &b); assert!(a_dot_b == 32.); // Euclidean norm and squared norm let norm_a = norm2(&a); let norm_sq_a = norm2_squared(&a); assert!(norm_sq_a == 14.); // Squared Euclidean norm of difference of vectors let norm_sq_a_minus_b = norm2_squared_diff(&a, &b); assert!(norm_sq_a_minus_b == 27.); // Sum of elements of vector let sum_a = sum(&a); assert!(sum_a == 6.); // Check whether all elements of a vector are finite assert!(is_finite(&a)); // Infinity norm let norm_inf_b = norm_inf(&b); assert!(norm_inf_b == 6.); }
Functions
inner_product | Calculate the inner product of two vectors |
is_finite | Checks whether all elements of a vector are finite |
norm1 | Calculate the 1-norm of a vector |
norm2 | Calculate the 2-norm of a vector |
norm2_squared_diff | Calculate the squared 2-norm of the difference of two vectors |
norm2_squared | Calculate the 2-norm of a vector |
norm_inf | Calculates the infinity-norm of a vector |
norm_inf_diff | Computes the infinity norm of the difference of two vectors |
sum | Calculate the sum of all elements of a vector |