Native functions standard library

Aseba provides a standard library of native functions. Targets should normally1 provide this library. If your target's firmware holds an old version of Aseba, not all functions might be available. In Aseba version 1.1, the following functions are available2:

math.copy(A,B)
Copy the array in the array , element by element: .
math.fill(A,c)
Fill each element of the array with the constant : .
math.addscalar(A, B, c)
Compute where is a scalar.
math.add(A, B, C)
Compute where , and are three arrays of the same size.
math.sub(A, B, C)
Compute where , and are three arrays of the same size.
math.mul(A, B, C)
Compute where , and are three arrays of the same size. Note that this is not a dot product.
math.div(A, B, C)
Compute where , and are three arrays of the same size. An exception will be triggered if a division by zero occurs.
math.min(A, B, C)
Write the minimum of each element of and in where , and are three arrays of the same size: .
math.max(A, B, C)
Write the maximum of each element of and in where , and are three arrays of the same size: .
math.dot(r, A, B, n)
Compute the dot product between two arrays of the same size and :
math.stat(V, min, max, mean)
Compute the minimum, the maximum and the mean values of array .
math.argbounds(A, argmin, argmax)
Get the indices argmin and argmax corresponding to the minimum respectively maximum values of array .
math.sort(A)
Sort the array in place.
math.muldiv(A, B, C, D)
Compute multiplication-division using internal 32-bit precision: . An exception will be triggered if a division by zero occurs.
math.atan2(A, Y, X)
Compute using the signs of and to determine the quadrant of the output, where , and are three arrays of the same size. Note that and will produce ..
math.sin(A, B)
Compute where and are two arrays of the same size.
math.cos(A, B)
Compute where and are two arrays of the same size.
math.rot2(A, B, angle)
Rotate the array by angle, write the result to . Note that and must both be arrays of size 2.
math.sqrt(A, B)
Compute where and are two arrays of the same size.
math.nzseq(a, B, m)
Write to the middle index of the largest sequence of non-zero elements from , if not found or if the sequence is smaller than .
math.rand(v)
Return a random value in the range .