4. CyML Language Specification¶
This document specifies the CyML language, an extended Cython subset supported.
5. CyML Language Specification¶
This document specifies the CyML language, an extended Cython subset supported.
5.1. Cython file types¶
- The implementation files, carrying a
.pyx
suffix.
5.4. Conditional Statements¶
- IF
- IF/Else
- IF/ElseIf/Else
The ELIF
and ELSE
clauses are optional. An IF
statement can appear
anywhere that a normal statement or declaration can appear
5.5. Integer For Loops¶
CyML recognises the usual Python for-in-range integer loop pattern:
for i in range(n):
...
for i in range(f,n):
...
for i in range(f,n, s):
...
Like other Python looping statements, break and continue may be used in the body, without else clause statement.
5.6. While Loop¶
- Like Python While loop
5.7. Function¶
- Parameters with declaration
- Default value is possible
5.8. Return Statement¶
- A function needs to return the same data type.
The following code is valid:
def fibonacci(int n):
if n <= 2:
return 1
else:
return fibonacci(n-1)+fibonacci(n-2)
5.9. Call functions¶
- Call to CyML functions are supported if the function
- is accessible on the module
- is accessible from import statement
5.10. Operators¶
Assignment
Assign | b = a |
Unary operators
UAdd | +a |
USub | -a |
Binary operators
Add | a + b |
Sub | a - b |
Mult | a * b |
Div | a / b |
Pow | a ** b |
Mod | a % b |
BitOr | a | b |
BitAnd | a & b |
Augmented assign statements
AugAdd | a += b |
AugSub | a -= b |
AugMult | a *= b |
AugDiv | a /= b |
Comparison Operators
Eq | a == b |
NotEq | a != b |
Lt | a < b |
LtE | a <= b |
Gt | a > b |
GtE | a >= b |
Bool Operators
&& | a and b |
|| | a or b |
5.11. Array routines¶
`` `` | Return a new array of given shape and type, without initializing entries. |
`` `` | Return a new array of given shape and type, filled with ones. |
`` `` | Return a new array of given shape and type, filled with zeros. |
5.12. Mathematical functions¶
Trigonometric functions
sin(x) |
Trigonometric sine, element-wise. |
cos(x) |
Cosine elementwise. |
tan(x) |
Compute tangent element-wise. |
arcsin(x) |
Inverse sine, element-wise. |
arccos(x) |
Trigonometric inverse cosine, element-wise. |
arctan(x) |
Trigonometric inverse tangent, element-wise. |
Hyperbolic functions
sinh(x) |
Hyperbolic sine, element-wise. |
cosh(x) |
Hyperbolic cosine, element-wise. |
tanh(x) |
Compute hyperbolic tangent element-wise. |