(git:d18deda)
Loading...
Searching...
No Matches
mathlib Module Reference

Collection of simple mathematical functions and subroutines. More...

Data Types

interface  det_3x3
 
interface  invert_matrix
 
interface  set_diag
 
interface  unit_matrix
 

Functions/Subroutines

real(kind=dp) function, public pswitch (x, a, b, order)
 Polynomial (5th degree) switching function f(a) = 1 .... f(b) = 0 with f'(a) = f"(a) = f'(b) = f"(b) = 0.
 
logical function, public abnormal_value (a)
 determines if a value is not normal (e.g. for Inf and Nan) based on IO to work also under optimization.
 
pure real(kind=dp) function, public angle (a, b)
 Calculation of the angle between the vectors a and b. The angle is returned in radians.
 
elemental real(kind=dp) function, public binomial (n, k)
 The binomial coefficient n over k for 0 <= k <= n is calculated, otherwise zero is returned.
 
elemental real(kind=dp) function, public binomial_gen (z, k)
 The generalized binomial coefficient z over k for 0 <= k <= n is calculated. (z) z*(z-1)*...*(z-k+2)*(z-k+1) ( ) = ------------------------— (k) k!
 
pure real(kind=dp) function, public multinomial (n, k)
 Calculates the multinomial coefficients.
 
pure subroutine, public build_rotmat (phi, a, rotmat)
 The rotation matrix rotmat which rotates a vector about a rotation axis defined by the vector a is build up. The rotation angle is phi (radians).
 
subroutine, public diamat_all (a, eigval, dac)
 Diagonalize the symmetric n by n matrix a using the LAPACK library. Only the upper triangle of matrix a is used. Externals (LAPACK 3.0)
 
pure real(kind=dp) function, public dihedral_angle (ab, bc, cd)
 Returns the dihedral angle, i.e. the angle between the planes defined by the vectors (-ab,bc) and (cd,-bc). The dihedral angle is returned in radians.
 
pure real(kind=dp) function, dimension(min(size(a, 1), size(a, 2))), public get_diag (a)
 Return the diagonal elements of matrix a as a vector.
 
pure real(kind=dp) function, dimension(3, 3), public inv_3x3 (a)
 Returns the inverse of the 3 x 3 matrix a.
 
subroutine, public invmat (a, info)
 returns inverse of matrix using the lapack routines DGETRF and DGETRI
 
subroutine, public invmat_symm (a, potrf, uplo)
 returns inverse of real symmetric, positive definite matrix
 
subroutine, public get_pseudo_inverse_svd (a, a_pinverse, rskip, determinant, sval)
 returns the pseudoinverse of a real, square matrix using singular value decomposition
 
subroutine, public get_pseudo_inverse_diag (a, a_pinverse, rskip)
 returns the pseudoinverse of a real, symmetric and positive definite matrix using diagonalization.
 
pure real(kind=dp) function, dimension(3), public reflect_vector (a, b)
 Reflection of the vector a through a mirror plane defined by the normal vector b. The reflected vector a is stored in a_mirror.
 
pure real(kind=dp) function, dimension(3), public rotate_vector (a, phi, b)
 Rotation of the vector a about an rotation axis defined by the vector b. The rotation angle is phi (radians). The rotated vector a is stored in a_rot.
 
subroutine, public symmetrize_matrix (a, option)
 Symmetrize the matrix a.
 
pure real(kind=dp) function, dimension(3), public vector_product (a, b)
 Calculation of the vector product c = a x b.
 
elemental integer function, public gcd (a, b)
 computes the greatest common divisor of two number
 
elemental integer function, public lcm (a, b)
 computes the least common multiplier of two numbers
 
elemental impure real(dp) function, public expint (n, x)
 computes the exponential integral En(x) = Int(exp(-x*t)/t^n,t=1..infinity) x>0, n=0,1,.. Note: Ei(-x) = -E1(x)
 
subroutine, public jacobi (a, d, v)
 Jacobi matrix diagonalization. The eigenvalues are returned in vector d and the eigenvectors are returned in matrix v in ascending order.
 
subroutine, public diag (n, a, d, v)
 Diagonalize matrix a. The eigenvalues are returned in vector d and the eigenvectors are returned in matrix v.
 
subroutine, public erfc_cutoff (eps, omg, r_cutoff)
 
  • compute a truncation radius for the shortrange operator

 
subroutine, public diag_complex (matrix, eigenvectors, eigenvalues)
 Diagonalizes a local complex Hermitian matrix using LAPACK. Based on cp_cfm_heevd.
 
subroutine, public diag_antisym (matrix, evecs, evals)
 Helper routine for diagonalizing anti symmetric matrices.
 

Detailed Description

Collection of simple mathematical functions and subroutines.

History
FUNCTION angle updated and FUNCTION dihedral angle added; cleaned (13.03.2004,MK)
Author
MK (15.11.1998)

Function/Subroutine Documentation

◆ pswitch()

real(kind=dp) function, public mathlib::pswitch ( real(kind=dp)  x,
real(kind=dp)  a,
real(kind=dp)  b,
integer  order 
)

Polynomial (5th degree) switching function f(a) = 1 .... f(b) = 0 with f'(a) = f"(a) = f'(b) = f"(b) = 0.

Parameters
x...
a...
b...
order...
Returns
=0 : f(x)
=1 : f'(x)
=2 : f"(x)

Definition at line 99 of file mathlib.F.

Here is the caller graph for this function:

◆ abnormal_value()

logical function, public mathlib::abnormal_value ( real(kind=dp)  a)

determines if a value is not normal (e.g. for Inf and Nan) based on IO to work also under optimization.

Parameters
ainput value
Returns
TRUE for NaN and Inf

Definition at line 150 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ angle()

pure real(kind=dp) function, public mathlib::angle ( real(kind=dp), dimension(:), intent(in)  a,
real(kind=dp), dimension(:), intent(in)  b 
)

Calculation of the angle between the vectors a and b. The angle is returned in radians.

Parameters
a...
b...
Returns
...
Date
14.10.1998
Author
MK
Version
1.0

Definition at line 175 of file mathlib.F.

Here is the caller graph for this function:

◆ binomial()

elemental real(kind=dp) function, public mathlib::binomial ( integer, intent(in)  n,
integer, intent(in)  k 
)

The binomial coefficient n over k for 0 <= k <= n is calculated, otherwise zero is returned.

Parameters
n...
k...
Returns
...
Date
08.03.1999
Author
MK
Version
1.0

Definition at line 205 of file mathlib.F.

Here is the caller graph for this function:

◆ binomial_gen()

elemental real(kind=dp) function, public mathlib::binomial_gen ( real(kind=dp), intent(in)  z,
integer, intent(in)  k 
)

The generalized binomial coefficient z over k for 0 <= k <= n is calculated. (z) z*(z-1)*...*(z-k+2)*(z-k+1) ( ) = ------------------------— (k) k!

Parameters
z...
k...
Returns
...
Date
11.11.2019
Author
FS
Version
1.0

Definition at line 229 of file mathlib.F.

Here is the caller graph for this function:

◆ multinomial()

pure real(kind=dp) function, public mathlib::multinomial ( integer, intent(in)  n,
integer, dimension(:), intent(in)  k 
)

Calculates the multinomial coefficients.

Parameters
n...
k...
Returns
...
Author
Ole Schuett

Definition at line 254 of file mathlib.F.

Here is the caller graph for this function:

◆ build_rotmat()

pure subroutine, public mathlib::build_rotmat ( real(kind=dp), intent(in)  phi,
real(kind=dp), dimension(3), intent(in)  a,
real(kind=dp), dimension(3, 3), intent(out)  rotmat 
)

The rotation matrix rotmat which rotates a vector about a rotation axis defined by the vector a is build up. The rotation angle is phi (radians).

Parameters
phi...
a...
rotmat...
Date
16.10.1998
Author
MK
Version
1.0

Definition at line 285 of file mathlib.F.

Here is the caller graph for this function:

◆ diamat_all()

subroutine, public mathlib::diamat_all ( real(kind=dp), dimension(:, :), intent(inout)  a,
real(kind=dp), dimension(:), intent(out)  eigval,
logical, intent(in), optional  dac 
)

Diagonalize the symmetric n by n matrix a using the LAPACK library. Only the upper triangle of matrix a is used. Externals (LAPACK 3.0)

Parameters
a...
eigval...
dac...
Date
29.03.1999
Variables
  • a : Symmetric matrix to be diagonalized (input; upper triangle) ->
  • eigenvectors of the matrix a (output).
  • dac : If true, then the divide-and-conquer algorithm is applied.
  • eigval : Eigenvalues of the matrix a (output).
Author
MK
Version
1.0

Definition at line 372 of file mathlib.F.

Here is the caller graph for this function:

◆ dihedral_angle()

pure real(kind=dp) function, public mathlib::dihedral_angle ( real(kind=dp), dimension(3), intent(in)  ab,
real(kind=dp), dimension(3), intent(in)  bc,
real(kind=dp), dimension(3), intent(in)  cd 
)

Returns the dihedral angle, i.e. the angle between the planes defined by the vectors (-ab,bc) and (cd,-bc). The dihedral angle is returned in radians.

Parameters
ab...
bc...
cd...
Returns
...
Date
13.03.2004
Author
MK
Version
1.0

Definition at line 467 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_diag()

pure real(kind=dp) function, dimension(min(size(a, 1), size(a, 2))), public mathlib::get_diag ( real(kind=dp), dimension(:, :), intent(in)  a)

Return the diagonal elements of matrix a as a vector.

Parameters
a...
Returns
...
Date
20.11.1998
Author
MK
Version
1.0

Definition at line 492 of file mathlib.F.

Here is the caller graph for this function:

◆ inv_3x3()

pure real(kind=dp) function, dimension(3, 3), public mathlib::inv_3x3 ( real(kind=dp), dimension(3, 3), intent(in)  a)

Returns the inverse of the 3 x 3 matrix a.

Parameters
a...
Returns
...
Date
13.03.2004
Author
MK
Version
1.0

Definition at line 515 of file mathlib.F.

Here is the caller graph for this function:

◆ invmat()

subroutine, public mathlib::invmat ( real(kind=dp), dimension(:, :), intent(inout)  a,
integer, intent(out)  info 
)

returns inverse of matrix using the lapack routines DGETRF and DGETRI

Parameters
a...
info...

Definition at line 542 of file mathlib.F.

Here is the caller graph for this function:

◆ invmat_symm()

subroutine, public mathlib::invmat_symm ( real(kind=dp), dimension(:, :), intent(inout)  a,
logical, intent(in), optional  potrf,
character(len=1), intent(in), optional  uplo 
)

returns inverse of real symmetric, positive definite matrix

Parameters
amatrix
potrfif cholesky decomposition of a was already done using dpotrf. If not given, cholesky decomposition of a will be done before inversion.
uploindicating if the upper or lower triangle of a is stored.
Author
Dorothea Golze [02.2015]

Definition at line 579 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pseudo_inverse_svd()

subroutine, public mathlib::get_pseudo_inverse_svd ( real(kind=dp), dimension(:, :)  a,
real(kind=dp), dimension(:, :)  a_pinverse,
real(kind=dp), intent(in)  rskip,
real(kind=dp), intent(out), optional  determinant,
real(kind=dp), dimension(:), intent(inout), optional, pointer  sval 
)

returns the pseudoinverse of a real, square matrix using singular value decomposition

Parameters
amatrix a
a_pinversepseudoinverse of matrix a
rskipparameter for setting small singular values to zero
determinantdeterminant of matrix a (optional output)
svalarray holding singular values of matrix a (optional output)
Author
Dorothea Golze [02.2015]

Definition at line 937 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pseudo_inverse_diag()

subroutine, public mathlib::get_pseudo_inverse_diag ( real(kind=dp), dimension(:, :)  a,
real(kind=dp), dimension(:, :)  a_pinverse,
real(kind=dp), intent(in)  rskip 
)

returns the pseudoinverse of a real, symmetric and positive definite matrix using diagonalization.

Parameters
amatrix a
a_pinversepseudoinverse of matrix a
rskipparameter for setting small eigenvalues to zero
Author
Dorothea Golze [02.2015]

Definition at line 1018 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reflect_vector()

pure real(kind=dp) function, dimension(3), public mathlib::reflect_vector ( real(kind=dp), dimension(3), intent(in)  a,
real(kind=dp), dimension(3), intent(in)  b 
)

Reflection of the vector a through a mirror plane defined by the normal vector b. The reflected vector a is stored in a_mirror.

Parameters
a...
b...
Returns
...
Date
16.10.1998
Author
MK
Version
1.0

Definition at line 1085 of file mathlib.F.

Here is the caller graph for this function:

◆ rotate_vector()

pure real(kind=dp) function, dimension(3), public mathlib::rotate_vector ( real(kind=dp), dimension(3), intent(in)  a,
real(kind=dp), intent(in)  phi,
real(kind=dp), dimension(3), intent(in)  b 
)

Rotation of the vector a about an rotation axis defined by the vector b. The rotation angle is phi (radians). The rotated vector a is stored in a_rot.

Parameters
a...
phi...
b...
Returns
...
Date
16.10.1998
Author
MK
Version
1.0

Definition at line 1123 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ symmetrize_matrix()

subroutine, public mathlib::symmetrize_matrix ( real(kind=dp), dimension(:, :), intent(inout)  a,
character(len=*), intent(in)  option 
)

Symmetrize the matrix a.

Parameters
a...
option...
Date
16.10.1998
Author
MK
Version
1.0

Definition at line 1196 of file mathlib.F.

Here is the caller graph for this function:

◆ vector_product()

pure real(kind=dp) function, dimension(3), public mathlib::vector_product ( real(kind=dp), dimension(3), intent(in)  a,
real(kind=dp), dimension(3), intent(in)  b 
)

Calculation of the vector product c = a x b.

Parameters
a...
b...
Returns
...
Date
16.10.1998
Author
MK
Version
1.0

Definition at line 1262 of file mathlib.F.

Here is the caller graph for this function:

◆ gcd()

elemental integer function, public mathlib::gcd ( integer, intent(in)  a,
integer, intent(in)  b 
)

computes the greatest common divisor of two number

Parameters
a...
b...
Returns
...
Author
Joost VandeVondele

Definition at line 1279 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lcm()

elemental integer function, public mathlib::lcm ( integer, intent(in)  a,
integer, intent(in)  b 
)

computes the least common multiplier of two numbers

Parameters
a...
b...
Returns
...
Author
Joost VandeVondele

Definition at line 1314 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expint()

elemental impure real(dp) function, public mathlib::expint ( integer, intent(in)  n,
real(dp), intent(in)  x 
)

computes the exponential integral En(x) = Int(exp(-x*t)/t^n,t=1..infinity) x>0, n=0,1,.. Note: Ei(-x) = -E1(x)

Parameters
n...
x...
Returns
...
History
05.2007 Created
Author
Manuel Guidon (adapted from Numerical recipies)

Definition at line 1392 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jacobi()

subroutine, public mathlib::jacobi ( real(kind=dp), dimension(:, :), intent(inout)  a,
real(kind=dp), dimension(:), intent(out)  d,
real(kind=dp), dimension(:, :), intent(out)  v 
)

Jacobi matrix diagonalization. The eigenvalues are returned in vector d and the eigenvectors are returned in matrix v in ascending order.

Parameters
a...
d...
v...
History
  • Creation (20.11.98, Matthias Krack)

Definition at line 1467 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ diag()

subroutine, public mathlib::diag ( integer, intent(in)  n,
real(kind=dp), dimension(:, :), intent(inout)  a,
real(kind=dp), dimension(:), intent(out)  d,
real(kind=dp), dimension(:, :), intent(out)  v 
)

Diagonalize matrix a. The eigenvalues are returned in vector d and the eigenvectors are returned in matrix v.

Parameters
nmatrix/vector extent (problem size)
amatrix to be diagonalised
dvector of eigenvalues
vmatrix of eigenvectors
History
  • Creation (20.11.98, Matthias Krack)

Definition at line 1495 of file mathlib.F.

Here is the caller graph for this function:

◆ erfc_cutoff()

subroutine, public mathlib::erfc_cutoff ( real(dp), intent(in)  eps,
real(dp), intent(in)  omg,
real(dp), intent(out)  r_cutoff 
)

  • compute a truncation radius for the shortrange operator

Parameters
epstarget accuracy!>
omgscreening parameter
omg...
r_cutoffcutoff radius
History
10.2012 created [Hossein Banihashemian] 05.2019 moved here from hfx_types (A. Bussy)
Author
Hossein Banihashemian

Definition at line 1685 of file mathlib.F.

Here is the caller graph for this function:

◆ diag_complex()

subroutine, public mathlib::diag_complex ( complex(kind=dp), dimension(:, :), intent(in)  matrix,
complex(kind=dp), dimension(:, :), intent(out)  eigenvectors,
real(kind=dp), dimension(:), intent(out)  eigenvalues 
)

Diagonalizes a local complex Hermitian matrix using LAPACK. Based on cp_cfm_heevd.

Parameters
matrixHermitian matrix is preserved
eigenvectors...
eigenvalues...
Author
A. Bussy

Definition at line 1742 of file mathlib.F.

Here is the caller graph for this function:

◆ diag_antisym()

subroutine, public mathlib::diag_antisym ( real(dp), dimension(:, :)  matrix,
complex(dp), dimension(:, :)  evecs,
complex(dp), dimension(:)  evals 
)

Helper routine for diagonalizing anti symmetric matrices.

Parameters
matrix...
evecs...
evals...

Definition at line 1794 of file mathlib.F.

Here is the call graph for this function:
Here is the caller graph for this function: