From 6de275a5934a91b9a0da7e32dfc369c70ed8ad8c Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 4 May 2010 16:53:03 +0200 Subject: [PATCH] removed CRLF (-> LF) from older files in tools-subfolder --- tools/AdrOp.h | 300 +++++++++++++++++++++---------------------- tools/ErrorMsg.cpp | 166 ++++++++++++------------ tools/ErrorMsg.h | 100 +++++++-------- tools/ExpenseLog.cpp | 282 ++++++++++++++++++++-------------------- tools/ExpenseLog.h | 184 +++++++++++++------------- 5 files changed, 516 insertions(+), 516 deletions(-) diff --git a/tools/AdrOp.h b/tools/AdrOp.h index 5c6cb2a..6568175 100644 --- a/tools/AdrOp.h +++ b/tools/AdrOp.h @@ -1,150 +1,150 @@ -/* -* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -/*! -\class AdrOp -\author Thorsten Liebig -\version $Revision: 1.10 $ -\date $Date: 2006/10/29 18:50:44 $ -*/ - -#ifndef ADROP_H -#define ADROP_H - -#include -#include -#include -#include -#include "ExpenseLog.h" -#include "ErrorMsg.h" - -using namespace std; - -class AdrOp{ -public: - ///Constructor, define dimension/size here - AdrOp(unsigned int muiImax, unsigned int muiYmax, unsigned int muiKmax=0, unsigned int muiLmax=0); - ///Copy-Constructor - AdrOp(AdrOp* origOP); - ///Deconstructor - virtual ~AdrOp(); - ///Set the current n-dim position, get 1-dim array position as return value - /*!A position has to be set or all other methodes will case error! \n The methode will exit with error message if invalid position is set! \sa ErrorMsg */ - unsigned int SetPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0); - - bool SetPosChecked(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0); - - void SetGrid(double *gridI,double *gridJ,double *gridK=NULL,double *gridL=NULL); - void SetGridDelta(double delta) {this->dDeltaUnit=delta;}; - - bool CheckPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0); - bool CheckRelativePos(int muiIrel=0,int muiJrel=0,int muiKrel=0, int muiLrel=0); - ///will return current 1-dim position, in addition to a relative n-dim shift - /*!In case of crossing the boundaries, activate reflection or an error will be invoked\sa SetReflection2Node \sa SetReflection2Cell \sa SetReflectionOff */ - unsigned int GetPos(int muiIrel=0,int muiJrel=0,int muiKrel=0, int muiLrel=0); - - double GetNodeVolume(unsigned int uiNode); - - double GetIndexWidth(int ny, int index); - double GetIndexCoord(int ny, int index); - ///Get the gird delta at the given index of direction ny. (if index<0 return negative value as index=0 would give, if index>=max-1 returns negative value as index=max-2 would give) - double GetIndexDelta(int ny, int index); - -// double GetCellVolume(unsigned int uiCell); - - unsigned int GetPosFromNode(int ny, unsigned int uiNode); - ///Set a shift in ny direction (e.g. 0 for i-direction) - /*!Shift set by this methode will be ignored by methode GetPos*/ - unsigned int Shift(int ny, int step); - ///Set a checked shift in ny direction (e.g. 0 for i-direction) - /*!Shift set by this methode will be ignored by methode GetPos*/ - bool CheckShift(int ny, int step); - ///Returns the current 1-dim position including shift by methode "Shift" - unsigned int GetShiftedPos(); - ///Reset shift set by "Shift"-methode - void ResetShift(); - ///Iterates through AdrOp; --- obsolete --- - unsigned int Iterate(int jump=1); - ///Retruns size of array - unsigned int GetSize(); - ///Set mode to reflect by node - /*!1D-example (6 nodes): \image html node_reflect.PNG order: 0,1,2,3,4,5,4,3,...*/ - void SetReflection2Node(); - ///Set mode to reflect by cell - /*!1D-example (5 cells): \image html cell_reflect.PNG order: 0,1,2,3,4,4,3,...*/ - void SetReflection2Cell(); - ///Deactivate reflection (default) - void SetReflectionOff(); - ///Add a cell adress operator (dimensions: i-1 j-1 k-1 l-1) - /*!\image html cells_nodes.png */ - AdrOp* AddCellAdrOp(); - - AdrOp* GetCellAdrOp() {return clCellAdr;}; - - ///Deconstructed cell adress operator if no longer needed - AdrOp* DeleteCellAdrOp(); - ///Shift cell in ny dircetion; cell reflection is active - unsigned int ShiftCell(int ny, int step); - ///Shift cell in ny dircetion; cell reflection is active; return check - bool ShiftCellCheck(int ny, int step); - ///Reset cell shift - void ResetCellShift(); - ///Get current cell position from cell adress operator - unsigned int GetCellPos(bool incShift=true); - ///Get cell position from cell adress operator - unsigned int GetCellPos(int i, int j, int k=0); - //get volume of cell; incl shift - double GetShiftCellVolume(int ny, int step); - - - void SetDebugOn() {this->bDebug=true;}; - void SetDebugOff() {this->bDebug=false;}; - -protected: - AdrOp *clCellAdr; - unsigned int uiDimension; - unsigned int uiSize; - unsigned int uiImax,uiJmax,uiKmax,uiLmax; - unsigned int uiIpos, uiJpos, uiKpos, uiLpos; - double *dGrid[4]; - double dDeltaUnit; - int iIshift, iJshift, iKshift; - int iCellShift[3]; - unsigned int i,j,k,l; - bool reflect; - unsigned int uiTypeOffset; - - bool bPosSet; - bool bDebug; - ErrorMsg *error; -}; - - -class deltaAdrOp -{ -public: - deltaAdrOp(unsigned int max=0); - virtual ~deltaAdrOp(); - void SetMax(unsigned int max); - unsigned int GetAdr(int pos); - -protected: - unsigned int uiMax; -}; - - -#endif // ADROP_H +/* +* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +/*! +\class AdrOp +\author Thorsten Liebig +\version $Revision: 1.10 $ +\date $Date: 2006/10/29 18:50:44 $ +*/ + +#ifndef ADROP_H +#define ADROP_H + +#include +#include +#include +#include +#include "ExpenseLog.h" +#include "ErrorMsg.h" + +using namespace std; + +class AdrOp{ +public: + ///Constructor, define dimension/size here + AdrOp(unsigned int muiImax, unsigned int muiYmax, unsigned int muiKmax=0, unsigned int muiLmax=0); + ///Copy-Constructor + AdrOp(AdrOp* origOP); + ///Deconstructor + virtual ~AdrOp(); + ///Set the current n-dim position, get 1-dim array position as return value + /*!A position has to be set or all other methodes will case error! \n The methode will exit with error message if invalid position is set! \sa ErrorMsg */ + unsigned int SetPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0); + + bool SetPosChecked(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0); + + void SetGrid(double *gridI,double *gridJ,double *gridK=NULL,double *gridL=NULL); + void SetGridDelta(double delta) {this->dDeltaUnit=delta;}; + + bool CheckPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos=0, unsigned int muiLpos=0); + bool CheckRelativePos(int muiIrel=0,int muiJrel=0,int muiKrel=0, int muiLrel=0); + ///will return current 1-dim position, in addition to a relative n-dim shift + /*!In case of crossing the boundaries, activate reflection or an error will be invoked\sa SetReflection2Node \sa SetReflection2Cell \sa SetReflectionOff */ + unsigned int GetPos(int muiIrel=0,int muiJrel=0,int muiKrel=0, int muiLrel=0); + + double GetNodeVolume(unsigned int uiNode); + + double GetIndexWidth(int ny, int index); + double GetIndexCoord(int ny, int index); + ///Get the gird delta at the given index of direction ny. (if index<0 return negative value as index=0 would give, if index>=max-1 returns negative value as index=max-2 would give) + double GetIndexDelta(int ny, int index); + +// double GetCellVolume(unsigned int uiCell); + + unsigned int GetPosFromNode(int ny, unsigned int uiNode); + ///Set a shift in ny direction (e.g. 0 for i-direction) + /*!Shift set by this methode will be ignored by methode GetPos*/ + unsigned int Shift(int ny, int step); + ///Set a checked shift in ny direction (e.g. 0 for i-direction) + /*!Shift set by this methode will be ignored by methode GetPos*/ + bool CheckShift(int ny, int step); + ///Returns the current 1-dim position including shift by methode "Shift" + unsigned int GetShiftedPos(); + ///Reset shift set by "Shift"-methode + void ResetShift(); + ///Iterates through AdrOp; --- obsolete --- + unsigned int Iterate(int jump=1); + ///Retruns size of array + unsigned int GetSize(); + ///Set mode to reflect by node + /*!1D-example (6 nodes): \image html node_reflect.PNG order: 0,1,2,3,4,5,4,3,...*/ + void SetReflection2Node(); + ///Set mode to reflect by cell + /*!1D-example (5 cells): \image html cell_reflect.PNG order: 0,1,2,3,4,4,3,...*/ + void SetReflection2Cell(); + ///Deactivate reflection (default) + void SetReflectionOff(); + ///Add a cell adress operator (dimensions: i-1 j-1 k-1 l-1) + /*!\image html cells_nodes.png */ + AdrOp* AddCellAdrOp(); + + AdrOp* GetCellAdrOp() {return clCellAdr;}; + + ///Deconstructed cell adress operator if no longer needed + AdrOp* DeleteCellAdrOp(); + ///Shift cell in ny dircetion; cell reflection is active + unsigned int ShiftCell(int ny, int step); + ///Shift cell in ny dircetion; cell reflection is active; return check + bool ShiftCellCheck(int ny, int step); + ///Reset cell shift + void ResetCellShift(); + ///Get current cell position from cell adress operator + unsigned int GetCellPos(bool incShift=true); + ///Get cell position from cell adress operator + unsigned int GetCellPos(int i, int j, int k=0); + //get volume of cell; incl shift + double GetShiftCellVolume(int ny, int step); + + + void SetDebugOn() {this->bDebug=true;}; + void SetDebugOff() {this->bDebug=false;}; + +protected: + AdrOp *clCellAdr; + unsigned int uiDimension; + unsigned int uiSize; + unsigned int uiImax,uiJmax,uiKmax,uiLmax; + unsigned int uiIpos, uiJpos, uiKpos, uiLpos; + double *dGrid[4]; + double dDeltaUnit; + int iIshift, iJshift, iKshift; + int iCellShift[3]; + unsigned int i,j,k,l; + bool reflect; + unsigned int uiTypeOffset; + + bool bPosSet; + bool bDebug; + ErrorMsg *error; +}; + + +class deltaAdrOp +{ +public: + deltaAdrOp(unsigned int max=0); + virtual ~deltaAdrOp(); + void SetMax(unsigned int max); + unsigned int GetAdr(int pos); + +protected: + unsigned int uiMax; +}; + + +#endif // ADROP_H diff --git a/tools/ErrorMsg.cpp b/tools/ErrorMsg.cpp index a0442dc..3232ee9 100644 --- a/tools/ErrorMsg.cpp +++ b/tools/ErrorMsg.cpp @@ -1,83 +1,83 @@ -/* -* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#include -#include -#include -#include "ErrorMsg.h" - -ErrorMsg::ErrorMsg(unsigned int NoMessage) -{ - NoMsg=NoMessage; - if (NoMsg>0) Msg = new char*[NoMsg]; if (Msg==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); } - for (unsigned int i=0;iNoMsg) || (Message==NULL)) ownError(); - Msg[nr-1] = new char[strlen(Message)+1]; if (Msg[nr-1]==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); } - Msg[nr-1]=strcpy(Msg[nr-1],Message); -} - -void ErrorMsg::Error(unsigned int nr,char *chAddMsg) -{ - if ((nr>0) && (nr<=NoMsg)) - { - if (Msg[nr-1]!=NULL) fprintf(stderr,"%s",Msg[nr-1]); - else fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr); - if (chAddMsg!=NULL) fprintf(stderr,"%s",chAddMsg); - getchar(); - exit(nr); - } - else - { - fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr); - getchar(); - exit(nr); - } -} - -void ErrorMsg::Error(unsigned int nr,int addNr) -{ - if ((nr>0) && (nr<=NoMsg)) - { - if (Msg[nr-1]!=NULL) fprintf(stderr,"%s",Msg[nr-1]); - else fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr); - fprintf(stderr,"%d",addNr); - getchar(); - exit(nr); - } - else - { - fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr); - getchar(); - exit(nr); - } -} - -void ErrorMsg::ownError(void) -{ - fprintf(stdout," Error occured by using Error Message class!! ... exiting..."); - exit(-1); -} +/* +* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#include +#include +#include +#include "ErrorMsg.h" + +ErrorMsg::ErrorMsg(unsigned int NoMessage) +{ + NoMsg=NoMessage; + if (NoMsg>0) Msg = new char*[NoMsg]; if (Msg==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); } + for (unsigned int i=0;iNoMsg) || (Message==NULL)) ownError(); + Msg[nr-1] = new char[strlen(Message)+1]; if (Msg[nr-1]==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); } + Msg[nr-1]=strcpy(Msg[nr-1],Message); +} + +void ErrorMsg::Error(unsigned int nr,char *chAddMsg) +{ + if ((nr>0) && (nr<=NoMsg)) + { + if (Msg[nr-1]!=NULL) fprintf(stderr,"%s",Msg[nr-1]); + else fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr); + if (chAddMsg!=NULL) fprintf(stderr,"%s",chAddMsg); + getchar(); + exit(nr); + } + else + { + fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr); + getchar(); + exit(nr); + } +} + +void ErrorMsg::Error(unsigned int nr,int addNr) +{ + if ((nr>0) && (nr<=NoMsg)) + { + if (Msg[nr-1]!=NULL) fprintf(stderr,"%s",Msg[nr-1]); + else fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr); + fprintf(stderr,"%d",addNr); + getchar(); + exit(nr); + } + else + { + fprintf(stderr,"unkown error occured!! Error code: %d exiting...",nr); + getchar(); + exit(nr); + } +} + +void ErrorMsg::ownError(void) +{ + fprintf(stdout," Error occured by using Error Message class!! ... exiting..."); + exit(-1); +} diff --git a/tools/ErrorMsg.h b/tools/ErrorMsg.h index 1967c50..fa63c93 100644 --- a/tools/ErrorMsg.h +++ b/tools/ErrorMsg.h @@ -1,50 +1,50 @@ -/* -* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -/*! -\class ErrorMsg -\author Thorsten Liebig -\version $Revision: 1.2 $ -\date $Date: 2006/01/25 11:47:07 $ -*/ - -#ifndef _ERRORMSG_H_ -#define _ERRORMSG_H_ - -class ErrorMsg -{ -public: - ///Constructor defines number of error messages - ErrorMsg(unsigned int NoMessage=0); - ///Deconstructor - virtual ~ErrorMsg(); - ///Methode for defining error messages - /*! \param nr Number of defining error message \param *Message Set error message string \sa Error */ - void SetMsg(unsigned int nr, const char *Message); - ///Call an error message. Will exit the program! - /*! \param nr Number of called error message. default is 0 \sa SetMsg*/ - void Error(unsigned int nr=0,char *chAddMsg=0); - - void Error(unsigned int nr,int addNr); - -protected: - void ownError(void); - unsigned int NoMsg; - char **Msg; -}; - -#endif //_ERRORMSG_H_ +/* +* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +/*! +\class ErrorMsg +\author Thorsten Liebig +\version $Revision: 1.2 $ +\date $Date: 2006/01/25 11:47:07 $ +*/ + +#ifndef _ERRORMSG_H_ +#define _ERRORMSG_H_ + +class ErrorMsg +{ +public: + ///Constructor defines number of error messages + ErrorMsg(unsigned int NoMessage=0); + ///Deconstructor + virtual ~ErrorMsg(); + ///Methode for defining error messages + /*! \param nr Number of defining error message \param *Message Set error message string \sa Error */ + void SetMsg(unsigned int nr, const char *Message); + ///Call an error message. Will exit the program! + /*! \param nr Number of called error message. default is 0 \sa SetMsg*/ + void Error(unsigned int nr=0,char *chAddMsg=0); + + void Error(unsigned int nr,int addNr); + +protected: + void ownError(void); + unsigned int NoMsg; + char **Msg; +}; + +#endif //_ERRORMSG_H_ diff --git a/tools/ExpenseLog.cpp b/tools/ExpenseLog.cpp index 1ddb7a7..ce9d50d 100644 --- a/tools/ExpenseLog.cpp +++ b/tools/ExpenseLog.cpp @@ -1,141 +1,141 @@ -#include "ExpenseLog.h" - -ExpenseModule::ExpenseModule(const char* moduleName) -{ - chModuleName=moduleName; - uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0; - uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0; -} - -ExpenseModule::~ExpenseModule() {}; - -void ExpenseModule::Clear() -{ - uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0; - uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0; -} - -void ExpenseModule::AddDoubleAdditons(unsigned int number) -{ - uiDoubleAdditions+=number; - if (uiDoubleAdditions>=MRD) - { - uiDoubleAdditions-=MRD; - ++uiMrdDA; - } -} - -void ExpenseModule::AddDoubleMultiplications(unsigned int number) -{ - uiDoubleMultiplications+=number; - if (uiDoubleMultiplications>=MRD) - { - uiDoubleMultiplications-=MRD; - ++uiMrdDM; - } -} - -void ExpenseModule::AddIntAdditons(unsigned int number) -{ - uiIntAdditions+=number; - if (uiIntAdditions>=MRD) - { - uiIntAdditions-=MRD; - ++uiMrdIA; - } -} - -void ExpenseModule::AddIntMultiplications(unsigned int number) -{ - uiIntMultiplications+=number; - if (uiIntMultiplications>=MRD) - { - uiIntMultiplications-=MRD; - ++uiMrdIM; - } -} - -void ExpenseModule::AddAssignments(unsigned int number) -{ - uiAssignments+=number; - if (uiAssignments>=MRD) - { - uiAssignments-=MRD; - ++uiMrdAssign; - } -} - -void ExpenseModule::AddBoolOperations(unsigned int number) -{ - uiBoolOp+=number; - if (uiBoolOp>=MRD) - { - uiBoolOp-=MRD; - ++uiMrdBO; - } -} - -void ExpenseModule::AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp) -{ - this->AddIntAdditons(IntAdd); - this->AddIntMultiplications(IntMul); - this->AddDoubleAdditons(DoubleAdd); - this->AddDoubleMultiplications(DoubleMul); - this->AddAssignments(Assigns); - this->AddBoolOperations(BoolOp); -} - -void ExpenseModule::PrintfSelf(FILE* file) -{ - fprintf(file,"\n***********\n Module: %s\n Additions:\n Double: %3.0d%9d\tInteger: %3.0d%9d",chModuleName,uiMrdDA,uiDoubleAdditions,uiMrdIA,uiIntAdditions); - fprintf(file,"\n\n Multiplications:\n Double: %3.0d%9d\tInteger: %3.0d%9d\n",uiMrdDM,uiDoubleMultiplications,uiMrdIM,uiIntMultiplications); - fprintf(file,"\n Assignments: %3.0d%9d\tBool Operations: %3.0d%9d\n",uiMrdAssign,uiAssignments,uiMrdBO,uiBoolOp); - fprintf(file,"\n***********\n"); -} - - - - -/***********************************************************************************************************************/ - -ExpenseLog::ExpenseLog(void) -{ -} - -ExpenseLog::~ExpenseLog(void) -{ - for (size_t i=0;iuiIntAdditions+(double)vModules.at(i)->uiDoubleAdditions) + 1e9*((double)vModules.at(i)->uiMrdIA+(double)vModules.at(i)->uiMrdIA); - totalMul+=((double)vModules.at(i)->uiIntMultiplications+(double)vModules.at(i)->uiDoubleMultiplications) + 1e9*(double)(vModules.at(i)->uiMrdIM+vModules.at(i)->uiMrdIM); - totalBool+=(double)vModules.at(i)->uiBoolOp + 1e9*(double)vModules.at(i)->uiMrdBO; - totalAssign+=(double)vModules.at(i)->uiAssignments + 1e9*(double)vModules.at(i)->uiMrdAssign; - vModules.at(i)->PrintfSelf(file); - } - fprintf(stderr," Total:\n Additions: %e Multiplications: %e\n Bool Operations: %e Assignments: %e\n",totalAdd,totalMul,totalBool,totalAssign); - fprintf(stderr,"\n ----------------\n"); -} - -void ExpenseLog::ClearAll() -{ - for (size_t i=0;iClear(); - } -} - +#include "ExpenseLog.h" + +ExpenseModule::ExpenseModule(const char* moduleName) +{ + chModuleName=moduleName; + uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0; + uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0; +} + +ExpenseModule::~ExpenseModule() {}; + +void ExpenseModule::Clear() +{ + uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0; + uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0; +} + +void ExpenseModule::AddDoubleAdditons(unsigned int number) +{ + uiDoubleAdditions+=number; + if (uiDoubleAdditions>=MRD) + { + uiDoubleAdditions-=MRD; + ++uiMrdDA; + } +} + +void ExpenseModule::AddDoubleMultiplications(unsigned int number) +{ + uiDoubleMultiplications+=number; + if (uiDoubleMultiplications>=MRD) + { + uiDoubleMultiplications-=MRD; + ++uiMrdDM; + } +} + +void ExpenseModule::AddIntAdditons(unsigned int number) +{ + uiIntAdditions+=number; + if (uiIntAdditions>=MRD) + { + uiIntAdditions-=MRD; + ++uiMrdIA; + } +} + +void ExpenseModule::AddIntMultiplications(unsigned int number) +{ + uiIntMultiplications+=number; + if (uiIntMultiplications>=MRD) + { + uiIntMultiplications-=MRD; + ++uiMrdIM; + } +} + +void ExpenseModule::AddAssignments(unsigned int number) +{ + uiAssignments+=number; + if (uiAssignments>=MRD) + { + uiAssignments-=MRD; + ++uiMrdAssign; + } +} + +void ExpenseModule::AddBoolOperations(unsigned int number) +{ + uiBoolOp+=number; + if (uiBoolOp>=MRD) + { + uiBoolOp-=MRD; + ++uiMrdBO; + } +} + +void ExpenseModule::AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp) +{ + this->AddIntAdditons(IntAdd); + this->AddIntMultiplications(IntMul); + this->AddDoubleAdditons(DoubleAdd); + this->AddDoubleMultiplications(DoubleMul); + this->AddAssignments(Assigns); + this->AddBoolOperations(BoolOp); +} + +void ExpenseModule::PrintfSelf(FILE* file) +{ + fprintf(file,"\n***********\n Module: %s\n Additions:\n Double: %3.0d%9d\tInteger: %3.0d%9d",chModuleName,uiMrdDA,uiDoubleAdditions,uiMrdIA,uiIntAdditions); + fprintf(file,"\n\n Multiplications:\n Double: %3.0d%9d\tInteger: %3.0d%9d\n",uiMrdDM,uiDoubleMultiplications,uiMrdIM,uiIntMultiplications); + fprintf(file,"\n Assignments: %3.0d%9d\tBool Operations: %3.0d%9d\n",uiMrdAssign,uiAssignments,uiMrdBO,uiBoolOp); + fprintf(file,"\n***********\n"); +} + + + + +/***********************************************************************************************************************/ + +ExpenseLog::ExpenseLog(void) +{ +} + +ExpenseLog::~ExpenseLog(void) +{ + for (size_t i=0;iuiIntAdditions+(double)vModules.at(i)->uiDoubleAdditions) + 1e9*((double)vModules.at(i)->uiMrdIA+(double)vModules.at(i)->uiMrdIA); + totalMul+=((double)vModules.at(i)->uiIntMultiplications+(double)vModules.at(i)->uiDoubleMultiplications) + 1e9*(double)(vModules.at(i)->uiMrdIM+vModules.at(i)->uiMrdIM); + totalBool+=(double)vModules.at(i)->uiBoolOp + 1e9*(double)vModules.at(i)->uiMrdBO; + totalAssign+=(double)vModules.at(i)->uiAssignments + 1e9*(double)vModules.at(i)->uiMrdAssign; + vModules.at(i)->PrintfSelf(file); + } + fprintf(stderr," Total:\n Additions: %e Multiplications: %e\n Bool Operations: %e Assignments: %e\n",totalAdd,totalMul,totalBool,totalAssign); + fprintf(stderr,"\n ----------------\n"); +} + +void ExpenseLog::ClearAll() +{ + for (size_t i=0;iClear(); + } +} + diff --git a/tools/ExpenseLog.h b/tools/ExpenseLog.h index 14613e9..e32af91 100644 --- a/tools/ExpenseLog.h +++ b/tools/ExpenseLog.h @@ -1,92 +1,92 @@ -#pragma once -#include -#include -#include - -using namespace std; - -#define EXPENSE_LOG 0 -#define MRD 1000000000 - -#if EXPENSE_LOG==1 - -#define EXPENSE_DEFINE \ -ExpenseLog EL; \ -ExpenseModule* EngineExpense=EL.AddModule("Static Engine Expenses"); \ -ExpenseModule* PPExpense=EL.AddModule("Static Post Processing"); \ -ExpenseModule* AdrOpExpense=EL.AddModule("Adress Operator"); -#define EXTERN_EXPENSE_DEFINE extern ExpenseLog EL; -#define ENGINEEXPENSE_DEFINE extern ExpenseModule* EngineExpense; -#define POSTPROCEXPENSE_DEFINE extern ExpenseModule* PPExpense; -#define ADREXPENSE_DEFINE extern ExpenseModule* AdrOpExpense; -#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO) EngineExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO)); -#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO) PPExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO)); -#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO) AdrOpExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO)); -#define EXPENSEPRINT EL.PrintAll(stderr); -#define EXPENSECLEAR EL.ClearAll(); -#else - -#define EXPENSE_DEFINE -#define EXTERN_EXPENSE_DEFINE -#define ENGINEEXPENSE_DEFINE -#define POSTPROCEXPENSE_DEFINE -#define ADREXPENSE_DEFINE -#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO) -#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO) -#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO) -#define EXPENSEPRINT -#define EXPENSECLEAR -#endif - -class ExpenseModule -{ -friend class ExpenseLog; -public: - ExpenseModule(const char* moduleName); - ~ExpenseModule(); - - void Clear(); - - void AddDoubleAdditons(unsigned int number); - void AddDoubleMultiplications(unsigned int number); - - void AddIntAdditons(unsigned int number); - void AddIntMultiplications(unsigned int number); - - void AddAssignments(unsigned int number); - void AddBoolOperations(unsigned int number); - - void AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp); - - void PrintfSelf(FILE* file=stdout); - -protected: - const char* chModuleName; - unsigned int uiDoubleAdditions; - unsigned int uiDoubleMultiplications; - unsigned int uiIntAdditions; - unsigned int uiIntMultiplications; - unsigned int uiAssignments; - unsigned int uiBoolOp; - unsigned int uiMrdDA; - unsigned int uiMrdDM; - unsigned int uiMrdIA; - unsigned int uiMrdIM; - unsigned int uiMrdAssign; - unsigned int uiMrdBO; -}; - -class ExpenseLog -{ -public: - ExpenseLog(void); - ~ExpenseLog(void); - - ExpenseModule* AddModule(const char* name); - void PrintAll(FILE *file=stdout); - void ClearAll(); -protected: - vector vModules; -}; - - +#pragma once +#include +#include +#include + +using namespace std; + +#define EXPENSE_LOG 0 +#define MRD 1000000000 + +#if EXPENSE_LOG==1 + +#define EXPENSE_DEFINE \ +ExpenseLog EL; \ +ExpenseModule* EngineExpense=EL.AddModule("Static Engine Expenses"); \ +ExpenseModule* PPExpense=EL.AddModule("Static Post Processing"); \ +ExpenseModule* AdrOpExpense=EL.AddModule("Adress Operator"); +#define EXTERN_EXPENSE_DEFINE extern ExpenseLog EL; +#define ENGINEEXPENSE_DEFINE extern ExpenseModule* EngineExpense; +#define POSTPROCEXPENSE_DEFINE extern ExpenseModule* PPExpense; +#define ADREXPENSE_DEFINE extern ExpenseModule* AdrOpExpense; +#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO) EngineExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO)); +#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO) PPExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO)); +#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO) AdrOpExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO)); +#define EXPENSEPRINT EL.PrintAll(stderr); +#define EXPENSECLEAR EL.ClearAll(); +#else + +#define EXPENSE_DEFINE +#define EXTERN_EXPENSE_DEFINE +#define ENGINEEXPENSE_DEFINE +#define POSTPROCEXPENSE_DEFINE +#define ADREXPENSE_DEFINE +#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO) +#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO) +#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO) +#define EXPENSEPRINT +#define EXPENSECLEAR +#endif + +class ExpenseModule +{ +friend class ExpenseLog; +public: + ExpenseModule(const char* moduleName); + ~ExpenseModule(); + + void Clear(); + + void AddDoubleAdditons(unsigned int number); + void AddDoubleMultiplications(unsigned int number); + + void AddIntAdditons(unsigned int number); + void AddIntMultiplications(unsigned int number); + + void AddAssignments(unsigned int number); + void AddBoolOperations(unsigned int number); + + void AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp); + + void PrintfSelf(FILE* file=stdout); + +protected: + const char* chModuleName; + unsigned int uiDoubleAdditions; + unsigned int uiDoubleMultiplications; + unsigned int uiIntAdditions; + unsigned int uiIntMultiplications; + unsigned int uiAssignments; + unsigned int uiBoolOp; + unsigned int uiMrdDA; + unsigned int uiMrdDM; + unsigned int uiMrdIA; + unsigned int uiMrdIM; + unsigned int uiMrdAssign; + unsigned int uiMrdBO; +}; + +class ExpenseLog +{ +public: + ExpenseLog(void); + ~ExpenseLog(void); + + ExpenseModule* AddModule(const char* name); + void PrintAll(FILE *file=stdout); + void ClearAll(); +protected: + vector vModules; +}; + +