This interface provides different methods to construct a
Tridiagonal matrix. Only the non-zero elements of are
stored, i.e.
Tridiagonal matrix filled with zeros: integer, parameter :: n = 100
type(Tridiagonal) :: A
A = Tridiagonal(n)
Tridiagonal matrix from rank-1 arrays: integer, parameter :: n
real(dp), allocatable :: dl(:), dv(:), du(:)
type(Tridiagonal) :: A
integer :: i
dl = [(i, i=1, n-1)]; dv = [(2*i, i=1, n)]; du = [(3*i, i=1, n)]
A = Tridiagonal(dl, dv, du)
Tridiagonal matrix with constant diagonals: integer, parameter :: n
real(dp), parameter :: a = 1.0_dp, b = 1.0_dp, c = 2.0_dp
type(Tridiagonal) :: A
A = Tridiagonal(a, b, c, n)
Note
Only double precision is currently supported for this matrix type.
Construct a Tridiagonal matrix from the rank-1 arrays dl,
dv and du.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | dl(:) |
Tridiagonal elements of the matrix. |
||
| real(kind=dp), | intent(in) | :: | dv(:) |
Tridiagonal elements of the matrix. |
||
| real(kind=dp), | intent(in) | :: | du(:) |
Tridiagonal elements of the matrix. |
Tridiagonal matrix.
Construct a Tridiagonal matrix with constant diagonal elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | dl |
Tridiagonal elements of the matrix. |
||
| real(kind=dp), | intent(in) | :: | dv |
Tridiagonal elements of the matrix. |
||
| real(kind=dp), | intent(in) | :: | du |
Tridiagonal elements of the matrix. |
||
| integer(kind=ilp), | intent(in) | :: | n |
Dimension of the matrix. |
Tridiagonal matrix.
Construct a Tridiagonal matrix filled with zeros.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ilp), | intent(in) | :: | n |
Dimension of the matrix. |
Tridiagonal matrix.
This interface provides methods to convert a Tridiagonal matrix
to a regular rank-2 array.
B = dense(A)
A : Matrix of Tridiagonal type.
It is an intent(in) argument.
B : Rank-2 array representation of the matrix .
Utility function to convert a Tridiagonal matrix to a rank-2
array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | 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
Tridiagonal.
d = det(A)
A : Matrix of Tridiagonal type.
It is in an intent(in) argument.
d : Determinant of the matrix.
Compute the determinant of a Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
Determinant of the matrix.
This interface overloads the eig interface from stdlib_linalg
to compute the eigenvalues and eigenvectors of a real-valued matrix
whose type is Tridiagonal.
call eig(A, lambda [, left] [, right])
A : real-valued matrix of Tridiagonal.
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.
left (optional) : complex rank-2 array of the same kind as
A returning the left eigenvectors of A.
It is an intent(out) argument.
right (optional) : complex rank-2 array of the same kind as
A returning the right eigenvectors of A.
It is an intent(out) argument.
Note
No specialized eigensolvers for generic Tridiagonal matrices exist
in LAPACK. This routine thus falls back to wrapping the eig
procedure from stdlib_linalg which uses *geev under the hood.
Utility function to compute the eigenvalues and eigenvectors of
a Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| complex(kind=dp), | intent(out) | :: | lambda(:) |
Eigenvalues. |
||
| complex(kind=dp), | intent(out), | optional | :: | left(:,:) |
Eigenvectors. |
|
| complex(kind=dp), | intent(out), | optional | :: | right(:,:) |
Eigenvectors. |
This interface overloads the eigvals interface from
stdlib_linalg to compute the eigenvalues of a real-valued matrix
whose type is Tridiagonal.
lambda = eigvals(A)
A : real-valued matrix of Tridiagonal type.
It is an intent(in) argument.
lambda : Vector of eigenvalues in increasing order.
Utility function to compute the eigenvalues of a real
Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
Eigenvalues.
Compute the inverse of a Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
Inverse of A.
This interface overloads the Fortran intrinsic matmul for a
Tridiagonal matrix, both for matrix-vector and matrix-matrix
products. For a matrix-matrix product , only the matrix
has to be a Tridiagonal 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 Tridiagonal
matrix . Both x and y are rank-1 arrays with the same
kind as A.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| real(kind=dp), | intent(in), | target | :: | x(:) |
Input vector. |
Output vector.
Compute the matrix-matrix product for a Tridiagonal
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(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| real(kind=dp), | intent(in) | :: | X(:,:) |
Input vectors. |
Output vectors.
Scalar multiplication with a Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A | |||
| real(kind=dp), | intent(in) | :: | alpha |
Scalar multiplication with a Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | alpha | |||
| type(Tridiagonal), | intent(in) | :: | A |
Return the shape of a Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
Shape of the matrix.
Return the size of Tridiagonal matrix along a given dimension.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | 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
Tridiagonal matrix. It also enables to solve a linear system with
multiple right-hand sides.
x = solve(A, b [, refine])
A : Matrix of Tridiagonal 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.
It is an intent(in) argument.
x : Solution of the linear system.
It has the same type and shape as b.
Solve the linear system where is of type
Tridiagonal 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(Tridiagonal), | intent(in) | :: | A |
Coefficient matrix. |
||
| real(kind=dp), | intent(in) | :: | b(:,:) |
Right-hand side vectors. |
||
| logical(kind=lk), | intent(in), | optional | :: | refine |
Whether iterative refined is used or not. |
Solution vectors.
Solve the linear system where is of type
Tridiagonal 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(Tridiagonal), | 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 is used or not. |
Solution vector.
This interface overloads the svd interface from stdlib_linalg
to compute the the singular value decomposition of a Tridiagonal
matrix .
call svd(A, s [, u] [, vt])
A : Matrix of Tridiagonal 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 Tridiagonal
matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
||
| real(kind=dp), | intent(out) | :: | s(:) |
Singular values in descending order. |
||
| real(kind=dp), | intent(out), | optional | :: | u(:,:) |
Left singular vectors as columns. |
|
| real(kind=dp), | intent(out), | optional | :: | vt(:,:) |
Right singular vectors as rows. |
This interface overloads the svdvals interface from
stdlib_linalg to compute the singular values of a Tridiagonal
matrix .
s = svdvals(A)
A : Matrix of Tridiagonal type.
It is an intent(in) argument.
s : Vector of singular values sorted in decreasing order.
Compute the singular values of a Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | 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 Tridiagonal.
tr = trace(A)
A : Matrix of Tridiagonal type.
It is an intent(in) argument.
tr: Trace of the matrix.
Compute the trace of a Tridiagonal matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
Trace of the matrix.
This interface overloads the Fortran intrinsic procedure to define
the transpose operation for a Tridiagonal matrix.
B = transpose(A)
A : Matrix of Tridiagonal type.
It is an intent(in) argument.
B : Resulting transposed matrix. It is of the same type as A.
Utility function to compute the transpose of a Tridiagonal
matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Tridiagonal), | intent(in) | :: | A |
Input matrix. |
Transpose of the matrix.
Base type used to define a Tridiagonal matrix of size [n, n]
with diagonals given by rank-1 arrays dl (size n), dv
(size n-1) and du (size n-1).
This interface provides different methods to construct a
Tridiagonal matrix. Only the non-zero elements of are
stored, i.e.
| private pure, module function construct (dl, dv, du) | Construct a |
| private pure, module function construct_constant (dl, dv, du, n) | Construct a |
| private pure, module function initialize (n) | Construct a |