Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Most Efficient Internal Representation of Matrices #14

Open
wkhudgins92 opened this issue Aug 3, 2016 · 3 comments
Open

Most Efficient Internal Representation of Matrices #14

wkhudgins92 opened this issue Aug 3, 2016 · 3 comments

Comments

@wkhudgins92
Copy link

In an email with @GordonLesti , the topic of efficient internal representation of matrices was discussed. There were concerns about the current approach of using nested arrays. The other alternative is to store one single array, and store another variable for the shape of the matrix. Currently I am researching which would be optimal.

I know you had mentioned that in some cases the nested array performed better and in other cases the single array representation performed better. Do you happen to remember or have it documented which operations were most efficient with which representation? That would be helpful information. I can generate new benchmarks if needed, but trying to save that step.

As I gain more insight into this, I will update this thread with relevant information and proposals. Thanks.

@rickynguyen4590
Copy link

Hi, I don't think array it the best solution for this project. I think the best solution is we have to write a new extension and store our matrix using fixed-size C++ array, and all of elements of this array should be the same type.

As I remember that the numpy loop with nditer is faster 10 times that native python loop, because it run on C++ instead of python. PHP using HashTable for storing array so it not really efficiency

@GordonLesti
Copy link
Member

Hello @rickynguyen
thank you very much for your feedback. Yes, real arrays would be fantastic, but in my eyes it is no option to transform a plain PHP library into a PHP extension. I started developing on version 2 of NumPHP with PHP 7 as requirement and have not changed the internal representation yet. My hope is that packed arrays will give some performance improvement.
Maybe after a stable release it can make sense to create a PHP array extension that will be used as suggested dependency.

@rickynguyen4590
Copy link

Just do some researching about how PHP7 optimized their array. I see that they store zval inside Hashtable instead of pointer like PHP5 before. Right now I think you has chosen the right way..! 🎈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants