weights.cc Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
weights.cc
Go to the documentation of this file.
1 /* weights.cc
2 */
3 #include "osl/eval/ml/weights.h"
4 #include "osl/misc/random.h"
5
6 osl::eval::ml::
7 Weights::Weights(size_t idim)
8 : values(idim), dim(idim)
9 {
10 std::fill(&values[0], &values[0]+dim, 0);
11 }
12 osl::eval::ml::
13 Weights::~Weights()
14 {
15 }
16
17 void osl::eval::ml::Weights::
18 setRandom()
19 {
20 for (size_t i=0; i<dim; ++i)
21 values[i] = osl::random() % 256 - 128;
22 }
23
24
25 void osl::eval::ml::
26 Weights::resetDimension(size_t new_dim)
27 {
28 dim = new_dim;
29 values.resize(new_dim);
30 std::fill(&values[0], &values[0]+dim, 0);
31 }
32
33
34
35 osl::eval::ml::
36 MultiWeights::MultiWeights(size_t idim)
37 : values(idim), one_dim(idim)
38 {
39 }
40 osl::eval::ml::
41 MultiWeights::~MultiWeights()
42 {
43 }
44
45 void osl::eval::ml::
46 MultiWeights::resetDimension(size_t new_dim)
47 {
48 one_dim = new_dim;
49 values.resize(new_dim);
50 std::fill(&values[0], &values[0]+one_dim, MultiInt());
51 }
52
53 void osl::eval::ml::MultiWeights::
54 setRandom()
55 {
56 for (size_t i=0; i<one_dim; ++i)
57 for (size_t s=0; s<MultiInt::size(); ++s)
58 values[i][s] = osl::random() % 256 - 128;
59 }
60
61 /* ------------------------------------------------------------------------- */
62 // ;;; Local Variables:
63 // ;;; mode:c++
64 // ;;; c-basic-offset:2
65 // ;;; End: