generate::C -- generate C formatted
string
Introductiongenerate::C(e) generates C output for the
MuPAD expression e.
Call(s)generate::C(e)
Parameterse |
- | an expression, equation or list of equations |
Returnsgenerate::C returns a string containing C code.
Related
Functionsfprint, print, generate::optimize
Detailsdouble.fprint. Use the printing option
Unquoted to remove quotes and to expand special characters
like newlines and tabs.generate::optimize may be used to
optimize the input before generating the C code.
Example
1A list of equations is converted into a sequence of assignments.
>> generate::C( [ x[1]=y[2+i]^2*(y[1]+sin(z)), x[2]=tan(x[1]^4) ] ): print(Unquoted,%)
x[1] = (y[i + 2]*y[i + 2])*(sin(z) + y[1]) ;
x[2] = tan(pow(x[1], 4.0)) ;
Example
2The code produced by generate::C is not
optimized:
>> print(Unquoted,
generate::C([x = a + b, y = (a + b)^2])):
x = a + b ;
y = pow(a + b, 2.0) ;
generate::optimize tries to
reduce the number of operations:
>> print(Unquoted,
generate::C(
generate::optimize([x = a + b, y = (a + b)^2])
)):
x = a + b ;
y = x*x ;