[Haskell-cafe] Re: Patrick Perry's BLAS package

Patrick Perry patperry at stanford.edu
Fri Jun 6 18:45:47 EDT 2008

>> a function like foo :: (BLAS1 e) => Matrix (m,n) e ->
>> Matrix (n,k) e -> Int -> Vector m e foo a b i = let x =
>> row b i in a <*> x will not type-check. (”<*>” is the
>> function to multiply a matrix by a vector. Everything is
>> ok if you replace “row” by “col”.) This feature has caught
>> a few bugs in my code.
> If I understand this correctly, the compiler can catch
> dimension mismatches so that using `col' will result in a
> compilation error when m and k are different, is it so?

Yes, the compiler infers the type of expression to be

Matrix(m,n) e -> Matrix (l,m) e -> Int -> Vector n e

which is different from the declared type.  The error will be  
something like "Expected type Vector m e, but got type Vector a1 e  

> I haven't look through the code, yet.  But it looks like
> there are certain levels of similarities between blas and
> hmatrix.  Is it possible for these two libraries to
> cooperate well with each other?  (I didn't look at HBlas, so
> can't say much about that.)

This is more work than you might think.  The data structures are  
different, many of the function names are different, and the module  
namespaces overlap.  I wouldn't recommend any switch from hmatrix to  
blas right now unless you really need mutable types-- hmatrix has a  
lot more linear algebra functionality.

> Apart from some warnings, the library compiles fine in my
> system.  But there is a minor issue about the library it
> links against when `./Setup test'.  I need to use `-lcblas'
> instead of `-lblas' to get it to link to correct libraries.
> I don't know other people's system.  But in my system,
> Gentoo Linux, I use blas library provided by atlas, and
> libblas.so is a fortran library and libcblas.so is for C.

I don't know of a good way to get around this.  It seems like every  
system has a different convention for the location and name of the  
cblas libraries.  So, everyone has to edit the "extra-libraries" and  
the "extra-lib-dirs" field in the blas.cabal file.  Does anyone know  
of a better way of doing this?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080606/f5c2fa83/attachment.htm

More information about the Haskell-Cafe mailing list