Perl6-Math-Matrix
Perl6-Math-Matrix copied to clipboard
OO vs native shaped array?
Looking at the implementation everything is row based and OO? Wouldnt it be better to wrap a native shaped array of num64? That way the memory will be the most efficient and you will gain all the benefits of vectorised SSE optimisations that might be made in the JIT around this area.
http://design.perl6.org/S09.html#Compact_arrays and http://design.perl6.org/S09.html#Fixed-size_arrays for some reference.
I have planned to use native shaped array, however, i still encounter some issues with non implemented parts of native arrays, you can see the code there: https://github.com/pierre-vigier/Perl6-Math-Matrix/tree/shaped-array Not finished yet, but if you have any inputs, one of the problem i have is in add methods, where: $.cells >>+<< $b.cells triggers an error: Type check failed in binding @dims; expected Positional but got Any Not sure why yet, also, to keep the syntax: $matrix[row][column], i encounter that:
my int @a[2,2] = (1,2),(3,4);
say @a[1][1];
that gives me:
Partially dimensioned views of arrays not yet implemented. Sorry.
in block <unit> at <unknown file> line 1
However the idea is to use native array, as for now, perfomance are pretty poor with the current implementation
i will look into that next
while i support the notion it will demand some massivly different internals and I think i will outsource this in a module like Math::Matrix::Native
I guess the first think would be to assess if the "glitches" i was seeing then are now solved on new version of perl6. As stated above, my first idea was to do everything with Native array, however, i encountered some blocking issues at the time
yes i looked into it but could not understood it fully what exactly was the glitch?
When trying to access element on shaped array with syntax @a[1][1], program was crashing, as of today, it is still not implemented. However, @a[1;1] .
But more to the point, let's say i have a shaped array for the matrix of 3x3, and i want to get the middle row, @matrix[1] will crash with the same error, @matrix[1;*] as well
are these results of recent tests?
A few hours ago, however, not the latest version of perl6, but still not too old:
This is Rakudo version 2018.01-100-g156876dbf built on MoarVM version 2018.01-77-g9a029b408 implementing Perl 6.c.
thanks, so i put it on backburner , my main issue for now is raise quality (docs tests consistency of what we have and add some easy things (split join, tensorproduct) and eigenvalues)
its still a hounting idea maybe write a parallel variant to experiment with
On moar 2018.08 , we still have the same "issue":
> my int @a[2,2] = (1,2),(3,4);
[[1 2] [3 4]]
> say @a[1][1];
Partially dimensioned views of shaped arrays not yet implemented. Sorry.
in block <unit> at <unknown file> line 1
thanks
@lichtkind @pierre-vigier please open tickets on https://github.com/rakudo/rakudo/issues. I'm very interested in seeing this implemented with native arrays. If it is slower, we can have nice benchmarks (native vs non-native) and maybe that will result in actionable tickets.
Also check https://github.com/perl-gsoc-2019/ideas, maybe some of the work can be done as a project? I also wonder if there's anything that needs to be added to core (generally it's not the best idea to pile things up in core, but looking at the success of numpy, maybe that's not the worst idea?).
i will check this. However, the current design gave up on the idea of NSA and there has to be some planning done, before we can reach for the fruits of it again. So yes I will react but have to make up my mind on some technical details before.