SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
mathematics
linalg
linsolver
IterativeLinearSolver.h
Go to the documentation of this file.
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 ITERATIVE_LINEAR_SOLVER_H_
11
#define ITERATIVE_LINEAR_SOLVER_H_
12
13
#include <
shogun/lib/config.h
>
14
#include <
shogun/mathematics/linalg/linsolver/LinearSolver.h
>
15
16
namespace
shogun
17
{
18
24
template
<
class
T,
class
ST=T>
class
CIterativeLinearSolver
:
public
CLinearSolver
<T, ST>
25
{
26
27
public
:
29
CIterativeLinearSolver
();
30
32
CIterativeLinearSolver
(
bool
store_residuals);
33
35
virtual
~CIterativeLinearSolver
();
36
44
virtual
SGVector<T>
solve
(
CLinearOperator<T>
* A,
SGVector<ST>
b) = 0;
45
47
void
set_iteration_limit
(
index_t
iteration_limit)
48
{
49
m_max_iteration_limit
=iteration_limit;
50
if
(
m_store_residuals
)
51
{
52
m_residuals
=
SGVector<float64_t>
(
m_max_iteration_limit
);
53
m_residuals
.
set_const
(0.0);
54
}
55
}
56
58
const
index_t
get_iteration_limit
()
const
59
{
60
return
m_max_iteration_limit
;
61
}
62
64
void
set_relative_tolerence
(
float64_t
relative_tolerence)
65
{
66
m_relative_tolerence
=relative_tolerence;
67
}
68
70
const
float64_t
get_relative_tolerence
()
const
71
{
72
return
m_relative_tolerence
;
73
}
74
76
void
set_absolute_tolerence
(
float64_t
absolute_tolerence)
77
{
78
m_absolute_tolerence
=absolute_tolerence;
79
}
80
82
const
float64_t
get_absolute_tolerence
()
const
83
{
84
return
m_absolute_tolerence
;
85
}
86
88
SGVector<float64_t>
get_residuals
()
const
89
{
90
return
m_residuals
;
91
}
92
94
virtual
const
char
*
get_name
()
const
95
{
96
return
"IterativeLinearSolver"
;
97
}
98
99
protected
:
100
102
index_t
m_max_iteration_limit
;
103
105
float64_t
m_relative_tolerence
;
106
108
float64_t
m_absolute_tolerence
;
109
111
SGVector<float64_t>
m_residuals
;
112
114
bool
m_store_residuals
;
115
private
:
117
void
init();
118
119
};
120
121
}
122
123
#endif // ITERATIVE_LINEAR_SOLVER_H_
SHOGUN
Machine Learning Toolbox - Documentation