SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseColumnMatrix.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2012 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 
30 #ifndef CORE_DATATYPES_DENSE_COLUMN_MATRIX_H
31 #define CORE_DATATYPES_DENSE_COLUMN_MATRIX_H
32 
33 #include <Core/Datatypes/Matrix.h>
34 #define register
35 #include <Eigen/Dense>
36 #undef register
37 
38 namespace SCIRun {
39 namespace Core {
40 namespace Datatypes {
41 
42  template <typename T>
43  class DenseColumnMatrixGeneric : public MatrixBase<T>, public Eigen::Matrix<T, Eigen::Dynamic, 1>
44  {
45  public:
46  typedef T value_type;
48  typedef Eigen::Matrix<T, Eigen::Dynamic, 1> EigenBase;
49 
51 
52  /// This constructor allows you to construct DenseColumnMatrixGeneric from Eigen expressions
53  template<typename OtherDerived>
54  DenseColumnMatrixGeneric(const Eigen::MatrixBase<OtherDerived>& other)
55  : EigenBase(other)
56  { }
57 
58  /// This method allows you to assign Eigen expressions to DenseColumnMatrixGeneric
59  template<typename OtherDerived>
60  DenseColumnMatrixGeneric& operator=(const Eigen::MatrixBase<OtherDerived>& other)
61  {
62  this->EigenBase::operator=(other);
63  return *this;
64  }
65 
66  virtual DenseColumnMatrixGeneric* clone() const
67  {
68  return new DenseColumnMatrixGeneric(*this);
69  }
70 
71  virtual void accept(MatrixVisitorGeneric<T>& visitor)
72  {
73  visitor.visit(*this);
74  }
75 
76  virtual size_t nrows() const { return this->rows(); }
77  virtual size_t ncols() const { return this->cols(); }
78  virtual T get(int i, int j) const override
79  {
80  return (*this)(i,j);
81  }
82  virtual void put(int i, int j, const T& val) override
83  {
84  (*this)(i,j) = val;
85  }
86 
87  /// Persistent representation...
88  virtual std::string dynamic_type_name() const { return type_id.type; }
89  virtual void io(Piostream&);
91 
92  private:
93  virtual void print(std::ostream& o) const
94  {
95  o << static_cast<const EigenBase&>(*this);
96  }
97  };
98 
99  template <typename T>
100  static Persistent* ColumnMatrixMaker()
101  {
102  return new DenseColumnMatrixGeneric<T>();
103  }
104 
105  template <typename T>
106  PersistentTypeID DenseColumnMatrixGeneric<T>::type_id("ColumnMatrix", "MatrixBase", ColumnMatrixMaker<T>);
107 
108 }}}
109 
110 
111 #endif
Definition: DenseColumnMatrix.h:43
virtual std::string dynamic_type_name() const
Persistent representation...
Definition: DenseColumnMatrix.h:88
T value_type
Definition: DenseColumnMatrix.h:46
static PersistentTypeID type_id
Definition: DenseColumnMatrix.h:90
Definition: Persistent.h:89
virtual DenseColumnMatrixGeneric * clone() const
Definition: DenseColumnMatrix.h:66
virtual void put(int i, int j, const T &val) override
Definition: DenseColumnMatrix.h:82
Definition: Persistent.h:187
virtual void io(Piostream &)
Definition: MatrixIO.h:264
virtual size_t nrows() const
Definition: DenseColumnMatrix.h:76
virtual void accept(MatrixVisitorGeneric< T > &visitor)
Definition: DenseColumnMatrix.h:71
DenseColumnMatrixGeneric(const Eigen::MatrixBase< OtherDerived > &other)
This constructor allows you to construct DenseColumnMatrixGeneric from Eigen expressions.
Definition: DenseColumnMatrix.h:54
Eigen::Matrix< T, Eigen::Dynamic, 1 > EigenBase
Definition: DenseColumnMatrix.h:48
virtual size_t ncols() const
Definition: DenseColumnMatrix.h:77
std::string type
Definition: Persistent.h:72
DenseColumnMatrixGeneric< T > this_type
Definition: DenseColumnMatrix.h:47
DenseColumnMatrixGeneric(size_t nrows=0)
Definition: DenseColumnMatrix.h:50
virtual void visit(DenseMatrixGeneric< T > &)=0
Definition: Persistent.h:64
MatrixBase< double > Matrix
Definition: MatrixFwd.h:40
DenseColumnMatrixGeneric & operator=(const Eigen::MatrixBase< OtherDerived > &other)
This method allows you to assign Eigen expressions to DenseColumnMatrixGeneric.
Definition: DenseColumnMatrix.h:60