21 #include "randomgenerator.h"
26 :
Linker(from, to, name), nrows(from->numNeurons()), ncols(to->numNeurons()), w(nrows, ncols, true) {
31 :
Linker( params, prefix ), nrows(from()->numNeurons()), ncols(to()->numNeurons()), w(nrows, ncols, true) {
33 QString str = params.
getValue(prefix +
"weights");
35 QStringList list = str.split(QRegExp(
"\\s+"), QString::SkipEmptyParts);
36 int cycleLength = nrows*ncols;
37 if (list.size() != cycleLength) {
39 qWarning() <<
"The number of elements of the weights in configuration file (" << list.size()
40 <<
") is different from the total number of weights (" << cycleLength <<
").";
42 cycleLength = std::min(list.size(), cycleLength);
44 for(
int i=0; i<cycleLength; i++) {
46 unsigned int r = i/ncols;
47 unsigned int c = i%ncols;
48 w[r][c] = list[i].toDouble(&ok);
64 for (
unsigned int i = 0; i<nrows; i++ ) {
65 for (
unsigned int j = 0; j<ncols; j++ ) {
66 w[i][j] =
globalRNG->getDouble( min, max );
87 if ( nrows != ncols ) {
88 qWarning() <<
"connectRandom with symmetric to TRUE is allowed only with square matrix" ;
92 for(
unsigned int r=0; r<
rows(); r++ ) {
93 for(
unsigned int c=r; c<
cols(); c++ ) {
97 if ( r==c && zeroDiagonal ) {
112 for(
unsigned int r=0; r<
rows(); r++ ) {
113 for(
unsigned int c=0; c<
cols(); c++ ) {
116 if ( r==c && zeroDiagonal ) {
131 for(
unsigned int r=0; r<
rows(); r++ ) {
132 for(
unsigned int c=0; c<
cols(); c++ ) {
145 for(
unsigned int r=0; r<
rows(); r++ ) {
146 for(
unsigned int c=0; c<
cols(); c++ ) {
159 for(
unsigned int r=0; r<
rows(); r++ ) {
160 for(
unsigned int c=0; c<
cols(); c++ ) {
161 list.push_back(QString::number(w[r][c]));