00001 // ConjugateGradientObserver.cpp: implementation of the ConjugateGradientObserver class. 00002 // 00004 00005 #include "ConjugateGradientObserver.h" 00006 00008 // Construction/Destruction 00010 00011 CConjugateGradientObserver::CConjugateGradientObserver() 00012 { 00013 00014 } 00015 00016 CConjugateGradientObserver::~CConjugateGradientObserver() 00017 { 00018 00019 } 00020 00021 // default behavior is to print plain text matrix seperated by single spaces 00022 00023 void CConjugateGradientObserver::Update(Subject *theChangedSubject) 00024 { 00025 int i; 00026 int j; 00027 int NParameters; 00028 // static cast may be dangerous 00029 CConjugateGradientMinimizer *CGM = (CConjugateGradientMinimizer *)theChangedSubject; 00030 00031 // write the experimental data to the temporary file 00032 fstream *forcefile = new fstream("ConjugateGradientForceVector.dat",ios::out); 00033 00034 const double *m_pdForceVector = CGM->GetForceVector(); 00035 NParameters = CGM->GetNParameters(); 00036 for (i=0; i < NParameters; i++) { 00037 *forcefile << m_pdForceVector[i] << endl; 00038 //cout << CGM->GetForceVector()[i] << " "; 00039 } 00040 00041 delete forcefile; 00042 00043 return; 00044 00045 }