matrixlinker.h
1 /********************************************************************************
2  * Neural Network Framework. *
3  * Copyright (C) 2005-2011 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #ifndef MATRIXLINKER_H
21 #define MATRIXLINKER_H
22 
23 #include "nnfwconfig.h"
24 #include "linker.h"
25 
26 namespace farsa {
27 
39 class FARSA_NNFW_API MatrixLinker : public Linker {
40 public:
45  MatrixLinker( Cluster* from, Cluster* to, QString name = "unnamed" );
47  MatrixLinker( ConfigurationParameters& params, QString prefix );
49  virtual ~MatrixLinker();
51  unsigned int rows() {
52  return nrows;
53  };
55  unsigned int cols() {
56  return ncols;
57  };
59  unsigned int size() const;
61  virtual void randomize( double min, double max );
63  virtual void setWeight( unsigned int from, unsigned int to, double weight );
65  virtual double weight( unsigned int from, unsigned int to );
67  DoubleMatrix& matrix() {
68  return w;
69  };
71  const DoubleMatrix& matrix() const {
72  return w;
73  };
82  virtual void save(ConfigurationParameters& params, QString prefix);
83 private:
85  unsigned int nrows, ncols;
87  DoubleMatrix w;
88 };
89 
90 }
91 
92 #endif
This file contains the common type defitions used on the whole framework.
unsigned int rows()
Get the number of rows.
Definition: matrixlinker.h:51
const DoubleMatrix & matrix() const
const version of matrix() method
Definition: matrixlinker.h:71
FARSA_UTIL_TEMPLATE const T max(const T &t1, const U &t2)
unsigned int cols()
Get the number of cols.
Definition: matrixlinker.h:55
This file contains the declaration of the linkers implemented.
MatrixLinker Class define a full connection between two cluster.
Definition: matrixlinker.h:39
Define the common interface among Clusters.
Definition: cluster.h:73
DoubleMatrix & matrix()
Return the weight matrix.
Definition: matrixlinker.h:67
Abstract Linker Class.
Definition: linker.h:38
FARSA_UTIL_TEMPLATE const T min(const T &t1, const U &t2)