_new_c
, e.g.,
cdef _new_c(self, defining data): cdef FreeModuleElement_generic_dense x x = PY_NEW(FreeModuleElement_generic_dense) x._parent = self._parent x._entries = v
SAGE has a special system in place for handling arithmetic operations for all Element subclasses. There are various rules that must be followed by both arithmetic implementors and callers.
A quick summary for the impatient:
Now in more detail. The aims of this system are to provide (1) an efficient calling protocol from both python and pyrex, (2) uniform coercion semantics across SAGE, (3) ease of use, (4) readability of code.
We will take addition of RingElements as an example; all other operators and classes are similar. There are four relevant functions.
def RingElement.__add__
This function is called by python or pyrex when the binary "+" operator is encountered. It ASSUMES that at least one of its arguments is a RingElement; only a really twisted programmer would violate this condition. It has a fast pathway to deal with the most common case where the arguments have the same parent. Otherwise, it uses the coercion module to work out how to make them have the same parent. After any necessary coercions have been performed, it calls _add_c to dispatch to the correct underlying addition implementation.
Note that although this function is declared as def, it doesn't have the usual overheads associated with python functions (either for the caller or for __add__ itself). This is because python has optimised calling protocols for such special functions.
cdef RingElement._add_c
DO ***NOT*** OVERRIDE THIS FUNCTION.
The two arguments to this function MUST have the SAME PARENT. Its return value MUST have the SAME PARENT as its arguments.
If you want to add two objects from pyrex, and you know that their parents are the same object, you are encouraged to call this function directly, instead of using "x + y".
This function dispatches to either _add_ or _add_c_impl as appropriate. It takes necessary steps to decide whether a pyrex implementation of _add_c_impl has been overridden by some python implementation of _add_. The code is optimised in favour of reaching _add_c_impl as soon as possible.
def RingElement._add_
This is the function you should override to implement addition in a python subclass of RingElement.
WARNING: if you override this in a *pyrex* class, it won't get called. You should override _add_c_impl instead. It is especially important to keep this in mind whenever you move a class down from python to pyrex.
The two arguments to this function are guaranteed to have the SAME PARENT. Its return value MUST have the SAME PARENT as its arguments.
If you want to add two objects from python, and you know that their parents are the same object, you are encouraged to call this function directly, instead of using "x + y".
The default implementation of this function is to call _add_c_impl, so if no-one has defined a python implementation, the correct pyrex implementation will get called.
cdef RingElement._add_c_impl
This is the function you should override to implement addition in a pyrex subclass of RingElement.
The two arguments to this function are guaranteed to have the SAME PARENT. Its return value MUST have the SAME PARENT as its arguments.
DO ***NOT*** CALL THIS FUNCTION DIRECTLY.
(Exception: you know EXACTLY what you are doing, and you know exactly which implementation you are trying to call; i.e. you're not trying to write generic code. In particular, if you call this directly, your code will not work correctly if you run it on a python class derived from a pyrex class where someone has redefined _add_ in python.)
The default implementation of this function is to raise a NotImplementedError, which will happen if no-one has supplied implementations of either _add_ or _add_c_impl.
For speed, there are also inplace version of the arithmetic commands. DD NOT call them directly, they may mutate the object and will be called when and only when it has been determined that the old object will no longer be accessible from the calling function after this operation.
def RingElement._iadd_
This is the function you should override to inplace implement addition in a python subclass of RingElement.
WARNING: if you override this in a *pyrex* class, it won't get called. You should override _iadd_c_impl instead. It is especially important to keep this in mind whenever you move a class down from python to pyrex.
The two arguments to this function are guaranteed to have the SAME PARENT. Its return value MUST have the SAME PARENT as its arguments.
The default implementation of this function is to call _add_c_impl, so if no-one has defined a python implementation, the correct pyrex implementation will get called.
cdef RingElement._iadd_c_impl
This is the function you should override to inplace implement addition in a pyrex subclass of RingElement.
The two arguments to this function are guaranteed to have the SAME PARENT. Its return value MUST have the SAME PARENT as its arguments.
The default implementation of this function is to call _add_c
Module-level Functions
) |
) |
) |
canonical_coercion(x,y) is what is called before doing an arithmetic operation between x and y. It returns a pair (z,w) such that z is got from x and w from y via canonical coercion and the parents of z and w are identical.
sage: A = Matrix([[0,1],[1,0]]) sage: canonical_coercion(A,1) ([0 1] [1 0], [1 0] [0 1])
) |
) |
) |
Computes
, where
is an integer, and
is an object which
supports multiplication. Optionally an additional argument,
which is used in the case that n == 0:
one: the "unit" element, returned directly (can be anything)
If this is not supplied, int(1) is returned.
sage: from sage.structure.element import generic_power sage: generic_power(int(12),int(0)) 1 sage: generic_power(int(0),int(100)) 0 sage: generic_power(Integer(10),Integer(0)) 1 sage: generic_power(Integer(0),Integer(23)) 0 sage: sum([generic_power(2,i) for i in range(17)]) #test all 4-bit combinations 131071 sage: F = Zmod(5) sage: a = generic_power(F(2), 5); a 2 sage: a.parent() is F True sage: a = generic_power(F(1), 2) sage: a.parent() is F True
sage: generic_power(int(5), 0) 1
) |
Return the global coercion model.
sage: import sage.structure.element as e sage: cm = e.get_coercion_model() sage: cm <sage.structure.coerce.CoercionModel_cache_maps object at ...>
) |
Return True if x is of type AdditiveGroupElement.
) |
Return True if x is of type AlgebraElement.
) |
Return True if x is of type CommutativeAlgebraElement.
) |
Return True if x is of type CommutativeRingElement.
) |
Return True if x is of type DedekindDomainElement.
) |
Return True if x is of type Element.
sage: is_Element(2/3) True sage: is_Element(QQ^3) False
) |
Return True if x is of type EuclideanDomainElement.
) |
Return True if x is of type FieldElement.
) |
Return True if x is of type InfinityElement.
) |
Return True if x is of type IntegralDomainElement.
) |
) |
Return True if x is of type ModuleElement.
This is even faster than using isinstance inline.
sage: is_ModuleElement(2/3) True sage: is_ModuleElement((QQ^3).0) True sage: is_ModuleElement('a') False
) |
Return True if x is of type MonoidElement.
) |
Return True if x is of type MultiplicativeGroupElement.
) |
Return True if x is of type PrincipalIdealDomainElement.
) |
Return True if x is of type RingElement.
) |
) |
) |
Used for unpickling Element objects (and subclasses).
This should work for any Python class deriving from Element, as long as it doesn't implement some screwy __new__() method.
See also Element.__reduce__().
) |
) |
) |
) |
) |
Class: AdditiveGroupElement
Functions: order
) |
Return additive order of element
Special Functions: __invert__
) |
Class: AlgebraElement
Class: CoercionModel
Functions: bin_op,
canonical_coercion
Class: CommutativeAlgebra
Class: CommutativeAlgebraElement
Class: CommutativeRingElement
Functions: divides,
inverse_mod,
mod
) |
Return True if self divides x.
sage: P.<x> = PolynomialRing(QQ) sage: x.divides(x^2) True sage: x.divides(x^2+2) False sage: (x^2+2).divides(x) False sage: P.<x> = PolynomialRing(ZZ) sage: x.divides(x^2) True sage: x.divides(x^2+2) False sage: (x^2+2).divides(x) False
) |
Return an inverse of self modulo the ideal
, if defined,
i.e., if
and self together generate the unit ideal.
) |
Return a representative for self modulo the ideal I (or the ideal generated by the elements of I if I is not an ideal.)
Integers Reduction of 5 modulo an ideal:
sage: n = 5 sage: n.mod(3*ZZ) 2
Reduction of 5 modulo the ideal generated by 3.
sage: n.mod(3) 2
Reduction of 5 modulo the ideal generated by 15 and 6, which is
.
sage: n.mod([15,6]) 2
Univiate polynomials
sage: R.<x> = PolynomialRing(QQ) sage: f = x^3 + x + 1 sage: f.mod(x + 1) -1
When little is implemented about a given ring, then mod may
return simply return
. For example, reduction is not
implemented for
yet. (TODO!)
sage: R.<x> = PolynomialRing(ZZ) sage: f = x^3 + x + 1 sage: f.mod(x + 1) x^3 + x + 1
Multivariate polynomials We reduce a polynomial in two variables modulo a polynomial and an ideal:
sage: R.<x,y,z> = PolynomialRing(QQ, 3) sage: (x^2 + y^2 + z^2).mod(x+y+z) 2*y^2 + 2*y*z + 2*z^2
Notice above that
is eliminated. In the next example,
both
and
are eliminated.
sage: (x^2 + y^2 + z^2).mod( (x - y, y - z) ) 3*z^2 sage: f = (x^2 + y^2 + z^2)^2; f x^4 + 2*x^2*y^2 + y^4 + 2*x^2*z^2 + 2*y^2*z^2 + z^4 sage: f.mod( (x - y, y - z) ) 9*z^4
In this example
is eliminated.
sage: (x^2 + y^2 + z^2).mod( (x^3, y - z) ) x^2 + 2*z^2
Special Functions: _im_gens_
) |
Class: DedekindDomainElement
Class: Element
Subtypes must either call __init__() to set _parent, or may set _parent themselves if that would be more efficient.
Functions: base_base_extend,
base_base_extend_canonical_sym,
base_extend,
base_extend_canonical,
base_extend_canonical_sym,
base_extend_recursive,
base_ring,
category,
is_zero,
n,
parent,
subs,
substitute
) |
Returns the base ring of this element's parent (if that makes sense).
) |
Return True if self equals self.parent()(0). The default implementation is to fall back to 'not self.__nonzero__'.
NOTE: Do not re-implement this method in your subclass but implement __nonzero__ instead.
) |
Return a numerical approximation of x with at least prec bits of precision.
sage: (2/3).n() 0.666666666666667 sage: a = 2/3 sage: pi.n(digits=10) 3.141592654 sage: pi.n(prec=20) # 20 bits 3.1416
) |
Returns parent of this element; or, if the optional argument x is supplied, the result of coercing x into the parent of this element.
) |
Substitutes given generators with given values while not touching other generators. This is a generic wrapper around __call__. The syntax is meant to be compatible with the corresponding method for symbolic expressions.
Input:
sage: x, y = PolynomialRing(ZZ,2,'xy').gens() sage: f = x^2 + y + x^2*y^2 + 5 sage: f((5,y)) 25*y^2 + y + 30 sage: f.subs({x:5}) 25*y^2 + y + 30 sage: f.subs(x=5) 25*y^2 + y + 30 sage: (1/f).subs(x=5) 1/(25*y^2 + y + 30) sage: Integer(5).subs(x=4) 5
) |
This is an alias for self.subs().
Input:
sage: x, y = PolynomialRing(ZZ,2,'xy').gens() sage: f = x^2 + y + x^2*y^2 + 5 sage: f((5,y)) 25*y^2 + y + 30 sage: f.substitute({x:5}) 25*y^2 + y + 30 sage: f.substitute(x=5) 25*y^2 + y + 30 sage: (1/f).substitute(x=5) 1/(25*y^2 + y + 30) sage: Integer(5).substitute(x=4) 5
Special Functions: __cmp__,
__eq__,
__ge__,
__gt__,
__init__,
__le__,
__lt__,
__ne__,
__reduce__,
_cmp_,
_coeff_repr,
_im_gens_,
_is_atomic,
_latex_coeff_repr,
_make_new_with_parent_c,
_repr_,
_richcmp_,
_set_parent
) |
) |
) |
) |
Return the image of self in codomain under the map that sends the images of the generators of the parent of self to the tuple of elements of im_gens.
) |
Return True if and only if parenthesis are not required when
*printing* out any of
,
,
and
.
sage: n = 5; n._is_atomic() True sage: n = x+1; n._is_atomic() False
) |
) |
) |
) |
) |
Input:
Class: EuclideanDomainElement
Functions: degree,
leading_coefficient,
quo_rem
Special Functions: __divmod__,
__floordiv__,
__mod__,
__rdivmod__,
__rfloordiv__,
__rmod__,
_gcd
) |
Return the quotient and remainder of self divided by other.
sage: divmod(5,3) (1, 2)
) |
Quotient of division of self by other. This is denoted //.
) |
Remainder of division of self by other.
sage: R.<x> = ZZ[] sage: x % (x+1) -1 sage: (x**3 + x - 1) % (x**2 - 1) 2*x - 1
) |
Return the greatest common divisor of self and other.
Algorithm 3.2.1 in Cohen, GTM 138.
Class: FieldElement
Functions: divides,
is_unit,
quo_rem
) |
Check whether self divides other, for field elements.
Since this is a field, all values divide all other values, except that zero does not divide any non-zero values.
sage: K.<rt3> = QQ[sqrt(3)] sage: K(0).divides(rt3) False sage: rt3.divides(K(17)) True sage: K(0).divides(K(0)) True sage: rt3.divides(K(0)) True
) |
Return True if self is a unit in its parent ring.
sage: a = 2/3; a.is_unit() True
On the other hand, 2 is not a unit, since its parent is ZZ.
sage: a = 2; a.is_unit() False sage: parent(a) Integer Ring
However, a is a unit when viewed as an element of QQ:
sage: a = QQ(2); a.is_unit() True
Special Functions: __floordiv__,
__rfloordiv__,
_gcd,
_lcm,
_xgcd
) |
) |
Return the greatest common divisor of self and other.
) |
Return the least common multiple of self and other.
) |
Class: FiniteFieldElement
Functions: charpoly,
matrix,
minimal_polynomial,
minpoly,
multiplicative_order,
norm,
nth_root,
trace
) |
Return the characteristic polynomial of self as a polynomial with given variable.
Input:
The result is not cached.
sage: k.<a> = GF(19^2) sage: parent(a) Finite Field in a of size 19^2 sage: a.charpoly('X') X^2 + 18*X + 2 sage: a^2 + 18*a + 2 0 sage: a.charpoly('X', algorithm='pari') X^2 + 18*X + 2
) |
Return the matrix of right multiplication by the element on
the power basis
for the field
extension. Thus the rows of this matrix give the images
of each of the
.
Input:
sage: k.<a> = GF(2^4) sage: a.vector(reverse=True), a.matrix(reverse=True) * a.vector(reverse=True) ((0, 0, 1, 0), (0, 1, 0, 0)) sage: a.vector(), a.matrix() * a.vector() ((0, 1, 0, 0), (0, 0, 1, 0))
) |
Returns the minimal polynomial of this element (over the corresponding prime subfield).
sage: k.<a> = FiniteField(3^4) sage: parent(a) Finite Field in a of size 3^4 sage: b=a**20;p=charpoly(b,"y");p y^4 + 2*y^2 + 1 sage: factor(p) (y^2 + 1)^2 sage: b.minimal_polynomial('y') y^2 + 1
) |
Returns the minimal polynomial of this element (over the corresponding prime subfield).
sage: k.<a> = FiniteField(19^2) sage: parent(a) Finite Field in a of size 19^2 sage: b=a**20;p=b.charpoly("x");p x^2 + 15*x + 4 sage: factor(p) (x + 17)^2 sage: b.minpoly('x') x + 17
) |
Return the multiplicative order of this field element.
) |
Return the norm of self down to the prime subfield.
This is the product of the Galois conjugates of self.
sage: S.<b> = GF(5^2); S Finite Field in b of size 5^2 sage: b.norm() 2 sage: b.charpoly('t') t^2 + 4*t + 2
Next we consider a cubic extension:
sage: S.<a> = GF(5^3); S Finite Field in a of size 5^3 sage: a.norm() 2 sage: a.charpoly('t') t^3 + 3*t + 3 sage: a * a^5 * (a^25) 2
) |
Returns an nth root of self.
Input:
Author: David Roe (2007-10-3)
) |
Return the trace of this element, which is the sum of the Galois conjugates.
sage: S.<a> = GF(5^3); S Finite Field in a of size 5^3 sage: a.trace() 0 sage: a.charpoly('t') t^3 + 3*t + 3 sage: a + a^5 + a^25 0 sage: z = a^2 + a + 1 sage: z.trace() 2 sage: z.charpoly('t') t^3 + 3*t^2 + 2*t + 2 sage: z + z^5 + z^25 2
Special Functions: _im_gens_,
_latex_,
_pari_init_
) |
Used for applying homomorphisms of finite fields.
sage: k.<a> = FiniteField(73^2, 'a') sage: K.<b> = FiniteField(73^4, 'b') sage: phi = k.hom([ b^(73*73+1) ]) sage: phi(0) 0 sage: phi(a) 7*b^3 + 13*b^2 + 65*b + 71
sage: phi(a+3) 7*b^3 + 13*b^2 + 65*b + 1
) |
Return the latex representation of self, which is just the latex representation of the polynomial representation of self.
sage: k.<b> = GF(5^2); k Finite Field in b of size 5^2 sage: b._latex_() 'b' sage: (b^2+1)._latex_() 'b + 4'
) |
Return string that when evaluated in PARI defines this element.
sage: S.<b> = GF(5^2); S Finite Field in b of size 5^2 sage: b._pari_init_() 'Mod(b, Mod(1, 5)*b^2 + Mod(4, 5)*b + Mod(2, 5))' sage: (2*b+3)._pari_init_() 'Mod(2*b + 3, Mod(1, 5)*b^2 + Mod(4, 5)*b + Mod(2, 5))'
Class: InfinityElement
Class: IntegralDomainElement
Functions: is_nilpotent
Class: Matrix
Special Functions: __imul__,
__mul__,
__rmul__
) |
) |
Multiplication of matrix by matrix, vector, or scalar
Gonzalo Tornaria (2007-06-25) - write test cases and fix them
NOTE:
scalar * matrix is implemented (and tested) in class RingElement vector * matrix is implemented (and tested) in class Vector
TEST CASES:
(matrix * matrix)
sage: x, y = var('x, y')
sage: parent(matrix(ZZ,2,2,[1,2,3,4])*matrix(ZZ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Integer Ring sage: parent(matrix(QQ,2,2,[1,2,3,4])*matrix(ZZ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: parent(matrix(ZZ,2,2,[1,2,3,4])*matrix(QQ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: parent(matrix(QQ,2,2,[1,2,3,4])*matrix(QQ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Rational Field
sage: parent(matrix(QQ,2,2,[1,2,3,4])*matrix(ZZ[x],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*matrix(QQ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ,2,2,[1,2,3,4])*matrix(ZZ[x][y],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*matrix(QQ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*matrix(ZZ[x][y],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*matrix(QQ[x],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ[y],2,2,[1,2,3,4])*matrix(ZZ[x][y],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*matrix(QQ[y],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*matrix(ZZ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Integer Ring' sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*matrix(QQ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Rational Field' sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*matrix(ZZ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Integer Ring' sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*matrix(QQ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Rational Field'
(matrix * vector)
sage: parent(matrix(ZZ,2,2,[1,2,3,4])*vector(ZZ,[1,2])) Ambient free module of rank 2 over the principal ideal domain Integer Ring sage: parent(matrix(QQ,2,2,[1,2,3,4])*vector(ZZ,[1,2])) Vector space of dimension 2 over Rational Field sage: parent(matrix(ZZ,2,2,[1,2,3,4])*vector(QQ,[1,2])) Vector space of dimension 2 over Rational Field sage: parent(matrix(QQ,2,2,[1,2,3,4])*vector(QQ,[1,2])) Vector space of dimension 2 over Rational Field
sage: parent(matrix(QQ,2,2,[1,2,3,4])*vector(ZZ[x],[1,2])) Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*vector(QQ,[1,2])) Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ,2,2,[1,2,3,4])*vector(ZZ[x][y],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*vector(QQ,[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*vector(ZZ[x][y],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*vector(QQ[x],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ[y],2,2,[1,2,3,4])*vector(ZZ[x][y],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*vector(QQ[y],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*vector(ZZ[y],[1,2])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring' and 'Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Integer Ring' sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*vector(QQ[y],[1,2])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring' and 'Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in y over Rational Field' sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*vector(ZZ[y],[1,2])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field' and 'Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Integer Ring' sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*vector(QQ[y],[1,2])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field' and 'Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in y over Rational Field'
(matrix * scalar)
sage: parent(matrix(ZZ,2,2,[1,2,3,4])*ZZ(1)) Full MatrixSpace of 2 by 2 dense matrices over Integer Ring sage: parent(matrix(QQ,2,2,[1,2,3,4])*ZZ(1)) Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: parent(matrix(ZZ,2,2,[1,2,3,4])*QQ(1)) Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: parent(matrix(QQ,2,2,[1,2,3,4])*QQ(1)) Full MatrixSpace of 2 by 2 dense matrices over Rational Field
sage: parent(matrix(QQ,2,2,[1,2,3,4])*ZZ[x](1)) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*QQ(1)) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ,2,2,[1,2,3,4])*ZZ[x][y](1)) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*QQ(1)) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*ZZ[x][y](1)) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*QQ[x](1)) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(QQ[y],2,2,[1,2,3,4])*ZZ[x][y](1)) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(matrix(ZZ[x][y],2,2,[1,2,3,4])*QQ[y](1)) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*ZZ[y](1)) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring' and 'Univariate Polynomial Ring in y over Integer Ring' sage: parent(matrix(ZZ[x],2,2,[1,2,3,4])*QQ[y](1)) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring' and 'Univariate Polynomial Ring in y over Rational Field' sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*ZZ[y](1)) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field' and 'Univariate Polynomial Ring in y over Integer Ring' sage: parent(matrix(QQ[x],2,2,[1,2,3,4])*QQ[y](1)) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field' and 'Univariate Polynomial Ring in y over Rational Field'
Class: MinusInfinityElement
Class: ModuleElement
Functions: additive_order,
order
) |
Return the additive order of self.
) |
Return the additive order of self.
Special Functions: __add__,
__iadd__,
__imul__,
__isub__,
__mul__,
__neg__,
__radd__,
__rmul__,
__rsub__,
__sub__,
_add_,
_iadd_,
_ilmul_,
_isub_,
_lmul_,
_lmul_nonscalar,
_neg_,
_rmul_,
_rmul_nonscalar,
_sub_
) |
Top-level addition operator for ModuleElements.
See extensive documentation at the top of element.pyx.
) |
) |
) |
) |
) |
Top-level negation operator for ModuleElements. See extensive documentation at the top of element.pyx.
) |
Top-level subtraction operator for ModuleElements. See extensive documentation at the top of element.pyx.
) |
Python classes should override this function to implement addition.
See extensive documentation at the top of element.pyx.
) |
) |
) |
) |
) |
) |
Python classes should override this function to implement negation.
See extensive documentation at the top of element.pyx.
) |
) |
) |
Python classes should override this function to implement subtraction.
See extensive documentation at the top of element.pyx.
Class: MonoidElement
Functions: multiplicative_order,
order
) |
Return the multiplicative order of self.
) |
Return the multiplicative order of self.
Special Functions: __mul__,
__pow__,
__rmul__,
__rpow__,
_mul_
) |
Top-level multiplication operator for monoid elements. See extensive documentation at the top of element.pyx.
) |
Class: MultiplicativeGroupElement
Functions: order
) |
Return the multiplicative order of self.
Special Functions: __div__,
__invert__,
__rdiv__,
_add_,
_div_
) |
) |
) |
) |
Python classes should override this function to implement division.
Class: PlusInfinityElement
Class: PrincipalIdealDomainElement
Functions: gcd,
lcm,
xgcd
) |
Returns the gcd of self and right, or 0 if both are 0.
) |
Returns the least common multiple of self and right.
) |
Return the extended gcd of self and other, i.e., elements
such that
Note: there is no guarantee on minimality of the cofactors. In the integer case, see documentation for Integer._xgcd() to obtain minimal cofactors.
Class: RingElement
Functions: abs,
additive_order,
is_nilpotent,
is_one,
is_unit,
multiplicative_order,
order
) |
Return the absolute value of self. (This just calls the __abs__ method, so it is equivalent to the abs() built-in function.)
sage: RR(-1).abs() 1.00000000000000 sage: ZZ(-1).abs() 1 sage: CC(I).abs() 1.00000000000000 sage: Mod(-15, 37).abs() Traceback (most recent call last): ... ArithmeticError: absolute valued not defined on integers modulo n.
) |
Return the additive order of self.
) |
Return True if self is nilpotent, i.e., some power of self is 0.
) |
Return the multiplicative order of self, if self is a unit, or raise
ArithmeticError
otherwise.
) |
Return the additive order of self.
Special Functions: __div__,
__idiv__,
__imul__,
__invert__,
__mul__,
__pos__,
__pow__,
__rdiv__,
__rmul__,
__rpow__,
__rtruediv__,
__truediv__,
_div_,
_idiv_,
_imul_,
_mul_
) |
Top-level multiplication operator for ring elements. See extensive documentation at the top of element.pyx.
) |
Top-level division operator for ring elements. See extensive documentation at the top of element.pyx.
) |
) |
) |
Top-level multiplication operator for ring elements. See extensive documentation at the top of element.pyx.
Gonzalo Tornaria (2007-06-25) - write base-extending test cases and fix them
TEST CASES:
(scalar * vector)
sage: x, y = var('x, y')
sage: parent(ZZ(1)*vector(ZZ,[1,2])) Ambient free module of rank 2 over the principal ideal domain Integer Ring sage: parent(QQ(1)*vector(ZZ,[1,2])) Vector space of dimension 2 over Rational Field sage: parent(ZZ(1)*vector(QQ,[1,2])) Vector space of dimension 2 over Rational Field sage: parent(QQ(1)*vector(QQ,[1,2])) Vector space of dimension 2 over Rational Field
sage: parent(QQ(1)*vector(ZZ[x],[1,2])) Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field sage: parent(ZZ[x](1)*vector(QQ,[1,2])) Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field
sage: parent(QQ(1)*vector(ZZ[x][y],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(ZZ[x][y](1)*vector(QQ,[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(QQ[x](1)*vector(ZZ[x][y],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(ZZ[x][y](1)*vector(QQ[x],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(QQ[y](1)*vector(ZZ[x][y],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(ZZ[x][y](1)*vector(QQ[y],[1,2])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(ZZ[x](1)*vector(ZZ[y],[1,2])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Integer Ring' and 'Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Integer Ring' sage: parent(ZZ[x](1)*vector(QQ[y],[1,2])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Integer Ring' and 'Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in y over Rational Field' sage: parent(QQ[x](1)*vector(ZZ[y],[1,2])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Rational Field' and 'Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Integer Ring' sage: parent(QQ[x](1)*vector(QQ[y],[1,2])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Rational Field' and 'Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in y over Rational Field'
(scalar * matrix)
sage: parent(ZZ(1)*matrix(ZZ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Integer Ring sage: parent(QQ(1)*matrix(ZZ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: parent(ZZ(1)*matrix(QQ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: parent(QQ(1)*matrix(QQ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Rational Field
sage: parent(QQ(1)*matrix(ZZ[x],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field sage: parent(ZZ[x](1)*matrix(QQ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field
sage: parent(QQ(1)*matrix(ZZ[x][y],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(ZZ[x][y](1)*matrix(QQ,2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(QQ[x](1)*matrix(ZZ[x][y],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(ZZ[x][y](1)*matrix(QQ[x],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(QQ[y](1)*matrix(ZZ[x][y],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(ZZ[x][y](1)*matrix(QQ[y],2,2,[1,2,3,4])) Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(ZZ[x](1)*matrix(ZZ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Integer Ring' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Integer Ring' sage: parent(ZZ[x](1)*matrix(QQ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Integer Ring' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Rational Field' sage: parent(QQ[x](1)*matrix(ZZ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Rational Field' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Integer Ring' sage: parent(QQ[x](1)*matrix(QQ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Rational Field' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Rational Field'
) |
) |
) |
Python classes should override this function to implement division.
) |
) |
) |
Python classes should override this function to implement multiplication. See extensive documentation at the top of element.pyx.
Class: Vector
Special Functions: __div__,
__imul__,
__mul__,
__rdiv__,
__rmul__,
_dot_product,
_magma_init_
) |
) |
) |
Multiplication of vector by vector, matrix, or scalar
Gonzalo Tornaria (2007-06-21) - write test cases and fix them
NOTE:
scalar * vector is implemented (and tested) in class RingElement matrix * vector is implemented (and tested) in class Matrix
TEST CASES:
(vector * vector)
sage: x, y = var('x, y')
sage: parent(vector(ZZ,[1,2])*vector(ZZ,[1,2])) Integer Ring sage: parent(vector(ZZ,[1,2])*vector(QQ,[1,2])) Rational Field sage: parent(vector(QQ,[1,2])*vector(ZZ,[1,2])) Rational Field sage: parent(vector(QQ,[1,2])*vector(QQ,[1,2])) Rational Field
sage: parent(vector(QQ,[1,2,3,4])*vector(ZZ[x],[1,2,3,4])) Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x],[1,2,3,4])*vector(QQ,[1,2,3,4])) Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ,[1,2,3,4])*vector(ZZ[x][y],[1,2,3,4])) Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2,3,4])*vector(QQ,[1,2,3,4])) Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ[x],[1,2,3,4])*vector(ZZ[x][y],[1,2,3,4])) Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2,3,4])*vector(QQ[x],[1,2,3,4])) Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ[y],[1,2,3,4])*vector(ZZ[x][y],[1,2,3,4])) Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2,3,4])*vector(QQ[y],[1,2,3,4])) Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(ZZ[x],[1,2,3,4])*vector(ZZ[y],[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 4 over the integral domain Univariate Polynomial Ring in x over Integer Ring' and 'Ambient free module of rank 4 over the integral domain Univariate Polynomial Ring in y over Integer Ring' sage: parent(vector(ZZ[x],[1,2,3,4])*vector(QQ[y],[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 4 over the integral domain Univariate Polynomial Ring in x over Integer Ring' and 'Ambient free module of rank 4 over the principal ideal domain Univariate Polynomial Ring in y over Rational Field' sage: parent(vector(QQ[x],[1,2,3,4])*vector(ZZ[y],[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 4 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field' and 'Ambient free module of rank 4 over the integral domain Univariate Polynomial Ring in y over Integer Ring' sage: parent(vector(QQ[x],[1,2,3,4])*vector(QQ[y],[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 4 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field' and 'Ambient free module of rank 4 over the principal ideal domain Univariate Polynomial Ring in y over Rational Field'
(vector * matrix)
sage: parent(vector(ZZ,[1,2])*matrix(ZZ,2,2,[1,2,3,4])) Ambient free module of rank 2 over the principal ideal domain Integer Ring sage: parent(vector(QQ,[1,2])*matrix(ZZ,2,2,[1,2,3,4])) Vector space of dimension 2 over Rational Field sage: parent(vector(ZZ,[1,2])*matrix(QQ,2,2,[1,2,3,4])) Vector space of dimension 2 over Rational Field sage: parent(vector(QQ,[1,2])*matrix(QQ,2,2,[1,2,3,4])) Vector space of dimension 2 over Rational Field
sage: parent(vector(QQ,[1,2])*matrix(ZZ[x],2,2,[1,2,3,4])) Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x],[1,2])*matrix(QQ,2,2,[1,2,3,4])) Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ,[1,2])*matrix(ZZ[x][y],2,2,[1,2,3,4])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2])*matrix(QQ,2,2,[1,2,3,4])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ[x],[1,2])*matrix(ZZ[x][y],2,2,[1,2,3,4])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2])*matrix(QQ[x],2,2,[1,2,3,4])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ[y],[1,2])*matrix(ZZ[x][y],2,2,[1,2,3,4])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2])*matrix(QQ[y],2,2,[1,2,3,4])) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(ZZ[x],[1,2])*matrix(ZZ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in x over Integer Ring' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Integer Ring' sage: parent(vector(ZZ[x],[1,2])*matrix(QQ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in x over Integer Ring' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Rational Field' sage: parent(vector(QQ[x],[1,2])*matrix(ZZ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Integer Ring' sage: parent(vector(QQ[x],[1,2])*matrix(QQ[y],2,2,[1,2,3,4])) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field' and 'Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in y over Rational Field'
(vector * scalar)
sage: parent(vector(ZZ,[1,2])*ZZ(1)) Ambient free module of rank 2 over the principal ideal domain Integer Ring sage: parent(vector(QQ,[1,2])*ZZ(1)) Vector space of dimension 2 over Rational Field sage: parent(vector(ZZ,[1,2])*QQ(1)) Vector space of dimension 2 over Rational Field sage: parent(vector(QQ,[1,2])*QQ(1)) Vector space of dimension 2 over Rational Field
sage: parent(vector(QQ,[1,2])*ZZ[x](1)) Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x],[1,2])*QQ(1)) Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ,[1,2])*ZZ[x][y](1)) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2])*QQ(1)) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ[x],[1,2])*ZZ[x][y](1)) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2])*QQ[x](1)) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(QQ[y],[1,2])*ZZ[x][y](1)) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field sage: parent(vector(ZZ[x][y],[1,2])*QQ[y](1)) Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
sage: parent(vector(ZZ[x],[1,2])*ZZ[y](1)) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in x over Integer Ring' and 'Univariate Polynomial Ring in y over Integer Ring' sage: parent(vector(ZZ[x],[1,2])*QQ[y](1)) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 2 over the integral domain Univariate Polynomial Ring in x over Integer Ring' and 'Univariate Polynomial Ring in y over Rational Field' sage: parent(vector(QQ[x],[1,2])*ZZ[y](1)) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field' and 'Univariate Polynomial Ring in y over Integer Ring' sage: parent(vector(QQ[x],[1,2])*QQ[y](1)) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 2 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field' and 'Univariate Polynomial Ring in y over Rational Field'
) |
) |
sage: v = vector([1,2,3]) sage: mv = magma(v); mv # optional (1 2 3) sage: mv.Type() # optional ModTupRngElt sage: mv.Parent() # optional Full RSpace of degree 3 over Integer Ring
sage: v = vector(QQ, [1/2, 3/4, 5/6]) sage: mv = magma(v); mv # optional (1/2 3/4 5/6) sage: mv.Type() # optional ModTupFldElt sage: mv.Parent() # optional Full Vector space of degree 3 over Rational Field
See About this document... for information on suggesting changes.