26 #ifndef SIMPLEMATRIX_H_ 27 #define SIMPLEMATRIX_H_ 32 #include <boost/serialization/utility.hpp> 33 #include <boost/serialization/split_member.hpp> 47 template<
class Archive>
48 void save(Archive & ar,
const unsigned int version)
const 54 for (
NeuronID i = 0 ; i < m_rows ; ++i) {
62 template<
class Archive>
63 void load(Archive & ar,
const unsigned int version)
84 BOOST_SERIALIZATION_SPLIT_MEMBER()
108 SimpleMatrix(SimpleMatrix * mat);
111 virtual ~SimpleMatrix();
135 void copy(SimpleMatrix * mat);
207 template <typename T>
213 template <
typename T>
219 template <
typename T>
226 template <
typename T>
232 template <
typename T>
239 template <
typename T>
247 template <
typename T>
257 template <
typename T>
269 template <
typename T>
273 if ( oldsize == newsize )
return;
274 const AurynLong copysize = std::min(oldsize,newsize);
284 ptrdiff_t offset = new_colinds-
colinds;
285 for (
NeuronID i = 0 ; i < m_rows+1 ; ++i ) {
295 colinds = new_colinds;
298 T * new_coldata =
new T [newsize];
307 template <
typename T>
316 template <
typename T>
323 template <
typename T>
329 template <
typename T>
338 template <
typename T>
344 template <
typename T>
347 init(rows,cols,datasize);
350 template <
typename T>
358 template <
typename T>
373 template <
typename T>
379 template <
typename T>
383 while ( i > current_row )
390 if (i >= current_row && j >= current_col) {
395 rowptrs[m_rows] = rowptrs[i+1];
402 template <
typename T>
409 template <
typename T>
415 template <
typename T>
418 for (
NeuronID i = current_row ; i < m_rows-1 ; ++i )
425 template <
typename T>
431 template <
typename T>
437 template <
typename T>
446 template <
typename T>
450 if ( !(i < m_rows && j < n_cols) )
return NULL;
453 std::cout <<
"enter search" << std::endl;
464 if ( *c < j ) lo = c+1;
467 std::cout << i <<
":" << j <<
" " << *lo <<
":" << *hi << std::endl;
478 template <
typename T>
484 template <
typename T>
490 template <
typename T>
496 template <
typename T>
502 template <
typename T>
514 template <
typename T>
520 for (
NeuronID * c = rowbegin ; c <= rowend ; ++c)
526 template <
typename T>
529 for (
AurynLong i = 0 ; i < n_nonzero ; ++i )
533 template <
typename T>
539 for (
NeuronID * c = rowbegin ; c <= rowend ; ++c)
545 template <
typename T>
548 for (
AurynLong i = 0 ; i < n_nonzero ; ++i )
552 template <
typename T>
555 for (
AurynLong i = 0 ; i < n_nonzero ; ++i ) {
560 template <
typename T>
564 for (
AurynLong i = 0 ; i < n_nonzero ; ++i ) {
571 template <
typename T>
574 for (
AurynLong i = 0 ; i < n_nonzero ; ++i ) {
579 template <
typename T>
585 template <
typename T>
591 template <
typename T>
597 template <
typename T>
603 template <
typename T>
610 template <
typename T>
616 template <
typename T>
622 template <
typename T>
629 template <
typename T>
632 return 1.*n_nonzero/datasize;
635 template <
typename T>
641 template <
typename T>
647 template <
typename T>
650 for (
NeuronID i = 0 ; i < m_rows ; ++i) {
657 template <
typename T>
667 template <
typename T>
673 template <
typename T>
679 template <
typename T>
685 template <
typename T>
691 template <
typename T>
void add_value(AurynLong data_index, T value)
Definition: SimpleMatrix.h:491
T * coldata
Definition: SimpleMatrix.h:100
SimpleMatrix()
Definition: SimpleMatrix.h:324
void prune()
Definition: SimpleMatrix.h:317
friend class boost::serialization::access
Definition: SimpleMatrix.h:46
AurynLong get_row_begin_index(NeuronID i)
Definition: SimpleMatrix.h:592
void set_all(T value)
Definition: SimpleMatrix.h:546
Template for a sparse matrix with row major ordering and fast access of rows.
Definition: SimpleMatrix.h:43
virtual ~SimpleMatrix()
Definition: SimpleMatrix.h:374
double AurynDouble
Higher precision floating point datatype.
Definition: auryn_definitions.h:158
void copy(SimpleMatrix *mat)
Definition: SimpleMatrix.h:359
void clear()
Definition: SimpleMatrix.h:248
int n
Definition: mkpat.py:5
void free()
Definition: SimpleMatrix.h:351
NeuronID * get_row_end(NeuronID i)
Definition: SimpleMatrix.h:598
NeuronID ** rowptrs
Definition: SimpleMatrix.h:96
AurynDouble get_fill_level()
Definition: SimpleMatrix.h:630
void push_back(const NeuronID i, const NeuronID j, const T value)
Definition: SimpleMatrix.h:380
AurynLong get_row_end_index(NeuronID i)
Definition: SimpleMatrix.h:604
Definition: ABSConnection.h:38
void set_data(AurynLong i, T value)
Definition: SimpleMatrix.h:233
unsigned long AurynLong
An unsigned long type used to count synapses or similar.
Definition: auryn_definitions.h:154
T get_data(const AurynLong i)
Definition: SimpleMatrix.h:214
T get_value(AurynLong data_index)
Definition: SimpleMatrix.h:485
void scale_col(NeuronID j, T value)
Definition: SimpleMatrix.h:553
NeuronID get_m_rows()
Definition: SimpleMatrix.h:636
NeuronID ** get_rowptrs()
Definition: SimpleMatrix.h:611
bool exists(NeuronID i, NeuronID j)
Definition: SimpleMatrix.h:438
bool set(NeuronID i, NeuronID j, T value)
Definition: SimpleMatrix.h:503
double mean()
Definition: SimpleMatrix.h:658
Definition: auryn_definitions.h:240
T * get_data_ptr(const AurynLong i)
Definition: SimpleMatrix.h:208
NeuronID get_n_cols()
Definition: SimpleMatrix.h:642
void set_row(NeuronID i, T value)
Definition: SimpleMatrix.h:534
T get(NeuronID i, NeuronID j)
Definition: SimpleMatrix.h:432
void resize_buffer_and_clear(AurynLong size)
Definition: SimpleMatrix.h:308
NeuronID * colinds
Definition: SimpleMatrix.h:98
void fill_zeros()
Same as fill_na.
Definition: SimpleMatrix.h:426
double sum_col(NeuronID j)
Definition: SimpleMatrix.h:561
NeuronID get_data_offset(NeuronID *r)
Definition: SimpleMatrix.h:692
void scale_all(T value)
Definition: SimpleMatrix.h:527
void set_col(NeuronID j, T value)
Definition: SimpleMatrix.h:572
AurynLong get_nonzero()
Definition: SimpleMatrix.h:410
void init(NeuronID m, NeuronID n, AurynLong size=256)
Definition: SimpleMatrix.h:258
Definition: auryn_definitions.h:224
T * get_data_begin()
Definition: SimpleMatrix.h:617
AurynLong get_datasize()
Definition: SimpleMatrix.h:403
void scale_data(AurynLong i, T value)
Definition: SimpleMatrix.h:240
void fill_na()
Marks the remainder of buffers non-existing connections.
Definition: SimpleMatrix.h:416
T * get_data_end()
Returns value behind last element in data array corresponding to a nonzero value. ...
Definition: SimpleMatrix.h:623
Definition: auryn_definitions.h:248
NeuronID get_colind(AurynLong data_index)
Definition: SimpleMatrix.h:497
NeuronID * get_ind_begin()
Definition: SimpleMatrix.h:580
void scale_row(NeuronID i, T value)
Definition: SimpleMatrix.h:515
T * get_ptr(NeuronID i, NeuronID j)
Definition: SimpleMatrix.h:447
void resize_buffer(AurynLong newsize)
Definition: SimpleMatrix.h:270
NeuronID * get_row_begin(NeuronID i)
Definition: SimpleMatrix.h:586
T * get_value_ptr(NeuronID i)
Definition: SimpleMatrix.h:680
void print()
Definition: SimpleMatrix.h:648
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151