Public Types | Public Member Functions | Private Attributes | Related Functions | List of all members
vnl_diag_matrix< T > Class Template Reference

stores a diagonal matrix as a single vector. More...

#include <vnl_diag_matrix.h>

Inheritance diagram for vnl_diag_matrix< T >:
Inheritance graph
[legend]

Public Types

typedef vnl_vector< T >::iterator iterator
 
typedef vnl_vector< T >::const_iterator const_iterator
 

Public Member Functions

 vnl_diag_matrix ()
 
 vnl_diag_matrix (unsigned nn)
 Construct an empty diagonal matrix. More...
 
 vnl_diag_matrix (unsigned nn, T const &value)
 Construct a diagonal matrix with diagonal elements equal to value. More...
 
 vnl_diag_matrix (vnl_vector< T > const &that)
 Construct a diagonal matrix from a vnl_vector. More...
 
 ~vnl_diag_matrix ()=default
 
vnl_diag_matrixoperator= (vnl_diag_matrix< T > const &that)
 
vnl_diag_matrix< T > & operator *= (T v)
 In-place arithmetic operation. More...
 
vnl_diag_matrix< T > & operator/= (T v)
 In-place arithmetic operation. More...
 
vnl_diag_matrixinvert_in_place ()
 Invert a vnl_diag_matrix in-situ. More...
 
determinant () const
 Return determinant as product of diagonal values. More...
 
vnl_vector< T > solve (vnl_vector< T > const &b) const
 Return inv(D) * b. More...
 
void solve (vnl_vector< T > const &b, vnl_vector< T > *out) const
 Return inv(D) * b. More...
 
operator() (unsigned i, unsigned j) const
 
T & operator() (unsigned i, unsigned j)
 
T & operator() (unsigned i)
 
T const & operator() (unsigned i) const
 
T & operator[] (unsigned i)
 
T const & operator[] (unsigned i) const
 
vnl_vector< T > get_diagonal () const
 Return a vector (copy) with the content of the (main) diagonal. More...
 
vnl_vector< T > const & diagonal () const
 Return diagonal elements as a vector. More...
 
vnl_diag_matrixfill_diagonal (T const &v)
 Set all diagonal elements of matrix to specified value. More...
 
vnl_diag_matrixset_diagonal (vnl_vector< T > const &v)
 Sets the diagonal elements of this matrix to the specified list of values. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
unsigned int size () const
 Return the total number of elements stored by the matrix. More...
 
unsigned int rows () const
 Return the number of rows. More...
 
unsigned int cols () const
 Return the number of columns. More...
 
unsigned int columns () const
 Return the number of columns. More...
 
void put (unsigned r, unsigned c, T const &v)
 set element with boundary checks. More...
 
get (unsigned r, unsigned c) const
 get element with boundary checks. More...
 
vnl_matrix< T > asMatrix () const
 Convert a vnl_diag_matrix to a Matrix. More...
 
vnl_matrix< T > as_ref () const
 
 operator vnl_matrix< T > () const
 
void set_size (int n)
 
void clear ()
 
vnl_diag_matrixfill (T const &x)
 
T * data_block ()
 Return pointer to the diagonal elements as a contiguous 1D C array;. More...
 
T const * data_block () const
 
vnl_diag_matrixset (vnl_vector< T > const &v)
 Set diagonal elements using vector. More...
 

Private Attributes

vnl_vector< T > diagonal_
 

Related Functions

(Note that these are not member functions.)

template<class T >
void vsl_b_write (vsl_b_ostream &os, const vnl_diag_matrix< T > &v)
 Binary save vnl_diag_matrix to stream. More...
 
template<class T >
void vsl_b_read (vsl_b_istream &is, vnl_diag_matrix< T > &v)
 Binary load vnl_diag_matrix from stream. More...
 
template<class T >
void vsl_print_summary (std::ostream &os, const vnl_diag_matrix< T > &b)
 Print human readable summary of object to a stream. More...
 
template<class T >
VNL_EXPORT vnl_diag_matrix< std::complex< T > > vnl_complexify (vnl_diag_matrix< T > const &R)
 Return complexified version of real diagonal matrix R. More...
 
template<class T >
VNL_EXPORT vnl_diag_matrix< std::complex< T > > vnl_complexify (vnl_diag_matrix< T > const &R, vnl_diag_matrix< T > const &I)
 Return complex diagonal matrix R+j*I from two real diagonal matrices R and I. More...
 
template<class T >
VNL_EXPORT vnl_sym_matrix< std::complex< T > > vnl_complexify (vnl_sym_matrix< T > const &R, vnl_sym_matrix< T > const &I)
 Return complex diagonal matrix R+j*I from two real diagonal matrices R and I. More...
 
template<class T >
VNL_EXPORT std::ostream & operator<< (std::ostream &, vnl_diag_matrix< T > const &)
 
template<class T >
vnl_diag_matrix< T > operator * (vnl_diag_matrix< T > const &A, vnl_diag_matrix< T > const &B)
 Multiply two vnl_diag_matrices. Just multiply the diag elements - n flops. More...
 
template<class T >
vnl_diag_matrix< T > operator+ (vnl_diag_matrix< T > const &A, vnl_diag_matrix< T > const &B)
 Add two vnl_diag_matrices. Just add the diag elements - n flops. More...
 
template<class T >
vnl_diag_matrix< T > operator- (vnl_diag_matrix< T > const &A, vnl_diag_matrix< T > const &B)
 Subtract two vnl_diag_matrices. Just subtract the diag elements - n flops. More...
 
template<class T >
VNL_EXPORT vnl_diag_matrix< T > vnl_imag (vnl_diag_matrix< std::complex< T > > const &C)
 Matrix of imaginary parts of vnl_diag_matrix<std::complex<T> >. More...
 
template<class T >
VNL_EXPORT std::ostream & vnl_matlab_print (std::ostream &, vnl_diag_matrix< T > const &, char const *variable_name=nullptr, vnl_matlab_print_format=vnl_matlab_print_format_default)
 print a vnl_diagonal_matrix<T>. More...
 
template<class T >
VNL_EXPORT vnl_diag_matrix< T > vnl_real (vnl_diag_matrix< std::complex< T > > const &C)
 Matrix of real parts of vnl_diag_matrix<std::complex<T> >. More...
 

Detailed Description

template<class T>
class vnl_diag_matrix< T >

stores a diagonal matrix as a single vector.

vnl_diag_matrix stores a diagonal matrix for time and space efficiency. Specifically, only the diagonal elements are stored, and some matrix operations (currently *, + and -) are overloaded to use more efficient algorithms.

Definition at line 30 of file vnl_diag_matrix.h.

Member Typedef Documentation

◆ const_iterator

template<class T>
typedef vnl_vector<T>::const_iterator vnl_diag_matrix< T >::const_iterator

Definition at line 110 of file vnl_diag_matrix.h.

◆ iterator

template<class T>
typedef vnl_vector<T>::iterator vnl_diag_matrix< T >::iterator

Definition at line 107 of file vnl_diag_matrix.h.

Constructor & Destructor Documentation

◆ vnl_diag_matrix() [1/4]

template<class T>
vnl_diag_matrix< T >::vnl_diag_matrix ( )
inline

Definition at line 45 of file vnl_diag_matrix.h.

◆ vnl_diag_matrix() [2/4]

template<class T>
vnl_diag_matrix< T >::vnl_diag_matrix ( unsigned  nn)
inline

Construct an empty diagonal matrix.

Definition at line 48 of file vnl_diag_matrix.h.

◆ vnl_diag_matrix() [3/4]

template<class T>
vnl_diag_matrix< T >::vnl_diag_matrix ( unsigned  nn,
T const &  value 
)
inline

Construct a diagonal matrix with diagonal elements equal to value.

Definition at line 51 of file vnl_diag_matrix.h.

◆ vnl_diag_matrix() [4/4]

template<class T>
vnl_diag_matrix< T >::vnl_diag_matrix ( vnl_vector< T > const &  that)
inline

Construct a diagonal matrix from a vnl_vector.

The vector elements become the diagonal elements.

Definition at line 55 of file vnl_diag_matrix.h.

◆ ~vnl_diag_matrix()

template<class T>
vnl_diag_matrix< T >::~vnl_diag_matrix ( )
default

Member Function Documentation

◆ as_ref()

template<class T>
vnl_matrix<T> vnl_diag_matrix< T >::as_ref ( ) const
inline

Definition at line 155 of file vnl_diag_matrix.h.

◆ asMatrix()

template<class T >
vnl_matrix< T > vnl_diag_matrix< T >::asMatrix ( ) const
inline

Convert a vnl_diag_matrix to a Matrix.

Definition at line 182 of file vnl_diag_matrix.h.

◆ begin() [1/2]

template<class T>
iterator vnl_diag_matrix< T >::begin ( )
inline

Definition at line 108 of file vnl_diag_matrix.h.

◆ begin() [2/2]

template<class T>
const_iterator vnl_diag_matrix< T >::begin ( ) const
inline

Definition at line 111 of file vnl_diag_matrix.h.

◆ clear()

template<class T>
void vnl_diag_matrix< T >::clear ( )
inline

Definition at line 162 of file vnl_diag_matrix.h.

◆ cols()

template<class T>
unsigned int vnl_diag_matrix< T >::cols ( ) const
inline

Return the number of columns.

A synonym for columns().

Definition at line 124 of file vnl_diag_matrix.h.

◆ columns()

template<class T>
unsigned int vnl_diag_matrix< T >::columns ( ) const
inline

Return the number of columns.

A synonym for cols().

Definition at line 128 of file vnl_diag_matrix.h.

◆ data_block() [1/2]

template<class T>
T* vnl_diag_matrix< T >::data_block ( )
inline

Return pointer to the diagonal elements as a contiguous 1D C array;.

Definition at line 166 of file vnl_diag_matrix.h.

◆ data_block() [2/2]

template<class T>
T const* vnl_diag_matrix< T >::data_block ( ) const
inline

Definition at line 167 of file vnl_diag_matrix.h.

◆ determinant()

template<class T >
T vnl_diag_matrix< T >::determinant ( ) const
inline

Return determinant as product of diagonal values.

Definition at line 213 of file vnl_diag_matrix.h.

◆ diagonal()

template<class T>
vnl_vector<T> const& vnl_diag_matrix< T >::diagonal ( ) const
inline

Return diagonal elements as a vector.

Definition at line 97 of file vnl_diag_matrix.h.

◆ end() [1/2]

template<class T>
iterator vnl_diag_matrix< T >::end ( )
inline

Definition at line 109 of file vnl_diag_matrix.h.

◆ end() [2/2]

template<class T>
const_iterator vnl_diag_matrix< T >::end ( ) const
inline

Definition at line 112 of file vnl_diag_matrix.h.

◆ fill()

template<class T>
vnl_diag_matrix& vnl_diag_matrix< T >::fill ( T const &  x)
inline

Definition at line 163 of file vnl_diag_matrix.h.

◆ fill_diagonal()

template<class T>
vnl_diag_matrix& vnl_diag_matrix< T >::fill_diagonal ( T const &  v)
inline

Set all diagonal elements of matrix to specified value.

Definition at line 100 of file vnl_diag_matrix.h.

◆ get()

template<class T>
T vnl_diag_matrix< T >::get ( unsigned  r,
unsigned  c 
) const
inline

get element with boundary checks.

Definition at line 142 of file vnl_diag_matrix.h.

◆ get_diagonal()

template<class T>
vnl_vector<T> vnl_diag_matrix< T >::get_diagonal ( ) const
inline

Return a vector (copy) with the content of the (main) diagonal.

Definition at line 94 of file vnl_diag_matrix.h.

◆ invert_in_place()

template<class T >
vnl_diag_matrix< T > & vnl_diag_matrix< T >::invert_in_place ( )
inline

Invert a vnl_diag_matrix in-situ.

Just replaces each element with its reciprocal.

Definition at line 201 of file vnl_diag_matrix.h.

◆ operator *=()

template<class T>
vnl_diag_matrix<T>& vnl_diag_matrix< T >::operator *= ( v)
inline

In-place arithmetic operation.

Definition at line 66 of file vnl_diag_matrix.h.

◆ operator vnl_matrix< T >()

template<class T>
vnl_diag_matrix< T >::operator vnl_matrix< T > ( ) const
inline

Definition at line 158 of file vnl_diag_matrix.h.

◆ operator()() [1/4]

template<class T>
T vnl_diag_matrix< T >::operator() ( unsigned  i,
unsigned  j 
) const
inline

Definition at line 79 of file vnl_diag_matrix.h.

◆ operator()() [2/4]

template<class T>
T& vnl_diag_matrix< T >::operator() ( unsigned  i,
unsigned  j 
)
inline

Definition at line 83 of file vnl_diag_matrix.h.

◆ operator()() [3/4]

template<class T>
T& vnl_diag_matrix< T >::operator() ( unsigned  i)
inline

Definition at line 87 of file vnl_diag_matrix.h.

◆ operator()() [4/4]

template<class T>
T const& vnl_diag_matrix< T >::operator() ( unsigned  i) const
inline

Definition at line 88 of file vnl_diag_matrix.h.

◆ operator/=()

template<class T>
vnl_diag_matrix<T>& vnl_diag_matrix< T >::operator/= ( v)
inline

In-place arithmetic operation.

Definition at line 68 of file vnl_diag_matrix.h.

◆ operator=()

template<class T>
vnl_diag_matrix& vnl_diag_matrix< T >::operator= ( vnl_diag_matrix< T > const &  that)
inline

Definition at line 58 of file vnl_diag_matrix.h.

◆ operator[]() [1/2]

template<class T>
T& vnl_diag_matrix< T >::operator[] ( unsigned  i)
inline

Definition at line 90 of file vnl_diag_matrix.h.

◆ operator[]() [2/2]

template<class T>
T const& vnl_diag_matrix< T >::operator[] ( unsigned  i) const
inline

Definition at line 91 of file vnl_diag_matrix.h.

◆ put()

template<class T>
void vnl_diag_matrix< T >::put ( unsigned  r,
unsigned  c,
T const &  v 
)
inline

set element with boundary checks.

Definition at line 131 of file vnl_diag_matrix.h.

◆ rows()

template<class T>
unsigned int vnl_diag_matrix< T >::rows ( ) const
inline

Return the number of rows.

Definition at line 120 of file vnl_diag_matrix.h.

◆ set()

template<class T>
vnl_diag_matrix& vnl_diag_matrix< T >::set ( vnl_vector< T > const &  v)
inline

Set diagonal elements using vector.

Definition at line 170 of file vnl_diag_matrix.h.

◆ set_diagonal()

template<class T>
vnl_diag_matrix& vnl_diag_matrix< T >::set_diagonal ( vnl_vector< T > const &  v)
inline

Sets the diagonal elements of this matrix to the specified list of values.

Definition at line 103 of file vnl_diag_matrix.h.

◆ set_size()

template<class T>
void vnl_diag_matrix< T >::set_size ( int  n)
inline

Definition at line 160 of file vnl_diag_matrix.h.

◆ size()

template<class T>
unsigned int vnl_diag_matrix< T >::size ( ) const
inline

Return the total number of elements stored by the matrix.

Since vnl_diag_matrix only stores values on the diagonal and must be square, size() == rows() == cols().

Definition at line 117 of file vnl_diag_matrix.h.

◆ solve() [1/2]

template<class T>
vnl_vector< T > vnl_diag_matrix< T >::solve ( vnl_vector< T > const &  b) const

Return inv(D) * b.

Definition at line 17 of file vnl_diag_matrix.hxx.

◆ solve() [2/2]

template<class T>
void vnl_diag_matrix< T >::solve ( vnl_vector< T > const &  b,
vnl_vector< T > *  out 
) const

Return inv(D) * b.

Definition at line 28 of file vnl_diag_matrix.hxx.

Friends And Related Function Documentation

◆ operator *()

template<class T >
vnl_diag_matrix< T > operator * ( vnl_diag_matrix< T > const &  A,
vnl_diag_matrix< T > const &  B 
)
related

Multiply two vnl_diag_matrices. Just multiply the diag elements - n flops.

Definition at line 226 of file vnl_diag_matrix.h.

◆ operator+()

template<class T >
vnl_diag_matrix< T > operator+ ( vnl_diag_matrix< T > const &  A,
vnl_diag_matrix< T > const &  B 
)
related

Add two vnl_diag_matrices. Just add the diag elements - n flops.

Definition at line 267 of file vnl_diag_matrix.h.

◆ operator-()

template<class T >
vnl_diag_matrix< T > operator- ( vnl_diag_matrix< T > const &  A,
vnl_diag_matrix< T > const &  B 
)
related

Subtract two vnl_diag_matrices. Just subtract the diag elements - n flops.

Definition at line 303 of file vnl_diag_matrix.h.

◆ operator<<()

template<class T >
VNL_EXPORT std::ostream & operator<< ( std::ostream &  ,
vnl_diag_matrix< T > const &   
)
related

◆ vnl_complexify() [1/3]

template<class T >
VNL_EXPORT vnl_diag_matrix< std::complex< T > > vnl_complexify ( vnl_diag_matrix< T > const &  R)
related

Return complexified version of real diagonal matrix R.

Definition at line 66 of file vnl_complex_ops.hxx.

◆ vnl_complexify() [2/3]

template<class T >
VNL_EXPORT vnl_diag_matrix< std::complex< T > > vnl_complexify ( vnl_diag_matrix< T > const &  R,
vnl_diag_matrix< T > const &  I 
)
related

Return complex diagonal matrix R+j*I from two real diagonal matrices R and I.

Definition at line 116 of file vnl_complex_ops.hxx.

◆ vnl_complexify() [3/3]

template<class T >
VNL_EXPORT vnl_sym_matrix< std::complex< T > > vnl_complexify ( vnl_sym_matrix< T > const &  R,
vnl_sym_matrix< T > const &  I 
)
related

Return complex diagonal matrix R+j*I from two real diagonal matrices R and I.

Definition at line 126 of file vnl_complex_ops.hxx.

◆ vnl_imag()

template<class T >
VNL_EXPORT vnl_diag_matrix< T > vnl_imag ( vnl_diag_matrix< std::complex< T > > const &  C)
related

Matrix of imaginary parts of vnl_diag_matrix<std::complex<T> >.

Definition at line 253 of file vnl_complex_ops.hxx.

◆ vnl_matlab_print()

template<class T >
VNL_EXPORT std::ostream & vnl_matlab_print ( std::ostream &  ,
vnl_diag_matrix< T > const &  ,
char const *  variable_name = nullptr,
vnl_matlab_print_format  = vnl_matlab_print_format_default 
)
related

print a vnl_diagonal_matrix<T>.

◆ vnl_real()

template<class T >
VNL_EXPORT vnl_diag_matrix< T > vnl_real ( vnl_diag_matrix< std::complex< T > > const &  C)
related

Matrix of real parts of vnl_diag_matrix<std::complex<T> >.

Definition at line 182 of file vnl_complex_ops.hxx.

◆ vsl_b_read()

template<class T >
void vsl_b_read ( vsl_b_istream &  is,
vnl_diag_matrix< T > &  v 
)
related

Binary load vnl_diag_matrix from stream.

◆ vsl_b_write()

template<class T >
void vsl_b_write ( vsl_b_ostream &  os,
const vnl_diag_matrix< T > &  v 
)
related

Binary save vnl_diag_matrix to stream.

◆ vsl_print_summary()

template<class T >
void vsl_print_summary ( std::ostream &  os,
const vnl_diag_matrix< T > &  b 
)
related

Print human readable summary of object to a stream.

Member Data Documentation

◆ diagonal_

template<class T>
vnl_vector<T> vnl_diag_matrix< T >::diagonal_
private

Definition at line 42 of file vnl_diag_matrix.h.


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