determinant slightly buggy



hi Stavros
it's OK,thank you. (For this use, invertmx,tr may be rewritten.)

load("matrix.lisp")$
matrix_element_mult:"."$
declare([x1,x2,x3,x4,y1,y2,y3,y4,z1,z2,z3],constant)$
a:matrix([x1,x2],[y1,y2])$
b:matrix([x3,x4],[y3,y4])$
c:matrix([x1,x2,x3],[y1,y2,y3],[z1,z2,z3])$
nest2(_f,_x):=block([_a:[_x],i],if listp(_f) then (
     _f:reverse(_f),for i:1 thru length(_f) do(_a:map(_f[i],_a)))
    else (_a:map(_f,_a)),_a[1]);
 nest3(_f,_x,_n):=block([_a,i],_a:[_x],for i:1 thru _n do
(_a:map(_f,_a)),_a);
(%i14) nest3(determinant,outermap("*",a,a),2)$
(%i15) factor(expand(%));
                                        4
(%o15)                   [(x1 y2 - x2 y1) ]
(%i16) nest3(determinant,outermap("*",a,b),2)$
(%i17) factor(expand(%));
                                     2               2
(%o17)               [(x1 y2 - x2 y1)  (x3 y4 - x4 y3) ]
(%i20) nest3(determinant,outermap("*",a,c),2)$
(%i21) factor(expand(%));
                       3
(%o21) [(x1 y2 - x2 y1)
        (x1 y2 z3 - x2 y1 z3 - x1 y3 z2 + x3 y1 z2 +
                     2
x2 y3 z1 - x3 y2 z1) ]
 this is correct so,determinant(x at y)=determinant(x)^n *
determinant(y)^m,this case m=2,n=3,
(%i24) showtime:true$
(%i22) nest3(determinant,outermap("*",c,c),2)$
(%i25) factor(expand(%o22));
Evaluation took 10.31 seconds (10.33 elapsed)
(%o25) [(x1 y2 z3 - x2 y1 z3 - x1 y3 z2 + x3 y1 z2 + x2 y3 z1 - x3 y2 z1)^6
]
(%i27) nest2([factor,determinant,determinant],outermap("*",c,c));
Evaluation took 1.80 seconds (1.84 elapsed)
same result
thank -s
gosei furuya









2007/5/29, Stavros Macrakis <macrakis at alum.mit.edu>:
>
> Yes, determinant ignores matrix_element_* currently.
>
> I have added a little code in CVS to handle this case.  It only works when
> ratmx=false and sparse=false.  I am also including the code below.  I would
> appreciate it if you could exercise this code to make sure it works
> properly.
>
>            -s
>
> (defun compumd (id row)
>   (prog (e minor i d sign ans)
>      (setq ans 0 sign -1 i id)
>      loop (when (null i) (return ans))
>      (setq d (car i) i (cdr i) sign (* -1 sign))
>      (cond ((equal (setq e (ith row d)) 0)
>             (go loop))
>            ((equal (setq minor (assoo (delete d (copy-tree id) :test
> #'equal) mdl)) 0)
>             (go loop)))
>      (setq ans
>            (if (and (eq $matrix_element_mult '|&*|)
>                     (eq $matrix_element_add '|&+|))
>                (add ans (mul sign e minor)) ;fast common case
>              (mapply $matrix_element_add
>                      (list ans
>                            (mapply $matrix_element_mult
>                                    (list sign e minor)
>                                    $matrix_element_mult))
>                      $matrix_element_add)))
>      (go loop)))
>
>