3.Linear Systems and Matrix operations

3.1 Solving Linear Systems

As the linear regresion method requires solving a linear system I implemented two familiar methods in the libregresion library: Gauss-Seidel and Gauss-Jordan, however the second is being reviewed at this moment. This methods are available for solving systems. (*)

Follow these steps to successfully solve a linear system:

For those who might want to use the library in their own programs here there is the systems API:
MethodDescription
public static double[] GaussSeidel (double[,] matrix, double[] solVctr, long iter) The Gauss-Seidel (iterative) method for solving linear systems.
public static double[] GaussJordan (double[,] matrix, double[] solVctr) The Gauss-Jordan method for solving linear systems.

3.2 Matrix operations

Most of the common matrix operations are implemented in the library and those not supported yet are likely to be implemented as needed or required by the users. (*)

MethodDescription
public static double[,] Multiply (double[,] a, double[,] b, uint n) Returns the result of multiplying matrix a per matrix b.
public static double[] Multiply (double[,] m, double[] v) Returns the result of multiplying matrix m per vector v.
public static double[,] Multiply (double[,] x, double c, uint order) Returns the result of multiplying matrix x per double c.
public static double[,] Multiply (double c, double[,] x, uint order) Returns the result of multiplying matrix x per double c.
public static double[,] Multiply (double[] v, double[,] m) Returns the result of multiplying the vector v per the matrix m.
public static double[,] Traspose (double[,] m, uint n) Returns the transpose of the matrix m.
public static double[,] AdjointMatrix (double[,] x, int n, int m, uint order) Returns the adjoint submatrix of order 'order' of the element n, m of the matrix x.
public static double Adjoint (double[,] x, int n, int m, uint order) Returns the determinant of the adjoint submatrix of the element n, m of the matrix x.
public static double[,] Adjoint (double[,] x, uint order) Returns the adjoint matrix of a complete matrix.
public static double[,] Inverse (double[,] x, uint order) Returns the inverse of the matrix x.
public static double Determinant (double[,] x, uint order) Returns the determinant of the matrix x.
public static double Trace (double[,] x, uint order) Returns the trace of the matrix x.
public static double[,] Copy (double[,] x, uint order) Returns a copy of the matrix x.
public static void Show (double[,] matrix, int n, int m) Prints the elements of the matrix x to the Console in an appropiate format.
public static double[] Pivoting (ref double[,] m, uint order) Submethod used for pivoting in Gauss-Jordan.
public static bool HasInverse (double[,] matrix, uint n) Returns true if the matrix 'matrix' has inverse, false in any other case.
public static bool HasInverse (double[,] matrix, uint n, double epsil) Returns true if the matrix 'matrix' has inverse or false if not for an appropiate minimum value 'epsil'.
public static double[,] Unitary (uint n) Returns a unitary matrix or order n.

(*) Note about complex numbers.

The libregresion library has been developed for workshop (experimental) purposes in mind and not for a theoretical point of view. The result is that I consider a matrix as a two dimensional array of doubles: double[,]. Operations are based on that kind of structures and complex numbers are not supported. Neither their is an alternative 'Matrix' class. It's very easy to develop those classes (Complex and Matrix) though.

In my personal opinion, based on my own experience, as C# has not complex builting types, nor we can do any kind of hard optimizations using preprocessor macros, etc, complex matrix operations are extremely slow (as far with the implementations I wrote and tried). You might want to ask for better advice on this in the Mono Project mailing list.

I am myself working on a similar project to libregresion/monumeric that aims to develop a little application for Quantum Mechanics learning. And I just can say that I am using the GNU Scientific Library for that as I think it's the only run time acceptable choice.