weights.h
Go to the documentation of this file.
00001 /* weights.h
00002  */
00003 #ifndef OSL_EVAL_WEIGHTS_H
00004 #define OSL_EVAL_WEIGHTS_H
00005 
00006 #include "osl/eval/ml/midgame.h"
00007 #include "osl/stl/vector.h"
00008 #include <valarray>
00009 #include <cassert>
00010 
00011 namespace osl
00012 {
00013   namespace eval
00014   {
00015     namespace ml
00016     {
00017       struct Weights
00018       {
00019       protected:
00020         std::valarray<signed short> values;
00021         size_t dim;
00022       public:
00023         explicit Weights(size_t dim=0);
00024         virtual ~Weights();
00025 
00026         void resetDimension(size_t new_dim);
00027         int value(size_t index) const { assert(index < dim); return values[index]; }
00028         void setRandom();
00029         size_t dimension() const { return dim; }
00030 
00031         void setValue(size_t index, int value) 
00032         {
00033           assert(index < dim);
00034           values[index] = value;
00035           assert(values[index] == value);
00036         }
00037       };
00038 
00039       class MultiWeights
00040       {
00041       protected:
00042         std::vector<MultiInt> values;
00043         size_t one_dim;
00044       public:
00045         explicit MultiWeights(size_t one_dim=0);
00046         virtual ~MultiWeights();
00047 
00048         void resetDimension(size_t one_dim);
00049         const MultiInt& value(size_t index) const { assert(index < one_dim); return values[index]; }
00050         void setRandom();
00051         size_t oneDimension() const { return one_dim; }
00052         void setValue(size_t index, MultiInt value) 
00053         {
00054           assert(index < one_dim);
00055           values[index] = value;
00056         }
00057       };
00058     }
00059   }
00060 }
00061 
00062 #endif /* OSL_EVAL_WEIGHTS_H */
00063 // ;;; Local Variables:
00064 // ;;; mode:c++
00065 // ;;; c-basic-offset:2
00066 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines