Inplace matrix operations #2669
Replies: 3 comments
-
Thanks for your question Joaquin, it's a good question. mathjs is designed with immutability in mind, so all operations like For example moment.js has this behavior where doing const start = moment()
const end = start.add(1, 'day') // whoops I accidentally changed start too! So in general I prefer immutable solutions. Using methods on a matrix instead which mutate the matrix itself can indeed improve performance when working with large matrices, so there it can be a very valid case. I doubt though whether it would be a good idea to combine both models (mutable and immutable) in the same library, that can lead to confusion I'm afraid. If you have a limited set of operations you want to perform on the large matrices you have, you could maybe extend the |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer. And yes, you are right: the inplace operations should be explicit, to avoid confusion. |
Beta Was this translation helpful? Give feedback.
-
Great to hear mathjs is such a good fit for your application. One area where there is much room for improvement in mathjs is performance (even without considering mutating matrices themselves). If you like I can email you a paper Eric and I wrote about mathjs a couple of years ago, which also has a section about performance. There are also some issues here in the issues section discussion options to improve performance. |
Beta Was this translation helpful? Give feedback.
-
Hello !
I am a newb in mathjs and this is my first time posting here...
My question:
When dealing with big matrices allocating memory can be costly.
Using subset I wrote a piece of code (see below) that allows to assign a new value in an already allocated matrix.
I was wondering is there is another way of doing so.
Also it would be great if operations could be done inplace. example
Or maybe there is a way of doing inline operations and I haven't figure it out....
Beta Was this translation helpful? Give feedback.
All reactions