mathematica.rtomstr
asir
uses [
, ]
to express a list,
but Mathematica
uses {
, }
.
This function makes this sort of translations.
[259] mathematica.rtomstr([1,2,3]); {1,2,3} [260] mathematica.rtomstr([[1,x,x^2],[1,y,y^2]]); {{1,x,x^2},{1,y,y^2}}
Let us see one more example.
The following function mathematica.inverse(M)
outputs
the inverse matrix of the matrix M
by calling ox_math
.
It translates asir
matrix M
into a Mathematica expression
by r_tostr(M)
and makes Mathematica compute the inverse matrix of M
by
ox_execute_string
.
def inverse(M) { P = 0; A = mathematica.rtomstr(M); ox_execute_string(P,"Inverse["+A+"]"); B = ox_pop_cmo(B); C = mathematica.tree_to_string(B); return(eval_str(C)); } [269] M=[[1,x,x^2],[1,y,y^2],[1,z,z^2]]; [[1,x,x^2],[1,y,y^2],[1,z,z^2]] [270] A=mathematica.inverse(M)$ [271] red(A[0][0]); (z*y)/(x^2+(-y-z)*x+z*y)
ox_execute_string
, ToExpression
(Mathematica),
mathematica.tree_to_string
Go to the first, previous, next, last section, table of contents.