CUV  0.9.201304091348
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
matrix.hpp
1 //*LB*
2 // Copyright (c) 2010, University of Bonn, Institute for Computer Science VI
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 // * Neither the name of the University of Bonn
14 // nor the names of its contributors may be used to endorse or promote
15 // products derived from this software without specific prior written
16 // permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //*LE*
29 
30 
31 
32 #ifndef __MATRIX_HPP__
33 #define __MATRIX_HPP__
34 
35 #include <cuv/tools/cuv_general.hpp>
36 
37 namespace cuv{
38 
39  template<class V, class T, class I>
40  class dia_matrix;
41 
42 
49 template<class __value_type, class __index_type>
50 class matrix
51  {
52  public:
53  typedef __value_type value_type;
54  typedef __index_type index_type;
55  template <class Archive, class V, class I> friend void serialize(Archive&, dia_matrix<V,host_memory_space, I>&, unsigned int) ;
56  protected:
59  public:
66  matrix(const index_type& h, const index_type& w)
67  : m_width(w), m_height(h)
68  {
69  }
74  : m_width(m.w()), m_height(m.h())
75  {
76  }
82  {
83  m_width = m.w();
84  m_height = m.h();
85  return *this;
86  }
87  virtual ~matrix(){
88  }
95  inline void resize(const index_type& h, const index_type& w)
96  {
97  cuvAssert(w*h == m_width*m_height);
98  m_width=w;
99  m_height=h;
100  }
101  inline index_type w()const { return m_width; }
102  inline index_type h()const { return m_height; }
103  inline index_type n()const { return w()*h(); }
104  //virtual void alloc() = 0; ///< Purely virtual
105  //virtual void dealloc() = 0; ///< Purely virtual
106  };
107 }
108 
109 #endif /* __MATRIX_HPP__ */