math module reference

math module reference

Mathematical functions.

This module is exactly like math-simple, except that the operators also work componentwise with vectors (num[X]) and matrices (num[X][Y]). All operators are PureOps.

(+ 1 2 3) #(<num= 6>)
(+ [1 2] [3 4]) #(<num[2]= [4 6]>)

The arguments for an operator generally have to be of the same type. However it is also okay to pass in scalar numbers together with a different type. The scalars will be repeated as necessary to fit the shape of other arguments:

(* [[1 2] [3 4]]
   2)
#(<num[2][2]= [[2 4] [6 8]]>)

The mul (*) operator is the only exception to this, as it handles matrix-matrix and matrix-vector multiplication according to linear algebra.

index

details