Maxima values scheme



I had forgotten, but we already have:

(%i1) load(defstruct)$
(%i2) [a,b] : [1,2];
(%o2) [1,2]
(%i3) a;
(%o3) 1
(%i4) b;
(%o4) 2
(%i5) [p] : [1,2];
Illegal list assignment: different lengths of [p] and [1,2].
 -- an error.  To debug this try debugmode(true);

I could make linsolve_by_lu *always* return a two member list
[sol, cnd]. But lu_factor doesn't compute a condition number
when it uses exact numbers. In this case, I think it would be
ok for cnd to be 0. At least that is today's thinking. (Or better,
I could have linsolve_by_lu return [sol, machine epsilon * condition 
number],
where machine epsilon = 0 for exact numbers.)

I don't like making a new global, say lu_condition, that gets
assigned to the latest condition number. It's just too error
prone (did something the user doesn't know about call lu_factor?)

As you suggest if [p] : [1,2] would just assign p and trash the 
2 might be ok too.

Barton

Raymond Toy <raymond.toy at ericsson.com> wrote on 02/20/2007 09:56:31 AM:

> >>>>> "Barton" == Barton Willis <willisb at unk.edu> writes:
> 
>     Barton> The other day I contributed a linsolve_by_lu function.  It 
does
>     Barton> a goofy mtell on the condition number. We need something 
better.
>     Barton> I could introduce a global mat_condition, I suppose. But 
what I'd
>     Barton> like is a CL 'values' scheme for Maxima:
> 
>     Barton> sol : linsolve_by_lu(m,b,floatfield);  <--ok
>     Barton> [sol, cnd] : linsolve_by_lu(m,b,floatfield);  <--also ok
> sets both sol and 
>     Barton> cnd
> 
>     Barton> If anybody wants to work on this, that would be great.
> 
> Although I haven't looked at this, it seems fairly difficult to make
> maxima support multiple values, at least in the Lisp sense.
> 
> But a kind of destructuring assignment seems doable.  linsolve_by_lu
> would return a list and 
> 
>       sol : linsolve_by_lu(foo)
> 
> would assign the list to sol.  But we could have
> 
>      [sol] : linsolve_by_lu(foo)
> 
> just take the first element, and
> 
>      [sol, cnd] : linsolve_by_lu(foo)
> 
> would assign sol and cnd with the first and second elements of the
> list.
> 
> Perhaps that would be a reasonable approach?
> 
> Ray
>