Math#
This module contains math functions.
Core
|
Return a sequence from batches of evenly spaced samples between pairs of milestone points. |
|
Rotation matrix with given rotation axis and dimension (2d or 3d). |
Field
|
|
|
|
|
Extract gradient or interpolated field values at quadrature points. |
|
Return values of a field or a tuple of fields. |
|
Calculate the norm of an array or the norms of a list of arrays. |
|
Interpolate method of field A. |
|
Gradient method of field A. |
Tensor
|
Identity according to matrix A with optional specified dim. |
|
Symmetric part of matrix A. |
|
Dyadic (outer or kronecker) product of two tensors. |
|
"Inverse of A with optionally pre-calculated determinant, optional additional output of the calculated determinant or a simplified calculation of the inverse for sym. |
|
Determinant of matrix A. |
|
Deviator of matrix A. |
|
Cofactor matrix of A (as a wrapper for the inverse of A). |
|
Eigenvalues and -vectors of matrix A. |
|
Eigenvalues and -vectors of a symmetric matrix A. |
|
Eigenvalues (and optional principal shear values) of a matrix A. |
|
Eigenvalues (and optional principal shear values) of a symmetric matrix A. |
|
Transpose (mode=1) or major-transpose (mode=2) of matrix A. |
|
|
|
The sum of the diagonal elements of A. |
|
ik - crossed dyadic-product of A and B. |
|
il - crossed dyadic-product of A and B. |
|
symmetric - crossed dyadic-product of A and B. |
|
Cross product of two vectors a and b. |
|
Dot-product of A and B with inputs of n trailing axes.. |
|
Double-Dot-product of A and B with inputs of n trailing axes. |
|
Convert (3, 3) tensor to (6, ) voigt notation. |
|
|
|
Detailed API Reference
- felupe.math.cdya(A, B, parallel=False, **kwargs)[source]#
symmetric - crossed dyadic-product of A and B.
- felupe.math.cdya_ik(A, B, parallel=False, **kwargs)[source]#
ik - crossed dyadic-product of A and B.
- felupe.math.cdya_il(A, B, parallel=False, **kwargs)[source]#
il - crossed dyadic-product of A and B.
- felupe.math.ddot(A, B, mode=(2, 2), parallel=False)[source]#
Double-Dot-product of A and B with inputs of n trailing axes.
- felupe.math.dot(A, B, mode=(2, 2), parallel=False)[source]#
Dot-product of A and B with inputs of n trailing axes..
- felupe.math.dya(A, B, mode=2, parallel=False, **kwargs)[source]#
Dyadic (outer or kronecker) product of two tensors.
- felupe.math.eigvals(A, shear=False, eig=<function eig>)[source]#
Eigenvalues (and optional principal shear values) of a matrix A.
- felupe.math.eigvalsh(A, shear=False)[source]#
Eigenvalues (and optional principal shear values) of a symmetric matrix A.
- felupe.math.extract(field, grad=True, sym=False, add_identity=True)[source]#
Extract gradient or interpolated field values at quadrature points.
- felupe.math.identity(A=None, dim=None, shape=None)[source]#
Identity according to matrix A with optional specified dim.
- felupe.math.inv(A, determinant=None, full_output=False, sym=False)[source]#
“Inverse of A with optionally pre-calculated determinant, optional additional output of the calculated determinant or a simplified calculation of the inverse for sym. matrices.
- felupe.math.linsteps(points, num=10, endpoint=True, axis=None, axes=None)[source]#
Return a sequence from batches of evenly spaced samples between pairs of milestone points.
- Parameters:
points (array_like) – The milestone values of the sequence.
num (int, optional) – Number of samples (without the end point) to generate. Must be non-negative (default is 10).
endpoint (bool, optional) – If True,
points[-1]
is the last sample. Otherwise, it is not included (default is True).axis (int or None, optional) – The axis in the result to store the samples. By default (None), the samples will be concatenated along the existing first axis. If
axis > 0
, the samples will be inserted at columnaxis
. Only positive integers are supported.axes (int or None, optional) – Number of output columns if
axis
is not None. Requiresaxes > axis
and will be set toaxes = axis + 1
by default (None).
- Returns:
samples – Concatenated batches of
num
equally spaced samples.- Return type:
ndarray
Examples
>>> import felupe as fem
>>> fem.math.linsteps([0, 0.5, 1.5, 3.5], num=2) array([0. , 0.25, 0.5 , 1. , 1.5 , 2.5 , 3.5 ])
Not including the end value of the sequence does not change the step size.
>>> fem.math.linsteps([0, 0.5, 1.5, 3.5], num=2, endpoint=False) array([0. , 0.25, 0.5 , 1. , 1.5 , 2.5 ])
>>> fem.math.linsteps([0, 0.5, 1.5, 3.5], num=2, axis=1) array([[0. , 0. ], [0. , 0.25], [0. , 0.5 ], [0. , 1. ], [0. , 1.5 ], [0. , 2.5 ], [0. , 3.5 ]])
Output with four columns:
>>> fem.math.linsteps([0, 0.5, 1.5, 3.5], num=2, axis=1, axes=4) array([[0. , 0. , 0. , 0. ], [0. , 0.25, 0. , 0. ], [0. , 0.5 , 0. , 0. ], [0. , 1. , 0. , 0. ], [0. , 1.5 , 0. , 0. ], [0. , 2.5 , 0. , 0. ], [0. , 3.5 , 0. , 0. ]])
The ouput degenerates to the end value
>>> fem.math.linsteps([0, 0.5, 1.5, 3.5], num=0) array([3.5])
or an empty array.
>>> fem.math.linsteps([0, 0.5, 1.5, 3.5], num=0, endpoint=False) array([], dtype=float64)
See also
numpy.linspace
Return evenly spaced numbers over a specified interval.
- felupe.math.norm(array, axis=None)[source]#
Calculate the norm of an array or the norms of a list of arrays.
- felupe.math.rotation_matrix(alpha_deg, dim=3, axis=0)[source]#
Rotation matrix with given rotation axis and dimension (2d or 3d).
- Parameters:
alpha_deg (int) – Rotation angle in degree.
dim (int, optional (default is 3)) – Dimension of the rotation matrix.
axis (int, optional (default is 0)) – Rotation axis.
- Returns:
rotation_matrix – Rotation matrix of dim 2 or 3 with given rotation axis.
- Return type:
ndarray