Vectors over callable symbolic rings

– Jason Grout (2010)


sage: f(r, theta, z) = (r*cos(theta), r*sin(theta), z)
sage: f.parent()
Vector space of dimension 3 over Callable function ring with arguments (r, theta, z)
sage: f
(r, theta, z) |--> (r*cos(theta), r*sin(theta), z)
sage: f[0]
(r, theta, z) |--> r*cos(theta)
sage: f+f
(r, theta, z) |--> (2*r*cos(theta), 2*r*sin(theta), 2*z)
sage: 3*f
(r, theta, z) |--> (3*r*cos(theta), 3*r*sin(theta), 3*z)
sage: f*f # dot product
(r, theta, z) |--> r^2*cos(theta)^2 + r^2*sin(theta)^2 + z^2
sage: f.diff()(0,1,2) # the matrix derivative
[cos(1)      0      0]
[sin(1)      0      0]
[     0      0      1]


sage: f(u,v,w) = (2*u+v,u-w,w^2+u)
sage: loads(dumps(f)) == f
class sage.modules.vector_callable_symbolic_dense.Vector_callable_symbolic_dense

Bases: sage.modules.free_module_element.FreeModuleElement_generic_dense


sage: type(vector([-1,0,3,pi]))   # indirect doctest
<class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>


Check that #11751 is fixed:

sage: K.<x> = QQ[]
sage: M = K^1
sage: N = M.span([[1/x]]); N
Free module of degree 1 and rank 1 over Univariate Polynomial Ring in x over Rational Field
Echelon basis matrix:
sage: N([1/x]) # this used to fail prior to #11751
sage: N([1/x^2])
Traceback (most recent call last):
TypeError: element (= [1/x^2]) is not in free module
sage: L=K^2
sage: R=L.span([[x,0],[0,1/x]], check=False, already_echelonized=True)
sage: R.basis()[0][0].parent()
Fraction Field of Univariate Polynomial Ring in x over Rational Field
sage: R=L.span([[x,x^2]])
sage: R.basis()[0][0].parent()
Univariate Polynomial Ring in x over Rational Field

Previous topic

Pickling for the old RDF vector class

Next topic

Space of Morphisms of Vector Spaces (Linear Transformations)

This Page