Thread overview
Is there anybody working on a linear algebra library for D2?
Oct 05, 2010
Michael Chen
Oct 05, 2010
jcc7
Oct 05, 2010
dsimcha
Oct 05, 2010
Gareth Charnock
Oct 05, 2010
Don
Oct 05, 2010
Gareth Charnock
Oct 05, 2010
Tomek Sowiński
Oct 09, 2010
Trass3r
October 05, 2010
I remember that one of D's goal is easy scientific computation.
However I haven't seen any linear algebra package for D2. My work
heavily relays on all kinds of matrix stuff (matrix multiplication,
factorization, linear system etc). I like D and am willing to work
with D. However without these facilities I can hardly start. I'd like
to have a matrix library of which the API is kind of like Matlab.
Is there anybody working on this or planning to work on this?

Regards,
Michael
October 05, 2010
== Quote from Michael Chen (sth4nth@gmail.com)'s article
> I remember that one of D's goal is easy scientific computation.
> However I haven't seen any linear algebra package for D2. My work
> heavily relays on all kinds of matrix stuff (matrix multiplication,
> factorization, linear system etc). I like D and am willing to work
> with D. However without these facilities I can hardly start. I'd like
> to have a matrix library of which the API is kind of like Matlab.
> Is there anybody working on this or planning to work on this?
> Regards,
> Michael

You might be able to find something useful for you in this list on this page: http://www.prowiki.org/wiki4d/wiki.cgi?ScientificLibraries

(You might not be able to find a D 2.x project for what you need, but it might not be much effort to make a minimal port from a D 1.x project.)

Good luck.

jcc7
October 05, 2010
On 05/10/10 14:41, Michael Chen wrote:
> I remember that one of D's goal is easy scientific computation.
> However I haven't seen any linear algebra package for D2. My work
> heavily relays on all kinds of matrix stuff (matrix multiplication,
> factorization, linear system etc). I like D and am willing to work
> with D. However without these facilities I can hardly start. I'd like
> to have a matrix library of which the API is kind of like Matlab.
> Is there anybody working on this or planning to work on this?
>
> Regards,
> Michael

I've attempted this in the past, however, each time I manage to work up renewed enthusiasm I keep running into compiler bugs that put me off. My current feeling is I should sit back at wait for the language to mature a little.

However, once D does mature there are some neat tricks that would be possible in a matrix library. For a start you could easily build something like ATLAS with all the tuning parameters being passed as template parameters. Another neat trick might be verifying that a matrix is othoginal/unitary/whatever with invariants. Again a static if and a template parameter makes this feature really trivial to add.

As for things that aren't vaporware, http://www.dsource.org/projects/mathextra/browser/trunk/blade might be a good place to start.
October 05, 2010
== Quote from jcc7 (jccalvarese@gmail.com)'s article
> == Quote from Michael Chen (sth4nth@gmail.com)'s article
> > I remember that one of D's goal is easy scientific computation.
> > However I haven't seen any linear algebra package for D2. My work
> > heavily relays on all kinds of matrix stuff (matrix multiplication,
> > factorization, linear system etc). I like D and am willing to work
> > with D. However without these facilities I can hardly start. I'd like
> > to have a matrix library of which the API is kind of like Matlab.
> > Is there anybody working on this or planning to work on this?
> > Regards,
> > Michael
> You might be able to find something useful for you in this list on this page:
> http://www.prowiki.org/wiki4d/wiki.cgi?ScientificLibraries
> (You might not be able to find a D 2.x project for what you need, but it might
not be much effort to
> make a minimal port from a D 1.x project.)
> Good luck.
> jcc7

Lars Kyllingstad's SciD library (http://dsource.org/projects/scid) is a good work in progress.  Unfortunately it depends heavily on Blas and Lapack.  I haven't figured out how to set these up on Windows yet.  However, it's definitely off the ground and looks pretty usable for those wizards sufficiently skilled in the art of fiddling with linker settings to get crufty old C and Fortran libraries to link with D code.

IMHO there should eventually be pure D versions of this functionality.  I tried to get started writing it, but got sidetracked by about a million other things.
October 05, 2010
Gareth Charnock wrote:
> On 05/10/10 14:41, Michael Chen wrote:
>> I remember that one of D's goal is easy scientific computation.
>> However I haven't seen any linear algebra package for D2. My work
>> heavily relays on all kinds of matrix stuff (matrix multiplication,
>> factorization, linear system etc). I like D and am willing to work
>> with D. However without these facilities I can hardly start. I'd like
>> to have a matrix library of which the API is kind of like Matlab.
>> Is there anybody working on this or planning to work on this?
>>
>> Regards,
>> Michael
> 
> I've attempted this in the past, however, each time I manage to work up renewed enthusiasm I keep running into compiler bugs that put me off. My current feeling is I should sit back at wait for the language to mature a little.
> 
> However, once D does mature there are some neat tricks that would be possible in a matrix library. For a start you could easily build something like ATLAS with all the tuning parameters being passed as template parameters. Another neat trick might be verifying that a matrix is othoginal/unitary/whatever with invariants. Again a static if and a template parameter makes this feature really trivial to add.
> 
> As for things that aren't vaporware, http://www.dsource.org/projects/mathextra/browser/trunk/blade might be a good place to start.

Please don't. That was a proof of concept, which had a big influence on D's array operations and the design of D's metaprogramming support. All of the ideas from BLADE will eventually be completely incorporated into array operations.
Basically, right now D has DAXPY and SAXPY from BLAS1, implemented as array operations. But it doesn't have anything else at present.
October 05, 2010
On 05/10/10 16:31, Don wrote:
> Gareth Charnock wrote:
>> On 05/10/10 14:41, Michael Chen wrote:
>>> I remember that one of D's goal is easy scientific computation.
>>> However I haven't seen any linear algebra package for D2. My work
>>> heavily relays on all kinds of matrix stuff (matrix multiplication,
>>> factorization, linear system etc). I like D and am willing to work
>>> with D. However without these facilities I can hardly start. I'd like
>>> to have a matrix library of which the API is kind of like Matlab.
>>> Is there anybody working on this or planning to work on this?
>>>
>>> Regards,
>>> Michael
>>
>> I've attempted this in the past, however, each time I manage to work
>> up renewed enthusiasm I keep running into compiler bugs that put me
>> off. My current feeling is I should sit back at wait for the language
>> to mature a little.
>>
>> However, once D does mature there are some neat tricks that would be
>> possible in a matrix library. For a start you could easily build
>> something like ATLAS with all the tuning parameters being passed as
>> template parameters. Another neat trick might be verifying that a
>> matrix is othoginal/unitary/whatever with invariants. Again a static
>> if and a template parameter makes this feature really trivial to add.
>>
>> As for things that aren't vaporware,
>> http://www.dsource.org/projects/mathextra/browser/trunk/blade might be
>> a good place to start.
>
> Please don't. That was a proof of concept, which had a big influence on
> D's array operations and the design of D's metaprogramming support. All
> of the ideas from BLADE will eventually be completely incorporated into
> array operations.
> Basically, right now D has DAXPY and SAXPY from BLAS1, implemented as
> array operations. But it doesn't have anything else at present.
Okay, sorry, I may have somewhat misunderstood the purpose of that library, I hadn't really looked at it in great detail, I just knew it was a math library.
October 05, 2010
Gareth Charnock napisał:

> I've attempted this in the past, however, each time I manage to work up renewed enthusiasm I keep running into compiler bugs that put me off. My current feeling is I should sit back at wait for the language to mature a little.

Welcome to the club:) I'm writing matrix modules for my QuantLibD project but compiler/Phobos bugs/changes are slowing me down.

I wonder how many people belong to that 'club'. If we join forces, we *might* end up with a usable matrix lib:)

-- 
Tomek
October 06, 2010
On Tue, 05 Oct 2010 15:01:03 +0000, dsimcha wrote:

> == Quote from jcc7 (jccalvarese@gmail.com)'s article
>> == Quote from Michael Chen (sth4nth@gmail.com)'s article
>> > I remember that one of D's goal is easy scientific computation. However I haven't seen any linear algebra package for D2. My work heavily relays on all kinds of matrix stuff (matrix multiplication, factorization, linear system etc). I like D and am willing to work with D. However without these facilities I can hardly start. I'd like to have a matrix library of which the API is kind of like Matlab. Is there anybody working on this or planning to work on this? Regards, Michael
>> You might be able to find something useful for you in this list on this page: http://www.prowiki.org/wiki4d/wiki.cgi?ScientificLibraries (You might not be able to find a D 2.x project for what you need, but it might
> not be much effort to
>> make a minimal port from a D 1.x project.) Good luck.
>> jcc7
> 
> Lars Kyllingstad's SciD library (http://dsource.org/projects/scid) is a good work in progress.  Unfortunately it depends heavily on Blas and Lapack.  I haven't figured out how to set these up on Windows yet. However, it's definitely off the ground and looks pretty usable for those wizards sufficiently skilled in the art of fiddling with linker settings to get crufty old C and Fortran libraries to link with D code.

Let me just start off by saying that if you are using Linux, there's less need for fiddling and wizardry. :)  On a 32-bit system the libraries should be available through your package manager, and all you need to do is to pass the -L-lblas and -L-llapack switches to DMD.  On a 64-bit system you may have to download them manually, but after that it's only a matter of telling DMD where to find them with -L-L/location/of/libs.

But I have to admit, the linear algebra stuff in SciD is fairly limited. I've mostly added stuff whenever I've needed it for work.  There's no full-fledged matrix type, just the scid.matrix.MatrixView type which provides a two-dimensional view (i.e. only getting and setting elements supported, no arithmetic) on an ordinary D array.  In addition, there's the scid.linalg package which provides user-friently interfaces to a few LAPACK algorithms.


> IMHO there should eventually be pure D versions of this functionality.

I completely agree.  More annoying than figuring out the BLAS/LAPACK library setup, which you only have to do once, is the fact that BLAS and LAPACK don't have support for the real and Complex!real types.


> I tried to get started writing it, but got sidetracked by about a million other things.

I see a real need for this, so when I get the time, and if dsimcha (or anyone else) doesn't beat me to it, I'll probably start working on this myself.

-Lars
October 09, 2010
I think lyla was aiming at that. I don't know how usable it is though since it isn't maintained anymore.
I just remember he tried to make it kinda backend-independent so you can choose between BLAS and other implementations.

http://www.dsource.org/projects/lyla