[Haskell-cafe] hmatrix, Windows and GCC
Patrick Perry
patperry at stanford.edu
Wed Jan 28 13:40:56 EST 2009
> Well, I guess I am not the only one!
>
> This blog show exactly what I am looking for!
>
> http://quantile95.com/2008/10/31/ann-blas-bindings-for-haskell-version-06/
If you're looking to implement other linear algebra algorithms in
Haskell, there's enough at
http://github.com/patperry/lapack
to implement a QR decomposition with column pivoting with fairly
minimal effort. Householder reflections and permutation matrices are
already supported. You will also need the latest BLAS bindings, also
available at github. Note that these libraries are not compatible
with hmatrix.
What would *really* be awesome would be an implementation of an SVD
algorithm: take a bidiagonal matrix and produce a (lazy) list of
Givens rotations that diagonalizes the matrix. That would probably be
a 2-4 week project, but would be really useful. Take a look at the
code and references at http://netlib.org/lapack/explore-html/zbdsqr.f.html
if you're interested.
The LAPACK version, zbdsqr, takes "B" and factors it as "B = Q S
P^H". Optionally, it sets
U := U Q
VT := P^H VT
C := Q^H C
Annoyingly, there is no way to specify an input matrix "D" and set
"D := D P".
It'd be really cool to have a Haskell function of type
svdBidiagonal :: (WriteBanded a m) => a (n,p) e -> m
[(Givens,Givens)]
The type signature means that "a" is a mutable banded matrix of shape
"(n,p)" with elements of type "e" that can be modified in monad "m".
I'm envisioning that the result is a lazy list, "gs", and that no
computation gets done until the "gs" list is traversed. So, if
someone just wants singular values, then they would do "liftM length .
svdBidiagonal". If they want to update "U := U Q", then they would do
something like:
mapM_ (applyGivens u) $ liftM (fst . unzip) $ svdDidiagonal a
The user has the option to update as many matrices they want in
whatever way they want. This is only possible with laziness. It is a
perfect example of the "glue" John Hughes talks about in "Why
Functional Programming Matters".
Patrick
>
> On Wed, Jan 28, 2009 at 08:21, Rafael Gustavo da Cunha Pereira Pinto <
> RafaelGCPP.Linux at gmail.com> wrote:
>
> > I was planning to recompile everything (ATLAS, LAPACK and GHC
> included)
> > this weekend, so I can have a similar environment on Windows and
> Linux...
> > Having to "borrow" libraries
> >
> > Since I am married, this means it will actually happen on some
> weekend till
> > 2010.
> >
> >
> > What I really would like to try is a (purely?) functional approach
> to
> > create a (P)LU decomposition of a matrix. I am not too much
> worried (at
> > first) with performance or memory constraints, since I only want
> to see how
> > beautiful it gets (or not!). (This one might happen somewhere in
> this
> > century...)
> >
> >
> > Thanks anyway
> >
> >
> >
> > On Wed, Jan 28, 2009 at 07:57, allan <a.d.clark at ed.ac.uk> wrote:
> >
> >> Hi
> >>
> >> The INSTALL file in the hmatrix repository has some very clear
> >> instructions for installation on Windows.
> >> http://perception.inf.um.es/~aruiz/darcs/hmatrix/INSTALL<http://perception.inf.um.es/%7Earuiz/darcs/hmatrix/INSTALL
> >
> >>
> >> However note this section at the bottom:
> >> "Unfortunately the lapack dll supplied by the R system does not
> include
> >> zgels_, zgelss_, and zgees_, so the functions depending on them
> >> (linearSolveLS, linearSolveSVD, and schur for complex data)
> >> will produce a "non supported in this OS" runtime error."
> >>
> >> Of course linearSolve is exactly what you will be wanting so this
> won't
> >> work for you.
> >> I ran into exactly this problem myself. I actually didn't get as
> far as a
> >> run-time error as I got a linker error.
> >>
> >> I don't have any solution for you though, sorry.
> >>
> >> regards
> >> allan
> >>
> >>
> >>
> >>
> >> Rafael Gustavo da Cunha Pereira Pinto wrote:
> >>
> >>>
> >>>
> >>> Hi all,
> >>>
> >>> I am writing a program that uses hmatrix for solving some linear
> systems.
> >>> The hmatrix package depends on BLAS, which, in turn, depend on
> GCC 4.2 to be
> >>> built (at least ATLAS does).
> >>>
> >>> GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it
> leaves me
> >>> with the impression that I would have incompatible ABIs.
> >>>
> >>> My questions:
> >>>
> >>> 1) Why GHC 6.10 still uses GCC 3.4.5 in Windows? I know mingw
> considers
> >>> GCC 4.2 to be alpha, but, lets face it, 4.2 is almost obsolete!
> >>> 2) Is it possible to rebuild GHC 6.10, using Windows and GCC
> 4.2? Is
> >>> there any guide for doing this?
> >>> 3) Has any of you tried hmatrix on Windows? How did you do it?
> >>>
> >>> Thanks,
> >>>
> >>> Rafael
> >>>
> >>> --
> >>> Rafael Gustavo da Cunha Pereira Pinto
> >>> Electronic Engineer, MSc.
> >>>
> >>>
> >>>
> ------------------------------------------------------------------------
> >>>
> >>> _______________________________________________
> >>> Haskell-Cafe mailing list
> >>> Haskell-Cafe at haskell.org
> >>> http://www.haskell.org/mailman/listinfo/haskell-cafe
> >>>
> >>
> >>
> >>
> >> --
> >> The University of Edinburgh is a charitable body, registered in
> >> Scotland, with registration number SC005336.
> >>
> >>
> >
> >
> > --
> > Rafael Gustavo da Cunha Pereira Pinto
> > Electronic Engineer, MSc.
> >
>
>
>
> --
> Rafael Gustavo da Cunha Pereira Pinto
> Electronic Engineer, MSc.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090128/4b1ba353/attachment.htm
>
More information about the Haskell-Cafe
mailing list