cheshirekow  v0.1.0
StreamAssignment.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_POLYNOMIAL_STREAMASSIGNMENT_H_
28 #define MPBLOCKS_POLYMOMIAL_STREAMASSIGNMENT_H_
29 
30 #include <iostream>
31 #include <cassert>
32 
33 namespace mpblocks {
34 namespace polynomial {
35 
36 
37 
39 template <class Exp>
41 {
42  public:
44 
45  private:
46  Exp& m_mat;
47  unsigned int m_i;
48 
49  public:
50 
51  StreamAssignment( Exp& M ):
52  m_mat(M),
53  m_i(0)
54  {}
55 
56  template <typename Scalar>
57  Stream_t& append( Scalar x )
58  {
59  if(m_mat.size() <= m_i )
60  m_mat.resize(m_i+1);
61  m_mat[m_i++] = x;
62  return *this;
63  }
64 
65  template <typename Scalar>
66  Stream_t& operator<<( Scalar x )
67  {
68  return append<Scalar>(x);
69  }
70 
71  template <typename Scalar>
72  Stream_t& operator,( Scalar x )
73  {
74  return append<Scalar>(x);
75  }
76 };
77 
78 
79 
80 
81 
82 
83 
84 
85 } // polynomial
86 } // mpblocks
87 
88 
89 
90 
91 
92 #endif // POLYMOMIAL_H_