From: Chris S. <san...@us...> - 2010-09-11 15:02:23
|
Update of /cvsroot/stack/stack-dev/maxima In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv21958 Modified Files: Tag: STACK2_2 stackmaxima.mac unittests.mac Log Message: Added function stack_op Index: stackmaxima.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/stackmaxima.mac,v retrieving revision 1.78.2.4 retrieving revision 1.78.2.5 diff -C2 -d -r1.78.2.4 -r1.78.2.5 *** stackmaxima.mac 3 Jun 2010 09:52:20 -0000 1.78.2.4 --- stackmaxima.mac 11 Sep 2010 15:02:13 -0000 1.78.2.5 *************** *** 590,593 **** --- 590,610 ---- )$ + /* ********************************** */ + /* Parts of expressions */ + /* ********************************** */ + + /* op(ex) is unsafe on atoms: this is a fix. */ + /* This function always returns a string */ + stack_op(ex) := block( + if atom(ex) then return(""), + if op(ex)#"-" then + if stringp(op(ex)) then return(op(ex)) else return(string(op(ex))) + else + if atom(first(ex)) then + return("") + else + if stringp(op(first(ex))) then return(op((first(ex)))) else return(string(op(ex))) + )$ + /* This function takes an expression ex and returns a list of coefficients of v */ coeff_list(ex,v):= block([deg,kloop,cl], Index: unittests.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/unittests.mac,v retrieving revision 1.13.2.1 retrieving revision 1.13.2.2 diff -C2 -d -r1.13.2.1 -r1.13.2.2 *** unittests.mac 3 Jun 2010 09:52:20 -0000 1.13.2.1 --- unittests.mac 11 Sep 2010 15:02:13 -0000 1.13.2.2 *************** *** 170,171 **** --- 170,185 ---- UT('stack_assignmentp(1=x),false); + UT('stack_op(1),""); + UT('stack_op(x),""); + UT('stack_op(%pi),""); + UT('stack_op(3+z),"+"); + UT('stack_op(3*z),"*"); + UT('stack_op(3^z),"^"); + UT('stack_op(3/z),STACK_DIV_OP); + UT('stack_op(sin(3*z)),"sin"); + UT('stack_op((-1)/(x^2+1)),"/"); + UT('stack_op(1-x),"+"); + UT('stack_op(x-1),"+"); + UT('stack_op("-"(x-1)),"+"); + UT('stack_op("-"(1/(x^2+1))),STACK_DIV_OP); + UT('stack_op("-"(2*x)),"*"); |