public void testSumma26() { double[,] mat1 = { { 1, 2, 3 }, { 2, 2, 2 }, { 4, 2, 3 } }; double[,] mat2 = { { 9, 2, 8 }, { 1, 2, 5 }, { 3, 19, -3 } }; double[,] mat23 = { { 1, 2, 3 }, { 2, 2, 2 } }; double[,] mat32 = { { 9, 2 }, { 1, 2 }, { 3, 19 } }; double[,] mat = Taulukot.Summa(mat1, mat2); Assert.AreEqual("10 4 11,3 4 7,7 21 0", Demo6.Matriisit.Jonoksi(mat, " ", "{0}", ","), "in method Summa, line 32"); mat = Taulukot.Summa(mat23, mat32); Assert.AreEqual("10 4,3 4", Demo6.Matriisit.Jonoksi(mat, " ", "{0}", ","), "in method Summa, line 34"); }
/// <summary> /// Testataan taulukkoaliohjelmia /// </summary> public static void Main() { Taulukot.ErotaDouble("k", 1); double[,] mat1 = { { 1, 2, 3 }, { 2, 2, 2 }, { 4, 2, 3 } }; double[,] mat2 = { { 9, 2, 8 }, { 1, 2, 5 }, { 3, 19, -3 } }; double[,] mat3 = Taulukot.Summa(mat1, mat2); Console.WriteLine(Matriisit.Jonoksi(mat3, " ", "{0,5:0.00}")); double[] luvut = Taulukot.ErotaLuvut("2.23 3 4 5 k 9 ;5"); Console.WriteLine(Matriisit.Jonoksi(luvut, " ", "{0,5:0.00}")); double[] l2 = luvut; Array.Resize(ref l2, 10); Console.WriteLine(Matriisit.Jonoksi(luvut, " ", "{0,5:0.00}")); Console.WriteLine(Matriisit.Jonoksi(l2, " ", "{0,5:0.00}")); l2 = luvut; Array.Resize(ref l2, 4); Console.WriteLine(Matriisit.Jonoksi(luvut, " ", "{0,5:0.00}")); Console.WriteLine(Matriisit.Jonoksi(l2, " ", "{0,5:0.00}")); }