Menu

#3487 rempart does not work on a list

None
wont-fix
nobody
5
2020-12-26
2018-10-29
dan hayes
No

wxMaxima version: 13.4.0
Maxima version: 5.31.1
Maxima build date: 2013-09-24 09:49:12
Host type: i686-pc-mingw32
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.8

load(lrats);
(matv:ident(3),declare(xx,symmetric)
,vecrv(lis31,lis32):=block([sout:0],for i thru 3 do for j thru 3 do 
 sout:sout+xx[i,j]*lis31[i]*lis32[j],return(sout) )/*end blk*/
,xv:[0,0,0], xv[1]:[1,0,0], xv[2]:[-xx[1,2]/xx[1,1],1,0]
,xv[3]:[(xx[1,1]*xx[2,3]-xx[1,2]*xx[1,3])*xx[1,2]/(xx[1,1]*xx[2,2]-xx[1,2]^2)/xx[1,1]
-xx[1,3]/xx[1,1], (xx[1,2]*xx[1,3]-xx[1,1]*xx[2,3])/(xx[1,1]*xx[2,2]-xx[1,2]^2),1] 
,xvsq:[0,0,0], for i thru 3 do(matv[i]:xv[i], xvsq[i]:ratsimp(vecrv(xv[i],xv[i])))

,xvsq4:[0,0,0],matv4:lratsubst(xx[1,1]=xx[1,1]+xx[4,4]+2*xx[1,4],matv)
,for j:2 thru 3 do matv4:lratsubst(xx[1,j]=xx[1,j]+xx[j,4],matv4)
,for i thru 3 do for j:i thru 3 do(tt:matv4[i,1]*matv4[j,1]
*(xx[1,1]+xx[4,4]+2*xx[1,4]),for k:2 thru 3 do(tt:tt
+(matv4[i,1]*matv4[j,k]+matv4[j,1]*matv4[i,k])
*(xx[1,k]+xx[k,4]),for m:2 thru 3 do tt:tt+matv4[i,k]*matv4[j,m]
*xx[k,m]),if i=j then(xvsq4[i]:ratsimp(tt),ldisp(["i",i,"xvsq4[i]",xvsq4[i]])) 
 else ldisp(["i",i,"j",j,ratsimp(tt)])),matv4 );

(permult(p1,p2):= block([p3:[]], for i in p2 do p3:endcons(part(p1,i),p3),p3)/*end blk*/

,lis0:makelist(i,i,1,6),psub:[lis0,[4,2,3,1,5,6],[1,3,2,4,5,6],[1,2,3,4,6,5]
,[4,3,2,1,5,6],[4,2,3,1,6,5],[1,3,2,4,6,5],[4,3,2,1,6,5]],lensub:8
,pcoset:[lis0],lencoset:1,fl1:false, for i thru 9 while lencoset<90 
 do(for i thru 5 while  lencoset<90 do for k:i+1 thru  6 while 
  lencoset<90 do(ptry0:copylist(lis0),ptry0[i]:k,ptry0[k]:i, for i thru 
 lencoset while  lencoset<90 do(ptry:permult(ptry0,pcoset[i]),fl:true
,for j thru lensub while fl do for i thru lencoset while fl do if ptry
=permult(pcoset[i],psub[j]) then fl:false, if fl then(pcoset:append(pcoset
,[ptry]),lencoset:lencoset+1)))));

(load(functs),t4:expand(lratsubst([p=5,q=6],ratnum(xx[p,q]-sum(sum(matv4[i,j]*(xx[j,q]
+(1-signum(j-1))*xx[4,q])
,j,1,3)*sum(matv4[i,k]*(xx[k,p]+(1-signum(k-1))*xx[4,p]),k,1,
3)/xvsq4[i],i,1,3))))
,tplis:[], len4:length(t4), for i thru len4 do(tp:part(t4,i), fl:true,for j:
 2 thru 6 while fl do
 if coeff(tp,xx[1,j])#0 then fl:false, if not fl then(fl:true, for i thru 6 while 
  fl do
 if coeff(tp,xx[i,4])#0 then(fl:false, tplis:append(tplis,[tp])))),lentp:length(tplis) 

,mat4:matrix(),mat4:addrow(mat4,makelist(1,lentp)),lsys:tplis,kill(pp,tsub),declare(xz,symmetric)
,for i:2 thru 2/*lencoset*/ do(fl1:true,mat4:addrow(mat4,makelist(0,matrix_size(mat4)[2]))
,pp:pcoset[i],tsub:flatten(makelist(makelist(xx[i,j]=xz[pp[i],pp[j]],j,i,6),i,1,6))
,tlis:subst(tsub,tplis),tsub:flatten(makelist(makelist(xz[i,j]=xx[i,j],j,i,6),i,1,6)) 
,tlis:subst(tsub,tlis)/*,ldisp(["i",i,tlis])  */
,lindx:makelist(i,i,1,length(lsys)),lisv:copylist(lsys)
, for i thru lentp do(fl:true,lt1:tlis[i], for j thru length(lisv) while fl do(cst:lt1/lisv[j]
,if constantp(cst) then(fl:false

,ldisp(["i",i,"lt1",lt1,"init j",j,"lisv init",lisv,"lindx",lindx,"lindx[j]",lindx[j],"mat4",mat4])

,lisv:rempart(lisv,j),mat4[matrix_size(mat4)[1]
,lindx[j]]:cst, for i:j thru length(lisv) do lindx[i]:lindx[i]+1

,ldisp(["i",i,"lt1",lt1,"j",j,"lisv Next",lisv,"lindx",lindx,"lindx[j]",lindx[j],"mat4",mat4])

))/*end j*/

,if fl then (fl1:false, lsys:append(lsys,[lt1]),mat4:addcol(mat4,append(makelist(0
,matrix_size(mat4)[1]-1),[1]))))/*end thru lentp*/,if fl1 then if rank(mat4)
<matrix_size(mat4)[1] then mat4:submatrix(matrix_size(mat4)[1],mat4)
  )/*end thru lencoset*/ );
 ~~~~
  and get the ridiculous error message:
 ~~~~
  "simplifya: operator is neither an atom nor a lambda expression: $ERREXP1
#0: rempart(exp=[2*xx[1,2]*xx[2,3]*xx[3,4]*xx[5,6],-2*xx[1,3]*xx[2,2]*xx[3,4]*xx[5,6],-2*xx[1,2]*xx[2,4]*xx[3,3]*xx[...,n=7)(functs.mac line 15)
 -- an error. To debug this try: debugmode(true);"

and there is nothing wrong with lisv as you can verify by displaying it and using it for all other things

Discussion

  • dan hayes

    dan hayes - 2018-10-29

    If i put instead
    ,lisv:append(rest(lisv,j-length(lisv)-1),rest(lisv,j))

    it works, which should be exactly the same as the prior more direct expression using rempart

     
  • dan hayes

    dan hayes - 2018-10-29

    that is lisv:rempart(lisv,j) should be exaclty the same as the more cumbersome having to do:
    lisv:append(rest(lisv,j-length(lisv)-1),rest(lisv,j))

    but by some bug in maxima in the context above the simpler lisv:rempart(lisv,j) gives error. Ofcourse u put in simple example it is the same but not in the context of the above program.

     
  • Robert Dodier

    Robert Dodier - 2019-02-06
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -6,7 +6,7 @@
      Lisp implementation version: GCL 2.6.8
    
    -
    +~~~~
     (matv:ident(3),declare(xx,symmetric)
     ,vecrv(lis31,lis32):=block([sout:0],for i thru 3 do for j thru 3 do 
      sout:sout+xx[i,j]*lis31[i]*lis32[j],return(sout) )/*end blk*/
    @@ -68,10 +68,11 @@
     ,matrix_size(mat4)[1]-1),[1]))))/*end thru lentp*/,if fl1 then if rank(mat4)
     <matrix_size(mat4)[1] then mat4:submatrix(matrix_size(mat4)[1],mat4)
       )/*end thru lencoset*/ );
    -  
    +  ~~~~
       and get the ridiculous error message:
    +  ~~~~
       "simplifya: operator is neither an atom nor a lambda expression: $ERREXP1
     #0: rempart(exp=[2*xx[1,2]*xx[2,3]*xx[3,4]*xx[5,6],-2*xx[1,3]*xx[2,2]*xx[3,4]*xx[5,6],-2*xx[1,2]*xx[2,4]*xx[3,3]*xx[...,n=7)(functs.mac line 15)
      -- an error. To debug this try: debugmode(true);"
    - 
    + ~~~~
      and there is nothing wrong with lisv as you can verify by displaying it and using it for all other things
    
     
  • Robert Dodier

    Robert Dodier - 2019-02-06

    I put in formatting marks (i.e. four tildes) to enclose code.

     
  • Robert Dodier

    Robert Dodier - 2019-02-06
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,7 +4,6 @@
      Host type: i686-pc-mingw32
      Lisp implementation type: GNU Common Lisp (GCL)
      Lisp implementation version: GCL 2.6.8
    -
    
     ~~~~
     (matv:ident(3),declare(xx,symmetric)
    @@ -68,11 +67,11 @@
     ,matrix_size(mat4)[1]-1),[1]))))/*end thru lentp*/,if fl1 then if rank(mat4)
     <matrix_size(mat4)[1] then mat4:submatrix(matrix_size(mat4)[1],mat4)
       )/*end thru lencoset*/ );
    -  ~~~~
    + ~~~~
       and get the ridiculous error message:
    -  ~~~~
    + ~~~~
       "simplifya: operator is neither an atom nor a lambda expression: $ERREXP1
     #0: rempart(exp=[2*xx[1,2]*xx[2,3]*xx[3,4]*xx[5,6],-2*xx[1,3]*xx[2,2]*xx[3,4]*xx[5,6],-2*xx[1,2]*xx[2,4]*xx[3,3]*xx[...,n=7)(functs.mac line 15)
      -- an error. To debug this try: debugmode(true);"
    - ~~~~
    +~~~~
      and there is nothing wrong with lisv as you can verify by displaying it and using it for all other things
    
     
  • Robert Dodier

    Robert Dodier - 2019-02-06

    Aargh ... take 2 on the formatting.

     
  • Robert Dodier

    Robert Dodier - 2020-12-26
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -6,6 +6,7 @@
      Lisp implementation version: GCL 2.6.8
    
     ~~~~
    +load(lrats);
     (matv:ident(3),declare(xx,symmetric)
     ,vecrv(lis31,lis32):=block([sout:0],for i thru 3 do for j thru 3 do 
      sout:sout+xx[i,j]*lis31[i]*lis32[j],return(sout) )/*end blk*/
    
     
  • Robert Dodier

    Robert Dodier - 2020-12-26

    Putting load(lrats); at the beginning since lratsubst is called.

     
  • Robert Dodier

    Robert Dodier - 2020-12-26
    • labels: --> rempart, share packages, functs
    • status: open --> wont-fix
     
  • Robert Dodier

    Robert Dodier - 2020-12-26

    I've tried to reproduce the error, but when I run the code as it's shown above, it runs to what appears to be a successful completion without an error. However, I see that the calls to ldisp within the innermost loop aren't called, and rempart isn't called. It appears that constantp always returns false, so the problematic part of the code is never executed.

    If there is some more context that can be added to cause the error, that would be very helpful. On the face of it, the error message suggests an invalid expression was constructed, which would be important to fix. However, an example which causes the error is needed.

    I tested this with some post-5.44 versions, and also 5.31.1 + Clisp. None of them produced the error. Closing this as "won't fix" since I wasn't able to reproduce it. We can reopen it if more info appears.

     

Log in to post a comment.