# mod_banded_matrix_hermitian Module

Contains types and routines to handle banded Hermitian matrices. We use the same conventions as explained in the LAPACK guide http://www.netlib.org/lapack/lug/node124.html.

## Derived Types

### type, public :: hermitian_banded_matrix_t

type to represent a complex Hermitian banded matrix

#### Components

TypeVisibilityAttributesNameInitial
integer, public :: n

number of rows/columns

character, public :: uplo

store upper ("U") or lower ("L") triangular part

integer, public :: kd

number of sub/superdiagonals

complex(kind=dp), public, allocatable:: AB(:,:)

the matrix in banded storage

#### Type-Bound Procedures

 procedure, public :: get_element procedure, public :: set_element procedure, public :: get_total_nb_elements procedure, public :: is_compatible_with procedure, public :: destroy

## Functions

### public function new_hermitian_banded_matrix(rows, diags, uplo) result(matrix)

Constructor for a new Hermitian banded matrix with a given number of rows and diagonals. Allocates and initialises the datatype. initialise all to zero

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: rows

number of rows/columns

integer, intent(in) :: diags

number of sub/superdiagonals

character, intent(in) :: uplo

store upper ("U") or lower ("L") triangular part

#### Return Value type(hermitian_banded_matrix_t)

the Hermitian matrix in banded storage

### private pure function get_element(this, row, col) result(element)

Retrieves the element at position (row, col) of the original matrix. See the LAPACK documentation, element $a_{ij}$ of the original matrix is stored at position $(kd + 1 + i - j, j)$ if uplo = "U" and at position $(1 + i - j, j)$ if uplo = "L" in the banded storage.

#### Arguments

TypeIntentOptionalAttributesName
class(hermitian_banded_matrix_t), intent(in) :: this

type instance

integer, intent(in) :: row

the row index of the original position

integer, intent(in) :: col

the column index of the original position

#### Return Value complex(kind=dp)

the element at the original position (row, col)

### private pure function get_total_nb_elements(this)

Returns the total number of elements inside the banded matrix

#### Arguments

TypeIntentOptionalAttributesName
class(hermitian_banded_matrix_t), intent(in) :: this

type instance

### private pure function uplo_is_valid(uplo)

Checks whether the given uplo parameter is valid.

#### Arguments

TypeIntentOptionalAttributesName
character, intent(in) :: uplo

uplo character to check

### private pure function is_within_band(matrix, row, col)

Checks if a given position (row, col) is within the banded structure. For uplo = "U" the position is within the band if for uplo = "L" the position is within the band if with $kd$ the number of sub/superdiagonals and $n$ the number of rows/columns.

#### Arguments

TypeIntentOptionalAttributesName
class(hermitian_banded_matrix_t), intent(in) :: matrix

Hermitian banded matrix structure

integer, intent(in) :: row

the row index

integer, intent(in) :: col

the column index

### private pure function is_compatible_with(this, other)

Checks if a Hermitian band matrix is compatible with another Hermitian band matrix. This implies that the following attributes should be equal: - number of rows/columns - number of sub/superdiagonals - storage of upper or lower triangular part - dimensions of the banded matrices themselves Returns .true. if all criteria are satisfied, .false. otherwise.

#### Arguments

TypeIntentOptionalAttributesName
class(hermitian_banded_matrix_t), intent(in) :: this

type instance

class(hermitian_banded_matrix_t), intent(in) :: other

other banded matrix

## Subroutines

### private pure subroutine set_element(this, row, col, element)

Sets the element $a_{ij}$ of the original array into the banded structure. The row and col arguments refer to the row and column indices of the element in the original array. This routine has no effect if the location falls outside of the banded structure.

#### Arguments

TypeIntentOptionalAttributesName
class(hermitian_banded_matrix_t), intent(inout) :: this

type instance

integer, intent(in) :: row

row index of element

integer, intent(in) :: col

column index of element

complex(kind=dp), intent(in) :: element

value for the element at (row, col)

### private pure subroutine destroy(this)

Destructor, deallocates the datastructure.

#### Arguments

TypeIntentOptionalAttributesName
class(hermitian_banded_matrix_t), intent(inout) :: this

type instance