Rename *ll* and *ul* to ll and ul in $defint
[maxima.git] / share / matrix / pfaff.mac
blob5f8e90a66ef91fb90c2ca6e875eae96276c7f9ec
1 ttyoff:true$
2 pfaffian(integ,list):=block([sgn:-1,ans:0,pdum,ldum],
3   if not (listp(list)
4           and integerp(integ)
5           and integ>0
6           and length(list)=integ*(integ+1)/2)
7   then error((errexp:[integ,list],"invalid arg to pfaffian.merrexp holds the offending expression.")),
8   if integ =1 then return(first(list)),
9   if evenp(integ)
10   then return(0),
11   if integ = 3
12   then return(list[1]*list[6]-list[2]*list[5]+list[3]*list[4])
13   else for kzero thru integ do
14         ans:ans+
15             inpart(list,kzero)*(sgn:-sgn)*
16                 pfaffian(integ-2,
17                          rest(inpart(list,
18                                      apply('allbut,
19                                            if listp(pdum:pfaffm[integ,kzero])
20                                            then pdum
21                                            else pfaffm[integ,kzero]:(ldum:(kzero+1)*(2*integ-kzero)/2,
22                                                                      pdum:[],
23                                                                      if kzero#1 then for mdum:2 thru kzero do
24                                                                        pdum:endcons(kzero+(mdum-1)*(2*integ-mdum)/2,pdum),
25                                                                      for mdum:kzero*(2*integ-kzero+1)/2+1 thru ldum do
26                                                                        pdum:endcons(mdum,pdum),
27                                                                      pdum))),integ)),
28   ans)$
29 ttyoff:false$