vnl_int_matrix.cxx
Go to the documentation of this file.
1 // This is core/vnl/vnl_int_matrix.cxx
2 //:
3 // \file
4 //
5 // vnl_int_matrix
6 // Author: Andrew W. Fitzgibbon, Oxford RRG
7 // Created: 27 Dec 96
8 //
9 //-----------------------------------------------------------------------------
10 
11 #include <fstream>
12 #include "vnl_int_matrix.h"
13 
14 //: Construct from matrix of double.
15 // The double-to-int conversion is simply the standard (int) cast.
17  Base(d.rows(), d.columns())
18 {
19  unsigned m = d.rows();
20  unsigned n = d.columns();
21 
22  for (unsigned i = 0; i < m; ++i)
23  for (unsigned j = 0; j < n; ++j)
24  (*this)(i,j) = (int)d(i,j);
25 }
26 
27 //: Load from disk
28 vnl_int_matrix::vnl_int_matrix(char const* filename)
29 {
30  std::ifstream s(filename);
31  read_ascii(s);
32 }
Specializes vnl_matrix for integers.
#define m
Definition: vnl_vector.h:43
vnl_int_matrix()=default
unsigned int rows() const
Return the number of rows.
Definition: vnl_matrix.h:179
bool read_ascii(std::istream &s)
Read a vnl_matrix from an ascii std::istream.
unsigned int columns() const
Return the number of columns.
Definition: vnl_matrix.h:187