core/vnl/vnl_int_matrix.cxx
Go to the documentation of this file.
00001 // This is core/vnl/vnl_int_matrix.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 //
00008 // vnl_int_matrix
00009 // Author: Andrew W. Fitzgibbon, Oxford RRG
00010 // Created: 27 Dec 96
00011 //
00012 //-----------------------------------------------------------------------------
00013 
00014 #include "vnl_int_matrix.h"
00015 #include <vcl_fstream.h>
00016 
00017 //: Construct from matrix of double.
00018 //  The double-to-int conversion is simply the standard (int) cast.
00019 vnl_int_matrix::vnl_int_matrix(const vnl_matrix<double>& d):
00020   Base(d.rows(), d.columns())
00021 {
00022   unsigned m = d.rows();
00023   unsigned n = d.columns();
00024 
00025   for (unsigned i = 0; i < m; ++i)
00026     for (unsigned j = 0; j < n; ++j)
00027       (*this)(i,j) = (int)d(i,j);
00028 }
00029 
00030 //: Load from disk
00031 vnl_int_matrix::vnl_int_matrix(char const* filename)
00032 {
00033   vcl_ifstream s(filename);
00034   read_ascii(s);
00035 }