Hello,
I'm trying to use linsolve( ) from within a subroutine in order to code up a solution algorithm that is independent of the dimension of the problem.
The desire is to dynamically allocate the equation and variable arrays within the subroutine itself, pass these to linsolve( ) and hopefully get back the results.
/* SUBROUTINE IDEA -- INCORRECT SYNTAX */
solution(p):=(
array(eq,p),
array(a,p),
for i:0 thru p do (
eq[i]: sum(binom(j+1,i)*a[j],j,i,p) = binom(p,i)
),
linsolve(eq,a) /* THIS IS WHERE THE PROBLEM LIES */
)$
Clearly, linsolve( ) doesn't like being passed arrays in this way.
If I manually provide the list of elements of the arrays, like below, it works for one particular case, which of course defeats the purpose of having the general subroutine.
linsolve([eq[0],eq[1],eq[2]],[a[0],a[1],a[2]])
/* UGLY: HAVE TO PASS EACH ELEMENT IN BY HAND */
Any insight would be appreciated!