Daniel-Diaz / matrix

A Haskell native implementation of matrices and their operations.
BSD 3-Clause "New" or "Revised" License
35 stars 31 forks source link

Space leak in luDecomp #16

Open kenta2 opened 9 years ago

kenta2 commented 9 years ago

luDecomp appears to have a space leak: calling it on a 100x100 matrix of Doubles requires over 5 GB of memory. Here is a simple test program

{-# LANGUAGE LambdaCase #-} module Main where { import Data.Matrix; import System.Environment(getArgs);

main::IO(); main= getArgs >>= \case { [n] -> print $ detLU $ randommatrix $ read n; _ -> error "need matrix size"; };

randommatrix :: Int -> Matrix Double; randommatrix size = fromList size size -- crude random number generator $ map (tan . fromIntegral) $ enumFromTo 1 $ size * size;

} --end

Seen in matrix-0.3.4.2 with GHC 7.8.4 and github version of matrix, with GHC 7.10 rc1

Daniel-Diaz commented 9 years ago

Yes, that is certainly a bad memory usage case. I don't have much time right now to look at this, but will do as soon as I can.

Thanks for reporting this.