Algebrite icon indicating copy to clipboard operation
Algebrite copied to clipboard

dedicated helper functions to get/set a row/column of a matrix (2D tensor)

Open CesMak opened this issue 8 years ago • 5 comments

Hey There i wonder if its is possible to set and get a vector within a matrix with algebrite I just found getting an entry within a matrix with cofactor.....

what I want is something like: getRowVectorofMatrix(Matrix,Row) and the same for Columns a getter and a setter this would be a really nice feature for me.

Best Markus

CesMak avatar Aug 22 '17 17:08 CesMak

let's stick to 2D as you mention - get/set of a row is trivial, as matrixes are stored by rows. Get/Set of a column is less trivial. In the meantime we have a function, just transpose, get/set, then transpose again.

davidedc avatar Aug 23 '17 14:08 davidedc

Does not seems trivial to me at API level (how to set a matrix in JS ?) BTW I hope I am not too stupid but I cannot figure out why Algebrite.eval('[[1,2],[3,4]]').toString() gives me "[[-1,-2],[-3,-4]]" .ful CAS Many thanks for helping me with this wonderfull CAS

Jean-MarieL avatar Jul 25 '18 19:07 Jean-MarieL

Other points I didn't think about:

  • setting a row/column should trigger a check so the number of elements in the row/column is correct
  • getting a row/column: should we get a row/column by reference or by value? (to be checked what similar sw does).

davidedc avatar Jul 25 '18 21:07 davidedc

Thanks, Davide, for your immediate reaction. I am eager to read from you again ! Bon courage pour tous vos développements. Jean-Marie

Le 25 juil. 2018 à 23:26, Davide Della Casa [email protected] a écrit :

No you are right it's not trivial. Matrixes are not stored "by rows", see below "elem" is a flat array of four elements, so it becomes a little cumbersome to get/set the right elements.

Algebrite.run('a = [[1,2],[3,4]]') "" Algebrite.eval("a").tensor.elem (4) [U, U, U, U] Plus there are other points I didn't think about:

setting a row/column should trigger a check so the number of elements in the row/column is correct getting a row/column: should we get a row/column by reference or by value? (to be checked what similar sw does). — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/davidedc/Algebrite/issues/51#issuecomment-407901283, or mute the thread https://github.com/notifications/unsubscribe-auth/AH7HOE9WEWyJy6eWzmjiaI-di5TPcs6Tks5uKOKCgaJpZM4O-97m.

Jean-MarieL avatar Jul 26 '18 16:07 Jean-MarieL

Hi @Jean-MarieL sorry I got confused in a previous comment. Indeed matrices are stored by row, meaning:

a=[[1,2],[3,4]]
a[1]
> [1,2]
a[2] = [5,6]
a
> [[1,2],[5,6]]

so it should be easy to get/set a row.

As for why you'd get Algebrite.eval('[[1,2],[3,4]]').toString() gives me "[[-1,-2],[-3,-4]]" that's indeed very strange. If you keep getting that result please open another issue and we'll look into that further.

davidedc avatar Jul 26 '18 20:07 davidedc