Closed burcin closed 14 years ago
Attached patches allow forming matrices and vectors with pynac expressions, and make them use the multi_derivative framework. This makes the jacobian command in the example above work.
allow forming matrices and vectors from pynac expressions
Attachment: trac_5546-1-pynac_matrix_vector.patch.gz
Attachment: trac_5546-2-pynac_derivative.patch.gz
make pynac expressions use the multi_derivative framework
With these two patches applied, you can get some wild things:
sage: var('x,y,z',ns=1)
(x, y, z)
sage: M = matrix(2,2,[x,y,z,x])
sage: M.base_ring()
New Symbolic Ring
sage: v = vector([x,y])
sage: v.base_ring()
New Symbolic Ring
sage: M * v
Exception exceptions.TypeError: 'mutable matrices are unhashable' in 'sage.modules.free_module_element.FreeModuleElement._cmp_same_ambient_c' ignored
<ERROR: mutable matrices are unhashable>
(([x y]
[z x])*x, ([x y]
[z x])*y)
sage: v * M
(x^2 + y*z, 2*x*y)
sage: M * v
<ERROR: mutable matrices are unhashable>
(([x y]
[z x])*x, ([x y]
[z x])*y)
sage: v * M * v
2*x*y^2 + (x^2 + y*z)*x
sage: v * (M * v)
/Users/ncalexan/.sage/temp/dhcp_v007_000.mobile.uci.edu/36399/_Users_ncalexan__sage_init_sage_0.py:1: RuntimeWarning: tp_compare didn't return -1 or -2 for exception
# -*- coding: utf-8 -*-
([x y] + ([x y]
Attachment: pynac-hash_exception.patch.gz
patch to pynac to handle exceptions during hashing
doctests for the fix
Attachment: 5546_doctests.patch.gz
attachment: pynac-hash_exception.patch fixes exception handling during hashing in pynac and the problems reported by Nick in comment:2.
I will hold off on doing another pynac release to address this, since I don't know if mhansen made any changes which might be affected.
BTW, another pynac release, 0.1.6 in this case, would introduce circular dependencies in trac. :)
Comments on how to proceed?
Comments on how to proceed?
I'd just like to remark that Mike Hansen is probably the best person I've ever met at using rebasing patches and using revision control systems. With him, I would not be worried about doing something that conflicts with what he has done or with circular trac dependencies.
The necessary changes for pynac, i.e., attachment: pynac-hash_exception.patch, is included in the new package for pynac-0.1.6 at #5777. The doctests in attachment: 5546_doctests.patch are also posted in #5777.
This now introduces a circular dependency in trac. I hope this won't cause problems, since all these patches will go in together. Faster reviews in the future may prevent this from happening again.
Note that only:
needs to be applied from this ticket.
Some variants of these patches seem to be in 4.0.rc0. This bug should be closed. Trac doesn't allow me to close bugs any more though.
This was fixed by #5777 and #5390
Reported by Alex Raichev on sage-support:
sage.symbolic.expression.Expression
doesn't support .derivative(), and the interface to .diff() doesn't match the Sage conventions.CC: @williamstein @mwhansen @robertwb
Component: symbolics
Issue created by migration from https://trac.sagemath.org/ticket/5546