MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RollingMatrix.h
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2016 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #ifndef _ROLLING_MATRIX_H
11 #define _ROLLING_MATRIX_H
12 
13 // Temporary, just to get going.
14 typedef vector< double > SparseVector;
15 
17  public:
18  // Specify empty matrix.
19  RollingMatrix();
21  RollingMatrix& operator=( const RollingMatrix& other );
22 
23  // Specify size of matrix. Allocations may happen later.
24  void resize( unsigned int numRows, unsigned int numColumns );
25 
26  // Return specified entry.
27  double get( unsigned int row, unsigned int column ) const;
28 
29  // Sum contents of input into entry at specfied row, column.
30  // Row index is relative to current zero.
31  void sumIntoEntry( double input, unsigned int row, unsigned int column );
32 
33  // Sum contents of input into vector at specfied row.
34  // Row index is relative to current zero.
35  void sumIntoRow( const vector< double >& input, unsigned int row );
36 
37  // Return dot product of input with internal vector at specified
38  // row, starting at specified column.
39  double dotProduct( const vector< double >& input, unsigned int row,
40  unsigned int startColumn ) const;
41 
42  // Return correlation found by summing dotProduct across all columns
43  void correl( vector< double >& ret, const vector< double >& input,
44  unsigned int row ) const;
45 
46  // Zero out contents of row.
47  void zeroOutRow( unsigned int row );
48 
49  // Roll the matrix by one row. What was row 0 becomes row 1, etc.
50  // Last row vanishes.
51  void rollToNextRow(); //
52 
53  private:
54  unsigned int nrows_;
55  unsigned int ncolumns_;
56  unsigned int currentStartRow_;
57 
58  vector< SparseVector > rows_;
59 };
60 
61 #endif // _ROLLING_MATRIX
vector< SparseVector > rows_
Definition: RollingMatrix.h:58
unsigned int nrows_
Definition: RollingMatrix.h:54
void resize(unsigned int numRows, unsigned int numColumns)
double dotProduct(const vector< double > &input, unsigned int row, unsigned int startColumn) const
void sumIntoRow(const vector< double > &input, unsigned int row)
unsigned int currentStartRow_
Definition: RollingMatrix.h:56
unsigned int ncolumns_
Definition: RollingMatrix.h:55
void zeroOutRow(unsigned int row)
void sumIntoEntry(double input, unsigned int row, unsigned int column)
void correl(vector< double > &ret, const vector< double > &input, unsigned int row) const
RollingMatrix & operator=(const RollingMatrix &other)
vector< double > SparseVector
Definition: RollingMatrix.h:14