diff --git a/src/UnitTests/LinearAlgebraTests/Double/SymmetricDenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/SymmetricDenseMatrixTests.cs
index 4e0f6e02..b0078994 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/SymmetricDenseMatrixTests.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/SymmetricDenseMatrixTests.cs
@@ -26,6 +26,7 @@
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
+ using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra.Double;
@@ -123,6 +124,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
+ ///
+ /// Matrix from array is a reference.
+ ///
+ [Test]
+ public void MatrixFrom1DArrayIsReference()
+ {
+ var data = new double[] { 1, 1, 1, 1, 1, 1 };
+ var matrix = new SymmetricDenseMatrix(3, data);
+ matrix[0, 0] = 10.0;
+ Assert.AreEqual(10.0, data[0]);
+ }
+
///
/// Can create a matrix form array.
///
@@ -144,5 +157,59 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.AreEqual(TestMatrices[name], testData[name]);
}
}
+
+ ///
+ /// Matrix from two-dimensional array is a copy.
+ ///
+ [Test]
+ public void MatrixFrom2DArrayIsCopy()
+ {
+ var matrix = new DenseMatrix(TestData2D["Singular3x3"]);
+ matrix[0, 0] = 10.0;
+ Assert.AreEqual(1.0, TestData2D["Singular3x3"][0, 0]);
+ }
+
+ ///
+ /// Can create a matrix with uniform values.
+ ///
+ [Test]
+ public void CanCreateMatrixWithUniformValues()
+ {
+ var matrix = new SymmetricDenseMatrix(10, 10.0);
+ for (var i = 0; i < matrix.RowCount; i++)
+ {
+ for (var j = 0; j < matrix.ColumnCount; j++)
+ {
+ Assert.AreEqual(matrix[i, j], 10.0);
+ }
+ }
+ }
+
+ ///
+ /// Can create an identity matrix.
+ ///
+ [Test]
+ public void CanCreateIdentity()
+ {
+ var matrix = SymmetricDenseMatrix.Identity(5);
+ for (var i = 0; i < matrix.RowCount; i++)
+ {
+ for (var j = 0; j < matrix.ColumnCount; j++)
+ {
+ Assert.AreEqual(i == j ? 1.0 : 0.0, matrix[i, j]);
+ }
+ }
+ }
+
+ ///
+ /// Identity with wrong order throws ArgumentOutOfRangeException.
+ ///
+ /// The size of the square matrix
+ [TestCase(0)]
+ [TestCase(-1)]
+ public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
+ {
+ Assert.Throws(() => SymmetricDenseMatrix.Identity(order));
+ }
}
}
\ No newline at end of file