2 #ifndef vnl_sym_matrix_hxx_ 3 #define vnl_sym_matrix_hxx_ 10 # include <vcl_msvc_warnings.h> 12 #include <vnl/vnl_config.h> 19 unsigned diagonal_start)
21 unsigned int end_val = diagonal_start +
m.nn_;
22 #if VNL_CONFIG_CHECK_BOUNDS && (!defined NDEBUG) 23 if (this->nn_ < end_val)
25 end_val, end_val,
m.nn_,
m.nn_);
27 for (
unsigned int i = diagonal_start; i < end_val; i++)
28 for (
unsigned int j = diagonal_start; j <= i; j++)
29 this->fast(i,j) =
m.fast(i-diagonal_start,j-diagonal_start);
54 if (&that ==
this)
return *
this;
56 set_size(that.
rows());
73 for (
unsigned i=0; i< nn_; ++i) { index_[i] = data; data += i+1; }
82 #if VNL_CONFIG_CHECK_BOUNDS && (!defined NDEBUG) 83 if (half_row.
size() != i+1)
85 half_row.
size(), i+1);
98 for (
unsigned i=0; i<M.
rows(); ++i)
100 for (
unsigned j=0; j<=i; ++j)
101 s << M.
fast(i,j) <<
' ';
112 if (a.
rows() != b.
rows())
return false;
115 const unsigned mn = a.
size();
116 for (
unsigned i = 0; i < mn; ++i)
117 if (a_data[i] != b_data[i])
return false;
128 const unsigned n = a.
rows();
129 for (
unsigned i=0; i< n; ++i)
131 for (
unsigned j=0; j<i; ++j)
132 if (a.
fast(i,j) != b(i,j) || a.
fast(i,j) != b(j,i))
return false;
133 if (a.
fast(i,i) != b(i,i))
return false;
148 #undef VNL_SYM_MATRIX_INSTANTIATE 149 #define VNL_SYM_MATRIX_INSTANTIATE(T) \ 150 template class VNL_EXPORT vnl_sym_matrix<T >; \ 151 template VNL_EXPORT std::ostream& operator<< (std::ostream& s, vnl_sym_matrix<T > const &); \ 152 template VNL_EXPORT bool operator==(const vnl_sym_matrix<T > &a, const vnl_sym_matrix<T > &b); \ 153 template VNL_EXPORT bool operator==(const vnl_sym_matrix<T > &a, const vnl_matrix<T > &b); \ 154 template VNL_EXPORT bool operator==(const vnl_matrix<T > &a, const vnl_sym_matrix<T > &b) 156 #endif // vnl_sym_matrix_hxx_ static void deallocate(T **, const std::size_t n_when_allocated)
unsigned int cols() const
Return the number of columns.
void swap(vnl_sym_matrix &m)
Swap contents of m with THIS.
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.
size_t size() const
Return the length, number of elements, dimension of this vector.
T fast(unsigned i, unsigned j) const
fast access, however i >= j.
vnl_sym_matrix< T > & operator=(vnl_sym_matrix< T > const &that)
unsigned int cols() const
Return the number of columns.
Contains class for symmetric matrices.
std::ostream & operator<<(std::ostream &s, vnl_decnum const &r)
decimal output.
void vnl_error_vector_dimension(char const *fcn, int l1, int l2)
Raise exception for invalid dimension.
unsigned int rows() const
Return the number of rows.
bool operator==(int r1, vnl_finite_int< N > const &r2)
unsigned int size() const
Return the total number of elements stored by the matrix.
An ordinary mathematical matrix.
Mathematical vector class, templated by type of element.
void vnl_error_matrix_dimension(char const *fcn, int r1, int c1, int r2, int c2)
Raise exception for invalid dimensions.
T * data_block()
Return pointer to the lower triangular elements as a contiguous 1D C array;.
unsigned int rows() const
Return the number of rows.
void setup_index()
Set up the index array.
void copy_out(T *) const
Copy elements to ptr[i].
void set_half_row(const vnl_vector< T > &half_row, unsigned i)
Set the first i values of row i.
stores a symmetric matrix as just the diagonal and lower triangular part.