g2o
Typedefs | Functions
sparse_block_matrix_test.cpp File Reference
#include "sparse_block_matrix.h"
#include <iostream>
Include dependency graph for sparse_block_matrix_test.cpp:

Go to the source code of this file.

Typedefs

typedef SparseBlockMatrix< MatrixXd > SparseBlockMatrixX
 

Functions

std::ostream & operator<< (std::ostream &os, const SparseBlockMatrixX::SparseMatrixBlock &m)
 
int main (int argc, char **argv)
 

Typedef Documentation

Definition at line 35 of file sparse_block_matrix_test.cpp.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 46 of file sparse_block_matrix_test.cpp.

References g2o::SparseBlockMatrix< MatrixType >::add(), g2o::SparseBlockMatrix< MatrixType >::block(), g2o::SparseBlockMatrix< MatrixType >::clear(), g2o::SparseBlockMatrix< MatrixType >::multiply(), g2o::SparseBlockMatrix< MatrixType >::symmPermutation(), and g2o::SparseBlockMatrix< MatrixType >::transpose().

46  {
47  int rcol[] = {3,6,8,12};
48  int ccol[] = {2,4,13};
49  cerr << "creation" << endl;
50  SparseBlockMatrixX* M=new SparseBlockMatrixX(rcol, ccol, 4,3);
51 
52  cerr << "block access" << endl;
53 
55  cerr << b->rows() << " " << b->cols() << endl;
56  for (int i=0; i<b->rows(); ++i)
57  for (int j=0; j<b->cols(); ++j){
58  (*b)(i,j)=i*b->cols()+j;
59  }
60 
61 
62  cerr << "block access 2" << endl;
63  b=M->block(0,2, true);
64  cerr << b->rows() << " " << b->cols() << endl;
65  for (int i=0; i<b->rows(); ++i)
66  for (int j=0; j<b->cols(); ++j){
67  (*b)(i,j)=i*b->cols()+j;
68  }
69 
70  b=M->block(3,2, true);
71  cerr << b->rows() << " " << b->cols() << endl;
72  for (int i=0; i<b->rows(); ++i)
73  for (int j=0; j<b->cols(); ++j){
74  (*b)(i,j)=i*b->cols()+j;
75  }
76 
77  cerr << *M << endl;
78 
79  cerr << "SUM" << endl;
80 
81  SparseBlockMatrixX* Ms=0;
82  M->add(Ms);
83  M->add(Ms);
84  cerr << *Ms;
85 
86  SparseBlockMatrixX* Mt=0;
87  M->transpose(Mt);
88  cerr << *Mt << endl;
89 
90  SparseBlockMatrixX* Mp=0;
91  M->multiply(Mp, Mt);
92  cerr << *Mp << endl;
93 
94  int iperm[]={3,2,1,0};
95  SparseBlockMatrixX* PMp=0;
96 
97  Mp->symmPermutation(PMp,iperm, false);
98  cerr << *PMp << endl;
99 
100  PMp->clear(true);
101  Mp->block(3,0)->fill(0.);
102  Mp->symmPermutation(PMp,iperm, true);
103  cerr << *PMp << endl;
104 
105 
106 
107 }
bool transpose(SparseBlockMatrix< MatrixTransposedType > *&dest) const
transposes a block matrix, The transposed type should match the argument false on failure ...
SparseMatrixBlock * block(int r, int c, bool alloc=false)
returns the block at location r,c. if alloc=true he block is created if it does not exist ...
void clear(bool dealloc=false)
this zeroes all the blocks. If dealloc=true the blocks are removed from memory
MatrixType SparseMatrixBlock
this is the type of the elementary block, it is an Eigen::Matrix.
SparseBlockMatrix< MatrixXd > SparseBlockMatrixX
bool symmPermutation(SparseBlockMatrix< MatrixType > *&dest, const int *pinv, bool onlyUpper=false) const
bool multiply(SparseBlockMatrix< MatrixResultType > *&dest, const SparseBlockMatrix< MatrixFactorType > *M) const
dest = (*this) * M
bool add(SparseBlockMatrix< MatrixType > *&dest) const
adds the current matrix to the destination
Sparse matrix which uses blocks.
std::ostream& operator<< ( std::ostream &  os,
const SparseBlockMatrixX::SparseMatrixBlock m 
)

Definition at line 37 of file sparse_block_matrix_test.cpp.

37  {
38  for (int i=0; i<m.rows(); ++i){
39  for (int j=0; j<m.cols(); ++j)
40  cerr << m(i,j) << " ";
41  cerr << endl;
42  }
43  return os;
44 }