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