MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RollingMatrix Class Reference

#include <RollingMatrix.h>

+ Collaboration diagram for RollingMatrix:

Public Member Functions

void correl (vector< double > &ret, const vector< double > &input, unsigned int row) const
 
double dotProduct (const vector< double > &input, unsigned int row, unsigned int startColumn) const
 
double get (unsigned int row, unsigned int column) const
 
RollingMatrixoperator= (const RollingMatrix &other)
 
void resize (unsigned int numRows, unsigned int numColumns)
 
 RollingMatrix ()
 
void rollToNextRow ()
 
void sumIntoEntry (double input, unsigned int row, unsigned int column)
 
void sumIntoRow (const vector< double > &input, unsigned int row)
 
void zeroOutRow (unsigned int row)
 
 ~RollingMatrix ()
 

Private Attributes

unsigned int currentStartRow_
 
unsigned int ncolumns_
 
unsigned int nrows_
 
vector< SparseVectorrows_
 

Detailed Description

Definition at line 16 of file RollingMatrix.h.

Constructor & Destructor Documentation

RollingMatrix::RollingMatrix ( )

Definition at line 16 of file RollingMatrix.cpp.

17  : nrows_(0), ncolumns_(0), currentStartRow_(0)
18 {;}
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56
unsigned int ncolumns_
Definition: RollingMatrix.h:55
RollingMatrix::~RollingMatrix ( )

Definition at line 21 of file RollingMatrix.cpp.

22 {;}

Member Function Documentation

void RollingMatrix::correl ( vector< double > &  ret,
const vector< double > &  input,
unsigned int  row 
) const

Definition at line 99 of file RollingMatrix.cpp.

References dotProduct(), and ncolumns_.

Referenced by SeqSynHandler::vProcess().

102 {
103  if ( ret.size() < ncolumns_ )
104  ret.resize( ncolumns_, 0.0 );
105  for ( unsigned int i = 0; i < ncolumns_; ++i ) {
106  ret[i] += dotProduct( input, row, i );
107  }
108 }
double dotProduct(const vector< double > &input, unsigned int row, unsigned int startColumn) const
unsigned int ncolumns_
Definition: RollingMatrix.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double RollingMatrix::dotProduct ( const vector< double > &  input,
unsigned int  row,
unsigned int  startColumn 
) const

startColumn is the middle of the kernel.

Definition at line 68 of file RollingMatrix.cpp.

References currentStartRow_, nrows_, and rows_.

Referenced by correl().

70 {
72  unsigned int index = (row + currentStartRow_) % nrows_;
73  const SparseVector& sv = rows_[index];
74  unsigned int i2 = input.size()/2;
75  unsigned int istart = (startColumn >= i2) ? 0 : i2-startColumn;
76  unsigned int colstart = (startColumn <= i2) ? 0 : startColumn - i2;
77  unsigned int iend = (sv.size()-startColumn > i2 ) ? input.size() :
78  i2 - startColumn + sv.size();
79 
80  // if ( iend >= istart ) cout << startColumn << i2 << istart << iend << colstart << "\n";
81  double ret = 0;
82  for (unsigned int i = istart, j = 0; i < iend; ++i, ++j )
83  ret += sv[j + colstart] * input[i];
84 
85  /*
86  double ret = 0;
87  if ( input.size() + startColumn <= sv.size() ) {
88  for (unsigned int i = 0; i < input.size(); ++i )
89  ret += sv[i + startColumn] * input[i];
90  } else if ( sv.size() > startColumn ) {
91  unsigned int end = sv.size() - startColumn;
92  for (unsigned int i = 0; i < end; ++i )
93  ret += sv[i + startColumn] * input[i];
94  }
95  */
96  return ret;
97 }
vector< SparseVector > rows_
Definition: RollingMatrix.h:58
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56
vector< double > SparseVector
Definition: RollingMatrix.h:14

+ Here is the caller graph for this function:

double RollingMatrix::get ( unsigned int  row,
unsigned int  column 
) const

Definition at line 45 of file RollingMatrix.cpp.

References currentStartRow_, nrows_, and rows_.

Referenced by SeqSynHandler::getHistory().

46 {
47  unsigned int index = (row + currentStartRow_ ) % nrows_;
48  return rows_[index][column];
49 }
vector< SparseVector > rows_
Definition: RollingMatrix.h:58
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56

+ Here is the caller graph for this function:

RollingMatrix & RollingMatrix::operator= ( const RollingMatrix other)

Definition at line 24 of file RollingMatrix.cpp.

References currentStartRow_, ncolumns_, nrows_, and rows_.

25 {
26  nrows_ = other.nrows_;
27  ncolumns_ = other.ncolumns_;
29  rows_ = other.rows_;
30  return *this;
31 }
vector< SparseVector > rows_
Definition: RollingMatrix.h:58
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56
unsigned int ncolumns_
Definition: RollingMatrix.h:55
void RollingMatrix::resize ( unsigned int  numRows,
unsigned int  numColumns 
)

Definition at line 34 of file RollingMatrix.cpp.

References currentStartRow_, ncolumns_, nrows_, and rows_.

Referenced by SeqSynHandler::SeqSynHandler(), SeqSynHandler::setHistoryTime(), SeqSynHandler::setSeqDt(), and SeqSynHandler::vSetNumSynapses().

35 {
36  rows_.resize( nrows );
37  nrows_ = nrows;
38  ncolumns_ = ncolumns;
39  for ( unsigned int i = 0; i < nrows; ++i ) {
40  rows_[i].resize( ncolumns, 0.0 );
41  }
42  currentStartRow_ = 0;
43 }
vector< SparseVector > rows_
Definition: RollingMatrix.h:58
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56
unsigned int ncolumns_
Definition: RollingMatrix.h:55

+ Here is the caller graph for this function:

void RollingMatrix::rollToNextRow ( )

Definition at line 116 of file RollingMatrix.cpp.

References currentStartRow_, nrows_, and zeroOutRow().

Referenced by SeqSynHandler::vProcess().

117 {
118  if ( currentStartRow_ == 0 )
119  currentStartRow_ = nrows_ - 1;
120  else
122  zeroOutRow( 0 );
123 }
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56
void zeroOutRow(unsigned int row)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RollingMatrix::sumIntoEntry ( double  input,
unsigned int  row,
unsigned int  column 
)

Definition at line 51 of file RollingMatrix.cpp.

References currentStartRow_, nrows_, and rows_.

52 {
53  unsigned int index = (row + currentStartRow_ ) % nrows_;
54  SparseVector& sv = rows_[index];
55  sv[column] += input;
56 }
vector< SparseVector > rows_
Definition: RollingMatrix.h:58
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56
vector< double > SparseVector
Definition: RollingMatrix.h:14
void RollingMatrix::sumIntoRow ( const vector< double > &  input,
unsigned int  row 
)

Definition at line 58 of file RollingMatrix.cpp.

References currentStartRow_, nrows_, and rows_.

Referenced by SeqSynHandler::vProcess().

59 {
60  unsigned int index = (row + currentStartRow_) % nrows_;
61  SparseVector& sv = rows_[index];
62 
63  for (unsigned int i = 0; i < input.size(); ++i )
64  sv[i] += input[i];
65 }
vector< SparseVector > rows_
Definition: RollingMatrix.h:58
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56
vector< double > SparseVector
Definition: RollingMatrix.h:14

+ Here is the caller graph for this function:

void RollingMatrix::zeroOutRow ( unsigned int  row)

Definition at line 110 of file RollingMatrix.cpp.

References currentStartRow_, nrows_, and rows_.

Referenced by rollToNextRow().

111 {
112  unsigned int index = (row + currentStartRow_) % nrows_;
113  rows_[index].assign( rows_[index].size(), 0.0 );
114 }
vector< SparseVector > rows_
Definition: RollingMatrix.h:58
unsigned int nrows_
Definition: RollingMatrix.h:54
unsigned int currentStartRow_
Definition: RollingMatrix.h:56

+ Here is the caller graph for this function:

Member Data Documentation

unsigned int RollingMatrix::currentStartRow_
private
unsigned int RollingMatrix::ncolumns_
private

Definition at line 55 of file RollingMatrix.h.

Referenced by correl(), operator=(), and resize().

unsigned int RollingMatrix::nrows_
private
vector< SparseVector > RollingMatrix::rows_
private

Definition at line 58 of file RollingMatrix.h.

Referenced by dotProduct(), get(), operator=(), resize(), sumIntoEntry(), sumIntoRow(), and zeroOutRow().


The documentation for this class was generated from the following files: