vnl_diag_matrix.hxx
Go to the documentation of this file.
1 // This is core/vnl/vnl_diag_matrix.hxx
2 #ifndef vnl_diag_matrix_hxx_
3 #define vnl_diag_matrix_hxx_
4 //:
5 // \file
6 
7 #include <iostream>
8 #include "vnl_diag_matrix.h"
9 
10 #ifdef _MSC_VER
11 # include <vcl_msvc_warnings.h>
12 #endif
13 
14 
15 //: Return inv(D) * b.
16 template <class T>
18 {
19  unsigned len = diagonal_.size();
20  vnl_vector<T> ret(len);
21  for (unsigned i = 0; i < len; ++i)
22  ret[i] = b[i] / diagonal_[i];
23  return ret;
24 }
25 
26 //: Return inv(D) * b.
27 template <class T>
29 {
30  unsigned len = diagonal_.size();
31  for (unsigned i = 0; i < len; ++i)
32  (*out)[i] = b[i] / diagonal_[i];
33 }
34 
35 //: Print in MATLAB diag([1 2 3]) form.
36 template <class T>
37 std::ostream& operator<< (std::ostream& s, const vnl_diag_matrix<T>& D)
38 {
39  s << "diag([ ";
40  for (unsigned i=0; i<D.rows(); ++i)
41  s << D(i,i) << ' ';
42  return s << "])";
43 }
44 
45 #undef VNL_DIAG_MATRIX_INSTANTIATE
46 #define VNL_DIAG_MATRIX_INSTANTIATE(T) \
47 template class VNL_EXPORT vnl_diag_matrix<T >; \
48 /*template VNL_EXPORT vnl_matrix<T > operator* (vnl_matrix<T > const &, vnl_diag_matrix<T > const &); */\
49 /*template VNL_EXPORT vnl_matrix<T > operator* (vnl_diag_matrix<T > const &, vnl_matrix<T > const &); */\
50 /*template VNL_EXPORT vnl_matrix<T > operator+ (vnl_matrix<T > const &, vnl_diag_matrix<T > const &); */\
51 /*template VNL_EXPORT vnl_matrix<T > operator+ (vnl_diag_matrix<T > const &, vnl_matrix<T > const &); */\
52 /*template VNL_EXPORT vnl_matrix<T > operator- (vnl_matrix<T > const &, vnl_diag_matrix<T > const &); */\
53 /*template VNL_EXPORT vnl_matrix<T > operator- (vnl_diag_matrix<T > const &, vnl_matrix<T > const &); */\
54 /*template VNL_EXPORT vnl_vector<T > operator* (const vnl_vector<T >&, vnl_diag_matrix<T > const &); */\
55 /*template VNL_EXPORT vnl_vector<T > operator* (vnl_diag_matrix<T > const &, const vnl_vector<T >&); */\
56 template VNL_EXPORT std::ostream& operator<< (std::ostream& s, vnl_diag_matrix<T > const &)
57 
58 //template bool epsilon_equals (vnl_diag_matrix<T > const & , vnl_diag_matrix<T > const & , double)
59 
60 #endif // vnl_diag_matrix_hxx_
unsigned int rows() const
Return the number of rows.
vnl_vector< T > solve(vnl_vector< T > const &b) const
Return inv(D) * b.
std::ostream & operator<<(std::ostream &s, vnl_decnum const &r)
decimal output.
Definition: vnl_decnum.h:393
Mathematical vector class, templated by type of element.
Definition: vnl_fwd.h:16
stores a diagonal matrix as a single vector.
Contains class for diagonal matrices.