SHOGUN  6.1.3
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
16
17 namespace shogun
18 {
19 template<class T> class SGVector;
20 template<class T> class SGMatrix;
21
28 template<class T> class CDenseMatrixOperator : public CMatrixOperator<T>
29 {
31 typedef bool supports_complex128_t;
32
33 public:
36
42  explicit CDenseMatrixOperator(SGMatrix<T> op);
43
49  CDenseMatrixOperator(const CDenseMatrixOperator<T>& orig);
50
53
60  virtual SGVector<T> apply(SGVector<T> b) const;
61
67  virtual void set_diagonal(SGVector<T> diag);
68
74  virtual SGVector<T> get_diagonal() const;
75
77  SGMatrix<T> get_matrix_operator() const;
78
82  template<class Scalar>
83  inline operator CDenseMatrixOperator<Scalar>*() const
84  {
85  REQUIRE(m_operator.matrix, "Matrix is not initialized!\n");
86
87  SGMatrix<Scalar> casted_m(m_operator.num_rows, m_operator.num_cols);
88  for (index_t i=0; i<m_operator.num_cols; ++i)
89  {
90  for (index_t j=0; j<m_operator.num_rows; ++j)
91  casted_m(j,i)=static_cast<Scalar>(m_operator(j,i));
92  }
93
94  return new CDenseMatrixOperator<Scalar>(casted_m);
95  }
96
98  virtual const char* get_name() const
99  {
100  return "DenseMatrixOperator";
101  }
102
103 private:
105  SGMatrix<T> m_operator;
106
108  void init();
109
110 };
111
112 }
113
114 #endif // DENSE_MATRIX_OPERATOR_H_
int32_t index_t
Definition: common.h:72
SGMatrix< T > get_matrix_operator() const
#define REQUIRE(x,...)
Definition: SGIO.h:181
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...
shogun matrix
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual const char * get_name() const
virtual SGVector< T > apply(SGVector< T > b) const

SHOGUN Machine Learning Toolbox - Documentation