public Matrix GetInverse() { // using Adjoint method // https://www.mathwords.com/i/inverse_of_a_matrix.htm return(Matrices.Divide( GetAdjugate(), GetDeterminant())); }
public Matrix GetHouseholder() { // https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections // creating a new alias to match commonly used algorithm variables Matrix A = this; // don't alter a1 or it will alter A ColumnVector a1 = A.GetColumnVector( 0, 0, A.Height); decimal norm = a1.GetNorm(); // create copy of vector that can be edited Matrix u = a1.AsMatrix(); // subtract norm * e vector // the sign is selected so it has the opposite sign of u1 decimal u1 = u[0, 0]; //u[0, 0] -= Math.Sign(u1) * norm; u[0, 0] -= norm; u.DivideBy(2); Matrix uT = u.GetTranspose(); Matrix uuT = Matrices.Multiply( u, uT); Matrix I = Matrices.GetIdentity( uuT.Width); uuT.MultiplyBy( 2 / norm); Matrix H = Matrices.Subtract( I, uuT); return(H); }