A collection of numerical array utilities.
These are general utility functions that depend only on the numpy array model. All pyformex modules needing numpy should import everything from this module:
from arraytools import *
Return the sin of an angle in degrees.
For convenience, this can also be used with an angle in radians, by specifying angle_spec=Rad.
Return the cos of an angle in degrees.
For convenience, this can also be used with an angle in radians, by specifying angle_spec=Rad.
Return the tan of an angle in degrees.
For convenience, this can also be used with an angle in radians, by specifying angle_spec=Rad.
Return the dot product of vectors of A and B in the direction of axis.
The default axis is the last.
Returns the length of the vectors of A in the direction of axis.
The default axis is the last.
Normalize the vectors of A in the direction of axis.
The default axis is the last.
Return the (signed) length of the projection of vector of A on B.
The default axis is the last.
Return thr n-norm of the vector v.
Default is the quadratic norm (vector length). n == 1 returns the sum. n <= 0 returns the max absolute value.
Returns an array flagging the elements close to target.
values is a float array, target is a float value. values and target should be broadcastable to the same shape.
The return value is a boolean array with shape of values flagging
where the values are close to target.
Two values a and b are considered close if
Return a unit vector in the direction of v.
v is either an integer specifying one of the global axes (0,1,2), or a 3-element array or compatible.
Return a rotation matrix over angle, optionally around axis.
The angle is specified in degrees, unless angle_spec=Rad is specified. If axis==None (default), a 2x2 rotation matrix is returned. Else, axis should specifying the rotation axis in a 3D world. It is either one of 0,1,2, specifying a global axis, or a vector with 3 components specifying an axis through the origin. In either case a 3x3 rotation matrix is returned. Note that:
but the latter functions calls are more efficient. The result is returned as an array.
Create a rotation matrix that rotates axis 0 to the given vector.
u is a vector representing the Return either a 3x3(default) or 4x4(if n==4) rotation matrix.
Check that an array a has the correct shape and type.
The input a is anything that can be converted into a numpy array. Either shape and/or kind can be specified. and will then be checked. The dimensions where shape contains a -1 value are not checked. The number of dimensions should match. If kind does not match, but the value is included in allow, conversion to the requested type is attempted.
Returns the array if valid; else, an error is raised.
Check that an array a has the correct size and type.
Either size and or kind can be specified. If kind does not match, but is included in allow, conversion to the requested type is attempted. Returns the array if valid. Else, an error is raised.
Check that an array contains a set of uniqe integers in range.
nrs is an integer array with any shape. All integers should be unique and in the range(nmin,nmax). Beware: this means that nmin <= i < nmax ! Default nmax is unlimited. Set nmin to None to error is the value to return if the tests are not passed. By default, a ValueError is raised. On success, None is returned