HILA
Loading...
Searching...
No Matches
DiagonalMatrix< n, T > Class Template Reference

Define type DiagonalMatrix<n,T> More...

#include <diagonal_matrix.h>

Public Member Functions

 DiagonalMatrix ()=default
 Define default constructors to ensure std::is_trivial.
 
e (const int i) const
 Element access - e(i) gives diagonal element i.
 
RowVector< n, T > row (int i) const
 Return row from Diagonal matrix.
 
Vector< n, T > column (int i) const
 Returns column vector i.
 
DiagonalMatrix< n, T > operator- () const
 Unary - operator.
 
const auto & operator+ () const
 Unary + operator.
 
template<typename S >
bool operator!= (const S &rhs) const
 Boolean operator != to check if matrices are exactly different.
 
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0>
DiagonalMatrixoperator= (const DiagonalMatrix< n, S > &rhs) &
 
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0>
DiagonalMatrixfill (const S rhs)
 fill with constant value - same as assignment
 
DiagonalMatrixtranspose () const
 transpose - leaves diagonal matrix as is
 
DiagonalMatrix dagger () const
 dagger - conjugate elements
 
DiagonalMatrix conj () const
 conj - conjugate elements
 
auto abs () const
 absolute value of all elements
 
auto real () const
 real and imaginary parts of diagonal matrix
 
template<typename S = T, std::enable_if_t< hila::is_arithmetic< S >::value, int > = 0>
max () const
 Find max or min value - only for arithmetic types.
 
DiagonalMatrixrandom ()
 Fills Matrix with random elements.
 
std::string str (int prec=8, char separator=' ') const
 convert to string for printing
 
Matrix< n, n, T > toMatrix () const
 convert to generic matrix
 
template<int N>
DiagonalMatrix< n, T > sort (Vector< N, int > &permutation, hila::sort order=hila::sort::ascending) const
 implement sort as casting to matrix
 

Static Public Member Functions

static constexpr int rows ()
 Returns matrix size - all give same result.
 

Detailed Description

template<int n, typename T>
class DiagonalMatrix< n, T >

Define type DiagonalMatrix<n,T>

Class for diagonal matrix

More optimal storage and algebra than normal square matrix

Template Parameters
ndimensionality
Ttype

Definition at line 18 of file diagonal_matrix.h.

Member Function Documentation

◆ abs()

template<int n, typename T >
auto DiagonalMatrix< n, T >::abs ( ) const
inline

absolute value of all elements

Returns a real DiagonalMatrix even if the original is complex

Definition at line 303 of file diagonal_matrix.h.

◆ column()

template<int n, typename T >
Vector< n, T > DiagonalMatrix< n, T >::column ( int  i) const
inline

Returns column vector i.

Definition at line 105 of file diagonal_matrix.h.

◆ e()

template<int n, typename T >
T DiagonalMatrix< n, T >::e ( const int  i) const
inline

Element access - e(i) gives diagonal element i.

Definition at line 73 of file diagonal_matrix.h.

◆ operator-()

template<int n, typename T >
DiagonalMatrix< n, T > DiagonalMatrix< n, T >::operator- ( ) const
inline

Unary - operator.

Definition at line 116 of file diagonal_matrix.h.

◆ operator=()

template<int n, typename T >
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0>
DiagonalMatrix & DiagonalMatrix< n, T >::operator= ( const DiagonalMatrix< n, S > &  rhs) &
inline

Assignment operators: assign from another DiagonalMatrix, scalar or initializer list

Definition at line 146 of file diagonal_matrix.h.

◆ random()

template<int n, typename T >
DiagonalMatrix & DiagonalMatrix< n, T >::random ( )
inline

Fills Matrix with random elements.

Works only for non-integer valued elements

Definition at line 385 of file diagonal_matrix.h.

◆ real()

template<int n, typename T >
auto DiagonalMatrix< n, T >::real ( ) const
inline

real and imaginary parts of diagonal matrix

Returns a real DiagonalMatrix even if the original is complex

Definition at line 316 of file diagonal_matrix.h.

◆ row()

template<int n, typename T >
RowVector< n, T > DiagonalMatrix< n, T >::row ( int  i) const
inline

Return row from Diagonal matrix.

Definition at line 95 of file diagonal_matrix.h.


The documentation for this class was generated from the following file: