Armadillo sparse matrix get the index of an element

#include <iostream>
#include <armadillo>

using namespace std;
using namespace arma;
typedef sp_fmat::row_iterator it1_t;

int main(int argc, char** argv)
{
	int dim = 10;
	sp_fmat a(dim,dim);
	sp_fmat b(dim,dim);
	for(size_t i = 0; i < dim; i++)
	  a(i,i) = i*8;
	a(2,3) = 3;
	b = b -a;
	cout<<b<<endl;
	cout<<a<<endl;
	for(it1_t it1 = a.begin_row(1); it1 != a.end_row(2);it1++)
	  cout<<*it1<<" "<<it1.row()<<" "<<it1.col()<<endl;
	cout<<b.n_rows<<" "<<b.n_cols<<endl; 
	return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章