Hi, On Jun 25, 9:12 pm, David Joyner <wdjoy...@gmail.com> wrote: > I know multiplication is very finicky. You might try using > R.<t> = PolynomialRing(RR, "t") instead, but I'm not sure that will work > either. > > Can you post more of your code so I can give a more detailed answer?
a = [-1, 0, 1.5, 3.2, 5] k = len(a) t = var('t') def delta(c,d): if c == d: return 1 else: return 0 def w(j,k,t): return (t-a[j-1])/(a[j+k-2]-a[j-1]) # for j,k integers it is just an expression in t L1 = [] for j in [1..k-1]: L1.append( piecewise([[(a[i-1],a[i]),delta(i,j)] for i in [1..k-1]]) ) L2 = [] for j in [1..k-2]: L2.append( w(j,2,t)*L1[j]+(1-w(j+1,2,t))*L1[j+1] ) Traceback (click to the left for traceback) ... TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and '<type 'instance'>' w(1,2,t)*L1[1] Traceback (click to the left for traceback) ... TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and '<type 'instance'>' L1[1]; type(L1[1]) Piecewise defined function with 4 parts, [[(-1, 0), 0], [(0, 1.50000000000000), 1], [(1.50000000000000, 3.20000000000000), 0], [(3.20000000000000, 5), 0]] <type 'instance'> w(1,2,t); type(w(1,2,t)) t + 1 <type 'sage.symbolic.expression.Expression'> I am guessing that having them both as functions of a variable "t" I should be able to manipulate them (it seems piecewise is not a function). Assuming, that is, that things like the "1" in the definition of L2 above would be coerced accordingly. David > On Thu, Jun 25, 2009 at 2:17 PM, David Sevilla<sevil...@gmail.com> wrote: > > > Hi, > > > I am trying to construct the usual spline basis functions. In short, I > > start with several piecewise functions that take values 1 and 0 only, > > and then make combinations of them. But there is something with the > > syntax that I am not managing to do well, I suppose: > > > L[1] > > Piecewise defined function with 3 parts, [[(-1, 0), 0], [(0, > > 1.50000000000000), 0], [(1.50000000000000, 3.20000000000000), 1]] > > > t = var('t') > > L[1]*t > > Traceback (click to the left for traceback) > > ... > > AttributeError: 'sage.symbolic.expression.Expression' object has no > > attribute 'domain' > > > It seems to me that I have to set things up so that L[1] is a function > > of t as well. I tried "lambda t: " in front where I define it, but now > > L[1] is a function whose value is always a certain piecewise > > function :) > > > Any suggestions? > > > Thanks, > > > David --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---