accord-net / framework

Machine learning, computer vision, statistics and general scientific computing for .NET
http://accord-framework.net
GNU Lesser General Public License v2.1
4.46k stars 2k forks source link

MatrixH(float[] elements) throws IndexOutOfRangeException when float[9] #2207

Open MathiasGlana opened 3 years ago

MathiasGlana commented 3 years ago

What would you like to submit? (put an 'x' inside the bracket that applies)

Issue description

public MatrixH(float[] elements) throws a IndexOutOfRangeException when elements is 9 elements long. Sample code

MatrixH(new float[9] {1, 0, 0, 0, 1, 0, 0, 0, 1}); // gives IndexOutOfRangeException 
else if (elements.Length == 9)
{
    this.elements = new float[8];
    for (int i = 0; i < elements.Length; i++)
    this.elements[i] = (float)(elements[i] / elements[8]);
}

should be

else if (elements.Length == 9)
{
    this.elements = new float[8];
    for (int i = 0; i < this.elements.Length; i++)
    this.elements[i] = (float)(elements[i] / elements[8]);
}