vnl_io_real_npolynomial.cxx
Go to the documentation of this file.
1 // This is core/vnl/io/vnl_io_real_npolynomial.cxx
2 //:
3 // \file
4 #include <iostream>
6 #include <vnl/io/vnl_io_vector.h>
7 #include <vnl/io/vnl_io_matrix.h>
8 
9 
10 //==============================================================================
11 //: Binary save self to stream.
12 void vsl_b_write(vsl_b_ostream & os, const vnl_real_npolynomial & p)
13 {
14  constexpr short io_version_no = 1;
15  vsl_b_write(os, io_version_no);
16 
17  vsl_b_write(os, p.coefficients());
18  vsl_b_write(os, p.polyn());
19 }
20 
21 //==============================================================================
22 //: Binary load self from stream.
23 void vsl_b_read(vsl_b_istream &is, vnl_real_npolynomial & p)
24 {
25  if (!is) return;
26 
27  short ver;
28  vnl_vector<double> coeffs;
30  vsl_b_read(is, ver);
31  switch (ver)
32  {
33  case 1:
34  vsl_b_read(is, coeffs);
35  vsl_b_read(is, polyn);
36  p.set(coeffs, polyn);
37  break;
38 
39  default:
40  std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vnl_real_npolynomial&)\n"
41  << " Unknown version number "<< ver << '\n';
42  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
43  return;
44  }
45 }
46 
47 //==============================================================================
48 //: Output a human readable summary to the stream
49 void vsl_print_summary(std::ostream & os,const vnl_real_npolynomial & p)
50 {
51  os<<"Coefficients: ";
53  os<<"Polynomial: ";
54  vsl_print_summary(os, p.polyn());
55 }
void vsl_print_summary(std::ostream &os, vnl_bignum const &b)
Print human readable summary of object to a stream.
void set(const vnl_vector< double > &c, const vnl_matrix< unsigned int > &p)
Set vector of coefficients of each product.
const vnl_vector< double > & coefficients() const
Return the vector of coefficients.
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.
real polynomial in N variables.
const vnl_matrix< unsigned int > & polyn() const
Return the polynomial matrix.