public void Generation() { for (var i = 1; i < 10; i++) { // *** Square matrices *** var diagData = TestData.GenerateTestDoubles(i); var diagonaleMatrix = MatrixFactory.Diagonal(diagData); Assert.IsTrue(diagonaleMatrix != null); Assert.IsTrue(diagonaleMatrix.Rows == i); Assert.IsTrue(diagonaleMatrix.Columns == i); var idMatrix = MatrixFactory.IdentityD(i, Math.PI); Assert.IsTrue(idMatrix != null); Assert.IsTrue(idMatrix.Rows == i); Assert.IsTrue(idMatrix.Columns == i); // Test square matrices for (var r = 0; r < i; r++) { for (var c = 0; c < i; c++) { Assert.AreEqual(diagonaleMatrix[r, c], r == c ? diagData[r] : 0); Assert.AreEqual(idMatrix[r, c], r == c ? Math.PI : 0, 1e-9); } } // *** Non-square matrices *** for (var j = 1; j < 10; j++) { var data = TestData.GenerateTestDoubles(i * j); var matrix = MatrixFactory.Build(i, j, data); Assert.IsTrue(matrix != null); Assert.IsTrue(matrix.Rows == i); Assert.IsTrue(matrix.Columns == j); var zeroMatrix = MatrixFactory.ZeroD(i, j); Assert.IsTrue(zeroMatrix != null); Assert.IsTrue(zeroMatrix.Rows == i); Assert.IsTrue(zeroMatrix.Columns == j); var oneMatrix = MatrixFactory.OneD(i, j, Math.PI); Assert.IsTrue(oneMatrix != null); Assert.IsTrue(oneMatrix.Rows == i); Assert.IsTrue(oneMatrix.Columns == j); if (i == 4 && j == 4) { Assert.IsInstanceOf(typeof(Matrix4x4d), matrix); } for (var r = 0; r < i; r++) { for (var c = 0; c < j; c++) { Assert.AreEqual(matrix[r, c], data[r * j + c], 1e-9); Assert.AreEqual(zeroMatrix[r, c], 0, 1e-9); Assert.AreEqual(oneMatrix[r, c], Math.PI, 1e-9); } } } } }