Ticket #11549: trac_11549_symbolic_vector_arithmetic.patch

File trac_11549_symbolic_vector_arithmetic.patch, 2.7 KB (added by jvkersch, 11 years ago)
  • sage/modules/free_module_element.pyx

    # HG changeset patch
    # User Joris Vankerschaver <joris.vankerschaver@gmail.com>
    # Date 1309208852 25200
    # Node ID 156217366e093e2035d3778f2f44ef1c19e05a93
    # Parent  4ad86990d7215498658440de04560aa028dcdeeb
    #11549: Symbolic vector arithmetic creates instance of FreeModuleElement_generic_dense
    
    diff -r 4ad86990d721 -r 156217366e09 sage/modules/free_module_element.pyx
    a b  
    32793279        # Create a new dense free module element with minimal overhead and
    32803280        # no type checking.
    32813281        cdef FreeModuleElement_generic_dense x
    3282         x = PY_NEW(FreeModuleElement_generic_dense)
     3282        x = <FreeModuleElement_generic_dense>PY_NEW(<object>PY_TYPE(self))
    32833283        x._is_mutable = 1
    32843284        x._parent = self._parent
    32853285        x._entries = v
  • sage/modules/vector_callable_symbolic_dense.py

    diff -r 4ad86990d721 -r 156217366e09 sage/modules/vector_callable_symbolic_dense.py
    a b  
    1414    sage: f[0]
    1515    (r, theta, z) |--> r*cos(theta)
    1616    sage: f+f
    17     ((r, theta, z) |--> 2*r*cos(theta), (r, theta, z) |--> 2*r*sin(theta), (r, theta, z) |--> 2*z)
     17    (r, theta, z) |--> (2*r*cos(theta), 2*r*sin(theta), 2*z)
    1818    sage: 3*f
    19     ((r, theta, z) |--> 3*r*cos(theta), (r, theta, z) |--> 3*r*sin(theta), (r, theta, z) |--> 3*z)
     19    (r, theta, z) |--> (3*r*cos(theta), 3*r*sin(theta), 3*z)
    2020    sage: f*f # dot product
    2121    (r, theta, z) |--> r^2*sin(theta)^2 + r^2*cos(theta)^2 + z^2
    2222    sage: f.diff()(0,1,2) # the matrix derivative
  • sage/modules/vector_symbolic_dense.py

    diff -r 4ad86990d721 -r 156217366e09 sage/modules/vector_symbolic_dense.py
    a b  
    2121    sage: u.simplify_full()
    2222    (1, log(6) + 2*log(y))
    2323
     24Check that the outcome of arithmetic with symbolic vectors is again
     25a symbolic vector (#11549):
     26
     27    sage: v = vector(SR, [1, 2])
     28    sage: w = vector(SR, [sin(x), 0])
     29    sage: type(v)
     30    <class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
     31    sage: type(w)
     32    <class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
     33    sage: type(v + w)
     34    <class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
     35    sage: type(-v)
     36    <class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
     37    sage: type(5*w)
     38    <class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
     39
    2440TESTS::
    2541
    2642    sage: u = vector(SR, [sin(x^2)])