Exemple #1
0
void PrintVector(CVector &vec) {
  if(! vec.Defined()) {throw ELENotDefined; }

  putchar('\n');
  for(int i=0; i<vec.m_pnDimSize[0]; i++) {
    printf("%e  ", double(vec[i]));
  } // for i
  printf("\n");
} // PrintVector
Exemple #2
0
void WritePlot(const char *strFileName, CVector &vecx, CVector &vec1, CVector &vec2, CVector &vec3) {
  FILE *file;
  if(! ( vecx.Defined() && vec1.Defined() && vec2.Defined() && vec3.Defined())) {throw ELENotDefined; }
  if(vecx.m_pnDimSize[0] != vec1.m_pnDimSize[0] || vecx.m_pnDimSize[0] != vec2.m_pnDimSize[0]) {throw ELEDimensionMisMatch; }
  if(vecx.m_pnDimSize[0] != vec3.m_pnDimSize[0]) {throw ELEDimensionMisMatch; }
  if(! (file=fopen(strFileName, "w+")) ) {
    // unable to open file
    printf("Unable to open file: %s\n", strFileName);
    return;
  } // if
  fprintf(file, "# File %s automatically created by linalfunc\n", strFileName);
  fprintf(file, "# Written by Rutger van Haasteren\n");
//              "12345678901234567890123456789012345678901234567890123456789012
  for(int i=0; i<vecx.m_pnDimSize[0]; i++) {
    fprintf(file, "%.18e %.18e %.18e %.18e\n", double(vecx[i]), double(vec1[i]), double(vec2[i]), double(vec3[i]));
  } // for i

  fclose(file);
  return;
} // WritePlot
Exemple #3
0
double Prod(CVector &vec) {
  double dProd=1;
  if(! vec.Defined()) {throw ELENotDefined; }

  for(int i=0; i<vec.m_pnDimSize[0]; i++) {
    dProd *= double(vec[i]);
  } // for i

  if(vec.Allocated()) {delete &vec; } // This should call for the destructor
  return dProd;
} // Prod
Exemple #4
0
double Max(CVector &vec) {
  double dMax;
  if(! vec.Defined()) {throw ELENotDefined; }
  
  dMax = vec[0];
  for(int i=0; i<vec.m_pnDimSize[0]; i++) {
    if(vec[i] > dMax) dMax = double(vec[i]);
  } // for i

  if(vec.Allocated()) {delete &vec; } // This should call for the destructor
  return dMax;
} // Max