private static void Test() { RealMatrix m = new RealMatrix(4, 4) { Indices = new Real[, ] { { 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 2 }, { 1, 1, 1, 1, 2, 3 }, { 1, 1, 1, 2, 3, 4 }, { 1, 1, 2, 3, 4, 5 }, { 1, 2, 3, 4, 5, 6 } } }; // m[0, VectorType.Row] = m[1, VectorType.Row]; Console.WriteLine(m.ToDeterminant(3, true)); }
private static void LinAlg() { int[,] ints = new int[2, 5]; for (int i = 0; i < 2; i++) { for (int j = 0; j < 5; j++) { ints[i, j] = 2; } } // A matrix with only 2's in it RealMatrix m = new RealMatrix(ints); RealMatrix n = new RealMatrix(5, 3) { Indices = new Real[, ] { { 2, 3, 7 }, { 0, 0, 0 }, { 2, 4, 6 }, { -1, 4, 5 }, { 0, 8, 3 } } }; RealMatrix p = m * n; Console.WriteLine(p[VectorType.Column]); RealMatrix e = n.ToReducedEchelonForm().ToRealMatrix(); RealMatrix u = n * n.Transpose().ToRealMatrix(); Console.WriteLine(e.IsReducedEchelon()); Console.WriteLine(); Console.WriteLine(u.ToDeterminant(3, true)); Console.WriteLine(); Console.WriteLine(u.Transpose().ToTable(3)); Console.WriteLine(u.IsSymmetric()); Console.WriteLine(); Console.WriteLine("The matrix e, in all its glory: \n" + e.ToTable(3)); Console.WriteLine(n); }
private static void BasicTest() { RealMatrix m1 = new RealMatrix(5, 3) { Indices = new Real[, ] { { 2, 3, 7 }, { 0, 0, 0 }, { 2, 4, 6 }, { -1, 4, 5 }, { 0, 8, 3 } } }; RealMatrix m2 = new RealMatrix(4, 4) { Indices = new Real[, ] { { 1, 1, 1, 1 }, { 1, 1, 1, 2 }, { 1, 1, 2, 3 }, { 1, 2, 3, 4 } } }; Console.WriteLine(m1.ToTable(3)); Console.WriteLine(); Console.WriteLine(m1.Transpose().ToTable(3)); Console.WriteLine(); Console.WriteLine((m1 * m1.Transpose()).ToDeterminant(3, true)); Console.WriteLine(); Console.WriteLine(m2.ToDeterminant(3, true)); }