// We create a row vector Vector v(1000, BaseArray::RowVector); // Initialize values with a random sequence v = RandomSequence(); // Compute the vector length (norm) double norm = (v*v.Transpose()).toScalar(); cout << "Norm(v) = " << norm << endl;
This module contains basic array and matrix operations such as the Gauss matrix inversion algorithm which can be used to solve linear systems, as illustrated by the example below:
#include "sopemtx.h" // ... // Creation of a random 5x5 matrix Matrix A(5,5); A = RandomSequence(RandomSequence::Flat); Vector X0(5); X0 = RandomSequence(RandomSequence::Gaussian); // Computing B = A*X0 Vector B = A*X0; // Solving the system A*X = B Vector X; LinSolve(A, B, X); // Checking the result Vector diff = X-X0; cout << "X-X0= " << diff ; double min,max; diff.MinMax(min, max); cout << " Min(X-X0) = " << min << " Max(X-X0) = " << max << endl;