I never used DPH, but for Matrices, I always tend to use Array (Int,Int) Double, as it accesses its elements in O(1). Arrays also can be unboxed (UArray), which are much faster, or monadic and mutable (MArray), which are more flexible. <br>
<br>I don&#39;t know if it is possible to use Arrays with DPH...<br><br><br><br><br><div class="gmail_quote">On Sun, Jan 17, 2010 at 21:35, Johannes Waldmann <span dir="ltr">&lt;<a href="mailto:waldmann@imn.htwk-leipzig.de">waldmann@imn.htwk-leipzig.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello.<br>
<br>
How can I multiply matrices (of Doubles)<br>
with dph (-0.4.0)?  (ghc-6.12.1)  -  I was trying<br>
<br>
type Vector = [:Double:]<br>
type Matrix = [:Vector:]<br>
<br>
times :: Matrix -&gt; Matrix -&gt; Matrix<br>
times a b =<br>
      mapP<br>
      ( \ row -&gt; mapP ( \ col -&gt; sumP ( zipWithP (*) row col  ) )<br>
                      ( transposeP b )<br>
      ) a<br>
<br>
but there is no such thing as transposeP.<br>
<br>
When I try any kind of index manipulations,<br>
the compiler invariably tells me<br>
that it does not want to build  [: :] - lists of indices<br>
(e.g., there is no enumFromToP)<br>
(I guess because I&#39;m using Data.Array.Parallel.Prelude.Double)<br>
<br>
Puzzled - J.W.<br>
<br>
<br>
PS: what&#39;s the recommended way to multiply matrices<br>
(better modelled as   Array (Int,Int) Double   or  [[Double]] ?)<br>
with the  par/pseq  approach (if this is recommended at all)?<br>
<br>
As I said earlier, I just want to have some nice and easy benchmarks<br>
for demonstration in a lecture (to be run on 2, 4, or 8 cores).<br>
Of course if they work, I&#39;d use them in real life as well...<br>
<br>
<br>
<br>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Rafael Gustavo da Cunha Pereira Pinto<br><br>