SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
mathematics
linalg
linop
DenseMatrixOperator.h
浏览该文件的文档.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
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
#include <
shogun/mathematics/linalg/linop/MatrixOperator.h
>
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
:
36
CDenseMatrixOperator
();
37
43
explicit
CDenseMatrixOperator
(SGMatrix<T> op);
44
50
CDenseMatrixOperator
(
const
CDenseMatrixOperator<T>& orig);
51
53
~CDenseMatrixOperator
();
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
SG_SDEBUG
(
"DenseMatrixOperator::static_cast(): Creating casted operator!\n"
);
95
96
return
new
CDenseMatrixOperator<Scalar>
(casted_m);
97
}
98
100
virtual
const
char
*
get_name
()
const
101
{
102
return
"DenseMatrixOperator"
;
103
}
104
105
private
:
107
SGMatrix<T>
m_operator;
108
110
void
init();
111
112
};
113
114
}
115
116
#endif // HAVE_EIGEN3
117
#endif // DENSE_MATRIX_OPERATOR_H_
SHOGUN
机器学习工具包 - 项目文档