weights.h
Go to the documentation of this file.
/* weights.h
*/
#ifndef OSL_EVAL_WEIGHTS_H
#define OSL_EVAL_WEIGHTS_H
#include "osl/eval/midgame.h"
#include <vector>
#include <valarray>
#include <cassert>
namespace osl
{
namespace eval
{
namespace ml
{
struct Weights
{
protected:
std::valarray<signed short> values;
size_t dim;
public:
explicit Weights(size_t dim=0);
virtual ~Weights();
void resetDimension(size_t new_dim);
int value(size_t index) const { assert(index < dim); return values[index]; }
void setRandom();
size_t dimension() const { return dim; }
void setValue(size_t index, int value)
{
assert(index < dim);
values[index] = value;
assert(values[index] == value);
}
};
class MultiWeights
{
protected:
std::vector<MultiInt> values;
size_t one_dim;
public:
explicit MultiWeights(size_t one_dim=0);
virtual ~MultiWeights();
void resetDimension(size_t one_dim);
const MultiInt& value(size_t index) const { assert(index < one_dim); return values[index]; }
void setRandom();
size_t oneDimension() const { return one_dim; }
void setValue(size_t index, MultiInt value)
{
assert(index < one_dim);
values[index] = value;
}
};
}
}
}
#endif /* OSL_EVAL_WEIGHTS_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::eval::ml::MultiWeights::~MultiWeights
virtual ~MultiWeights()
Definition weights.cc:41
osl::eval::ml::MultiWeights::MultiWeights
MultiWeights(size_t one_dim=0)
Definition weights.cc:36
osl::eval::ml::MultiWeights::setValue
void setValue(size_t index, MultiInt value)
Definition weights.h:52
osl::eval::ml::MultiWeights::setRandom
void setRandom()
Definition weights.cc:54
osl::eval::ml::MultiWeights::one_dim
size_t one_dim
Definition weights.h:43
osl::eval::ml::MultiWeights::oneDimension
size_t oneDimension() const
Definition weights.h:51
osl::eval::ml::MultiWeights::values
std::vector< MultiInt > values
Definition weights.h:42
osl::eval::ml::MultiWeights::value
const MultiInt & value(size_t index) const
Definition weights.h:49
osl::eval::ml::MultiWeights::resetDimension
void resetDimension(size_t one_dim)
Definition weights.cc:46
midgame.h
osl::eval::ml
Definition eval_pieceStand.cc:470
osl::eval
Definition eval_pieceStand.cc:468
osl
Definition additionalEffect.h:6
osl::MultiInt
QuadInt MultiInt
Definition midgame.h:13
osl::eval::ml::Weights::setRandom
void setRandom()
Definition weights.cc:18
osl::eval::ml::Weights::dimension
size_t dimension() const
Definition weights.h:29
osl::eval::ml::Weights::setValue
void setValue(size_t index, int value)
Definition weights.h:31
osl::eval::ml::Weights::value
int value(size_t index) const
Definition weights.h:27
osl::eval::ml::Weights::~Weights
virtual ~Weights()
Definition weights.cc:13
osl::eval::ml::Weights::resetDimension
void resetDimension(size_t new_dim)
Definition weights.cc:26
osl::eval::ml::Weights::Weights
Weights(size_t dim=0)
Definition weights.cc:7
osl::eval::ml::Weights::dim
size_t dim
Definition weights.h:21
osl::eval::ml::Weights::values
std::valarray< signed short > values
Definition weights.h:20