Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "vector" constructor methods taking ring as input #3669

Merged
merged 1 commit into from
Feb 23, 2025

Conversation

d-torrance
Copy link
Member

Currently, we can do the following for matrices and it works as expected:

i1 : matrix(QQ, {{1, 2}, {3, 4}})

o1 = | 1 2 |
     | 3 4 |

              2       2
o1 : Matrix QQ  <-- QQ

But it doesn't work for vectors:

i2 : vector(QQ, {1, 2, 3})
stdio:2:6:(3): error: no method found for applying vector to:
     argument 1 :  QQ (of class Ring)
     argument 2 :  {1, 2, 3} (of class List)

We add this functionality. In particular, given a Ring (or RingFamily, so we catch RR, CC, and RRi) and a matrix, list, number, or ring element, we construct an element of the appropriate free module over that ring:

i1 : vector(QQ, {1, 2, 3})

o1 = | 1 |
     | 2 |
     | 3 |

       3
o1 : QQ

The output will be an element of the appropriate free module over that
ring.
@d-torrance d-torrance requested a review from mahrud February 23, 2025 01:48
Copy link
Member

@mahrud mahrud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had convinced myself that vector(QQ^3, {1, 2, 3}) works and it's just as good as vector(QQ, {1, 2, 3}), but I see the appeal.

@d-torrance d-torrance merged commit f7ac45d into Macaulay2:development Feb 23, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants