<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Monospace">
<p>Henning:</p>
<p></p>
<p><span style="color:#008000">&gt;I was wrong, the different names are synonymes for the same type. :-(</span></p>
<p></p>
<p>I agree that we must statically distinguish Vector and Matrix (see below).</p>
<p></p>
<p><span style="color:#008000">&gt;  Some notes: I would not call it a matrix library but a linear algebra</span></p>
<p><span style="color:#008000">&gt; library. Then setup modules like LinearAlgebra.Matrix,</span></p>
<p><span style="color:#008000">&gt; LinearAlgebra.Vector and so on and move functions related to each type</span></p>
<p><span style="color:#008000">&gt; into these modules. Vector is more basic than Matrix, thus Matrix should</span></p>
<p><span style="color:#008000">&gt; import Vector, not vice versa, it should contain Matrix-Vector operations.</span></p>
<p><span style="color:#008000">&gt; The Vector module could contain e.g. the scalar product. I also find it</span></p>
<p><span style="color:#008000">&gt; good style not to repeat the modules name in function and type names. E.g.</span></p>
<p><span style="color:#008000">&gt; Matrix.mulVector is a good function name, but the type name should also</span></p>
<p><span style="color:#008000">&gt; not be Matrix.Matrix but say Matrix.T. Unfortunately this style is not</span></p>
<p><span style="color:#008000">&gt; very widely spread currently, I wished it would be more. </span></p>
<p></p>
<p>You are right, module structure and names are provisional.</p>
<p></p>
<p><span style="color:#008000">&gt; Then you may </span></p>
<p><span style="color:#008000">&gt; consider no to restrict the library to Double. Most operations can be</span></p>
<p><span style="color:#008000">&gt; defined in terms of any numbers (including even say matrices of matrices).</span></p>
<p><span style="color:#008000">&gt; This can be handled by type classes. The instances for Double can invoke</span></p>
<p><span style="color:#008000">&gt; GSL, others may use Haskell routines.</span></p>
<p></p>
<p>Ok. Currently we can have &quot;blocks&quot; of Storable types. Block Double works with </p>
<p>the GSL and Block Int is only in Num, using Haskell. Clearly we should admit </p>
<p>other any number as base type. </p>
<p></p>
<p><span style="color:#008000">&gt;  If you are interested I have here some algorithm for computing the</span></p>
<p><span style="color:#008000">&gt; determinant of a n by n matrix in n^4 steps which does not need division</span></p>
<p><span style="color:#008000">&gt; and thus can be used for integers and polynomials.</span></p>
<p></p>
<p>Of course I would like to see it, and we can include it in the library...</p>
<p></p>
<p></p>
<p>David: </p>
<p></p>
<p><span style="color:#008000">&gt; The one thing I'd like to see (and here I agree with Hennig) is a</span></p>
<p><span style="color:#008000">&gt; distinction between matrices and tensors.  Your library is really very</span></p>
<p><span style="color:#008000">&gt; tensor-based, but tensors and matrices are very different beasts.</span></p>
<p><span style="color:#008000">&gt;</span></p>
<p><span style="color:#008000">&gt; I imagine one could take your Block, which is really a sort of generalized</span></p>
<p><span style="color:#008000">&gt; tensor, and implement a Matrix type such as</span></p>
<p><span style="color:#008000">&gt;</span></p>
<p><span style="color:#008000">&gt; data Matrix = M (Block Double)</span></p>
<p><span style="color:#008000">&gt;</span></p>
<p><span style="color:#008000">&gt; (or perhaps for arbitrary element type) with the constructor not exported,</span></p>
<p><span style="color:#008000">&gt; so that Matrices will always be guaranteed to be two-dimensional.</span></p>
<p><span style="color:#008000">&gt;</span></p>
<p><span style="color:#008000">&gt; Then for matrices one could define * to be matrix multiplication, sqrt,</span></p>
<p><span style="color:#008000">&gt; exp, cos, sin etc to be matrix functions (expm etc in octave-speak), and</span></p>
<p><span style="color:#008000">&gt; then define .* and ./ to be as defined in octave.</span></p>
<p><span style="color:#008000">&gt;</span></p>
<p><span style="color:#008000">&gt; This definition would allow considerably more type-safeness than your</span></p>
<p><span style="color:#008000">&gt; current implementation (which seems scarily dynamically typed to me).</span></p>
<p></p>
<p>To me too! Due to the type trickery required to statically check matrix </p>
<p>dimensions in this first version I also used a common type for blocks with </p>
<p>any number of indices, which ruins many of the Haskell advantages.</p>
<p></p>
<p>I will work on your idea. We can have different types for scalar, vector and </p>
<p>matrix, with elementwise numeric operations, and using multiparamenter </p>
<p>classes we can statically check typical multiplications and other functions. </p>
<p>We can also define a constructor from vectors or matrices to arbitrary </p>
<p>blocks, to be used (dynamically) in more general but less frequent </p>
<p>situations. </p>
<p></p>
<p><span style="color:#008000">&gt; Alas, we'd still not have the truly strong typing I'd dream about where one</span></p>
<p><span style="color:#008000">&gt; could define</span></p>
<p><span style="color:#008000">&gt;</span></p>
<p><span style="color:#008000">&gt; matMul :: Int n, m, l =&gt;  Matrix n m -&gt; Matrix m l -&gt; Matrix n l</span></p>
<p><span style="color:#008000">&gt;</span></p>
<p><span style="color:#008000">&gt; which as I understand things, isn't possible in Haskell without some sort</span></p>
<p><span style="color:#008000">&gt; of weird type trickery.  Of course, if you had this kind of type trickery,</span></p>
<p><span style="color:#008000">&gt; you might not need to declare a separate Matrix type, since you'd be able</span></p>
<p><span style="color:#008000">&gt; to represent the dimensionality of the Block in its type.</span></p>
<p><span style="color:#008000">&gt;</span></p>
<p><span style="color:#008000">&gt; And hopefully you and he can work together to create a great library (and</span></p>
<p><span style="color:#008000">&gt; I'll be able to mooch off of whatever you create...).  :)</span></p>
<p></p>
<p>Of course! I am very happy to know that other people is also interested in a </p>
<p>simple &quot;scientific computing&quot; library for Haskell.</p>
<p></p>
<p>Alberto</p>
<p></p>
</body></html>