Go to the first, previous, next, last section, table of contents.


mathematica.rtomstr

mathematica.rtomstr(t)
:: translate the object t into a string that can be understandable by Mathematica as far as possible.
return
String
t
Object
[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)
Reference
ox_execute_string, ToExpression(Mathematica), mathematica.tree_to_string


Go to the first, previous, next, last section, table of contents.