(git:34ef472)
mathlib Module Reference

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

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. More...
 
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. More...
 
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. More...
 
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. More...
 
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! More...
 
pure real(kind=dp) function, public multinomial (n, k)
 Calculates the multinomial coefficients. More...
 
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). More...
 
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) More...
 
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. More...
 
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. More...
 
pure real(kind=dp) function, dimension(3, 3), public inv_3x3 (a)
 Returns the inverse of the 3 x 3 matrix a. More...
 
subroutine, public invmat (a, info)
 returns inverse of matrix using the lapack routines DGETRF and DGETRI More...
 
subroutine, public invmat_symm (a, cholesky_triangle)
 returns inverse of real symmetric, positive definite matrix More...
 
subroutine, public get_pseudo_inverse_svd (a, a_pinverse, rskip, determinant, sval)
 returns the pseudoinverse of a real, square matrix using singular value decomposition More...
 
subroutine, public get_pseudo_inverse_diag (a, a_pinverse, rskip)
 returns the pseudoinverse of a real, symmetric and positive definite matrix using diagonalization. More...
 
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. More...
 
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. More...
 
subroutine, public symmetrize_matrix (a, option)
 Symmetrize the matrix a. More...
 
pure real(kind=dp) function, dimension(3), public vector_product (a, b)
 Calculation of the vector product c = a x b. More...
 
elemental integer function, public gcd (a, b)
 computes the greatest common divisor of two number More...
 
elemental integer function, public lcm (a, b)
 computes the least common multiplier of two numbers More...
 
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) More...
 
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. More...
 
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. More...
 
subroutine, public erfc_cutoff (eps, omg, r_cutoff)
 
  • compute a truncation radius for the shortrange operator
More...
 
subroutine, public complex_diag (matrix, eigenvectors, eigenvalues)
 Diagonalizes a local complex Hermitian matrix using LAPACK. Based on cp_cfm_heevd. More...
 

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 98 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 149 of file mathlib.F.

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 174 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 204 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 228 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 253 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 284 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 371 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 call graph for this function:
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,
character(len=1), intent(in), optional  cholesky_triangle 
)

returns inverse of real symmetric, positive definite matrix

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

Definition at line 573 of file mathlib.F.

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 948 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 1029 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 1096 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 1134 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 1207 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 1273 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 1290 of file mathlib.F.

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 1325 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 1403 of file mathlib.F.

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 1478 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 1506 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 1688 of file mathlib.F.

Here is the caller graph for this function:

◆ complex_diag()

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

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

Parameters
matrix...
eigenvectors...
eigenvalues...
Author
A. Bussy

Definition at line 1745 of file mathlib.F.

Here is the caller graph for this function: