Notes on Code Translation to CSharp
This help page describes details particular to code translation using the CodeGeneration[CSharp] function. For general information applicable to all the functions in the CodeGeneration package, see CodeGeneration/Details.
Description
In addition to the functions listed on the CodeGeneration/Details help page, the following Maple functions are recognized by CodeGeneration[CSharp]: cat, ceil, floor, and if (operator form).
Generally, math functions recognized by CodeGeneration[CSharp] are translated to functions in the System.Math library. Additionally, the Maple symbol Pi is translated to the System.Math constant Math.PI.
If the parameter to CodeGeneration[CSharp] is a procedure, the output is embedded in a class CodeGenerationClass so that it can be included easily in another CSharp program.
Note that System.Math does not have equivalents for the hyperbolic trigonometric functions, so CodeGeneration[CSharp] expresses them in terms of exponential functions.
Since there are no equivalents for sign, and signum in CSharp, CodeGeneration[CSharp] translates them to expressions involving the conditional operator.
The functions mod, modp, and mods are all translated to CSharp expressions using the modulus operator %.
Note: The behavior of these functions is inconsistent with the behavior of % for some values of the arguments.
Because Maple expressions involving powers greater than 2 are translated into Math.Pow function calls, the automatic type deduction system may not be able to deduce the most appropriate type in all cases.
CodeGeneration[CSharp] translates printf statements to Console.WriteLine calls, but performs only limited analysis of the printf format string. Thus some formatting instructions (for example, precision for floats) are ignored in translation.
Conversions between single-precision and double-precision floats are not performed. If the precision=single option is specified, explicit type casts must be added to the results of any System.Math calls generated by CodeGeneration[CSharp].
Ranges of Maple Arrays and rtables are adjusted so that the resulting CSharp arrays start with index 0.
A Maple module is translated to a CSharp class, with module members mapped to static class members. Exports of the module are translated as public methods or fields in the CSharp class, while variables local to the module are translated as private methods or fields. All class members are made static.
Types are expressed using the System types (e.g., System.String rather than string).
See Also
CodeGeneration
CodeGeneration/Details
CodeGeneration[CSharp]
Download Help Document