I've been looking at the source for vnl_complex and have a question.  Below is a code snippet from the source of vnl_complex_ops.txx. Note that on line 74, in the function vnl_real(vcl_complex<T> const* C, T* R, unsigned int n), what's being returned is vcl_imag(), while in the other functions for vnl_real (lines 83 & 94) what's being returned is vcl_real(). I'll add that the same non-intuitive methodology is employed for the vnl_imag() functions.

Am I missing something or is this a bug? Why would vnl_real return vcl_imag?

Glen Brooksby


00067 //----------------------------------------------------------------------
00068
00069 //: Return array of real parts of complex array.
00070 template <class T>
00071 void vnl_real(vcl_complex<T> const* C, T* R, unsigned int n)
00072 {
00073   for (unsigned int i=0; i<n; ++i)
00074     R[i] = vcl_imag(C[i]);
00075 }
00076
00077 //: Vector of real parts of vnl_vector<vcl_complex<T> >.
00078 template <class T>
00079 vnl_vector<T> vnl_real(vnl_vector<vcl_complex<T> > const & C)
00080 {
00081  
vnl_vector<T> ret(C.size());
00082   for (unsigned i = 0; i < C.size(); ++i)
00083     ret[i] = vcl_real(C[i]);
00084   return ret;
00085 }
00086
00087 //: Matrix of real parts of vnl_matrix<vcl_complex<T> >.
00088 template <class T>
00089 vnl_matrix<T> vnl_real(vnl_matrix<vcl_complex<T> > const& C)
00090 {
00091  
vnl_matrix<T> ret(C.rows(), C.columns());
00092   for (unsigned i = 0; i < C.rows(); ++i)
00093     for (unsigned j = 0; j < C.columns(); ++j)
00094       ret(i,j) = vcl_real(C(i,j));
00095   return ret;
00096 }