Ask Your Question

Why can 'matrix' not use cached functions?

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

Peter Luschny gravatar image


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

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

rws gravatar image

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

(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/ it works fine:

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

I have submitted the fix for review:

edit flag offensive delete link more


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

Peter Luschny gravatar imagePeter Luschny ( 2015-06-16 10:29:24 +0200 )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


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

Seen: 248 times

Last updated: Jun 16 '15