vnl_real.h
Go to the documentation of this file.
1 // This is core/vnl/vnl_real.h
2 #ifndef vnl_real_h_
3 #define vnl_real_h_
4 //:
5 // \file
6 // \brief Functions to return the real parts of complex arrays, vectors, matrices
7 //
8 // \verbatim
9 // Modifications
10 // Peter Vanroose - 2 July 2002 - part of vnl_complex_ops.h moved here
11 // \endverbatim
12 
13 #include <complex>
14 #ifdef _MSC_VER
15 # include <vcl_msvc_warnings.h>
16 #endif
17 #include <vnl/vnl_vector.h>
18 #include <vnl/vnl_vector_fixed.h>
19 #include <vnl/vnl_matrix.h>
20 #include <vnl/vnl_matrix_fixed.h>
21 #include <vnl/vnl_diag_matrix.h>
23 #include <vnl/vnl_sym_matrix.h>
24 #include "vnl/vnl_export.h"
25 
26 //: Return array R of real parts of complex array C.
27 template <class T> VNL_EXPORT
28 void
29 vnl_real(std::complex<T> const* C, T* R, unsigned int n);
30 
31 // - vnl_vector
32 // - vnl_vector_fixed
33 // - vnl_matrix
34 // - vnl_matrix_fixed
35 // - vnl_diag_matrix
36 // - vnl_diag_matrix_fixed
37 // - vnl_sym_matrix
38 
39 //: Vector of real parts of vnl_vector<std::complex<T> >.
40 // \relatesalso vnl_vector
41 template <class T> VNL_EXPORT
43 vnl_real(vnl_vector<std::complex<T> > const& C);
44 
45 //: Vector of real parts of vnl_vector_fixed<std::complex<T>, N >.
46 // \relatesalso vnl_vector_fixed
47 template <class T, unsigned int N>
49 vnl_real(vnl_vector_fixed<std::complex<T>, N > const& C)
50 {
52  typename vnl_vector_fixed<std::complex<T>,N >::const_iterator cIt = C.begin();
53  typename vnl_vector_fixed<T,N>::iterator rIt = R.begin();
54  for (; cIt != C.end(); ++cIt, ++rIt)
55  *rIt = std::real(*cIt);
56  return R;
57 }
58 
59 //: Matrix of real parts of vnl_matrix<std::complex<T> >.
60 // \relatesalso vnl_matrix
61 template <class T> VNL_EXPORT
63 vnl_real(vnl_matrix<std::complex<T> > const& C);
64 
65 //: Matrix of real parts of vnl_matrix_fixed<std::complex<T>,NRow,NCol >.
66 // \relatesalso vnl_matrix_fixed
67 template <class T, unsigned int NRow, unsigned int NCol>
69 vnl_real(vnl_matrix_fixed<std::complex<T>,NRow,NCol > const& C)
70 {
72  typename vnl_matrix_fixed<std::complex<T>,NRow,NCol >::const_iterator cIt = C.begin();
74  for (; cIt != C.end(); ++cIt, ++rIt)
75  *rIt = std::real(*cIt);
76  return R;
77 }
78 
79 //: Matrix of real parts of vnl_diag_matrix<std::complex<T> >.
80 // \relatesalso vnl_diag_matrix
81 template <class T> VNL_EXPORT
83 vnl_real(vnl_diag_matrix<std::complex<T> > const& C);
84 
85 //: Matrix of real parts of vnl_diag_matrix_fixed<std::complex<T> >.
86 // \relatesalso vnl_diag_matrix_fixed
87 template <class T, unsigned int N>
89 vnl_real(vnl_diag_matrix_fixed<std::complex<T>,N > const& C)
90 {
92  typename vnl_diag_matrix_fixed<std::complex<T>,N >::const_iterator cIt = C.begin();
94  for (; cIt != C.end(); ++cIt, ++rIt)
95  *rIt = std::real(*cIt);
96  return R;
97 }
98 
99 //: Matrix of real parts of vnl_sym_matrix<std::complex<T> >.
100 // \relatesalso vnl_sym_matrix
101 template <class T> VNL_EXPORT
103 vnl_real(vnl_sym_matrix<std::complex<T> > const& C);
104 
105 #endif // vnl_real_h_
An ordinary mathematical matrix.
VNL_EXPORT vnl_vector< T > vnl_real(vnl_vector< std::complex< T > > const &C)
Vector of real parts of vnl_vector<std::complex<T> >.
Fixed size, stack-stored, space-efficient matrix.
Definition: vnl_fwd.h:23
iterator end()
Iterator pointing to element beyond end of data.
Contains class for symmetric matrices.
iterator end()
Iterator pointing to element beyond end of data.
An ordinary mathematical matrix.
Definition: vnl_adjugate.h:22
Mathematical vector class, templated by type of element.
Definition: vnl_fwd.h:16
fixed size matrix
Fixed length stack-stored vector.
iterator begin()
Iterator pointing to start of data.
stores a diagonal matrix as a single vector.
T * iterator
Iterators.
stores a diagonal matrix as a single vector.
Contains class for diagonal matrices.
iterator begin()
Iterator pointing to start of data.
vnl_vector_fixed< T, N >::iterator iterator
stores a symmetric matrix as just the diagonal and lower triangular part.
Contains class for diagonal matrices.