Opened 2 years ago
Closed 2 years ago
#28566 closed enhancement (fixed)
improve conversions between Macaulay2 and Sage
Reported by:  ghmwageringel  Owned by:  

Priority:  major  Milestone:  sage9.0 
Component:  interfaces: optional  Keywords:  macaulay2, IMA Coding Sprint 
Cc:  saliola, dimpase, ghantonleykin  Merged in:  
Authors:  Markus Wageringel  Reviewers:  Franco Saliola 
Report Upstream:  N/A  Work issues:  
Branch:  21025bd (Commits, GitHub, GitLab)  Commit:  21025bd8c1b49daacee50d6a892df97dadf0f93f 
Dependencies:  Stopgaps: 
Description
This ticket implements and improves conversions between Macaulay2 and Sage:
 vectors/free module elements
 matrices: The function
InterfaceElement._matrix_()
is implemented to allow for this syntax:sage: A = macaulay2('matrix {{1,2},{3,4}}') sage: matrix(QQ, A) [1 2] [3 4]
This ticket also fixes an issue where the elements are not promoted to the correct ring:sage: R.<x,y> = QQ[] sage: m = macaulay2(matrix(R, [[1, 2], [3, 4]])) sage: m.ring() # should be R ZZ
 finite fields: An issue is fixed where the generator names are not preserved:
sage: K = GF(49, 'b') sage: K.gens(), macaulay2(K).gens() # should be the same ((b,), {a})
Change History (9)
comment:1 Changed 2 years ago by
 Branch set to public/interfaces/m2/28566
 Cc saliola dimpase added
 Commit set to 602f6eb2663bb4a3cce1da4d9f69ac5eceda8e05
comment:2 Changed 2 years ago by
 Cc ghantonleykin added
 Keywords IMA Coding Sprint added
comment:3 Changed 2 years ago by
 Commit changed from 602f6eb2663bb4a3cce1da4d9f69ac5eceda8e05 to ce24186223fc5340a15d06b0a708a2f8ddb6e0f8
Branch pushed to git repo; I updated commit sha1. New commits:
ce24186  simplify some doctests

comment:4 followup: ↓ 6 Changed 2 years ago by
I reviewed all the changes up to this point (602f6eb) and have only a couple of minor suggestions for the presentation of doctests (see ce24186).
After discussions, it seems that instead of using promote
in M2, one should use the matrix(R,v)
constructor in M2; see matrix(R,v) documentation for M2.
This also applies to constructing vectors: first construct a matrix in M2 over the correct base ring and then apply the vector command vector(Matrix)
.
comment:5 Changed 2 years ago by
 Commit changed from ce24186223fc5340a15d06b0a708a2f8ddb6e0f8 to 21025bd8c1b49daacee50d6a892df97dadf0f93f
Branch pushed to git repo; I updated commit sha1. New commits:
21025bd  28566: use ringpreserving constructor for Macaulay2 matrix/vector

comment:6 in reply to: ↑ 4 Changed 2 years ago by
Replying to saliola:
After discussions, it seems that instead of using
promote
in M2, one should use thematrix(R,v)
constructor in M2; see matrix(R,v) documentation for M2.This also applies to constructing vectors: first construct a matrix in M2 over the correct base ring and then apply the vector command
vector(Matrix)
.
Thanks, I have changed it.
comment:7 Changed 2 years ago by
 Status changed from new to needs_review
comment:8 Changed 2 years ago by
 Reviewers set to Franco Saliola
 Status changed from needs_review to positive_review
comment:9 Changed 2 years ago by
 Branch changed from public/interfaces/m2/28566 to 21025bd8c1b49daacee50d6a892df97dadf0f93f
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
28566: implement _matrix_() in Macaulay2 interface
28566: implement conversion of vectors in Macaulay2 interface
28566: preserve variable name in Macaulay2 Galois fields