AIToolbox
A library that offers tools for AI problem solving.
FactoredMatrix.hpp
Go to the documentation of this file.
1
#ifndef AI_TOOLBOX_FACTORED_UTILS_FACTORED_MATRIX_HEADER_FILE
2
#define AI_TOOLBOX_FACTORED_UTILS_FACTORED_MATRIX_HEADER_FILE
3
4
#include <
AIToolbox/Factored/Types.hpp
>
5
6
namespace
AIToolbox::Factored
{
32
struct
BasisFunction
{
33
PartialKeys
tag
;
34
Vector
values
;
35
};
36
60
struct
FactoredVector
{
69
double
getValue
(
const
Factors
& space,
const
Factors
& value)
const
;
70
83
double
getValue
(
const
Factors
& space,
const
Factors
& value,
const
Vector
& weights)
const
;
84
100
FactoredVector
&
operator*=
(
const
Vector
& w);
101
109
FactoredVector
&
operator*=
(
const
double
v);
110
111
std::vector<BasisFunction>
bases
;
112
};
113
128
struct
BasisMatrix
{
129
PartialKeys
tag
;
130
PartialKeys
actionTag
;
131
Matrix2D
values
;
132
};
133
140
struct
FactoredMatrix2D
{
151
double
getValue
(
const
Factors
& space,
const
Factors
& actions,
const
Factors
& value,
const
Factors
& action)
const
;
152
167
double
getValue
(
const
Factors
& space,
const
Factors
& actions,
const
Factors
& value,
const
Factors
& action,
const
Vector
& weights)
const
;
168
184
FactoredMatrix2D
&
operator*=
(
const
Vector
& w);
185
193
FactoredMatrix2D
&
operator*=
(
const
double
v);
194
195
std::vector<BasisMatrix>
bases
;
196
};
197
198
// @}
199
200
// This stuff is in FactoredVectorOps.cpp
201
// BasisFunction - BasisFunction
202
203
BasisFunction
dot
(
const
Factors
& space,
const
BasisFunction
& lhs,
const
BasisFunction
& rhs);
204
BasisFunction
plus
(
const
Factors
& space,
const
BasisFunction
& lhs,
const
BasisFunction
& rhs);
205
BasisFunction
minus
(
const
Factors
& space,
const
BasisFunction
& lhs,
const
BasisFunction
& rhs);
206
207
BasisFunction
plusSubset
(
const
Factors
& space,
BasisFunction
retval,
const
BasisFunction
& rhs);
208
BasisFunction
minusSubset
(
const
Factors
& space,
BasisFunction
retval,
const
BasisFunction
& rhs);
209
210
BasisFunction
&
plusEqualSubset
(
const
Factors
& space,
BasisFunction
& retval,
const
BasisFunction
& rhs);
211
BasisFunction
&
minusEqualSubset
(
const
Factors
& space,
BasisFunction
& retval,
const
BasisFunction
& rhs);
212
213
// FactoredVector - BasisFunction
214
215
FactoredVector
plus
(
const
Factors
& space,
FactoredVector
retval,
const
BasisFunction
& rhs);
216
FactoredVector
&
plusEqual
(
const
Factors
& space,
FactoredVector
& retval,
const
BasisFunction
& basis);
217
FactoredVector
&
plusEqual
(
const
Factors
& space,
FactoredVector
& retval,
BasisFunction
&& basis);
218
219
FactoredVector
minus
(
const
Factors
& space,
FactoredVector
retval,
const
BasisFunction
& rhs,
bool
clearZero =
false
);
220
FactoredVector
&
minusEqual
(
const
Factors
& space,
FactoredVector
& retval,
const
BasisFunction
& basis,
bool
clearZero =
false
);
221
222
// FactoredVector - FactoredVector
223
224
FactoredVector
plus
(
const
Factors
& space,
FactoredVector
retval,
const
FactoredVector
& rhs);
225
FactoredVector
&
plusEqual
(
const
Factors
& space,
FactoredVector
& retval,
const
FactoredVector
& rhs);
226
FactoredVector
&
plusEqual
(
const
Factors
& space,
FactoredVector
& retval,
FactoredVector
&& rhs);
227
228
FactoredVector
minus
(
const
Factors
& space,
FactoredVector
retval,
const
FactoredVector
& rhs,
bool
clearZero =
false
);
229
FactoredVector
&
minusEqual
(
const
Factors
& space,
FactoredVector
& retval,
const
FactoredVector
& rhs,
bool
clearZero =
false
);
230
231
// This stuff is in FactoredMatrix2DOps.cpp
232
// BasisMatrix - BasisMatrix
233
234
BasisMatrix
plus
(
const
Factors
& space,
const
Factors
& actions,
const
BasisMatrix
& lhs,
const
BasisMatrix
& rhs);
235
BasisMatrix
plusSubset
(
const
Factors
& space,
const
Factors
& actions,
BasisMatrix
retval,
const
BasisMatrix
& rhs);
236
BasisMatrix
&
plusEqualSubset
(
const
Factors
& space,
const
Factors
& actions,
BasisMatrix
& retval,
const
BasisMatrix
& rhs);
237
238
// FactoredMatrix2D - BasisMatrix
239
240
FactoredMatrix2D
&
plusEqual
(
const
Factors
& space,
const
Factors
& actions,
FactoredMatrix2D
& retval,
const
BasisMatrix
& basis);
241
FactoredMatrix2D
&
plusEqual
(
const
Factors
& space,
const
Factors
& actions,
FactoredMatrix2D
& retval,
BasisMatrix
&& basis);
242
243
// FactoredMatrix2D - FactoredMatrix2D
244
245
FactoredMatrix2D
&
plusEqual
(
const
Factors
& space,
const
Factors
& actions,
FactoredMatrix2D
& retval,
const
FactoredMatrix2D
& rhs);
246
FactoredMatrix2D
&
plusEqual
(
const
Factors
& space,
const
Factors
& actions,
FactoredMatrix2D
& retval,
FactoredMatrix2D
&& rhs);
247
248
// These are in FactoredMatrix.cpp
249
// Scalar ops
250
251
FactoredVector
operator*
(
FactoredVector
lhs,
const
Vector
& w);
252
FactoredVector
operator*
(
const
Vector
& w,
FactoredVector
rhs);
253
FactoredVector
operator*
(
FactoredVector
lhs,
const
double
v);
254
FactoredVector
operator*
(
const
double
v,
FactoredVector
rhs);
255
256
FactoredMatrix2D
operator*
(
FactoredMatrix2D
lhs,
const
Vector
& w);
257
FactoredMatrix2D
operator*
(
const
Vector
& w,
FactoredMatrix2D
rhs);
258
FactoredMatrix2D
operator*
(
FactoredMatrix2D
lhs,
const
double
v);
259
FactoredMatrix2D
operator*
(
const
double
v,
FactoredMatrix2D
rhs);
260
}
261
262
#endif
AIToolbox::Factored::BasisMatrix::tag
PartialKeys tag
Definition:
FactoredMatrix.hpp:129
AIToolbox::Factored::minus
BasisFunction minus(const Factors &space, const BasisFunction &lhs, const BasisFunction &rhs)
AIToolbox::Factored::PartialKeys
std::vector< size_t > PartialKeys
Definition:
Types.hpp:63
AIToolbox::Factored::FactoredVector
This class represents a factored vector.
Definition:
FactoredMatrix.hpp:60
AIToolbox::Factored::FactoredMatrix2D::operator*=
FactoredMatrix2D & operator*=(const Vector &w)
This function multiplies each basis function with a weight.
AIToolbox::Factored::plusEqual
FactoredVector & plusEqual(const Factors &space, FactoredVector &retval, const BasisFunction &basis)
AIToolbox::Factored::BasisFunction::values
Vector values
Definition:
FactoredMatrix.hpp:34
AIToolbox::Factored::minusSubset
BasisFunction minusSubset(const Factors &space, BasisFunction retval, const BasisFunction &rhs)
AIToolbox::Factored::BasisMatrix
This struct represents a basis matrix.
Definition:
FactoredMatrix.hpp:128
AIToolbox::Factored::operator*
FactoredVector operator*(FactoredVector lhs, const Vector &w)
AIToolbox::Matrix2D
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Eigen::AutoAlign > Matrix2D
Definition:
Types.hpp:18
AIToolbox::Factored::BasisMatrix::actionTag
PartialKeys actionTag
Definition:
FactoredMatrix.hpp:130
AIToolbox::Factored::BasisMatrix::values
Matrix2D values
Definition:
FactoredMatrix.hpp:131
AIToolbox::Factored::FactoredMatrix2D
This class represents a factored 2D matrix.
Definition:
FactoredMatrix.hpp:140
AIToolbox::Factored::BasisFunction::tag
PartialKeys tag
Definition:
FactoredMatrix.hpp:33
AIToolbox::Factored::dot
BasisFunction dot(const Factors &space, const BasisFunction &lhs, const BasisFunction &rhs)
AIToolbox::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Definition:
Types.hpp:16
AIToolbox::Factored::plusSubset
BasisFunction plusSubset(const Factors &space, BasisFunction retval, const BasisFunction &rhs)
AIToolbox::Factored::Factors
std::vector< size_t > Factors
Definition:
Types.hpp:62
AIToolbox::Factored::FactoredMatrix2D::getValue
double getValue(const Factors &space, const Factors &actions, const Factors &value, const Factors &action) const
This function returns the value of the FactoredMatrix2D at the specified point.
AIToolbox::Factored::FactoredVector::operator*=
FactoredVector & operator*=(const Vector &w)
This function multiplies each basis function with a weight.
AIToolbox::Factored::plusEqualSubset
BasisFunction & plusEqualSubset(const Factors &space, BasisFunction &retval, const BasisFunction &rhs)
AIToolbox::Factored
Definition:
GraphUtils.hpp:12
Types.hpp
AIToolbox::Factored::BasisFunction
This struct represents a basis function.
Definition:
FactoredMatrix.hpp:32
AIToolbox::Factored::minusEqualSubset
BasisFunction & minusEqualSubset(const Factors &space, BasisFunction &retval, const BasisFunction &rhs)
AIToolbox::Factored::FactoredVector::bases
std::vector< BasisFunction > bases
Definition:
FactoredMatrix.hpp:111
AIToolbox::Factored::plus
BasisFunction plus(const Factors &space, const BasisFunction &lhs, const BasisFunction &rhs)
AIToolbox::Factored::minusEqual
FactoredVector & minusEqual(const Factors &space, FactoredVector &retval, const BasisFunction &basis, bool clearZero=false)
AIToolbox::Factored::FactoredVector::getValue
double getValue(const Factors &space, const Factors &value) const
This function returns the value of the FactoredVector at the specified point.
AIToolbox::Factored::FactoredMatrix2D::bases
std::vector< BasisMatrix > bases
Definition:
FactoredMatrix.hpp:195