Closed bvenn closed 2 years ago
Describe the bug
When transforming jagged sequences to column oriented matrices there are three specialized functions for sequences, lists, and arrays respectively.
Matrix.ofJaggedColList [[1. .. 4.];[2. .. 5.]] generates the correct result:
Matrix.ofJaggedColList [[1. .. 4.];[2. .. 5.]]
val it : Matrix<float> = matrix [[1.0; 2.0] [2.0; 3.0] [3.0; 4.0] [4.0; 5.0]]
Matrix.ofJaggedColSeq and Matrix.ofJaggedColArray fail with System.IndexOutOfRangeException: Index was outside the bounds of the array.
Matrix.ofJaggedColSeq
Matrix.ofJaggedColArray
System.IndexOutOfRangeException: Index was outside the bounds of the array.
To Reproduce
Matrix.ofJaggedColSeq [|[|1. .. 4.|];[|2. .. 5.|]|] Matrix.ofJaggedColArray [|[|1. .. 4.|];[|2. .. 5.|]|]
Additional context
I'm pretty sure, the error is in the following and I'm going to fix it and provide tests:
https://github.com/fslaborg/FSharp.Stats/blob/6874435eeee928a9cd79c58bf3fd108d5a46db90/src/FSharp.Stats/AlgTypes.fs#L476
I just saw that there are already tests for these functions, but they are based on square matrices, which unintentionally covers the problem.
https://github.com/fslaborg/FSharp.Stats/blob/6874435eeee928a9cd79c58bf3fd108d5a46db90/tests/FSharp.Stats.Tests/Matrix.fs#L84
Describe the bug
When transforming jagged sequences to column oriented matrices there are three specialized functions for sequences, lists, and arrays respectively.
Matrix.ofJaggedColList [[1. .. 4.];[2. .. 5.]]
generates the correct result:Matrix.ofJaggedColSeq
andMatrix.ofJaggedColArray
fail withSystem.IndexOutOfRangeException: Index was outside the bounds of the array.
To Reproduce
Additional context
I'm pretty sure, the error is in the following and I'm going to fix it and provide tests:
https://github.com/fslaborg/FSharp.Stats/blob/6874435eeee928a9cd79c58bf3fd108d5a46db90/src/FSharp.Stats/AlgTypes.fs#L476