C Functions
SymbolicC supports working with C functions, as described in this section.
Defining Functions
First, you need to load the package.
Needs["SymbolicC`"]Now, you can create a C function with CFunction.
CFunction[ int, name, {}, {CAssign[a, b], COperator[Plus, {a, b}]}]//ToCCodeStringYou can give a list as the type specification if you need type qualifiers.
CFunction[{static, int}, name, {}, {CAssign[a, b], COperator[Plus, {a, b}]}]//ToCCodeStringCalling Functions
First, you need to load the package.
Needs["SymbolicC`"]Now, you can call a C function with CCall.
CCall[function, {a, b}]//ToCCodeStringStandard Math Operators
First, you need to load the package.
Needs["SymbolicC`"]SymbolicC provides a full range of the standard C math operators. These generate function calls, as shown in the following.
CStandardMathOperator[Cos, {a}]//ToCCodeStringFor some standard math operators there is no corresponding Wolfram Language function. In this case a string is used, as shown below.
CStandardMathOperator["ldexp", {a}]//ToCCodeStringThe full list of standard math operators is given below, showing the name in the Wolfram Language and the output C name.
| ArcCos | acos |
| ArcSin | asin |
| ArcTan | atan (one argument) |
| ArcTan | atan2 (two arguments) |
| Ceiling | ceil |
| Cos | cos |
| Cosh | cosh |
| Exp | exp |
| Abs | fabs |
| Floor | floor |
| "frexp" | frexp |
| "ldexp" | ldexp |
| Log | log |
| Log10 | log10 |
| "modf" | modf |
| Power | pow |
| Sin | sin |
| Sinh | sinh |
| Sqrt | sqrt |
| Tan | tan |
| Tanh | tanh |
Wolfram Language function names and the corresponding standard math functions.