Ask Your Question
0

Why can 'matrix' not use cached functions?

asked 2015-06-15 22:09:01 +0100

Peter Luschny gravatar image

Consider

def L(n,k):
    if n==k: return 1
    if k<0 or k>n: return 0
    return L(n-1,k-1)+(n+k-1)*L(n-1,k)

print parent(L)
matrix(ZZ, 8, L)

This works. However, as soon as I decorate the above function L with the very reasonable "@CachedFunction" I receive an ValueError: "Invalid matrix constructor".

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-16 09:38:51 +0100

rws gravatar image

updated 2015-06-16 16:47:14 +0100

(after change of CachedFunction to cached_function there is a ValueError)

It's a bug. When I add sage.misc.cachefunc.CachedFunction to this line in matrix/constructor.py it works fine:

if isinstance(args[0], (types.FunctionType, types.LambdaType, types.MethodType)):

I have submitted the fix for review: http://trac.sagemath.org/ticket/18713

edit flag offensive delete link more

Comments

Of course it's a bug. It does not make any sense. Thanks!

Peter Luschny gravatar imagePeter Luschny ( 2015-06-16 10:29:24 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-06-15 22:09:01 +0100

Seen: 279 times

Last updated: Jun 16 '15