Skip to content

Vectorize Macaulay2 functions #177

@dkahle

Description

@dkahle

Last night I ran into this problem with dimension(): I wanted to use primary_decomposition() to compute a primary decomposition of an ideal. In Macaulay2, the result of a call to primaryDecomposition is a list of ideals. Fine. (I actually created a class for this, BTW: m2_ideal_list and m2_ideal_list_pointer; it just seems these things will be pretty common.)

The problem became the dimension() is not vectorized in R or Macaulay2. In other words, if you have an ideal I in Macaulay2, you compute its dimension with dim(I). But if it's a List whose elements are ideals, that won't work, and instead you have to use apply(i, dim), so I baked that into dimension(): it now works on ideals and lists of ideals.

I think the same behavior should apply more broadly. Off the top of my head, we have functions like factor_poly() which wraps the M2 code factor(poly), but if you give it a mpolyList or a character vector of poly's, I expect it to error. I think it would be more sensible to have Macaulay2 vectorize it. So: check if the thing is a vector, and if it is use Macaulay2's apply(x, f) construct to get the job done.

Thoughts?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions