SHOGUN  4.1.0
DenseMatrixOperator.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Soumyajit De
8  */
9
10 #ifndef DENSE_MATRIX_OPERATOR_H_
11 #define DENSE_MATRIX_OPERATOR_H_
12
13 #include <shogun/lib/config.h>
14
15 #ifdef HAVE_EIGEN3
16
17
18 namespace shogun
19 {
20 template<class T> class SGVector;
21 template<class T> class SGMatrix;
22
29 template<class T> class CDenseMatrixOperator : public CMatrixOperator<T>
30 {
32 typedef bool supports_complex128_t;
33
34 public:
37
43  explicit CDenseMatrixOperator(SGMatrix<T> op);
44
50  CDenseMatrixOperator(const CDenseMatrixOperator<T>& orig);
51
54
61  virtual SGVector<T> apply(SGVector<T> b) const;
62
68  virtual void set_diagonal(SGVector<T> diag);
69
75  virtual SGVector<T> get_diagonal() const;
76
78  SGMatrix<T> get_matrix_operator() const;
79
83  template<class Scalar>
84  inline operator CDenseMatrixOperator<Scalar>*() const
85  {
86  REQUIRE(m_operator.matrix, "Matrix is not initialized!\n");
87
88  SGMatrix<Scalar> casted_m(m_operator.num_rows, m_operator.num_cols);
89  for (index_t i=0; i<m_operator.num_cols; ++i)
90  {
91  for (index_t j=0; j<m_operator.num_rows; ++j)
92  casted_m(j,i)=static_cast<Scalar>(m_operator(j,i));
93  }
94
95  return new CDenseMatrixOperator<Scalar>(casted_m);
96  }
97
99  virtual const char* get_name() const
100  {
101  return "DenseMatrixOperator";
102  }
103
104 private:
106  SGMatrix<T> m_operator;
107
109  void init();
110
111 };
112
113 }
114
115 #endif // HAVE_EIGEN3
116 #endif // DENSE_MATRIX_OPERATOR_H_
SGMatrix< T > get_matrix_operator() const
int32_t index_t
Definition: common.h:62
#define REQUIRE(x,...)
Definition: SGIO.h:206
virtual SGVector< T > apply(SGVector< T > b) const
shogun matrix
virtual void set_diagonal(SGVector< T > diag)
virtual SGVector< T > get_diagonal() const
Class that represents a dense-matrix linear operator. It computes matrix-vector product in its apply...
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual const char * get_name() const

SHOGUN Machine Learning Toolbox - Documentation