Ignore:
Timestamp:
Oct 18, 2008, 3:05:54 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
94ca12
Parents:
d87482
Message:

ColumnCounter -> *ColumnCounter

columns of the MatrixContainer class may now be variable over each matrix. This was changed globally to allow for varying column numbers of the new class HessianMatrix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/parser.cpp

    rd87482 rb4c71a  
    5959  Matrix = (double ***) Malloc(sizeof(double **)*(1), "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule
    6060  RowCounter = (int *) Malloc(sizeof(int)*(1), "MatrixContainer::MatrixContainer: *RowCounter");
     61  ColumnCounter = (int *) Malloc(sizeof(int)*(1), "MatrixContainer::MatrixContainer: *ColumnCounter");
    6162  Matrix[0] = NULL;
    6263  RowCounter[0] = -1;
    6364  MatrixCounter = 0;
    64   ColumnCounter = 0;
     65  ColumnCounter[0] = -1;
    6566};
    6667
     
    7071  if (Matrix != NULL) {
    7172    for(int i=MatrixCounter;i--;) {
    72       if (RowCounter != NULL) {
     73      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
    7374          for(int j=RowCounter[i]+1;j--;)
    7475            Free((void **)&Matrix[i][j], "MatrixContainer::~MatrixContainer: *Matrix[][]");
     
    7677      }
    7778    }
    78     if ((RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
     79    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
    7980      for(int j=RowCounter[MatrixCounter]+1;j--;)
    8081        Free((void **)&Matrix[MatrixCounter][j], "MatrixContainer::~MatrixContainer: *Matrix[MatrixCounter][]");
     
    9192  Free((void **)&Header, "MatrixContainer::~MatrixContainer: *Header");
    9293  Free((void **)&RowCounter, "MatrixContainer::~MatrixContainer: *RowCounter");
    93 };
    94 
     94  Free((void **)&ColumnCounter, "MatrixContainer::~MatrixContainer: *RowCounter");
     95};
     96
     97/** Either copies index matrix from another MatrixContainer or initialises with trivial mapping if NULL.
     98 * This either copies the index matrix or just maps 1 to 1, 2 to 2 and so on for all fragments.
     99 * \param *Matrix pointer to other MatrixContainer
     100 * \return true - copy/initialisation sucessful, false - dimension false for copying
     101 */
     102bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix)
     103{
     104  cout << "Initialising indices";
     105  if (Matrix == NULL) {
     106    cout << " with trivial mapping." << endl;
     107    Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "MatrixContainer::InitialiseIndices: **Indices");
     108    for(int i=MatrixCounter+1;i--;) {
     109      Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     110      for(int j=RowCounter[i];j--;)
     111        Indices[i][j] = j;
     112    }
     113  } else {
     114    cout << " from other MatrixContainer." << endl;
     115    if (MatrixCounter != Matrix->MatrixCounter)
     116      return false;
     117    Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "MatrixContainer::InitialiseIndices: **Indices");
     118    for(int i=MatrixCounter+1;i--;) {
     119      if (RowCounter[i] != Matrix->RowCounter[i])
     120        return false;
     121      Indices[i] = (int *) Malloc(sizeof(int)*Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     122      for(int j=Matrix->RowCounter[i];j--;)
     123        Indices[i][j] = Matrix->Indices[i][j];
     124    }
     125  }
     126  return true;
     127};
    95128
    96129/** Parsing a number of matrices.
     
    130163    line >> Header;
    131164  //cout << line.str() << endl;
    132   ColumnCounter=0;
     165  ColumnCounter[MatrixNr]=0;
    133166  while ( getline(line,token, '\t') ) {
    134167    if (token.length() > 0)
    135       ColumnCounter++;
     168      ColumnCounter[MatrixNr]++;
    136169  }
    137170  //cout << line.str() << endl;
    138   //cout << "ColumnCounter: " << ColumnCounter << "." << endl;
    139   if (ColumnCounter == 0)
    140     cerr << "ColumnCounter: " << ColumnCounter << " from file " << name << ", this is probably an error!" << endl;
     171  cout << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
     172  if (ColumnCounter[MatrixNr] == 0)
     173    cerr << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;
    141174 
    142175  // scan rest for number of rows/lines
     
    150183    }
    151184  }
    152   //cout << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
     185  cout << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
    153186  if (RowCounter[MatrixNr] == 0)
    154187    cerr << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;
    155188 
    156189  // allocate matrix if it's not zero dimension in one direction
    157   if ((ColumnCounter > 0) && (RowCounter[MatrixNr] > -1)) {
     190  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
    158191    Matrix[MatrixNr] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixNr]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    159192 
     
    168201    strncpy(Header, line.str().c_str(), 1023); 
    169202    for(int j=0;j<RowCounter[MatrixNr];j++) {
    170       Matrix[MatrixNr][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     203      Matrix[MatrixNr][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixNr], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
    171204      input.getline(filename, 1023);
    172205      stringstream lines(filename);
     
    174207      for(int k=skipcolumns;k--;)
    175208        lines >> filename;
    176       for(int k=0;(k<ColumnCounter) && (!lines.eof());k++) {
     209      for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
    177210        lines >> Matrix[MatrixNr][j][k];
    178211        //cout << " " << setprecision(2) << Matrix[MatrixNr][j][k];;
    179212      }
    180213      //cout << endl;
    181       Matrix[MatrixNr][ RowCounter[MatrixNr] ] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[RowCounter[MatrixNr]][]");
    182       for(int j=ColumnCounter;j--;)
     214      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixNr], "MatrixContainer::ParseFragmentMatrix: *Matrix[RowCounter[MatrixNr]][]");
     215      for(int j=ColumnCounter[MatrixNr];j--;)
    183216        Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.;
    184217    }
    185218  } else {
    186     cerr << "ERROR: Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl;
     219    cerr << "ERROR: Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl;
    187220  }
    188221  input.close();
     
    235268  Matrix = (double ***) ReAlloc(Matrix, sizeof(double **)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
    236269  RowCounter = (int *) ReAlloc(RowCounter, sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *RowCounter");
     270  ColumnCounter = (int *) ReAlloc(ColumnCounter, sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *ColumnCounter");
    237271  for(int i=MatrixCounter+1;i--;) {
    238272    Matrix[i] = NULL;
    239273    RowCounter[i] = -1;
     274    ColumnCounter[i] = -1;
    240275  }
    241276  for(int i=0; i < MatrixCounter;i++) {
     
    255290 * \param MCounter number of matrices
    256291 * \param *RCounter number of rows for each matrix
    257  * \param CCounter number of columns for all matrices
     292 * \param *CCounter number of columns for each matrices
    258293 * \return Allocation successful
    259294 */
    260 bool MatrixContainer::AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int CCounter)
     295bool MatrixContainer::AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int *CCounter)
    261296{
    262297  Header = (char *) Malloc(sizeof(char)*1024, "MatrixContainer::ParseFragmentMatrix: *EnergyHeader");
     
    264299
    265300  MatrixCounter = MCounter;
    266   ColumnCounter = CCounter;
    267301  Matrix = (double ***) Malloc(sizeof(double **)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
    268302  RowCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *RowCounter");
     303  ColumnCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *ColumnCounter");
    269304  for(int i=MatrixCounter+1;i--;) {
    270305    RowCounter[i] = RCounter[i];
     306    ColumnCounter[i] = CCounter[i];
    271307    Matrix[i] = (double **) Malloc(sizeof(double *)*(RowCounter[i]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 
    272308    for(int j=RowCounter[i]+1;j--;) {
    273       Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
    274       for(int k=ColumnCounter;k--;)
     309      Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter[i], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     310      for(int k=ColumnCounter[i];k--;)
    275311        Matrix[i][j][k] = 0.;
    276312    }
     
    286322  for(int i=MatrixCounter+1;i--;)
    287323    for(int j=RowCounter[i]+1;j--;)
    288       for(int k=ColumnCounter;k--;)
     324      for(int k=ColumnCounter[i];k--;)
    289325        Matrix[i][j][k] = 0.;
    290326   return true;
     
    299335  for(int i=MatrixCounter+1;i--;)
    300336    for(int j=RowCounter[i]+1;j--;)
    301       for(int k=ColumnCounter;k--;)
     337      for(int k=ColumnCounter[i];k--;)
    302338        if (fabs(Matrix[i][j][k]) > max)
    303339          max = fabs(Matrix[i][j][k]);
     
    315351  for(int i=MatrixCounter+1;i--;)
    316352    for(int j=RowCounter[i]+1;j--;)
    317       for(int k=ColumnCounter;k--;)
     353      for(int k=ColumnCounter[i];k--;)
    318354        if (fabs(Matrix[i][j][k]) < min)
    319355          min = fabs(Matrix[i][j][k]);
     
    331367{
    332368  for(int j=RowCounter[MatrixCounter]+1;j--;)
    333     for(int k=skipcolumns;k<ColumnCounter;k++)
     369    for(int k=skipcolumns;k<ColumnCounter[MatrixCounter];k++)
    334370      Matrix[MatrixCounter][j][k] = value;
    335371   return true;
     
    344380{
    345381  for(int j=RowCounter[MatrixCounter]+1;j--;)
    346     for(int k=skipcolumns;k<ColumnCounter;k++)
     382    for(int k=skipcolumns;k<ColumnCounter[MatrixCounter];k++)
    347383      Matrix[MatrixCounter][j][k] = values[j][k];
    348384   return true;
     
    351387/** Sums the energy with each factor and put into last element of \a ***Energies.
    352388 * Sums over "E"-terms to create the "F"-terms
    353  * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.
     389 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
    354390 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
    355391 * \param Order bond order
     
    384420              }
    385421              if (Order == SubOrder) { // equal order is always copy from Energies
    386                 for(int l=ColumnCounter;l--;) // then adds/subtract each column
     422                for(int l=ColumnCounter[ KeySet.OrderSet[SubOrder][j] ];l--;) // then adds/subtract each column
    387423                  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][l] += MatrixValues.Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];
    388424              } else {
    389                 for(int l=ColumnCounter;l--;)
     425                for(int l=ColumnCounter[ KeySet.OrderSet[SubOrder][j] ];l--;)
    390426                  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][l] -= Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];
    391427              }
    392428            }
    393             //if ((ColumnCounter>1) && (RowCounter[0]-1 >= 1))
     429            //if ((ColumnCounter[ KeySet.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1))
    394430             //cout << "Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;
    395431          }
     
    428464    output << Header << endl;
    429465    for(int j=0;j<RowCounter[i];j++) {
    430       for(int k=0;k<ColumnCounter;k++)
     466      for(int k=0;k<ColumnCounter[i];k++)
    431467        output << scientific << Matrix[i][j][k] << "\t";
    432468      output << endl;
     
    457493  output << Header << endl;
    458494  for(int j=0;j<RowCounter[MatrixCounter];j++) {
    459     for(int k=0;k<ColumnCounter;k++)
     495    for(int k=0;k<ColumnCounter[MatrixCounter];k++)
    460496      output << scientific << Matrix[MatrixCounter][j][k] << "\t";
    461497    output << endl;
     
    467503// ======================================= CLASS EnergyMatrix =============================
    468504
    469 /** Create a trivial energy index mapping.
    470  * This just maps 1 to 1, 2 to 2 and so on for all fragments.
    471  * \return creation sucessful
    472  */
    473 bool EnergyMatrix::ParseIndices()
    474 {
    475   cout << "Parsing energy indices." << endl;
    476   Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "EnergyMatrix::ParseIndices: **Indices");
    477   for(int i=MatrixCounter+1;i--;) {
    478     Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");
    479     for(int j=RowCounter[i];j--;)
    480       Indices[i][j] = j;
    481   }
    482   return true;
    483 };
    484 
    485505/** Sums the energy with each factor and put into last element of \a EnergyMatrix::Matrix.
    486506 * Sums over the "F"-terms in ANOVA decomposition.
    487  * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.
     507 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
    488508 * \param CorrectionFragments MatrixContainer with hydrogen saturation correction per fragments
    489509 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
     
    498518    for(int i=KeySet.FragmentsPerOrder[Order];i--;)
    499519      for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;)
    500         for(int k=ColumnCounter;k--;)
     520        for(int k=ColumnCounter[ KeySet.OrderSet[Order][i] ];k--;)
    501521          Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k];
    502522  else
    503523    for(int i=KeySet.FragmentsPerOrder[Order];i--;)
    504524      for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;)
    505         for(int k=ColumnCounter;k--;)
     525        for(int k=ColumnCounter[ KeySet.OrderSet[Order][i] ];k--;)
    506526          Matrix[MatrixCounter][j][k] += sign*(Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k] + CorrectionFragments->Matrix[ KeySet.OrderSet[Order][i] ][j][k]);
    507527  return true;
     
    524544    // count maximum of columns
    525545    RowCounter[MatrixCounter] = 0;
    526     for(int j=0; j < MatrixCounter;j++) // (energy matrix might be bigger than number of atoms in terms of rows)
     546    ColumnCounter[MatrixCounter] = 0;
     547    for(int j=0; j < MatrixCounter;j++) { // (energy matrix might be bigger than number of atoms in terms of rows)
    527548      if (RowCounter[j] > RowCounter[MatrixCounter])
    528549        RowCounter[MatrixCounter] = RowCounter[j];
     550      if (ColumnCounter[j] > ColumnCounter[MatrixCounter])  // take maximum of all for last matrix
     551        ColumnCounter[MatrixCounter] = ColumnCounter[j];
     552    }
    529553    // allocate last plus one matrix
    530     cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter << " columns." << endl;
     554    cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
    531555    Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    532556    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    533       Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     557      Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
    534558   
    535559    // try independently to parse global energysuffix file if present
     
    589613
    590614/** Sums the forces and puts into last element of \a ForceMatrix::Matrix.
    591  * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.
     615 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
    592616 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
    593617 * \param Order bond order
     
    609633      if (j != -1) {
    610634        //if (j == 0) cout << "Summing onto ion 0, type 0 from fragment " << FragmentNr << ", ion " << l << "." << endl;
    611         for(int k=2;k<ColumnCounter;k++)
     635        for(int k=2;k<ColumnCounter[MatrixCounter];k++)
    612636          Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ FragmentNr ][l][k];
    613637      }
     
    655679    RowCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
    656680    input.close();
     681
     682    ColumnCounter[MatrixCounter] = 0;
     683    for(int j=0; j < MatrixCounter;j++) { // (energy matrix might be bigger than number of atoms in terms of rows)
     684      if (ColumnCounter[j] > ColumnCounter[MatrixCounter])  // take maximum of all for last matrix
     685        ColumnCounter[MatrixCounter] = ColumnCounter[j];
     686    }
    657687 
    658688    // allocate last plus one matrix
    659     cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter << " columns." << endl;
     689    cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
    660690    Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    661691    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    662       Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     692      Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
    663693
    664694    // try independently to parse global forcesuffix file if present
     
    686716  stringstream line;
    687717 
    688   cout << "Parsing force indices for " << MatrixCounter << " matrices." << endl;
     718  cout << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl;
    689719  Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "HessianMatrix::ParseIndices: **Indices");
    690720  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    720750
    721751/** Sums the hessian entries and puts into last element of \a HessianMatrix::Matrix.
    722  * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.
     752 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
    723753 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
    724754 * \param Order bond order
     
    739769      }
    740770      if (j != -1) {
    741         //for(int m=0;m<ColumnCounter[ FragmentNr ];m++) {
    742         for(int m=0;m<ColumnCounter;m++) {
     771        for(int m=0;m<ColumnCounter[ FragmentNr ];m++) {
    743772          int k = Indices[ FragmentNr ][m];
    744 //          if (k > ColumnCounter[MatrixCounter]) {
    745 //            cerr << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << "!" << endl;
    746           if (k > ColumnCounter) {
    747             cerr << "Current hessian index " << k << " is greater than " << ColumnCounter << "!" << endl;
     773          if (k > ColumnCounter[MatrixCounter]) {
     774            cerr << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << "!" << endl;
    748775            return false;
    749776          }
     
    784811    }
    785812    RowCounter[MatrixCounter] = 0;
     813    ColumnCounter[MatrixCounter] = 0;
    786814    while (!input.eof()) {
    787815      input.getline(filename, 1023);
     
    790818        zeile >> nr;
    791819        //cout << "Current index: " << nr << "." << endl;
    792         if (nr > RowCounter[MatrixCounter])
     820        if (nr > RowCounter[MatrixCounter]) {
    793821          RowCounter[MatrixCounter] = nr;
     822          ColumnCounter[MatrixCounter] = nr;
     823        }
    794824      }
    795825    }
    796826    RowCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
     827    ColumnCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
    797828    input.close();
    798829 
    799830    // allocate last plus one matrix
    800     cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter << " columns." << endl;
     831    cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
    801832    Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    802833    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    803       Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     834      Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
    804835
    805836    // try independently to parse global forcesuffix file if present
Note: See TracChangeset for help on using the changeset viewer.