December 28, 2013
>
> Sounds good to me.  By the way, I think Cristi was considering targeting the linear algebra work towards Phobos -- you might like to consider if some parts of SciD could be reworked as standard library features, although obviously you have greater freedom to extend and experiment in an independent library.
>

I don't think anything related to linear algebra belongs in the standard library. See here, for example: http://forum.dlang.org/thread/rmyaglfeimzuggoluxvd@forum.dlang.org?page=2#post-rfnnzssennvpxcihmcmb:40forum.dlang.org. The basic point is that linear algebra libraries are too dependent on hardware, available libraries, and implementation details to have any place in a language specific standard library.

But I definitely support a D matrix library getting some love and attention. Especially since, if I understood the SciD code correctly when I looked at it a month ago, it currently is a nice wrapper for a matrix type and solving matrix equations and finding eigenvalues. It lacks support for matrix multiplication, addition, etc.. I'm not sure if D's operator overloading is sufficiently rich to allow separate operators for matrix multiplication and element-wise multiplication in matrix. (Dealing with this is a pain in numpy, the most common Python matrix library, as well as in Eigen, a common c++ matrix library.)

Also worth noting Some of the most popular C++ matrix & linear algebra libraries, such as Eigen and Armadillo, are based on expression templates. This leads to not terribly readable code, which I suspect D could clean up. But that isn't anywhere near the first feature to add to a matrix library.
December 28, 2013
On 28/12/13 06:53, CJS wrote:
> I don't think anything related to linear algebra belongs in the standard
> library. See here, for example:
> http://forum.dlang.org/thread/rmyaglfeimzuggoluxvd@forum.dlang.org?page=2#post-rfnnzssennvpxcihmcmb:40forum.dlang.org.
> The basic point is that linear algebra libraries are too dependent on hardware,
> available libraries, and implementation details to have any place in a language
> specific standard library.

Thanks for your detailed writeup and reference list there -- it's very useful.

My own take on this is pretty much: let's make sure that there is a nice library which is Phobos-compatible -- by which I mean, its licence and coding style match what's in the standard library -- and approach any decisions about where it belongs on the basis of what gets created.

I imagine that putting in the effort to write a really good linear algebra library from scratch in D, with attention to all prior work, would probably be very rewarding and an excellent stress test of the language, but would also involve far too much effort given that we can bind what already exists.

> But I definitely support a D matrix library getting some love and attention.
> Especially since, if I understood the SciD code correctly when I looked at it a
> month ago, it currently is a nice wrapper for a matrix type and solving matrix
> equations and finding eigenvalues. It lacks support for matrix multiplication,
> addition, etc.. I'm not sure if D's operator overloading is sufficiently rich to
> allow separate operators for matrix multiplication and element-wise
> multiplication in matrix. (Dealing with this is a pain in numpy, the most common
> Python matrix library, as well as in Eigen, a common c++ matrix library.)

I don't see why in principle it shouldn't be doable.  Whether it's possible to directly define custom operators for this akin to what MATLAB/Octave have: .+, .-, .*, ./, etc. I'm not sure, but it ought to be possible to define some kind of DSL/template along the lines of:

    c = ElementWise!("a + b");
December 29, 2013
> > I'm not sure if D's operator overloading is
>> sufficiently rich to
>> allow separate operators for matrix multiplication and element-wise
>> multiplication in matrix. (Dealing with this is a pain in numpy, the most common
>> Python matrix library, as well as in Eigen, a common c++ matrix library.)
>
> I don't see why in principle it shouldn't be doable.  Whether it's possible to directly define custom operators for this akin to what MATLAB/Octave have: .+, .-, .*, ./, etc. I'm not sure, but it ought to be possible to define some kind of DSL/template along the lines of:
>
>     c = ElementWise!("a + b");

A variation of that is what numpy and Eigen use. In numpy, for
the array class '*' is element-wise by default and the function
np.dot is matrix multiplication. For Eigen '*' is matrix
multiplication by default while the (member) function
cwiseProduct is element-wise. One the one hand, this is more
readable than matlab or R in terms of having a clear default.
(Whereas in matlab you have to be careful to distinguish between
'.*' and '*', or '*' and '%*%' in R.) But it's both hideous to
look at and to type. An improvement over .add or .times in Java
matrix libraries, but far from Nirvana. I'm hoping D can do
better.
December 30, 2013
On Sunday, 29 December 2013 at 21:26:33 UTC, CJS wrote:
> A variation of that is what numpy and Eigen use. In numpy, for
> the array class '*' is element-wise by default and the function
> np.dot is matrix multiplication. For Eigen '*' is matrix
> multiplication by default while the (member) function
> cwiseProduct is element-wise. One the one hand, this is more
> readable than matlab or R in terms of having a clear default.
> (Whereas in matlab you have to be careful to distinguish between
> '.*' and '*', or '*' and '%*%' in R.) But it's both hideous to
> look at and to type. An improvement over .add or .times in Java
> matrix libraries, but far from Nirvana. I'm hoping D can do
> better.

How would you like the syntax to be, in an ideal world?
1 2 3 4 5 6 7
Next ›   Last »