diff --git a/Sources/Accord.Imaging/MatrixH.cs b/Sources/Accord.Imaging/MatrixH.cs index 9875bbbf9..c80f7d315 100644 --- a/Sources/Accord.Imaging/MatrixH.cs +++ b/Sources/Accord.Imaging/MatrixH.cs @@ -97,7 +97,7 @@ public MatrixH(float[] elements) else if (elements.Length == 9) { this.elements = new float[8]; - for (int i = 0; i < elements.Length; i++) + for (int i = 0; i < this.elements.Length; i++) this.elements[i] = (float)(elements[i] / elements[8]); } else diff --git a/Unit Tests/Accord.Tests.Imaging/MatrixHTest.cs b/Unit Tests/Accord.Tests.Imaging/MatrixHTest.cs index 7aeb8b10a..e93791ae1 100644 --- a/Unit Tests/Accord.Tests.Imaging/MatrixHTest.cs +++ b/Unit Tests/Accord.Tests.Imaging/MatrixHTest.cs @@ -42,6 +42,15 @@ public void MultiplyTest() Assert.IsTrue(Accord.Math.Matrix.IsEqual( expected.Elements, actual.Elements)); + try + { + A = new MatrixH(new float[8] {1, 0, 0, 0, 1, 0, 0, 1}); + B = new MatrixH(new float[9] {1, 0, 0, 0, 1, 0, 0, 0, 1}); + } + catch (System.Exception e) + { + Assert.Fail(e.Message); + } double[,] a = {