June 09, 2015
On Tuesday, 9 June 2015 at 03:26:25 UTC, Ilya Yaroshenko wrote:
> On Sunday, 7 June 2015 at 18:27:16 UTC, Robert burner Schadek wrote:
>> Phobos is awesome, the libs of go, python and rust only have better marketing.
>> As discussed on dconf, phobos needs to become big and blow the rest out of the sky.
>>
>> http://wiki.dlang.org/DIP80
>>
>> lets get OT, please discuss
>
> There are
> https://github.com/9il/simple_matrix and
> https://github.com/9il/cblas .
> I will try to rework them for Phobos.
>
> Any ideas and suggestions?
>
> Some notes about portability:
>   1. OS X has Accelerated framework builtin.
>   2. Linux has blast by default or it can be easily installed. However default blast is very slow. The openBLAS is preferred.
>   3. Looks like there is no simple way to have BLAS support on Windows.
>
> Should we provide BLAS library with DMD for Windows and maybe Linux?
>
> Regards,
> Ilya

... probably std.container.Array is good template to start.
June 09, 2015
On 2015-06-08 05:53, Manu via Digitalmars-d wrote:

> I've been humoring the idea of porting my engine to D. It's about 15
> years of development, better/cleaner than most proprietary engines
> I've used at game studios.

Perhaps you could try using magicport.

-- 
/Jacob Carlborg
June 09, 2015
On 6/8/15 8:26 PM, Ilya Yaroshenko wrote:
> On Sunday, 7 June 2015 at 18:27:16 UTC, Robert burner Schadek wrote:
>> Phobos is awesome, the libs of go, python and rust only have better
>> marketing.
>> As discussed on dconf, phobos needs to become big and blow the rest
>> out of the sky.
>>
>> http://wiki.dlang.org/DIP80
>>
>> lets get OT, please discuss
>
> There are
> https://github.com/9il/simple_matrix and
> https://github.com/9il/cblas .
> I will try to rework them for Phobos.
>
> Any ideas and suggestions?
>
> Some notes about portability:
>    1. OS X has Accelerated framework builtin.
>    2. Linux has blast by default or it can be easily installed. However
> default blast is very slow. The openBLAS is preferred.
>    3. Looks like there is no simple way to have BLAS support on Windows.
>
> Should we provide BLAS library with DMD for Windows and maybe Linux?

I think licensing matters would make this difficult. What I do think we can do is:

(a) Provide standard data layouts in std.array for the typical shapes supported by linear algebra libs: row major, column major, alongside with striding primitives.

(b) Provide signatures for C and Fortran libraries so people who have them can use them easily with D.

(c) Provide high-level wrappers on top of those functions.


Andrei





June 09, 2015
On Monday, 8 June 2015 at 03:53:52 UTC, Manu wrote:
> I've been humoring the idea of porting my engine to D. It's about 15
> years of development, better/cleaner than most proprietary engines
> I've used at game studios.
> I wonder if there would be interest in this? Problem is, I need all
> the cross compilers to exist before I pull the plug on the C code... a
> game engine is no good if it's not portable to all the consoles under
> the sun. That said, I think it would be a good case-study to get the
> cross compilers working against.

What cross-compilers are you waiting for?  Nobody is working on XBone or PS4 as far as I know, but Dan's work on iOS seems pretty far along, if you want to try that out.
June 09, 2015
On Tuesday, 9 June 2015 at 06:59:07 UTC, Andrei Alexandrescu wrote:
> On 6/8/15 8:26 PM, Ilya Yaroshenko wrote:
>> On Sunday, 7 June 2015 at 18:27:16 UTC, Robert burner Schadek wrote:
>>> Phobos is awesome, the libs of go, python and rust only have better
>>> marketing.
>>> As discussed on dconf, phobos needs to become big and blow the rest
>>> out of the sky.
>>>
>>> http://wiki.dlang.org/DIP80
>>>
>>> lets get OT, please discuss
>>
>> There are
>> https://github.com/9il/simple_matrix and
>> https://github.com/9il/cblas .
>> I will try to rework them for Phobos.
>>
>> Any ideas and suggestions?
>>
>> Some notes about portability:
>>    1. OS X has Accelerated framework builtin.
>>    2. Linux has blast by default or it can be easily installed. However
>> default blast is very slow. The openBLAS is preferred.
>>    3. Looks like there is no simple way to have BLAS support on Windows.
>>
>> Should we provide BLAS library with DMD for Windows and maybe Linux?
>
> I think licensing matters would make this difficult. What I do think we can do is:
>
> (a) Provide standard data layouts in std.array for the typical shapes supported by linear algebra libs: row major, column major, alongside with striding primitives.

I don't think this is quite the right approach. Multidimensional arrays and matrices are about accessing and iteration over data, not data structures themselves. The standard layouts are common special cases.

> (b) Provide signatures for C and Fortran libraries so people who have them can use them easily with D.
>
> (c) Provide high-level wrappers on top of those functions.
>
>
> Andrei

That is how e.g. numpy works and it's OK, but D can do better.

Ilya, I'm very interested in discussing this further with you. I have a reasonable idea and implementation of how I would want the generic n-dimensional types in D to work, but you seem to have more experience with BLAS and LAPACK than me* and of course interfacing with them is critical.

*I rarely interact with them directly.
June 09, 2015
On Tuesday, 9 June 2015 at 08:50:16 UTC, John Colvin wrote:
> On Tuesday, 9 June 2015 at 06:59:07 UTC, Andrei Alexandrescu wrote:
>> On 6/8/15 8:26 PM, Ilya Yaroshenko wrote:
>>> On Sunday, 7 June 2015 at 18:27:16 UTC, Robert burner Schadek wrote:
>>>> Phobos is awesome, the libs of go, python and rust only have better
>>>> marketing.
>>>> As discussed on dconf, phobos needs to become big and blow the rest
>>>> out of the sky.
>>>>
>>>> http://wiki.dlang.org/DIP80
>>>>
>>>> lets get OT, please discuss
>>>
>>> There are
>>> https://github.com/9il/simple_matrix and
>>> https://github.com/9il/cblas .
>>> I will try to rework them for Phobos.
>>>
>>> Any ideas and suggestions?
>>>
>>> Some notes about portability:
>>>   1. OS X has Accelerated framework builtin.
>>>   2. Linux has blast by default or it can be easily installed. However
>>> default blast is very slow. The openBLAS is preferred.
>>>   3. Looks like there is no simple way to have BLAS support on Windows.
>>>
>>> Should we provide BLAS library with DMD for Windows and maybe Linux?
>>
>> I think licensing matters would make this difficult. What I do think we can do is:
>>
>> (a) Provide standard data layouts in std.array for the typical shapes supported by linear algebra libs: row major, column major, alongside with striding primitives.
>
> I don't think this is quite the right approach. Multidimensional arrays and matrices are about accessing and iteration over data, not data structures themselves. The standard layouts are common special cases.

Probably we need both approaches:

[1]. Multidimensional random access slices (ranges, not only arrays)

We can do it easily:

size_t anyNumber;
auto ar = new int[3 * 8 * 9 + anyNumber];
auto slice = Slice[0..3, 4..8, 1..9];
assert(ar.canBeSlicedWith(slice)); //checks that ar.length <= 3 * 8 * 9

auto tensor = ar.sliced(slice);
tensor[0, 1, 2] = 4;

auto matrix = tensor[0..$, 1, 0..$];
assert(matrix[0, 2] == 4);


[2]. BLAS Transposed.no/yes and Major.row/column (naming can be changed) flags for plain 2D matrixes based on
  2.1 D arrays (both GC and manual memory management)
  2.2 std.container.array (RefCounted)
RowMajor and RowMinor are not needed if Transposed is already defined. But this stuff helps engineers implement software in terms of corresponding mathematical documentation.

I hope to create @nogc versions for 2.1 and 2.2 (because GC is not needed for slices).
Furthermore [2] can be based on [1].


>> (b) Provide signatures for C and Fortran libraries so people who have them can use them easily with D.
>>
>> (c) Provide high-level wrappers on top of those functions.
>>
>>
>> Andrei
>
> That is how e.g. numpy works and it's OK, but D can do better.
>
> Ilya, I'm very interested in discussing this further with you. I have a reasonable idea and implementation of how I would want the generic n-dimensional types in D to work, but you seem to have more experience with BLAS and LAPACK than me* and of course interfacing with them is critical.
>
> *I rarely interact with them directly.

John, please describe your ideas and use cases. I think github issues is more convenient place. You have opened https://github.com/kyllingstad/scid/issues/24 . So I think we can past our code examples at SciD issue.
June 09, 2015
> size_t anyNumber;
> auto ar = new int[3 * 8 * 9 + anyNumber];
> auto slice = Slice[0..3, 4..8, 1..9];
> assert(ar.canBeSlicedWith(slice)); //checks that ar.length <= 3 * 8 * 9
>
> auto tensor = ar.sliced(slice);
> tensor[0, 1, 2] = 4;
>
> auto matrix = tensor[0..$, 1, 0..$];
> assert(matrix[0, 2] == 4);

assert(&matrix[0, 2] is &tensor[0, 1, 2]);
June 09, 2015
On 9 June 2015 at 17:32, Joakim via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On Monday, 8 June 2015 at 03:53:52 UTC, Manu wrote:
>>
>> I've been humoring the idea of porting my engine to D. It's about 15
>> years of development, better/cleaner than most proprietary engines
>> I've used at game studios.
>> I wonder if there would be interest in this? Problem is, I need all
>> the cross compilers to exist before I pull the plug on the C code... a
>> game engine is no good if it's not portable to all the consoles under
>> the sun. That said, I think it would be a good case-study to get the
>> cross compilers working against.
>
>
> What cross-compilers are you waiting for?  Nobody is working on XBone or PS4 as far as I know, but Dan's work on iOS seems pretty far along, if you want to try that out.

XBone works. PS4 is probably easy or already working.
Android, iOS are critical. Nintendo platforms also exist.
I would hope we'll see Enscripten and NaCl at some point; I could use
them at work right now.

The phones do appear to be moving recently, which is really encouraging.
June 09, 2015
> Ilya, I'm very interested in discussing this further with you. I have a reasonable idea and implementation of how I would want the generic n-dimensional types in D to work, but you seem to have more experience with BLAS and LAPACK than me* and of course interfacing with them is critical.
>
> *I rarely interact with them directly.

I have created Phobos PR. Now we can discuss it at GitHub.
https://github.com/D-Programming-Language/phobos/pull/3397
June 09, 2015
On Tuesday, 9 June 2015 at 08:50:16 UTC, John Colvin wrote:
> I don't think this is quite the right approach. Multidimensional arrays and matrices are about accessing and iteration over data, not data structures themselves. The standard layouts are common special cases.

Yes, I really want to D supports multidimensional arrays, matrices, rational numbers and quaternions.

I believe that Phobos must support some common methods of linear algebra and general mathematics. I have no desire to join D with Fortran libraries :)

Rational numbers and quaternions have already been implemented are:
https://github.com/k3kaimu/carbon/blob/master/source/carbon/rational.d
https://github.com/k3kaimu/carbon/blob/master/source/carbon/quaternion.d

Satisfactory developments with matrices have here:
https://github.com/k3kaimu/carbon/blob/master/source/carbon/linear.d