Hello,
Is there a reason why I cannot do
f(x)=abs(x)
f(vector([1,2,3]))
Many related things work fine:
abs(vector([1,2,3])) # works
def f(x): return abs(x)
f(vector([1,2,3])) # works
Session below shows the trouble.
Thanks,
Scott
[EMAIL PROTECTED]:~$ sage
----------------------------------------------------------------------
| Sage Version 3.2, Release Date: 2008-11-20 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: v=vector([1,2,3])
sage: abs(v)
sqrt(14)
sage: f(x)=abs(x)
sage: f
x |--> abs(x)
sage: f(-3)
3
sage: f(v)
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/home/walck/<ipython console> in <module>()
/usr/local/src/sage-3.2/local/lib/python2.5/site-packages/sage/
calculus/calculus.pyc in __call__(self, *args, **kwargs)
5810 dct = dict(zip(self.args(), args))
5811 dct.update(kwargs)
-> 5812 return self._expr.substitute(dct)
5813
5814 def _repr_(self, simplify=True):
/usr/local/src/sage-3.2/local/lib/python2.5/site-packages/sage/
calculus/calculus.pyc in substitute(self, in_dict, **kwds)
3700 kwds = self.__parse_in_dict(in_dict, kwds)
3701 kwds = self.__varify_kwds(kwds)
-> 3702 return X._recursive_sub(kwds)
3703
3704 def subs(self, *args, **kwds):
/usr/local/src/sage-3.2/local/lib/python2.5/site-packages/sage/
calculus/calculus.pyc in _recursive_sub(self, kwds)
6163 def _recursive_sub(self, kwds):
6164 ops = self._operands
-> 6165 return ops[0](ops[1]._recursive_sub(kwds))
6166
6167 def _recursive_sub_over_ring(self, kwds, ring):
/usr/local/src/sage-3.2/local/lib/python2.5/site-packages/sage/
calculus/calculus.pyc in __call__(self, x)
6571
6572 def __call__(self, x): # special case
-> 6573 return SymbolicComposition(self, SR(x))
6574
6575 abs_symbolic = Function_abs()
/usr/local/src/sage-3.2/local/lib/python2.5/site-packages/sage/
calculus/calculus.pyc in __call__(self, x)
452 msg, s, pos = err.args
453 raise TypeError, "%s: %s !!! %s" % (msg, s
[:pos], s[pos:])
--> 454 return self._coerce_impl(x)
455
456 def _coerce_impl(self, x):
/usr/local/src/sage-3.2/local/lib/python2.5/site-packages/sage/
calculus/calculus.pyc in _coerce_impl(self, x)
508 return self(x._sage_())
509 else:
--> 510 raise TypeError, "cannot coerce type '%s' into a
SymbolicExpression."%type(x)
511
512 def _repr_(self):
TypeError: cannot coerce type '<type
'sage.modules.vector_integer_dense.Vector_integer_dense'>' into a
SymbolicExpression.
sage: version()
'Sage Version 3.2, Release Date: 2008-11-20'
sage:
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---