Hi,

I'm building one simple version of Gauss Elimination, but I would like to iterate only over non zero elements.
I got an execution error pointing to the iterators. I think I can't explain what is happening without post the code, so I copy it below.
Could you tell me if there's any problem with iteration in sparse matrix/vector?
I wrote the code based on this link (http://www.bauv.unibw-muenchen.de/~winkler/ublas/tuc/ublas/matrix_sparse_usage.html).

Thank you for your time,

Frederico B. Teixeira
--
Electrical Enginnering
UFMG, Brazil

CODE:
typedef boost::numeric::ublas::compressed_matrix<double> sparse_matrix;
typedef boost::numeric::ublas::vector<double> dense_vector;

template <class Matrix>
void gauss(std::size_t n, Matrix &A)  {
    double m;
    typedef sparse_matrix::iterator1 i1_t;
    typedef sparse_matrix::iterator2 i2_t;

    i1_t i1 = A.begin1();
    i2_t i2;
   
    for(int k=0;k<n-1;k++) {
        for(int i=k+1;i<n;i++) {
            m = A(i,k)/A(k,k);
            i2 = i1.begin();
            while(i2 != i1.end()) {
                A(i,i2.index2()) -= m*(*i2);
                i2++;
            }
        }
        i1++;
    }
}