This interface provides different methods to construct a
SymTridiagonal matrix. Only the non-zero elements of are
stored, i.e.
SymTridiagonal matrix filled with zeros: integer, parameter :: n = 100
type(SymTridiagonal) :: A
A = SymTridiagonal(n)
SymTridiagonal matrix from rank-1 arrays: integer, parameter :: n
real(dp), allocatable :: ev(:), dv(:)
type(SymTridiagonal) :: A
integer :: i
dv = [(i, i=1, n)]; ev = [(2*i, i=1, n)]
A = Tridiagonal(dv, ev)
SymTridiagonal matrix with constant diagonals: integer, parameter :: n
real(dp), parameter :: d = 1.0_dp, e = 2.0_dp
type(SymTridiagonal) :: A
A = SymTridiagonal(d, e, n)
Note
Only double precision is currently supported for this matrix type.
Note
If is known to be symmetric positive definite, it can be
constructed as A = SymTridiagonal(dv, ev, ifposdef=.true.):w
Construct a SymTridiagonal matrix from the rank-1 arrays
dv and ev.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | dv(:) |
SymTridiagonal elements of the matrix. |
||
| real(kind=dp), | intent(in) | :: | ev(:) |
SymTridiagonal elements of the matrix. |
||
| logical(kind=lk), | intent(in), | optional | :: | isposdef |
Whether |
Symmetric Tridiagonal matrix.
Construct a SymTridiagonal matrix with constant diagonal
elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | d |
SymTridiagonal elements of the matrix. |
||
| real(kind=dp), | intent(in) | :: | e |
SymTridiagonal elements of the matrix. |
||
| integer(kind=ilp), | intent(in) | :: | n |
Dimension of the matrix. |
||
| logical(kind=lk), | intent(in), | optional | :: | isposdef |
Whether |
Symmetric Tridiagonal matrix.
Construct a SymTridiagonal matrix filled with zeros.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ilp), | intent(in) | :: | n |
Dimension of the matrix. |
Symmetric Tridiagonal matrix.
This interface provides methods to convert a SymTridiagonal matrix
to a regular rank-2 array.
B = dense(A)
A : Matrix of SymTridiagonal type.
It is an intent(in) argument.
B : Rank-2 array representation of the matrix .
Convert a SymTridiagonal matrix to a rank-2 array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input diagonal matrix. |
Output dense rank-2 array.
This interface overloads the det interface from stdlib_linag to
compute the determinant where is of type
SymTridiagonal.
d = det(A)
A : Matrix of SymTridiagonal type.
It is in an intent(in) argument.
d : Determinant of the matrix.
Compute the determinant of a SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
Determinant of the matrix.
This interface overloads the eigh interface from stdlib_linalg
to compute the eigenvalues and eigenvectors of a matrix whose
type is SymTridiagonal.
call eigh(A, lambda [, vectors])
A : Matrix of SymTridiagonal.
It is an intent(in) argument.
lambda : Rank-1 real array returning the eigenvalues of A
in increasing order. It is an intent(out) argument.
vectors (optional) : Rank-2 array of the same kind as A
returning the eigenvectors of A.
It is an intent(out) argument.
Compute the eigenvalues and eigenvectors of a SymTridiagonal
matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| real(kind=dp), | intent(out), | allocatable | :: | lambda(:) |
Eigenvalues. |
|
| real(kind=dp), | intent(out), | optional, | allocatable, target | :: | vectors(:,:) |
Eigenvectors. |
This interface overloads the eigvalsh interface from
stdlib_linalg to compute the eigenvalues of a matrix whose
type is SymTridiagonal.
lambda = eigvalsh(A)
A : real-valued matrix of SymTridiagonal type.
It is an intent(in) argument.
lambda : Vector of eigenvalues in increasing order.
Utility function to compute the eigenvalues of a real
SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
Eigenvalues.
Compute the inverse of a SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
Inverse of A.
This interface overloads the Fortran intrinsic matmul for a
SymTridiagonal matrix, both for matrix-vector and matrix-matrix
products. For a matrix-matrix product , only the matrix
has to be a SymTridiagonal matrix. Both and
need to be standard Fortran rank-2 arrays. All the underlying
functions are defined as pure.
y = matmul(A, x)
Compute the matrix-vector product for a SymTridiagonal
matrix . Both x and y are rank-1 arrays with the same
kind as A.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| real(kind=dp), | intent(in), | target | :: | x(:) |
Input vector. |
Output vector.
Compute the matrix-matrix product for a SymTridiagonal
matrix and a dense matrix (rank-2 array). is
also a rank-2 array with the same dimensions as .
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| real(kind=dp), | intent(in) | :: | X(:,:) |
Input vectors. |
Output vectors.
Scalar multiplication with a SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A | |||
| real(kind=dp), | intent(in) | :: | alpha |
Scalar multiplication with a SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | alpha | |||
| type(SymTridiagonal), | intent(in) | :: | A |
Return the shape of a SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
Shape of the matrix.
Return the size of SymTridiagonal matrix along a given
dimension.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| integer(kind=ilp), | intent(in), | optional | :: | dim |
Queried dimension. |
Size of the matrix along the dimension dim.
This interface overloads the solve interface from stdlib_linalg
for solving a linear system where is a
SymTridiagonal matrix. It also enables to solve a linear system
with multiple right-hand sides.
x = solve(A, b [, refine])
A : Matrix of SymTridiagonal type.
It is an intent(in) argument.
b : Rank-1 or rank-2 array defining the right-hand side(s).
It is an intent(in) argument.
refine (optional) : Logical switch to enable solution refinement.
x : Solution of the linear system.
It has the same type and shape as b.
Solve the linear system where is of type
SymTridiagonal and B a standard rank-2 array. The solution
matrix X has the same dimensions and kind as B.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Coefficient matrix. |
||
| real(kind=dp), | intent(in) | :: | b(:,:) |
Right-hand side vectors. |
||
| logical(kind=lk), | intent(in), | optional | :: | refine |
Whether iterative refinement of the solution is used or not. |
Solution vectors.
Solve the linear system where is of type
SymTridiagonal and b a standard rank-1 array. The solution
vector x has the same dimension and kind as b.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Coefficient matrix. |
||
| real(kind=dp), | intent(in), | target | :: | b(:) |
Right-hand side vector. |
|
| logical(kind=lk), | intent(in), | optional | :: | refine |
Whether iterative refinement of the solution is used or not. |
Solution vector.
This interface overloads the svd interface from stdlib_linalg to
compute the the singular value decomposition of a SymTridiagonal
matrix .
call svd(A, s [, u] [, vt])
A : Matrix of SymTridiagonal type.
It is an intent(in) argument.
s : Rank-1 array real array returning the singular values of
A. It is an intent(out) argument.
u (optional) : Rank-2 array of the same kind as A returning
the left singular vectors of A as columns. Its
size should be [n, n].
It is an intent(out) argument.
vt (optional) : Rank-2 array of the same kind as A returning
the right singular vectors of A as rows. Its
size should be [n, n].
It is an intent(out) argument.
Compute the singular value decomposition of a SymTridiagonal
matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| real(kind=dp), | intent(out), | allocatable | :: | s(:) |
Singular values in descending order. |
|
| real(kind=dp), | intent(out), | optional, | allocatable | :: | u(:,:) |
Left singular vectors as columns. |
| real(kind=dp), | intent(out), | optional, | allocatable | :: | vt(:,:) |
Right singular vectors as rows. |
This interface overloads the svdvals interface from stdlib_linalg
to compute the singular values of a SymTridiagonal matrix .
s = svdvals(A)
A : Matrix of SymTridiagonal type.
It is an intent(in) argument.
s : Vector of singular values sorted in decreasing order.
Compute the singular values of a SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
Singular values in descending order.
This interface overloads the trace interface from stdlib_linalg
to compute the trace of a matrix of type SymTridiagonal.
tr = trace(A)
A : Matrix of SymTridiagonal type.
It is an intent(in) argument.
tr: Trace of the matrix.
Compute the trace of a SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
Trace of the matrix.
This interface overloads the Fortran intrinsic procedure to define
the transpose operation for a SymTridiagonal matrix.
B = transpose(A)
A : Matrix of SymTridiagonal type.
It is an intent(in) argument.
B : Resulting transposed matrix. It is of the same type as A.
Compute the transpose of a SymTridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SymTridiagonal), | intent(in) | :: | A |
Input matrix. |
Transpose of the matrix.
Base type used to define a SymTridiagonal matrix of size [n, n]
with diagonals given by rank-1 arrays dv (size n) and ev
(size n-1).
This interface provides different methods to construct a
SymTridiagonal matrix. Only the non-zero elements of are
stored, i.e.
| private pure, module function construct (dv, ev, isposdef) | Construct a |
| private pure, module function construct_constant (d, e, n, isposdef) | Construct a |
| private pure, module function initialize (n) | Construct a |