SIRIUS 7.5.0
Electronic structure library and applications
Classes | Functions
sirius::r3 Namespace Reference

Work with 3D vectors and matrices. More...

Classes

class  matrix
 Handling of a 3x3 matrix of numerical data types. More...
 
class  vector
 Simple implementation of 3d vector. More...
 

Functions

template<typename T , typename U >
vector< decltype(T{}+U{})> operator+ (vector< T > const &a, vector< U > const &b)
 
template<typename T , typename U >
vector< decltype(T{} - U{})> operator- (vector< T > const &a, vector< U > const &b)
 
template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, vector< decltype(T{} *U{})> > operator* (vector< T > const &vec, U p)
 
template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, vector< decltype(T{} *U{})> > operator* (U p, vector< T > const &vec)
 
template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, vector< decltype(T{} *U{})> > operator/ (vector< T > const &vec, U p)
 
template<typename T , typename U >
auto dot (vector< T > const a, vector< U > const b) -> decltype(T{} *U{})
 
template<typename T >
auto cross (vector< T > const a, vector< T > const b)
 
template<typename T >
std::ostream & operator<< (std::ostream &out, r3::vector< T > const &v)
 
template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, matrix< decltype(T{} *U{})> > operator* (matrix< T > const &a__, U p__)
 Multiply matrix by a scalar number. More...
 
template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, matrix< decltype(T{} *U{})> > operator* (U p__, matrix< T > const &a__)
 
bool operator== (matrix< int > const &a__, matrix< int > const &b__)
 
template<typename T , typename U >
auto dot (matrix< T > const &a__, matrix< U > const &b__)
 Multiply two matrices. More...
 
template<typename T , typename U >
auto dot (matrix< T > const &m__, vector< U > const &b__)
 Matrix-vector multiplication. More...
 
template<typename T , typename U >
auto dot (vector< U > const &b__, matrix< T > const &m__)
 Vector-matrix multiplication. More...
 
template<typename T >
auto transpose (matrix< T > src)
 Return transpose of the matrix. More...
 
template<typename T >
auto inverse_aux (matrix< T > src)
 
auto inverse (matrix< int > src)
 Return inverse of the integer matrix. More...
 
template<typename T >
auto inverse (matrix< T > src)
 Return inverse of the matrix. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &out, matrix< T > const &v)
 
auto reduce_coordinates (vector< double > coord__)
 Reduce the coordinates to the first unit cell. More...
 
auto find_translations (double radius__, matrix< double > const &lattice_vectors__)
 Find supercell that circumscribes the sphere with a given radius. More...
 
auto spherical_coordinates (vector< double > vc)
 Transform Cartesian coordinates [x,y,z] to spherical coordinates [r,theta,phi]. More...
 

Detailed Description

Work with 3D vectors and matrices.

Function Documentation

◆ operator+()

template<typename T , typename U >
vector< decltype(T{}+U{})> sirius::r3::operator+ ( vector< T > const &  a,
vector< U > const &  b 
)
inline

Definition at line 157 of file r3.hpp.

◆ operator-()

template<typename T , typename U >
vector< decltype(T{} - U{})> sirius::r3::operator- ( vector< T > const &  a,
vector< U > const &  b 
)
inline

Definition at line 168 of file r3.hpp.

◆ operator*() [1/4]

template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, vector< decltype(T{} *U{})> > sirius::r3::operator* ( vector< T > const &  vec,
p 
)
inline

Definition at line 179 of file r3.hpp.

◆ operator*() [2/4]

template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, vector< decltype(T{} *U{})> > sirius::r3::operator* ( p,
vector< T > const &  vec 
)
inline

Definition at line 190 of file r3.hpp.

◆ operator/()

template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, vector< decltype(T{} *U{})> > sirius::r3::operator/ ( vector< T > const &  vec,
p 
)
inline

Definition at line 197 of file r3.hpp.

◆ dot() [1/4]

template<typename T , typename U >
auto sirius::r3::dot ( vector< T > const  a,
vector< U > const  b 
) -> decltype(T{} * U{})
inline

Definition at line 207 of file r3.hpp.

◆ cross()

template<typename T >
auto sirius::r3::cross ( vector< T > const  a,
vector< T > const  b 
)
inline

Definition at line 213 of file r3.hpp.

◆ operator<<() [1/2]

template<typename T >
std::ostream & sirius::r3::operator<< ( std::ostream &  out,
r3::vector< T > const &  v 
)

Definition at line 223 of file r3.hpp.

◆ operator*() [3/4]

template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, matrix< decltype(T{} *U{})> > sirius::r3::operator* ( matrix< T > const &  a__,
p__ 
)
inline

Multiply matrix by a scalar number.

Definition at line 373 of file r3.hpp.

◆ operator*() [4/4]

template<typename T , typename U >
std::enable_if_t< std::is_scalar< U >::value, matrix< decltype(T{} *U{})> > sirius::r3::operator* ( p__,
matrix< T > const &  a__ 
)
inline

Definition at line 385 of file r3.hpp.

◆ operator==()

bool sirius::r3::operator== ( matrix< int > const &  a__,
matrix< int > const &  b__ 
)
inline

Definition at line 390 of file r3.hpp.

◆ dot() [2/4]

template<typename T , typename U >
auto sirius::r3::dot ( matrix< T > const &  a__,
matrix< U > const &  b__ 
)
inline

Multiply two matrices.

Definition at line 404 of file r3.hpp.

◆ dot() [3/4]

template<typename T , typename U >
auto sirius::r3::dot ( matrix< T > const &  m__,
vector< U > const &  b__ 
)
inline

Matrix-vector multiplication.

Definition at line 419 of file r3.hpp.

◆ dot() [4/4]

template<typename T , typename U >
auto sirius::r3::dot ( vector< U > const &  b__,
matrix< T > const &  m__ 
)
inline

Vector-matrix multiplication.

Definition at line 432 of file r3.hpp.

◆ transpose()

template<typename T >
auto sirius::r3::transpose ( matrix< T >  src)
inline

Return transpose of the matrix.

Definition at line 445 of file r3.hpp.

◆ inverse_aux()

template<typename T >
auto sirius::r3::inverse_aux ( matrix< T >  src)
inline

Definition at line 457 of file r3.hpp.

◆ inverse() [1/2]

auto sirius::r3::inverse ( matrix< int >  src)
inline

Return inverse of the integer matrix.

Definition at line 475 of file r3.hpp.

◆ inverse() [2/2]

template<typename T >
auto sirius::r3::inverse ( matrix< T >  src)
inline

Return inverse of the matrix.

Definition at line 486 of file r3.hpp.

◆ operator<<() [2/2]

template<typename T >
std::ostream & sirius::r3::operator<< ( std::ostream &  out,
matrix< T > const &  v 
)
inline

Definition at line 498 of file r3.hpp.

◆ reduce_coordinates()

auto sirius::r3::reduce_coordinates ( vector< double >  coord__)
inline

Reduce the coordinates to the first unit cell.

Split the input vector in lattice coordinates to the sum r0 + T, where T is the lattice translation vector (three integers) and r0 is the vector within the first unit cell with coordinates in [0, 1) range.

Definition at line 523 of file r3.hpp.

◆ find_translations()

auto sirius::r3::find_translations ( double  radius__,
matrix< double > const &  lattice_vectors__ 
)
inline

Find supercell that circumscribes the sphere with a given radius.

Search for the translation limits (N1, N2, N3) such that the resulting supercell with the lattice vectors a1 * N1, a2 * N2, a3 * N3 fully contains the sphere with a given radius. This is done by equating the expressions for the volume of the supercell: Volume = |(A1 x A2) * A3| = N1 * N2 * N3 * |(a1 x a2) * a3| Volume = h * S = 2 * R * |a_i x a_j| * N_i * N_j

Definition at line 572 of file r3.hpp.

◆ spherical_coordinates()

auto sirius::r3::spherical_coordinates ( vector< double >  vc)
inline

Transform Cartesian coordinates [x,y,z] to spherical coordinates [r,theta,phi].

Definition at line 590 of file r3.hpp.