getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-users] a matrix question on gmm++


From: Umut Tabak
Subject: [Getfem-users] a matrix question on gmm++
Date: Thu, 14 Jan 2010 14:05:25 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Dear all,

I was trying to use gmm++ library to interface some of my matrices that are exported from a commercial FE code. I have these matrices in matrix market format and thanks to the gmm++ library that you can directly interface this matrix into csr matrix with the code below:

#include <iostream>
#include <gmm/gmm.h>
#include <gmm/gmm_inoutput.h>
#include <gmm/gmm_def.h>

int main()
{
gmm::col_matrix< gmm::wsvector<double> > M1; // M1 MatrixMarket_load("mm5by5.mm", M1);
 gmm::csr_matrix<double> M2;
 gmm::copy(M1, M2);                            // M1 -> M2
 // output the vector
std::cout << M2 << std::endl; std::cout << "Number of nonzeros: " << gmm::nnz(M2) << std::endl;
 //
 for(int i=0;i<5;++i)
   std::cout << gmm::mat_row(M2,i) << std::endl;
 //
 return 0;
}

What I would like to do is to iterate over the non-zero on each row in a loop. I can see that standard output is overloaded for

std::cout << gmm::mat_row(M2,i) << std::endl;

which results in

vector(5) [ (r0,1) (r3,6) ]
vector(5) [ (r1,10.5) ]
vector(5) [ (r2,0.015) ]
vector(5) [ (r1,250.5) (r3,-280) (r4,33.32) ]
vector(5) [ (r4,12) ]

How can I reach these non zeros elements in my matrix, I am a bit confused, I read the deeper inside gmm++ section but could not find my way there?


Any pointers are appreciated.

Umut



reply via email to

[Prev in Thread] Current Thread [Next in Thread]