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
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 .
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
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
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
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
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
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