weights.cc
Go to the documentation of this file.
/* weights.cc
*/
#include "osl/eval/weights.h"
#include "osl/random.h"
osl::eval::ml::
Weights::Weights(size_t idim)
: values(idim), dim(idim)
{
std::fill(&values[0], &values[0]+dim, 0);
}
osl::eval::ml::
Weights::~Weights()
{
}
void osl::eval::ml::Weights::
setRandom()
{
for (size_t i=0; i<dim; ++i)
values[i] = osl::random() % 256 - 128;
}
void osl::eval::ml::
Weights::resetDimension(size_t new_dim)
{
dim = new_dim;
values.resize(new_dim);
std::fill(&values[0], &values[0]+dim, 0);
}
␌
osl::eval::ml::
MultiWeights::MultiWeights(size_t idim)
: values(idim), one_dim(idim)
{
}
osl::eval::ml::
MultiWeights::~MultiWeights()
{
}
void osl::eval::ml::
MultiWeights::resetDimension(size_t new_dim)
{
one_dim = new_dim;
values.resize(new_dim);
std::fill(&values[0], &values[0]+one_dim, MultiInt());
}
void osl::eval::ml::MultiWeights::
setRandom()
{
for (size_t i=0; i<one_dim; ++i)
for (size_t s=0; s<MultiInt::size(); ++s)
values[i][s] = osl::random() % 256 - 128;
}
/* ------------------------------------------------------------------------- */
// ;;; 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::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::values
std::vector< MultiInt > values
Definition weights.h:42
osl::eval::ml::MultiWeights::resetDimension
void resetDimension(size_t one_dim)
Definition weights.cc:46
osl::random
unsigned int random()
Definition random.cc:4
osl::MultiInt
QuadInt MultiInt
Definition midgame.h:13
random.h
osl::container::QuadInt::size
static size_t size()
Definition quadInt.h:123
osl::eval::ml::Weights::setRandom
void setRandom()
Definition weights.cc:18
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
weights.h