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

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

#include <diagonal_matrix.h>

Public Member Functions

auto abs () const
 absolute value of all elements
 
Vector< n, T > column (int i) const
 Returns column vector i.
 
DiagonalMatrix conj () const
 conj - conjugate elements
 
DiagonalMatrix dagger () const
 dagger - conjugate elements
 
 DiagonalMatrix ()=default
 Define default constructors to ensure std::is_trivial.
 
e (const int i) const
 Element access - e(i) gives diagonal element i.
 
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
 
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.
 
template<typename S >
bool operator!= (const S &rhs) const
 Boolean operator != to check if matrices are exactly different.
 
const auto & operator+ () const
 Unary + operator.
 
DiagonalMatrix< n, T > operator- () const
 Unary - operator.
 
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0>
DiagonalMatrixoperator= (const DiagonalMatrix< n, S > &rhs)
 
template<typename S >
bool operator== (const DiagonalMatrix< n, S > &rhs) const
 Boolean operator == to determine if two matrices are exactly the same.
 
template<typename S , typename Mtype >
bool operator== (const Matrix_t< n, n, S, Mtype > &rhs) const
 Boolean operator == to compare with square matrix.
 
DiagonalMatrixrandom ()
 Fills Matrix with random elements.
 
auto real () const
 real and imaginary parts of diagonal matrix
 
RowVector< n, T > row (int i) const
 Return row from Diagonal 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
 
std::string str (int prec=8, char separator=' ') const
 convert to string for printing
 
Matrix< n, n, T > toMatrix () const
 convert to generic matrix
 
const DiagonalMatrixtranspose () const
 transpose - leaves diagonal matrix as is
 

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 335 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 104 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 72 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 115 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 178 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 417 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 348 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 94 of file diagonal_matrix.h.


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