This project has moved and is read-only. For the latest updates, please go here.

Inverse and Transpose

Mar 24, 2011 at 8:26 PM

I already add the dll and did the example:

            var A = new DenseMatrix(2, 2, 1.0);
            var x = new DenseMatrix(2, 1, 2.0);
            var y = A * x;

so i have it working.

How can i get the inverse and the transpose of a matrix!?

Thanks :)

Mar 24, 2011 at 9:01 PM

Without compiling or testing:


var B = A.Transpose();

Inverse (A is square):

var C = A.LU().Solve(DenseMatrix.Identity(A.ColumnCount));

Pseudo Inverse (A rows > columns):

var D = A.QR().Solve(DenseMatrix.Identity(A.RowCount));

Pseudo Inverse (A columns > rows) (we currently don't support LQ):

var E = A.Transponse().QR().Solve(DenseMatrix.Identity(A.ColumnCount)).Transpose();


(looks like we may want to implement a simple Inverse() or PseudoInverse() method that covers all these cases)

Mar 25, 2011 at 5:56 AM
Edited Mar 25, 2011 at 5:58 AM

>C = A.LU().Solve(DenseMatrix.Identity(A.ColumnCount));

You could also do:
var c = A.Inverse();

which basically does what Chris wrote above.

>Pseudo Inverse (A columns > rows) (we currently don't support LQ)

Our current QR implementation does not support solving when columns > rows.

Mar 28, 2011 at 6:18 PM


Is there a clean way  to print or show the matrix in the command line!?