Initialize vector matrix using a function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paulzhang
    New Member
    • Jul 2013
    • 1

    Initialize vector matrix using a function

    I've many matrix like vector<vector<d ouble> > A1, ..., Am, and I want to initialize them using a function like the following instead of do them repeatly. But it does not work. Who can please shed some light on this?
    Code:
    double_mtx(vector<vector<double> > &mtx,int row, int col){
            
            mtx.resize(row);
            for(int i=0;i<row;i++)mtx[row].resize(col);
            for(int i=0;i<row;i++)
                    for(int j=0;j<col;j++)mtx[i][j]=0.;
         
            return;
    }
    Last edited by Rabbit; Jul 12 '13, 08:23 PM. Reason: Please use code tags when posting code.
Working...