This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Eigen/Sparse> | |
#include <iostream> | |
using namespace Eigen; | |
typedef SparseMatrix<double> sparseMatrix_t; | |
typedef SparseVector<double> sparseVector_t; | |
typedef MatrixXd denseMatrix_t; | |
typedef VectorXd denseVector_t; | |
int main(int argc, char *argv[]) | |
{ | |
IOFormat ioformat = IOFormat (StreamPrecision, | |
DontAlignCols, | |
",", ",", "", "", "(", ")"); | |
ioformat.rowSpacer = ""; | |
sparseMatrix_t m1 (1, 2); | |
m1.insert (0, 0) = 1.; | |
m1.insert (0, 1) = 2.; | |
sparseMatrix_t m2 (2, 1); | |
m2.insert (0, 0) = 1.; | |
m2.insert (1, 0) = 2.; | |
sparseVector_t v (2); | |
v.insert (0) = 1.; | |
v.insert (1) = 2.; | |
std::cout << denseMatrix_t (m1).format (ioformat) << std::endl; | |
std::cout << denseMatrix_t (m2).format (ioformat) << std::endl; | |
std::cout << denseVector_t (v).format (ioformat) << std::endl; | |
v += m1.transpose (); | |
std::cout << denseVector_t (v).format (ioformat) << std::endl; | |
v += m2; | |
std::cout << denseVector_t (v).format (ioformat) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment