You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
This sounds reasonable. Quite a few of our functions expect a list of parameters as their main argument. How difficult is it to implement vectorization, and would it break any current usage of these functions?
In particular, would it require adding a third calling option? We already have all combinations of "_" and "." versions, adding a third to make 8 different functions would be chaos.
Last night I ran into this problem with
dimension()
: I wanted to useprimary_decomposition()
to compute a primary decomposition of an ideal. In Macaulay2, the result of a call toprimaryDecomposition
is a list of ideals. Fine. (I actually created a class for this, BTW:m2_ideal_list
andm2_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 idealI
in Macaulay2, you compute its dimension withdim(I)
. But if it's aList
whose elements are ideals, that won't work, and instead you have to useapply(i, dim)
, so I baked that intodimension()
: 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 codefactor(poly)
, but if you give it ampolyList
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'sapply(x, f)
construct to get the job done.Thoughts?
The text was updated successfully, but these errors were encountered: