First time here? Check out the FAQ!

Ask Your Question
0

Why can 'matrix' not use cached functions?

asked 9 years ago

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".

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 9 years ago

rws gravatar image

updated 9 years ago

(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

Preview: (hide)
link

Comments

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

Peter Luschny gravatar imagePeter Luschny ( 9 years ago )

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: 9 years ago

Seen: 303 times

Last updated: Jun 16 '15