
instead of (!) (or readArray in stateful code) helped a lot. So then I went to optimize my gaussian elimination function and found just the opposite. unsafeRead is slower than readArray. This struck me as very
The functions gaussElimSafe and gaussElimUnsafe are different in their outputs (*). I guess you made a mistake during conversion from one version to the other. BTW, the attached file contains an outline of a pure functional and indexless implementation. It calculates the inverse of a quadratic matrix in time O(n^3), so maybe you can get rid of all this exclamation marks and IO stuff... BR, (*) Try: newStdGen >>= \ g -> flip mapM_ [gaussElimSafe,gaussElimUnsafe] $ \ f -> makeMatrix g >>= \ m -> printMatrix m >> f m >> printMatrix m -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ ---