Various (mostly linear algebra) functions, particularly for use with small matrices.
Checks if two arrays are elementwise close within tolerance
Checks if two rank-1 floating point arrays of type double are close within tolerance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:) | :: | a | (m,) array |
|
real(kind=rp), | intent(in), | dimension(:) | :: | b | (m,) array |
|
real(kind=rp), | intent(in), | optional | :: | rel_tol | Relative tolerance; default 1e-10 |
|
real(kind=rp), | intent(in), | optional | :: | abs_tol | Absolute tolerance; default 0.0 |
Checks if two rank-2 floating point arrays of type double are close within tolerance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:,:) | :: | a | (m,n) array |
|
real(kind=rp), | intent(in), | dimension(:,:) | :: | b | (m,n) array |
|
real(kind=rp), | intent(in), | optional | :: | rel_tol | Relative tolerance; default 1e-10 |
|
real(kind=rp), | intent(in), | optional | :: | abs_tol | Absolute tolerance; default 0.0 |
Checks if two rank-3 floating point arrays of type double are close within tolerance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:,:,:) | :: | a | (m,n,p) array |
|
real(kind=rp), | intent(in), | dimension(:,:,:) | :: | b | (m,n,p) array |
|
real(kind=rp), | intent(in), | optional | :: | rel_tol | Relative tolerance; default 1e-10 |
|
real(kind=rp), | intent(in), | optional | :: | abs_tol | Absolute tolerance; default 0.0 |
Swaps two arrays
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | a | |||
integer, | intent(inout) | :: | b |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(inout) | :: | a | |||
real(kind=rp), | intent(inout) | :: | b |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=rp), | intent(inout) | :: | a | |||
complex(kind=rp), | intent(inout) | :: | b |
Returns the scalar triple product a.(b x c)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(3) | :: | a | ||
real(kind=rp), | intent(in), | dimension(3) | :: | b | ||
real(kind=rp), | intent(in), | dimension(3) | :: | c |
Returns the determinant of an (N x N) matrix, where N = 2, 3, or 4.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:,:) | :: | A | (N,N) array, where N = 2, 3, or 4. |
Returns the trace of a square matrix
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in) | :: | mat(:,:) | (N,N) array |
Checks if two floating point numbers of type double are close within tolerance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in) | :: | a | |||
real(kind=rp), | intent(in) | :: | b | |||
real(kind=rp), | intent(in), | optional | :: | rel_tol | Relative tolerance, |
|
real(kind=rp), | intent(in), | optional | :: | abs_tol | Absolute tolerance, |
Checks if two rank-1 floating point arrays of type double are close within tolerance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:) | :: | a | (m,) array |
|
real(kind=rp), | intent(in), | dimension(:) | :: | b | (m,) array |
|
real(kind=rp), | intent(in), | optional | :: | rel_tol | Relative tolerance; default 1e-10 |
|
real(kind=rp), | intent(in), | optional | :: | abs_tol | Absolute tolerance; default 0.0 |
Checks if two rank-2 floating point arrays of type double are close within tolerance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:,:) | :: | a | (m,n) array |
|
real(kind=rp), | intent(in), | dimension(:,:) | :: | b | (m,n) array |
|
real(kind=rp), | intent(in), | optional | :: | rel_tol | Relative tolerance; default 1e-10 |
|
real(kind=rp), | intent(in), | optional | :: | abs_tol | Absolute tolerance; default 0.0 |
Checks if two rank-3 floating point arrays of type double are close within tolerance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:,:,:) | :: | a | (m,n,p) array |
|
real(kind=rp), | intent(in), | dimension(:,:,:) | :: | b | (m,n,p) array |
|
real(kind=rp), | intent(in), | optional | :: | rel_tol | Relative tolerance; default 1e-10 |
|
real(kind=rp), | intent(in), | optional | :: | abs_tol | Absolute tolerance; default 0.0 |
Calculates the quadratic form x^T A x, where A is an n x n matrix and x is a vector of length n
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:,:) | :: | A | (n,n) array |
|
real(kind=rp), | intent(in), | dimension(:) | :: | x | (n,) array |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in) | :: | rad | |||
real(kind=rp), | intent(out) | :: | deg |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in) | :: | deg | |||
real(kind=rp), | intent(out) | :: | rad |
Calculates the cross product between two 3-element vectors
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(3) | :: | a | ||
real(kind=rp), | intent(in), | dimension(3) | :: | b | ||
real(kind=rp), | intent(out), | dimension(3) | :: | c | Cross product of |
Calculates the cross product matrix of a 3-element vector. The cross product matrix A of a is defined as a x b = A . b, where b is another 3-element vector.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(3) | :: | a | ||
real(kind=rp), | intent(out), | dimension(3,3) | :: | mat | Cross product matrix of |
Calculates the outer product of two vectors, .
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:) | :: | a | (m,) array |
|
real(kind=rp), | intent(in), | dimension(:) | :: | b | (n,) array |
|
real(kind=rp), | intent(out), | dimension(:,:) | :: | c | (m,n) array; Outer product |
Returns the vector triple product d = a x (b x c)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(3) | :: | a | ||
real(kind=rp), | intent(in), | dimension(3) | :: | b | ||
real(kind=rp), | intent(in), | dimension(3) | :: | c | ||
real(kind=rp), | intent(out), | dimension(3) | :: | d | Vector triple product |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | a | |||
integer, | intent(inout) | :: | b |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(inout) | :: | a | |||
real(kind=rp), | intent(inout) | :: | b |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=rp), | intent(inout) | :: | a | |||
complex(kind=rp), | intent(inout) | :: | b |
Normalizes a vector in-place. If the magnitude of the vector is nearly zero, no normalization takes place and the vector is returned as is with a warning message.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(inout), | dimension(:) | :: | a | (m,) array |
Generates evenly spaced numbers over a specified interval. Both end
points are included. If start
< finish
, the returned step size (if
step
is present) will be negative.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in) | :: | start | Starting point |
||
real(kind=rp), | intent(in) | :: | finish | Ending point, |
||
integer, | intent(in) | :: | num | Number of values to generate, |
||
real(kind=rp), | intent(out), | dimension(:) | :: | val | ( |
|
real(kind=rp), | intent(out), | optional | :: | step | Step size |
Generates numbers spaced evenly on a log scale.
In linear space, the sequence starts at base ** start
(base
to the power of start
) and ends with base ** stop
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in) | :: | start | Starting point, |
||
real(kind=rp), | intent(in) | :: | finish | Ending point, |
||
integer, | intent(in) | :: | num | Number of values to generate, |
||
real(kind=rp), | intent(out), | dimension(:) | :: | val | ( |
|
real(kind=rp), | intent(in), | optional | :: | base | Base of the logspace, default 10 |
Creates an identity matrix of size n x n.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(out), | dimension(:,:) | :: | mat_eye | (n,n) array |
Returns the diagonal elements of a square matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:,:) | :: | mat | (n,n) array |
|
real(kind=rp), | intent(out), | dimension(:) | :: | d | (n,) array; contains the entries of the main diagonal |
Adds a square matrix and its transpose in place:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(inout), | dimension(:,:) | :: | mat | (n,n) array |
Calculates the difference of a square matrix and its transpose in place:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(inout), | dimension(:,:) | :: | mat |
Multiplies a matrix with its transpose:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(:,:) | :: | A | (m,n) array |
|
real(kind=rp), | intent(out), | dimension(:,:) | :: | B | (m,m) array |
Orthogonalizes a set of vectors in-place using Gram-Schmidt orthonormalization
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(inout), | dimension(:,:) | :: | a | (m,n) array, where m <= n. The first m columns of the matrix are overwritten with the orthogonal basis vectors. |
Inverts a 3x3 matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(3,3) | :: | a | ||
real(kind=rp), | intent(out), | dimension(3,3) | :: | inv_a |
Calculates the eigenvalues of a 3 x 3 real symmetric matrix. The eigenvalues calculated are in decreasing order. Only the diagonal and lower triangular part of the matrix is accessed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | dimension(3,3) | :: | a | ||
real(kind=rp), | intent(out), | dimension(3) | :: | ev |
Calculates the eigenvalues of a symmetric 3x3 matrix A using Cardano's analytical algorithm. Only the diagonal and upper triangular parts of A are accessed. The access is read-only.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=RP), | intent(in), | DIMENSION(3,3) | :: | A | ||
real(kind=RP), | intent(out), | DIMENSION(3) | :: | W(3) |