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

stores a symmetric matrix as just the diagonal and lower triangular part. More...

#include <vnl_sym_matrix.h>

Public Types

typedef T * iterator
 
typedef const T * const_iterator
 

Public Member Functions

 vnl_sym_matrix ()
 Construct an empty symmetric matrix. More...
 
 vnl_sym_matrix (unsigned nn)
 Construct a symmetric matrix of size nn by nn. More...
 
 vnl_sym_matrix (T const *data, unsigned nn)
 Construct a symmetric matrix with elements equal to data. More...
 
 vnl_sym_matrix (unsigned nn, const T &value)
 Construct a symmetric matrix with all elements equal to value. More...
 
 vnl_sym_matrix (vnl_matrix< T > const &that)
 Construct a symmetric matrix from a full matrix. More...
 
 vnl_sym_matrix (vnl_sym_matrix< T > const &that)
 Copy constructor. More...
 
 ~vnl_sym_matrix ()
 
vnl_sym_matrix< T > & operator= (vnl_sym_matrix< T > const &that)
 
vnl_sym_matrix< T > & operator *= (T v)
 In-place arithmetic operations. More...
 
vnl_sym_matrix< T > & operator/= (T v)
 In-place arithmetic operations. More...
 
operator() (unsigned i, unsigned j) const
 
T & operator() (unsigned i, unsigned j)
 
const T * operator [] (unsigned i) const
 Access a half-row of data. More...
 
fast (unsigned i, unsigned j) const
 fast access, however i >= j. More...
 
T & fast (unsigned i, unsigned j)
 fast access, however i >= j. 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. More...
 
get (unsigned r, unsigned c) const
 get element. More...
 
vnl_matrix< T > as_matrix () const
 Convert a vnl_sym_matrix to a vnl_matrix. More...
 
void set_size (int n)
 Resize matrix to n by n. More...
 
T * data_block ()
 Return pointer to the lower triangular elements as a contiguous 1D C array;. More...
 
T const * data_block () const
 Return pointer to the lower triangular elements as a contiguous 1D C array;. More...
 
void set_half_row (const vnl_vector< T > &half_row, unsigned i)
 Set the first i values of row i. More...
 
vnl_sym_matrix< T > & update (vnl_sym_matrix< T > const &m, unsigned diag_start=0)
 Replaces the symmetric submatrix of THIS matrix with the elements of matrix m. More...
 
void swap (vnl_sym_matrix &m)
 Swap contents of m with THIS. More...
 

Protected Member Functions

void setup_index ()
 Set up the index array. More...
 

Protected Attributes

T * data_
 
T ** index_
 
unsigned nn_
 

Related Functions

(Note that these are not member functions.)

template<class T >
void vsl_b_write (vsl_b_ostream &os, const vnl_sym_matrix< T > &v)
 Binary save vnl_matrix to stream. More...
 
template<class T >
void vsl_b_read (vsl_b_istream &is, vnl_sym_matrix< T > &v)
 Binary load vnl_matrix from stream. More...
 
template<class T >
void vsl_print_summary (std::ostream &os, const vnl_sym_matrix< T > &b)
 Print human readable summary of object to a stream. More...
 
template<class T >
VNL_EXPORT vnl_sym_matrix< std::complex< T > > vnl_complexify (vnl_sym_matrix< T > const &R)
 Return complexified version of real symmetric matrix R. More...
 
template<class T >
VNL_EXPORT vnl_sym_matrix< T > vnl_imag (vnl_sym_matrix< std::complex< T > > const &C)
 Matrix of imaginary parts of vnl_sym_matrix<std::complex<T> >. More...
 
template<class T >
VNL_EXPORT vnl_sym_matrix< T > vnl_real (vnl_sym_matrix< std::complex< T > > const &C)
 Matrix of real parts of vnl_sym_matrix<std::complex<T> >. More...
 
template<class T >
VNL_EXPORT std::ostream & operator<< (std::ostream &, vnl_sym_matrix< T > const &)
 
template<class T >
void swap (vnl_sym_matrix< T > &a, vnl_sym_matrix< T > &b)
 Swap the contents of a and b. More...
 

Detailed Description

template<class T>
class vnl_sym_matrix< T >

stores a symmetric matrix as just the diagonal and lower triangular part.

vnl_sym_matrix stores a symmetric matrix for time and space efficiency. Specifically, only the diagonal and lower triangular elements are stored.

Definition at line 20 of file vnl_sym_matrix.h.

Member Typedef Documentation

◆ const_iterator

template<class T>
typedef const T* vnl_sym_matrix< T >::const_iterator

Definition at line 100 of file vnl_sym_matrix.h.

◆ iterator

template<class T>
typedef T* vnl_sym_matrix< T >::iterator

Definition at line 97 of file vnl_sym_matrix.h.

Constructor & Destructor Documentation

◆ vnl_sym_matrix() [1/6]

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

Construct an empty symmetric matrix.

Definition at line 31 of file vnl_sym_matrix.h.

◆ vnl_sym_matrix() [2/6]

template<class T>
vnl_sym_matrix< T >::vnl_sym_matrix ( unsigned  nn)
inlineexplicit

Construct a symmetric matrix of size nn by nn.

Definition at line 34 of file vnl_sym_matrix.h.

◆ vnl_sym_matrix() [3/6]

template<class T >
vnl_sym_matrix< T >::vnl_sym_matrix ( T const *  data,
unsigned  nn 
)
inline

Construct a symmetric matrix with elements equal to data.

Value should be stored row-wise, and contain the n*(n+1)/2 diagonal and lower triangular elements

Definition at line 184 of file vnl_sym_matrix.h.

◆ vnl_sym_matrix() [4/6]

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

Construct a symmetric matrix with all elements equal to value.

Definition at line 196 of file vnl_sym_matrix.h.

◆ vnl_sym_matrix() [5/6]

template<class T >
vnl_sym_matrix< T >::vnl_sym_matrix ( vnl_matrix< T > const &  that)
inlineexplicit

Construct a symmetric matrix from a full matrix.

If NDEBUG is set, the symmetry of the matrix will be asserted.

Definition at line 207 of file vnl_sym_matrix.h.

◆ vnl_sym_matrix() [6/6]

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

Copy constructor.

Definition at line 223 of file vnl_sym_matrix.h.

◆ ~vnl_sym_matrix()

template<class T >
vnl_sym_matrix< T >::~vnl_sym_matrix ( )

Definition at line 62 of file vnl_sym_matrix.hxx.

Member Function Documentation

◆ as_matrix()

template<class T >
vnl_matrix< T > vnl_sym_matrix< T >::as_matrix ( ) const
inline

Convert a vnl_sym_matrix to a vnl_matrix.

Definition at line 232 of file vnl_sym_matrix.h.

◆ begin() [1/2]

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

Definition at line 98 of file vnl_sym_matrix.h.

◆ begin() [2/2]

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

Definition at line 101 of file vnl_sym_matrix.h.

◆ cols()

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

Return the number of columns.

A synonym for columns().

Definition at line 115 of file vnl_sym_matrix.h.

◆ columns()

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

Return the number of columns.

A synonym for cols().

Definition at line 119 of file vnl_sym_matrix.h.

◆ data_block() [1/2]

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

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

Definition at line 154 of file vnl_sym_matrix.h.

◆ data_block() [2/2]

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

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

Definition at line 156 of file vnl_sym_matrix.h.

◆ end() [1/2]

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

Definition at line 99 of file vnl_sym_matrix.h.

◆ end() [2/2]

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

Definition at line 102 of file vnl_sym_matrix.h.

◆ fast() [1/2]

template<class T>
T vnl_sym_matrix< T >::fast ( unsigned  i,
unsigned  j 
) const
inline

fast access, however i >= j.

Definition at line 84 of file vnl_sym_matrix.h.

◆ fast() [2/2]

template<class T>
T& vnl_sym_matrix< T >::fast ( unsigned  i,
unsigned  j 
)
inline

fast access, however i >= j.

Definition at line 90 of file vnl_sym_matrix.h.

◆ get()

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

get element.

Definition at line 134 of file vnl_sym_matrix.h.

◆ operator *=()

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

In-place arithmetic operations.

Definition at line 61 of file vnl_sym_matrix.h.

◆ operator []()

template<class T>
const T* vnl_sym_matrix< T >::operator [] ( unsigned  i) const
inline

Access a half-row of data.

Only the first i+1 values from this pointer are valid.

Definition at line 78 of file vnl_sym_matrix.h.

◆ operator()() [1/2]

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

Definition at line 68 of file vnl_sym_matrix.h.

◆ operator()() [2/2]

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

Definition at line 72 of file vnl_sym_matrix.h.

◆ operator/=()

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

In-place arithmetic operations.

Definition at line 63 of file vnl_sym_matrix.h.

◆ operator=()

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

Definition at line 52 of file vnl_sym_matrix.hxx.

◆ put()

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

set element.

Definition at line 122 of file vnl_sym_matrix.h.

◆ rows()

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

Return the number of rows.

Definition at line 111 of file vnl_sym_matrix.h.

◆ set_half_row()

template<class T >
void vnl_sym_matrix< T >::set_half_row ( const vnl_vector< T > &  half_row,
unsigned  i 
)

Set the first i values of row i.

or the top i values of column i

Definition at line 80 of file vnl_sym_matrix.hxx.

◆ set_size()

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

Resize matrix to n by n.

You will loose any existing data.

Definition at line 243 of file vnl_sym_matrix.h.

◆ setup_index()

template<class T >
void vnl_sym_matrix< T >::setup_index ( )
protected

Set up the index array.

Definition at line 70 of file vnl_sym_matrix.hxx.

◆ size()

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

Return the total number of elements stored by the matrix.

Since vnl_sym_matrix only stores the diagonal and lower triangular elements and must be square, this returns n*(n+1)/2, where n == rows() == cols().

Definition at line 108 of file vnl_sym_matrix.h.

◆ swap()

template<class T >
void vnl_sym_matrix< T >::swap ( vnl_sym_matrix< T > &  m)

Swap contents of m with THIS.

Definition at line 36 of file vnl_sym_matrix.hxx.

◆ update()

template<class T >
vnl_sym_matrix< T > & vnl_sym_matrix< T >::update ( vnl_sym_matrix< T > const &  m,
unsigned  diagonal_start = 0 
)

Replaces the symmetric submatrix of THIS matrix with the elements of matrix m.

Replaces the symmetric submatrix of THIS matrix, starting at top left corner, by the elements of matrix m.

Starting at top left corner. Complexity is $O(m^2)$.

O(m*m).

Definition at line 18 of file vnl_sym_matrix.hxx.

Friends And Related Function Documentation

◆ operator<<()

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

◆ swap()

template<class T >
void swap ( vnl_sym_matrix< T > &  a,
vnl_sym_matrix< T > &  b 
)
related

Swap the contents of a and b.

Definition at line 268 of file vnl_sym_matrix.h.

◆ vnl_complexify()

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

Return complexified version of real symmetric matrix R.

Definition at line 75 of file vnl_complex_ops.hxx.

◆ vnl_imag()

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

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

Definition at line 266 of file vnl_complex_ops.hxx.

◆ vnl_real()

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

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

Definition at line 195 of file vnl_complex_ops.hxx.

◆ vsl_b_read()

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

Binary load vnl_matrix from stream.

◆ vsl_b_write()

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

Binary save vnl_matrix to stream.

◆ vsl_print_summary()

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

Print human readable summary of object to a stream.

Member Data Documentation

◆ data_

template<class T>
T* vnl_sym_matrix< T >::data_
protected

Definition at line 173 of file vnl_sym_matrix.h.

◆ index_

template<class T>
T** vnl_sym_matrix< T >::index_
protected

Definition at line 174 of file vnl_sym_matrix.h.

◆ nn_

template<class T>
unsigned vnl_sym_matrix< T >::nn_
protected

Definition at line 175 of file vnl_sym_matrix.h.


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