~ubuntu-branches/ubuntu/precise/brian/precise

« back to all changes in this revision

Viewing changes to dev/ideas/cppgen/stateupdater.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Yaroslav Halchenko
  • Date: 2010-11-02 18:19:15 UTC
  • Revision ID: james.westby@ubuntu.com-20101102181915-ivwy29820copccu2
Tags: upstream-1.2.2~svn2229
ImportĀ upstreamĀ versionĀ 1.2.2~svn2229

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "brianlib.h"
 
2
#include<sstream>
 
3
 
 
4
void LinearStateUpdater::__call__(NeuronGroup *group)
 
5
{
 
6
//    n = len(P)
 
7
//    m = len(self)
 
8
//    S = P._S
 
9
//    A = self.A
 
10
//    c = self._C
 
11
        int m = this->M_n;
 
12
        int n = group->num_neurons;
 
13
        double *A = this->M;
 
14
        double *c = this->b;
 
15
    double x[m];
 
16
    //for(int i=0;i<m;i++) cout << c[i] << endl;
 
17
    for(int i=0;i<n;i++)  
 
18
    {
 
19
        for(int j=0;j<m;j++)
 
20
        {
 
21
            x[j] = c[j];
 
22
            for(int k=0;k<m;k++)
 
23
                //x[j] += A(j,k) * S(k,i);
 
24
                //x[j] += A[j+k*m] * S[k+i*m];
 
25
                //x[j] += A[k+j*m] * S[i+k*n];
 
26
                x[j] += A[k+j*m] * neuron_value(group, i, k);
 
27
        }
 
28
        for(int j=0;j<m;j++)
 
29
            //S[j+i*m] = x[j];
 
30
                //S[i+j*n] = x[j];
 
31
                neuron_value(group, i, j) = x[j];
 
32
    }   
 
33
}
 
34
 
 
35
string LinearStateUpdater::__repr__()
 
36
{
 
37
        int m = this->M_n;
 
38
        double *A = this->M;
 
39
        double *c = this->b;
 
40
        stringstream out;
 
41
        out << "LinearStateUpdater" << endl;
 
42
        out << "A = " << endl;
 
43
        for(int i=0;i<m;i++)
 
44
        {
 
45
                for(int j=0;j<m;j++)
 
46
                        out << A[j+i*m] << " ";
 
47
                out << endl;
 
48
        }
 
49
        out << "c = ";
 
50
        for(int i=0;i<m;i++)
 
51
                out << c[i] << " ";
 
52
        return out.str();       
 
53
}