Opened 2 years ago

Closed 2 years ago

#28566 closed enhancement (fixed)

improve conversions between Macaulay2 and Sage

Reported by: gh-mwageringel Owned by:
Priority: major Milestone: sage-9.0
Component: interfaces: optional Keywords: macaulay2, IMA Coding Sprint
Cc: saliola, dimpase, gh-antonleykin Merged in:
Authors: Markus Wageringel Reviewers: Franco Saliola
Report Upstream: N/A Work issues:
Branch: 21025bd (Commits, GitHub, GitLab) Commit: 21025bd8c1b49daacee50d6a892df97dadf0f93f
Dependencies: Stopgaps:

Status badges

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 gh-mwageringel

  • Authors set to Markus Wageringel
  • Branch set to public/interfaces/m2/28566
  • Cc saliola dimpase added
  • Commit set to 602f6eb2663bb4a3cce1da4d9f69ac5eceda8e05

New commits:

03d146028566: implement _matrix_() in Macaulay2 interface
5308c9028566: implement conversion of vectors in Macaulay2 interface
602f6eb28566: preserve variable name in Macaulay2 Galois fields

comment:2 Changed 2 years ago by gh-mwageringel

  • Cc gh-antonleykin added
  • Keywords IMA Coding Sprint added

comment:3 Changed 2 years ago by git

  • Commit changed from 602f6eb2663bb4a3cce1da4d9f69ac5eceda8e05 to ce24186223fc5340a15d06b0a708a2f8ddb6e0f8

Branch pushed to git repo; I updated commit sha1. New commits:

ce24186simplify some doctests

comment:4 follow-up: Changed 2 years ago by saliola

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).

Last edited 2 years ago by saliola (previous) (diff)

comment:5 Changed 2 years ago by git

  • Commit changed from ce24186223fc5340a15d06b0a708a2f8ddb6e0f8 to 21025bd8c1b49daacee50d6a892df97dadf0f93f

Branch pushed to git repo; I updated commit sha1. New commits:

21025bd28566: use ring-preserving constructor for Macaulay2 matrix/vector

comment:6 in reply to: ↑ 4 Changed 2 years ago by gh-mwageringel

Replying to saliola:

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).

Thanks, I have changed it.

comment:7 Changed 2 years ago by saliola

  • Status changed from new to needs_review

comment:8 Changed 2 years ago by saliola

  • Reviewers set to Franco Saliola
  • Status changed from needs_review to positive_review

comment:9 Changed 2 years ago by vbraun

  • Branch changed from public/interfaces/m2/28566 to 21025bd8c1b49daacee50d6a892df97dadf0f93f
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.