diff --git a/src/FSharp.Stats/Matrix.fs b/src/FSharp.Stats/Matrix.fs index cac019ca..cbf71faf 100644 --- a/src/FSharp.Stats/Matrix.fs +++ b/src/FSharp.Stats/Matrix.fs @@ -1493,7 +1493,7 @@ module Matrix = else loop (nColI) (colI-1) - loop (nRows-2) (nRows-1) + loop (nCols-2) (nCols-1) /// Splits a matrix along row direction according to given indices. Returns (matrix including rows according to indices, rest) /// diff --git a/tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj b/tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj index 0a373c39..af6b5eb2 100644 --- a/tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj +++ b/tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj @@ -74,7 +74,7 @@ - + diff --git a/tests/FSharp.Stats.Tests/Matrix.fs b/tests/FSharp.Stats.Tests/Matrix.fs index 519ebf23..754f450e 100644 --- a/tests/FSharp.Stats.Tests/Matrix.fs +++ b/tests/FSharp.Stats.Tests/Matrix.fs @@ -1183,6 +1183,37 @@ let floatImplementationDenseTests = testCase "getRows" <| fun () -> () ] + testList "removeCols" [ + testCase "removeColAt" <| fun () -> + let m = + [| + [|0.;1.|] + [|0.;3.|] + [|0.;5.|] + |] |> Matrix.ofJaggedArray + let actual = Matrix.removeColAt 0 m + let expected = + [| + [|1.|] + [|3.|] + [|5.|] + |] |> Matrix.ofJaggedArray + Expect.equal actual expected "Matrix.removeColAt did not return the correct matrix" + ] + testList "removeRows" [ + testCase "removeRowAt" <| fun () -> + let m = + [| + [|0.;0.;0.;|] + [|1.;3.;5.;|] + |] |> Matrix.ofJaggedArray + let actual = Matrix.removeRowAt 1 m + let expected = + [| + [|0.;0.;0.|] + |] |> Matrix.ofJaggedArray + Expect.equal actual expected "Matrix.removeRowAt did not return the correct matrix" + ] testList "getRegion" [ testCase "get Region" <| fun () ->