Replies: 1 comment 1 reply
-
If a mathjs function crashes on a valid input, that is a bug. Please file this example as an issue, thank you. On the other hand, as to your suggested code, it cannot be correct to
If I am reading your code correctly, it would return the same thing on all three of these inputs? Of course, some matrices may simply be too large to represent in memory. However, your example does not crash on my machine:
successfully prints out
and runs to completion. So please if/when you do file an issue, please post as exact a way as possible to generate the crash, and make sure to note what environment you are running mathjs in (I ran the above code in Node v22.13.1, for example; but perhaps it does crash some browser when it runs in-browser -- just let us know the details of how you are running it). |
Beta Was this translation helpful? Give feedback.
-
I recently had a case where the new dimensions of a matrix were [1, 1, 1, 1, 318, 512, 512]. I attempted to use the reshape function, but it was hitting the heap limit and failing. I ended up importing the function and adding a case where if the size of a dimension is 1, don't do anything and keep going. That seemed to work well.
I do not think having 1 size for a dimension is common, but in some cases I definitely think it is a improvement. The following is the modification I made.
Beta Was this translation helpful? Give feedback.
All reactions