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