This interface provides different methods to construct a
Bidiagonal
matrix. Only the non-zero elements of are
stored, i.e.
if is lower-bidiagonal or
if is upper-bidiagonal.
Warning
By default, the matrix is lower-bidiagonal. To create an upper-
bidiagonal, set A%which = "U"
.
Bidiagonal
matrix filled with zeros: integer, parameter :: n = 100
type(Bidiagonal) :: A
A = Bidiagonal(n)
Bidiagonal
matrix from rank-1 arrays: integer, parameter :: n
real(dp), allocatable :: ev(:), dv(:)
type(Bidiagonal) :: A
integer :: i
dv = [(i, i=1, n)]; ev = [(2*i, i=1, n)]
A = Bidiagonal(dv, ev)
Bidiagonal
matrix with constant diagonals: integer, parameter :: n
real(dp), parameter :: d = 1.0_dp, e = 2.0_dp
type(Bidiagonal) :: A
A = Bidiagonal(d, e, n)
Note
Only double precision
is currently supported for this matrix type.
Construct a Bidiagonal
matrix from the rank-1 arrays dv
and ev
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | dv(:) |
Bidiagonal elements of the matrix. |
||
real(kind=dp), | intent(in) | :: | ev(:) |
Bidiagonal elements of the matrix. |
||
character(len=1), | intent(in), | optional | :: | which |
Whether |
Bidiagonal matrix.
Construct a Bidiagonal
matrix with constant diagonal elements.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | d |
Bidiagonal elements of the matrix. |
||
real(kind=dp), | intent(in) | :: | e |
Bidiagonal elements of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | n |
Dimension of the matrix. |
||
character(len=1), | intent(in), | optional | :: | which |
Whether |
Symmetric Bidiagonal matrix.
Construct a Bidiagonal
matrix filled with zeros.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ilp), | intent(in) | :: | n |
Dimension of the matrix. |
Symmetric Bidiagonal matrix.
This interface provides methods to convert a Bidiagonal
matrix
to a regular rank-2 array.
B = dense(A)
A
: Matrix of Bidiagonal
type.
It is an intent(in)
argument.
B
: Rank-2 array representation of the matrix .
Utility function to convert a Bidiagonal
matrix to a
rank-2 array.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | 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
Bidiagonal
.
d = det(A)
A
: Matrix of Bidiagonal
type.
It is in an intent(in)
argument.
d
: Determinant of the matrix.
Compute the determinant of a Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | 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 real-valued matrix
whose type is Bidiagonal
.
call eig(A, lambda [, left] [, right])
A
: real
-valued matrix of Bidiagonal
.
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 Bidiagonal
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
Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | 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 eigvalsh
interface from
stdlib_linalg
to compute the eigenvalues of a real-valued matrix
whose type is Bidiagonal
.
lambda = eigvals(A)
A
: real
-valued matrix of Bidiagonal
type.
It is an intent(in)
argument.
lambda
: Vector of eigenvalues in increasing order.
Utility function to compute the eigenvalues of a real
Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | intent(in) | :: | A |
Input matrix. |
Eigenvalues.
Utility function to compute the inverse of a Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | intent(in) | :: | A |
Input matrix. |
Inverse of A
.
This interface overloads the Fortran intrinsic matmul
for a
Bidiagonal
matrix, both for matrix-vector and matrix-matrix
products. For a matrix-matrix product , only the matrix
has to be a Bidiagonal
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 Bidiagonal
matrix . Both x
and y
are rank-1 arrays with the same
kind as A
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | intent(in), | target | :: | A |
Input matrix. |
|
real(kind=dp), | intent(in), | target | :: | x(:) |
Input vector. |
Output vector.
Compute the matrix-matrix product for a Bidiagonal
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(Bidiagonal), | intent(in) | :: | A |
Input matrix. |
||
real(kind=dp), | intent(in) | :: | X(:,:) |
Input vectors. |
Output vectors.
Utility function to perform a scalar multiplication with a
Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | intent(in) | :: | A | |||
real(kind=dp), | intent(in) | :: | alpha |
Utility function to perform a scalar multiplication with a
Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | alpha | |||
type(Bidiagonal), | intent(in) | :: | A |
Utility function to get the shape of a Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | intent(in) | :: | A |
Input matrix. |
Shape of the matrix.
Utility function to return the size of Bidiagonal
matrix along
a given dimension.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | 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
Bidiagonal
matrix. It also enables to solve a linear system with
multiple right-hand sides.
x = solve(A, b)
A
: Matrix of Bidiagonal
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.
x
: Solution of the linear system.
It has the same type and shape as b
.
Solve the linear system where is of type
Bidiagonal
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(Bidiagonal), | intent(in) | :: | A |
Coefficient matrix. |
||
real(kind=dp), | intent(in) | :: | b(:,:) |
Right-hand side vectors. |
Solution vectors.
Solve the linear system where is of type
Bidiagonal
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(Bidiagonal), | intent(in) | :: | A |
Coefficient matrix. |
||
real(kind=dp), | intent(in) | :: | b(:) |
Right-hand side vector. |
Solution vector.
This interface overloads the svd
interface from stdlib_linalg
to compute the the singular value decomposition of a Bidiagonal
matrix .
call svd(A, s [, u] [, vt])
A
: Matrix of Bidiagonal
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 Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | 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 Bidiagonal
matrix .
s = svdvals(A)
A
: Matrix of Bidiagonal
type.
It is an intent(in)
argument.
s
: Vector of singular values sorted in decreasing order.
Compute the singular values of a Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | 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 Bidiagonal
.
tr = trace(A)
A
: Matrix of Bidiagonal
type.
It is an intent(in)
argument.
tr
: Trace of the matrix.
Compute the trace of a Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | intent(in) | :: | A |
Input matrix. |
Trace of the matrix.
This interface overloads the Fortran intrinsic
procedure to define
the transpose of a Bidiagonal
matrix.
B = transpose(A)
A
: Matrix of Bidiagonal
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 Bidiagonal
matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Bidiagonal), | intent(in) | :: | A |
Input matrix. |
Transpose of the matrix.
Base type used to define a Bidiagonal
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
Bidiagonal
matrix. Only the non-zero elements of are
stored, i.e.
private pure, module function construct (dv, ev, which) | Construct a |
private pure, module function construct_constant (d, e, n, which) | Construct a |
private pure, module function initialize (n) | Construct a |