M2
M2 copied to clipboard
Promote
This PR addresses some of the issues raised in #3184. before:
i1 : R=QQ[x]
o1 = R
o1 : PolynomialRing
i2 : S=R[y]
o2 = S
o2 : PolynomialRing
i3 : 1/x+1/y
stdio:3:3:(3): error: expected pair to have a method for '+'
i4 : matrix{{1/x}}*matrix{{1/y}}
stdio:4:13:(3): error: maps over incompatible rings
i5 : promote(1/x_R,frac S)
stdio:5:7:(3): error: no method found for applying promote to:
1
argument 1 : - (of class frac R)
x
argument 2 : frac S
i6 : lift(1/x_S,frac R)
stdio:6:4:(3): error: no method found for applying lift to:
1
argument 1 : - (of class frac S)
x
argument 2 : frac R
and
i1 : R=QQ[x]
o1 = R
o1 : PolynomialRing
i2 : T=R**QQ[z]
o2 = T
o2 : PolynomialRing
i3 : x_R*z
stdio:3:3:(3): error: expected pair to have a method for '*'
after:
i1 : R=QQ[x]
o1 = R
o1 : PolynomialRing
i2 : S=R[y]
o2 = S
o2 : PolynomialRing
i3 : 1/x+1/y
y + x
o3 = -----
x*y
o3 : frac S
i4 : matrix{{1/x}}*matrix{{1/y}}
o4 = | 1/xy |
1 1
o4 : Matrix (frac S) <-- (frac S)
i5 : promote(1/x_R,frac S)
1
o5 = -
x
o5 : frac S
i6 : lift(1/x_S,frac R)
1
o6 = -
x
o6 : frac R
and
i1 : R=QQ[x]
o1 = R
o1 : PolynomialRing
i2 : T=R**QQ[z]
o2 = T
o2 : PolynomialRing
i3 : x_R*z
o3 = x*z
o3 : T
In particular it introduces a new method setupPromote which makes it easy to (automatically) promote from A -> B given a map f: A -> B.