I'm new to Sage, coming from a Maple background. I have some fairly complicated
multivariate polynomial Vandermonde inverses to generate, and my method of
choice is constructing a generic polynomial, applying whatever operations I
wish (differentiate, integrate, sample, etc) for constraints, then taking the
Jacobian of the constraints with respect to polynomial coefficients (which are
symbolic placeholders at this point), and finally inverting that Jacobian and
multiplying by the RHS data that fits those constraints. This requires the use
of a symbolic vector as a placeholder. The only way I've found of doing this so
far (for a half-tensor 2-D polynomial) is:
N = 4
var('x','y')
ns = (N+1)*N/2
p = 0
count = 0
for j in range(N) :
for i in range(N) :
if ( i + j ) < N :
p = p + var('a%s'%count) * x^i * y^j
count = count + 1
And this works just fine, and I can take the Jacobian of constraints as:
A = jacobian( constr , ( [ var('a%s'%i) for i in range(ns) ] ) )
But, I cannot then assign to the coefficients to retrieve the fitted polynomial
and perform further operations on it. I've tried this, and it fails:
coefs = A^-1 * vector( [ var('m%s'%i) for i in range(ns) ] )
for i in range(ns) :
'a%s'%i = coefs[i]
As I expected, I get "SyntaxError: can't assign to operator." How can I assign
to a generated variable name? Better still, is there a way to create a symbolic
vector that isn't assigned values, that I can use as a placeholder? Thanks,
-Matt
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.