File read and fill matrix in boost, cpp

guven
2013-12-15
2013-12-15
  • guven
    guven
    2013-12-15

    Hi,
    I have following set of code

    using namespace std;

    using std::vector;

    include <boost numeric="" ublas="" matrix.hpp="">

    include <boost numeric="" ublas="" io.hpp="">

    include <boost numeric="" ublas="" operation.hpp="">

    using namespace boost::numeric::ublas;

    boost::numeric::ublas::matrix<double> A_MATRIX(10,10);

    int main(){

    int i,j,temp1,temp2;
        double temp3;
    
    ifstream ptrReadCtvtxt;
    
    ptrReadCtvtxt.open("ctv.txt");
    
    for(i=0;i<10;i++){
    
        for(j = 0; j < 10; j++){
            if(j==0){
                ptrReadCtvtxt >> temp1;
                if(temp1>maxCtv)
                    maxCtv=temp1;
            }
                if(j==1) ptrReadCtvtxt >> temp2;
                if(j==2) ptrReadCtvtxt >>temp3;             
            }
    
               A_MATRIX (temp1-1)(temp2-1)=temp3;
    
    }
    ptrReadCtvtxt.close();
    

    return 0;

    }
    When I build, I receive this error for line A_MATRIX (temp1-1)(temp2-1)=temp3;

    error: no match for call to ‘(boost::numeric::ublas::matrix, boost::numeric::ublas::unbounded_array > >) (int)’

    I appreciate any help. Thanks a lot

    PS: I am sure, temp1, and temp2 values are within bounds of matrix.