Ask Your Question

Why can 'matrix' not use cached functions?

asked 2015-06-15 15:09:01 -0500

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 02:38:51 -0500

updated 2015-06-16 09:47:14 -0500

(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 03:29:24 -0500 )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 15:09:01 -0500

Seen: 81 times

Last updated: Jun 16 '15