core/vnl/vnl_fortran_copy.txx
Go to the documentation of this file.
00001 // This is core/vnl/vnl_fortran_copy.txx
00002 #ifndef vnl_fortran_copy_txx_
00003 #define vnl_fortran_copy_txx_
00004 //:
00005 // \file
00006 // \author Andrew W. Fitzgibbon, Oxford RRG
00007 // \date   29 Aug 96
00008 //-----------------------------------------------------------------------------
00009 
00010 #include "vnl_fortran_copy.h"
00011 
00012 //: Generate a fortran column-storage matrix from the given matrix.
00013 template <class T>
00014 vnl_fortran_copy<T>::vnl_fortran_copy(vnl_matrix<T> const & M)
00015 {
00016   unsigned n = M.rows();
00017   unsigned p = M.columns();
00018 
00019   data = vnl_c_vector<T>::allocate_T(sz = n*p);
00020   T *d = data;
00021   for (unsigned j = 0; j < p; ++j)
00022     for (unsigned i = 0; i < n; ++i)
00023       *d++ = M(i,j);
00024 }
00025 
00026 //: Destructor
00027 template <class T>
00028 vnl_fortran_copy<T>::~vnl_fortran_copy()
00029 {
00030   vnl_c_vector<T>::deallocate(data, sz);
00031 }
00032 
00033 //--------------------------------------------------------------------------------
00034 
00035 #undef VNL_FORTRAN_COPY_INSTANTIATE
00036 #define VNL_FORTRAN_COPY_INSTANTIATE(T) template class vnl_fortran_copy<T >
00037 
00038 #endif // vnl_fortran_copy_txx_