i1 : R = QQ[x_{1,1}..x_{4,4}];
i2 : indexOfVariable x_{2,3}
o2 = {2, 3}
o2 : List
Currently, via the method variableIndex in MatrixSchubert.m2, a variable is type-cast to a string, parsed with regex, and the index is type-cast back to some M2 type through value.
variableIndex RingElement := Sequence => (elem) -> (
--convert to string, parse, and select index, convert back
value replace(".*_+", "", toString elem)
)
This is bad. After some discussion, the following will accomplish the same task, but in a better way:
indexOfVariable = v -> ( i := index v; last toList (ring v).generatorSymbols#i )
However, this requires debug Core to be executed so that generatorSymbols can be used. Is there a way to do this without using debug Core? If not, how to do this in the setting of a package?
TL,DR Implement a way to get the index of an
IndexedVariable
or generator of a polynomial ring.Examples
Currently, via the method
variableIndex
inMatrixSchubert.m2
, a variable is type-cast to a string, parsed with regex, and the index is type-cast back to some M2 type throughvalue
.This is bad. After some discussion, the following will accomplish the same task, but in a better way:
However, this requires
debug Core
to be executed so thatgeneratorSymbols
can be used. Is there a way to do this without usingdebug Core
? If not, how to do this in the setting of a package?