cgv
cgv::math::diag_mat< T > Struct Template Reference

#include <diag_mat.h>

Public Member Functions

unsigned size () const
 size of storage
 
unsigned nrows () const
 number of rows
 
unsigned ncols () const
 number of columns
 
 diag_mat ()
 standard constructor
 
 diag_mat (unsigned n)
 creates nxn diagonal matrix
 
 diag_mat (unsigned n, const T &c)
 creates nxn diagonal matrix and set all diagonal elements to c
 
 diag_mat (const vec< T > &dv)
 creates a diagonal matrix and set the diagonal vector to dv
 
 diag_mat (const mat< T > &m)
 creates a diagonal matrix and set the diagonal vector to diagonal entries of m
 
 diag_mat (const diag_mat< T > &m)
 copy constructor
 
virtual ~diag_mat ()
 destructor
 
 operator T* ()
 cast into array of element type
 
 operator const T * () const
 cast into array of const element type
 
diag_mat< T > sub_mat (unsigned top_left, unsigned size) const
 create sub diagonal matrix d(top_left)...d(top_left+size)
 
 operator const mat< T > () const
 cast into const full storage matrix
 
void identity ()
 set diagonal matrix to identity
 
void fill (const T &c)
 fills all diagonal entries with c
 
void zeros ()
 fills all diagonal entries with zero
 
void exchange_diagonal_elements (unsigned i, unsigned j)
 exchange diagonal elements i and j
 
const T & operator() (unsigned i) const
 const access to the ith diagonal element
 
T & operator() (unsigned i)
 non const access to the ith diagonal element
 
bool is_square ()
 returns true because diagonal matrices are always square
 
diag_mat< T > & operator= (const diag_mat< T > &m)
 assignment of a matrix with the same element type
 
template<typename S >
diag_mat< T > & operator= (const diag_mat< S > &m)
 assignment of a matrix with a different element type
 
template<typename S >
diag_mat< T > & operator= (const vec< S > &v)
 
diag_mat< T > & operator= (const T &s)
 assignment of a scalar s to each element of the matrix
 
frobenius_norm () const
 returns the frobenius norm of matrix m
 
void identity (unsigned dim)
 set dim x dim identity matrix
 
void zero ()
 set zero matrix
 
diag_mat< T > & operator+= (const diag_mat< T > &d)
 in place addition of diagonal matrix
 
diag_mat< T > & operator-= (const diag_mat< T > &d)
 in place subtraction of diagonal matrix
 
diag_mat< T > & operator*= (const T &s)
 in place multiplication with scalar s
 
diag_mat< T > operator* (const T &s) const
 multiplication with scalar s
 
diag_mat< T > operator+ (const diag_mat< T > &d) const
 addition of diagonal matrix
 
diag_mat< T > operator- (const diag_mat< T > &d) const
 subtraction of diagonal matrix
 
vec< T > operator* (const vec< T > &v) const
 multiplication with vector
 
const up_tri_mat< T > operator* (const up_tri_mat< T > &m)
 matrix multiplication of matrix m by a diagonal matrix s
 
 operator mat< T > ()
 cast into full matrix type
 

Public Attributes

vec< T > _data
 pointer to data storage
 

Detailed Description

template<typename T>
struct cgv::math::diag_mat< T >

A diagonal matrix type which internally stores the elements on the main diagonal in a vector.

Member Function Documentation

◆ operator=()

template<typename T >
template<typename S >
diag_mat<T>& cgv::math::diag_mat< T >::operator= ( const vec< S > &  v)
inline

assignment of a vector with a vector to set the diagonal


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