[Haskell-cafe] Matrices

2009-04-19 Thread Cetin Sert
http://ccnmtl.columbia.edu/projects/qmss/the_chisquare_test/about_the_chisquare_test.html given two matrices, Prelude Data.Matrix.Dense Data.Vector.Dense m listMatrix (2,2) [46.0,37.0,71.0,83.0] Prelude Data.Matrix.Dense Data.Vector.Dense es listMatrix (2,2)

Re: [Haskell-cafe] Matrices

2009-04-19 Thread Alberto Ruiz
Using hmatrix-static: import Numeric.LinearAlgebra.Static m = [$mat| 46.0,37.0; 71.0,83.0 |] es = [$mat| 40.9746835443038,42.0253164556962; 76.0253164556962,77.9746835443038 |] chisquare = sum . toList . flatten $ (m - es)^2 / es ::Double -- 1.8732940252518542 Cetin

Re: [Haskell-cafe] Matrices

2009-04-19 Thread Don Stewart
Very cool! We need an hmatrix-static tutorial! aruiz: Using hmatrix-static: import Numeric.LinearAlgebra.Static m = [$mat| 46.0,37.0; 71.0,83.0 |] es = [$mat| 40.9746835443038,42.0253164556962; 76.0253164556962,77.9746835443038 |] chisquare = sum . toList .

Re: [Haskell-cafe] Matrices in Haskell

2007-07-22 Thread Ivan Lazar Miljenovic
On Tue, 2007-03-20 at 15:09 +1000, Matthew Brecknell wrote: I'm not sure I see the problem, since any operation that touches all the elements of a n-by-n matrix will be at least O(n^2). For such an operation, a transposition should just add a constant factor. What I was hoping for was a data

Re: [Haskell-cafe] Matrices in Haskell

2007-03-20 Thread Vincent Kraeutler
Matthew Brecknell wrote: Ivan Miljenovic: As such, I'd like to know if there's any way of storing a an n-by-n matrix such that the algorithm/function to get either the rows or the columns is less than O(n^2) like transposition is. I did try using an Array, but my (admittedly hurried and

Re: [Haskell-cafe] Matrices in Haskell

2007-03-20 Thread Claus Reinke
When you tried using Arrays, I presume you used an array indexed by a pair (i,j), and just reversed the order of the index pair to switch from row-wise to column-wise access? It's hard to see how that would slow you down. Perhaps the slowdown was caused by excessive array copying? the

Re: [Haskell-cafe] Matrices in Haskell

2007-03-20 Thread Vincent Kraeutler
Claus Reinke wrote: When you tried using Arrays, I presume you used an array indexed by a pair (i,j), and just reversed the order of the index pair to switch from row-wise to column-wise access? It's hard to see how that would slow you down. Perhaps the slowdown was caused by excessive array

Re: [Haskell-cafe] Matrices in Haskell

2007-03-20 Thread Claus Reinke
it seems unlikely to me that this would cause a degradation in performance with respect to lists... that might depend on the number of operations per transposition, i guess. lists and explicit transpositions make it very obvious what is going on in terms of iteration order, so i would be

[Haskell-cafe] Matrices in Haskell

2007-03-19 Thread Ivan Miljenovic
Some of you might recall me annoying people on #haskell over the New Year about my Latin Squares project. Well, I'm looking at re-doing it from scratch, but the first thing I need to do is find a new way of representing my square. I have been using a list of lists ([[a]]) to represent a matrix.

Re: [Haskell-cafe] Matrices in Haskell

2007-03-19 Thread Matthew Brecknell
Ivan Miljenovic: As such, I'd like to know if there's any way of storing a an n-by-n matrix such that the algorithm/function to get either the rows or the columns is less than O(n^2) like transposition is. I did try using an Array, but my (admittedly hurried and naive) usage of them took