public void LupDecompositionTest() { var a = new NRealMatrix(3, 3); a[0, 0] = 1; a[0, 1] = 2; a[0, 2] = 3; a[1, 0] = 4; a[1, 1] = 5; a[1, 2] = 6; a[2, 0] = 7; a[2, 1] = 8; a[2, 2] = 9; var p = new NRealMatrix(3, 3); p[0, 0] = 1; p[0, 1] = 0; p[0, 2] = 0; p[1, 0] = 0; p[1, 1] = 0; p[1, 2] = 1; p[2, 0] = 0; p[2, 1] = 1; p[2, 2] = 0; Console.WriteLine(p * a); var l = new NRealMatrix(3, 3); var u = new NRealMatrix(3, 3); Console.WriteLine(a); Console.WriteLine(p); var mlib = new NLapackLib(); mlib.LupDecompostion(a, p, l, u); //var lib = new MLapackLib(); //lib.LUPDecomposition(a.ManagedMatrix, p.ManagedMatrix, l.ManagedMatrix, u.ManagedMatrix); Console.WriteLine(l); Console.WriteLine(u); var result = l * u; Console.WriteLine(result); Console.WriteLine(p * a); }
public void RandomMatrixTest() { var seed = new MCJIMatrix(2, 2); seed.setAt(0, 0, 1); seed.setAt(0, 1, 3); seed.setAt(1, 0, 5); seed.setAt(1, 1, 7); var nlib = new NLapackLib(); for (int i = 0; i < 10; i++) { var result = nlib.RandomMatrix(RandomDistributionType.Uniform_0_1, seed, 2, 2); Console.WriteLine(result); } }
public void EigenValsTestManaged() { var w = new NComplexMatrix(2, 2); var vl = new NComplexMatrix(2, 2); var vr = new NComplexMatrix(2, 2); var lib = new NLapackLib(); var matrix1 = new NRealMatrix(2, 2); matrix1[0, 0] = 1; matrix1[0, 1] = 2; matrix1[1, 0] = 3; matrix1[1, 1] = 4; lib.EigenVals(matrix1, w, vl, vr); Console.WriteLine("w=\n" + w); Console.WriteLine("vl=\n" + vl); Console.WriteLine("vr=\n" + vl); }
public void CholTest() { var a = new NRealMatrix(3, 3); a[0, 0] = 2; a[0, 1] = 1; a[0, 2] = 1; a[1, 0] = 1; a[1, 1] = 2; a[1, 2] = 1; a[2, 0] = 1; a[2, 1] = 1; a[2, 2] = 2; var lib = new NLapackLib(); var result = lib.Chol(a); Console.WriteLine(result); }
public void EigenValsXTest() { var matrix1 = new NRealMatrix(2, 2); matrix1[0, 0] = 1; matrix1[0, 1] = 2; matrix1[1, 0] = 3; matrix1[1, 1] = 4; var w = new NComplexMatrix(2, 2); var vl = new NComplexMatrix(2, 2); var vr = new NComplexMatrix(2, 2); var rconde = new NRealMatrix(2, 2); var rcondv = new NRealMatrix(2, 2); //var lib = new MLapackLib(); //lib.eigenValsX(Convert.ToInt16(BalanceType.None), matrix1, w, vl, vr, rconde, rcondv); var nlib = new NLapackLib(); nlib.EigenValsX(BalanceType.None, matrix1, w, vl, vr, rconde, rcondv); Console.WriteLine("w="); Console.WriteLine(w); Console.WriteLine("vl="); Console.WriteLine(vl); Console.WriteLine("vr="); Console.WriteLine(vr); Console.WriteLine("rconde="); Console.WriteLine(rconde); Console.WriteLine("rcondv="); Console.WriteLine(rcondv); }