2 #ifndef vnl_io_matrix_fixed_hxx_ 3 #define vnl_io_matrix_fixed_hxx_ 9 #include <vsl/vsl_b_read_block_old.h> 10 #include <vsl/vsl_block_binary.h> 11 #include <vsl/vsl_indent.h> 15 template<
class T,
unsigned m,
unsigned n>
18 constexpr
short version_no = 2;
30 template<
class T,
unsigned m,
unsigned n>
36 unsigned stream_m, stream_n;
43 if ( stream_n != n || stream_m !=
m ) {
44 std::cerr <<
"I/O ERROR: vsl_b_read(vsl_b_istream&, vnl_matrix_fixed<T>&)\n" 45 <<
" Expected size " <<
m <<
',' << n <<
"; got " << stream_m <<
',' << stream_n <<
'\n';
46 is.is().clear(std::ios::badbit);
51 vsl_b_read_block_old(is, p.
begin(), p.
size());
57 if ( stream_n != n || stream_m !=
m ) {
58 std::cerr <<
"I/O ERROR: vsl_b_read(vsl_b_istream&, vnl_matrix_fixed<T>&)\n" 59 <<
" Expected size " <<
m <<
',' << n <<
"; got " << stream_m <<
',' << stream_n <<
'\n';
60 is.is().clear(std::ios::badbit);
69 std::cerr <<
"I/O ERROR: vsl_b_read(vsl_b_istream&, vnl_matrix_fixed<T>&)\n" 70 <<
" Unknown version number "<<
v <<
'\n';
71 is.is().clear(std::ios::badbit);
78 template<
class T,
unsigned nrows,
unsigned ncols>
81 os<<
"Size: "<<p.
rows()<<
" x "<<p.
cols()<<std::endl;
83 unsigned int m = 5;
unsigned int n = 5;
90 for (
unsigned int i=0;i<
m;i++)
92 os<<vsl_indent()<<
" (";
94 for (
unsigned int j=0; j<n; j++)
96 if (p.
cols()>n) os<<
"...";
99 if (p.
rows()>
m) os <<vsl_indent()<<
" (...\n";
104 #define VNL_IO_MATRIX_FIXED_INSTANTIATE(T,m,n) \ 105 template void vsl_print_summary(std::ostream &, const vnl_matrix_fixed<T,m,n > &); \ 106 template void vsl_b_read(vsl_b_istream &, vnl_matrix_fixed<T,m,n > &); \ 107 template void vsl_b_write(vsl_b_ostream &, const vnl_matrix_fixed<T,m,n > &) 109 #endif // vnl_io_matrix_fixed_hxx_ unsigned int cols() const
Return the number of columns.
void vsl_print_summary(std::ostream &os, vnl_bignum const &b)
Print human readable summary of object to a stream.
T const * data_block() const
Access the contiguous block storing the elements in the matrix row-wise. O(1).
Fixed size, stack-stored, space-efficient matrix.
unsigned int rows() const
Return the number of rows.
void vsl_b_read(vsl_b_istream &is, vnl_bignum &v)
Binary load vnl_bignum from stream.
void vsl_b_write(vsl_b_ostream &os, vnl_bignum const &v)
Binary save vnl_bignum to stream.
iterator begin()
Iterator pointing to start of data.
unsigned int size() const
Return the total number of elements stored by the matrix.