include/sparsematrixlinker.h

Go to the documentation of this file.
00001 /********************************************************************************
00002  *  Neural Network Framework.                                                   *
00003  *  Copyright (C) 2005-2008 Gianluca Massera <emmegian@yahoo.it>                     *
00004  *                                                                              *
00005  *  This program is free software; you can redistribute it and/or modify        *
00006  *  it under the terms of the GNU General Public License as published by        *
00007  *  the Free Software Foundation; either version 2 of the License, or           *
00008  *  (at your option) any later version.                                         *
00009  *                                                                              *
00010  *  This program is distributed in the hope that it will be useful,             *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00013  *  GNU General Public License for more details.                                *
00014  *                                                                              *
00015  *  You should have received a copy of the GNU General Public License           *
00016  *  along with this program; if not, write to the Free Software                 *
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00018  ********************************************************************************/
00019 
00020 #ifndef SPARSEMATRIXLINKER_H
00021 #define SPARSEMATRIXLINKER_H
00022 
00026 #include "types.h"
00027 #include "linker.h"
00028 #include "matrixlinker.h"
00029 
00030 namespace nnfw {
00031 
00037 class NNFW_API SparseMatrixLinker : public MatrixLinker {
00038 public:
00041 
00044     SparseMatrixLinker( Cluster* from, Cluster* to, const char* name = "unnamed" );
00045 
00048     SparseMatrixLinker( Real prob, Cluster* from, Cluster* to, const char* name = "unnamed" );
00049 
00055     SparseMatrixLinker( Cluster* from, Cluster* to, Real prob, bool zeroDiagonal = false, bool symmetricMask = false, const char* name = "unnamed" );
00056 
00059     SparseMatrixLinker( PropertySettings& prop );
00060 
00063     virtual ~SparseMatrixLinker();
00064 
00066 
00068 
00071     virtual void setWeight( u_int from, u_int to, Real weight );
00072 
00075     virtual void randomize( Real min, Real max );
00076 
00079     void update();
00080 
00083     void connect( u_int from, u_int to );
00084 
00087     void connectRandom( Real prob );
00088 
00091     void connectAll();
00092 
00095     void disconnect( u_int from, u_int to );
00096 
00099     void disconnectRandom( Real prob );
00100 
00103     void disconnectAll();
00104 
00108     MatrixData<bool>& getMask() {
00109         return maskm;
00110     };
00111 
00113     MatrixData<bool>& mask() {
00114         return maskm;
00115     };
00116 
00118     Variant maskP() {
00119         return Variant( &maskm );
00120     };
00121 
00123     void setMask( const MatrixData<bool>& mask );
00124 
00126     bool setMask( const Variant& v );
00127 
00129     virtual SparseMatrixLinker* clone() const;
00130 
00132 
00133 private:
00135     MatrixData<bool> maskm;
00136 };
00137 
00138 }
00139 
00140 #endif
BerliOS Developer Logo Valid XHTML 1.0 Transitional Valid CSS!