From 8535e73333494b3af121ac8c0426b6c782b9ddab Mon Sep 17 00:00:00 2001 From: pospelov <pospelov@fz-juelich.de> Date: Fri, 14 Sep 2012 10:20:50 +0200 Subject: [PATCH] Performance: const cvektor in evaluate_q --- .../inc/DecouplingApproximationStrategy.h | 2 +- .../inc/IInterferenceFunctionStrategy.h | 2 +- .../LocalMonodisperseApproximationStrategy.h | 2 +- .../inc/MultiLayerRoughnessDWBASimulation.h | 4 +-- .../src/DecouplingApproximationStrategy.cpp | 4 +-- .../src/LayerDecoratorDWBASimulation.cpp | 2 +- ...LocalMonodisperseApproximationStrategy.cpp | 2 +- .../src/MultiLayerRoughnessDWBASimulation.cpp | 4 +-- Core/FormFactors/inc/FormFactorCrystal.h | 2 +- Core/FormFactors/inc/FormFactorCylinder.h | 2 +- .../inc/FormFactorDecoratorPositionFactor.h | 6 ++-- Core/FormFactors/inc/FormFactorFullSphere.h | 2 +- Core/FormFactors/inc/FormFactorGauss.h | 2 +- Core/FormFactors/inc/FormFactorLorentz.h | 2 +- Core/FormFactors/inc/FormFactorPrism3.h | 2 +- Core/FormFactors/inc/FormFactorPyramid.h | 2 +- .../inc/FormFactorSphereGaussianRadius.h | 4 +-- Core/FormFactors/inc/IFormFactor.h | 2 +- Core/FormFactors/src/FormFactorCrystal.cpp | 2 +- Core/FormFactors/src/FormFactorCylinder.cpp | 2 +- Core/FormFactors/src/FormFactorFullSphere.cpp | 2 +- Core/FormFactors/src/FormFactorGauss.cpp | 2 +- Core/FormFactors/src/FormFactorLorentz.cpp | 2 +- Core/FormFactors/src/FormFactorPrism3.cpp | 2 +- Core/FormFactors/src/FormFactorPyramid.cpp | 2 +- .../src/PythonInterface_classes_1.cpp | 6 ++-- .../src/PythonInterface_classes_3.cpp | 34 +++++++++---------- Core/Samples/inc/IInterferenceFunction.h | 2 +- .../inc/InterferenceFunction1DParaCrystal.h | 2 +- Core/Samples/inc/InterferenceFunctionNone.h | 2 +- Core/Samples/src/Crystal.cpp | 4 ++- .../src/InterferenceFunction1DParaCrystal.cpp | 2 +- Examples/Performance/perf_history.txt | 11 +++++- shared.pri | 2 +- 34 files changed, 69 insertions(+), 58 deletions(-) diff --git a/Core/Algorithms/inc/DecouplingApproximationStrategy.h b/Core/Algorithms/inc/DecouplingApproximationStrategy.h index 2a340db76dc..665720c9d9c 100644 --- a/Core/Algorithms/inc/DecouplingApproximationStrategy.h +++ b/Core/Algorithms/inc/DecouplingApproximationStrategy.h @@ -26,7 +26,7 @@ public: virtual void init(const std::vector<IFormFactor *> &form_factors, const std::vector<double> &fractions, const std::vector<IInterferenceFunction *> &interference_functions); - virtual double evaluate(cvector_t k_i, cvector_t k_f, + virtual double evaluate(const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) const; private: bool checkVectorSizes(); diff --git a/Core/Algorithms/inc/IInterferenceFunctionStrategy.h b/Core/Algorithms/inc/IInterferenceFunctionStrategy.h index 333b8325f86..8d145c3f264 100644 --- a/Core/Algorithms/inc/IInterferenceFunctionStrategy.h +++ b/Core/Algorithms/inc/IInterferenceFunctionStrategy.h @@ -27,7 +27,7 @@ public: virtual void init(const std::vector<IFormFactor *> &form_factors, const std::vector<double> &fractions, const std::vector<IInterferenceFunction *> &interference_functions); - virtual double evaluate(cvector_t k_i, cvector_t k_f, + virtual double evaluate(const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) const=0; // virtual double evaluateForComplexkz(kvector_t k_i, kvector_t k_f, // complex_t k_iz, complex_t k_fz) const=0; diff --git a/Core/Algorithms/inc/LocalMonodisperseApproximationStrategy.h b/Core/Algorithms/inc/LocalMonodisperseApproximationStrategy.h index 7f52dd520de..723cc78b5e8 100644 --- a/Core/Algorithms/inc/LocalMonodisperseApproximationStrategy.h +++ b/Core/Algorithms/inc/LocalMonodisperseApproximationStrategy.h @@ -25,7 +25,7 @@ public: virtual void init(const std::vector<IFormFactor *> &form_factors, const std::vector<double> &fractions, const std::vector<IInterferenceFunction *> &interference_functions); - virtual double evaluate(cvector_t k_i, cvector_t k_f, + virtual double evaluate(const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) const; private: bool checkVectorSizes(); diff --git a/Core/Algorithms/inc/MultiLayerRoughnessDWBASimulation.h b/Core/Algorithms/inc/MultiLayerRoughnessDWBASimulation.h index d49d5161e38..11f33c9eb8b 100644 --- a/Core/Algorithms/inc/MultiLayerRoughnessDWBASimulation.h +++ b/Core/Algorithms/inc/MultiLayerRoughnessDWBASimulation.h @@ -36,14 +36,14 @@ public: void setTAndRFunctions(int i, const IDoubleToComplexFunction &T_function, const IDoubleToComplexFunction &R_function); // evaluate - virtual double evaluate(cvector_t k_i, cvector_t k_f, double alpha_i, double alpha_f); + virtual double evaluate(const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f); protected: MultiLayerRoughnessDWBASimulation(const MultiLayerRoughnessDWBASimulation &); MultiLayerRoughnessDWBASimulation &operator=(const MultiLayerRoughnessDWBASimulation &); complex_t get_refractive_term(int ilayer); - complex_t get_sum4terms(int ilayer, cvector_t k_i, cvector_t k_f, double alpha_i, double alpha_f); + complex_t get_sum4terms(int ilayer, const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f); std::vector<IDoubleToComplexFunction *> mp_T_function; std::vector<IDoubleToComplexFunction *> mp_R_function; diff --git a/Core/Algorithms/src/DecouplingApproximationStrategy.cpp b/Core/Algorithms/src/DecouplingApproximationStrategy.cpp index b88ff5faa86..806bfa1fc89 100644 --- a/Core/Algorithms/src/DecouplingApproximationStrategy.cpp +++ b/Core/Algorithms/src/DecouplingApproximationStrategy.cpp @@ -16,8 +16,8 @@ void DecouplingApproximationStrategy::init( } } -double DecouplingApproximationStrategy::evaluate(cvector_t k_i, - cvector_t k_f, double alpha_i, double alpha_f) const +double DecouplingApproximationStrategy::evaluate(const cvector_t &k_i, + const cvector_t &k_f, double alpha_i, double alpha_f) const { double intensity = 0.0; complex_t amplitude = complex_t(0.0, 0.0); diff --git a/Core/Algorithms/src/LayerDecoratorDWBASimulation.cpp b/Core/Algorithms/src/LayerDecoratorDWBASimulation.cpp index 92ac5b50186..213261389c4 100644 --- a/Core/Algorithms/src/LayerDecoratorDWBASimulation.cpp +++ b/Core/Algorithms/src/LayerDecoratorDWBASimulation.cpp @@ -31,7 +31,7 @@ void LayerDecoratorDWBASimulation::run() IInterferenceFunctionStrategy *p_strategy = createAndInitStrategy(); calculateCoherentIntensity(p_strategy); - calculateInCoherentIntensity(); + //calculateInCoherentIntensity(); delete p_strategy; diff --git a/Core/Algorithms/src/LocalMonodisperseApproximationStrategy.cpp b/Core/Algorithms/src/LocalMonodisperseApproximationStrategy.cpp index 24343b23a2f..eedea35b345 100644 --- a/Core/Algorithms/src/LocalMonodisperseApproximationStrategy.cpp +++ b/Core/Algorithms/src/LocalMonodisperseApproximationStrategy.cpp @@ -17,7 +17,7 @@ void LocalMonodisperseApproximationStrategy::init( } double LocalMonodisperseApproximationStrategy::evaluate( - cvector_t k_i, cvector_t k_f, double alpha_i, double alpha_f) const + const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) const { double intensity = 0.0; for (size_t i=0; i<m_form_factors.size(); ++i) { diff --git a/Core/Algorithms/src/MultiLayerRoughnessDWBASimulation.cpp b/Core/Algorithms/src/MultiLayerRoughnessDWBASimulation.cpp index 8684d149d7d..3832a8495e6 100644 --- a/Core/Algorithms/src/MultiLayerRoughnessDWBASimulation.cpp +++ b/Core/Algorithms/src/MultiLayerRoughnessDWBASimulation.cpp @@ -50,7 +50,7 @@ void MultiLayerRoughnessDWBASimulation::run() } -double MultiLayerRoughnessDWBASimulation::evaluate(cvector_t k_i, cvector_t k_f, +double MultiLayerRoughnessDWBASimulation::evaluate(const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) { kvector_t ki_real(k_i.x().real(), k_i.y().real(), k_i.z().real()); @@ -103,7 +103,7 @@ complex_t MultiLayerRoughnessDWBASimulation::get_refractive_term(int ilayer) -complex_t MultiLayerRoughnessDWBASimulation::get_sum4terms(int ilayer, cvector_t k_i, cvector_t k_f, +complex_t MultiLayerRoughnessDWBASimulation::get_sum4terms(int ilayer, const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) { complex_t qz1 = k_i.z() + k_f.z(); diff --git a/Core/FormFactors/inc/FormFactorCrystal.h b/Core/FormFactors/inc/FormFactorCrystal.h index 6c47d05d9fc..22b490adb91 100644 --- a/Core/FormFactors/inc/FormFactorCrystal.h +++ b/Core/FormFactors/inc/FormFactorCrystal.h @@ -34,7 +34,7 @@ public: virtual void setAmbientRefractiveIndex(complex_t refractive_index); protected: - virtual complex_t evaluate_for_q(cvector_t q) const; + virtual complex_t evaluate_for_q(const cvector_t &q) const; private: void calculateLargestReciprocalDistance(); Lattice m_lattice; diff --git a/Core/FormFactors/inc/FormFactorCylinder.h b/Core/FormFactors/inc/FormFactorCylinder.h index fd9dff26ff7..b83b8057c68 100644 --- a/Core/FormFactors/inc/FormFactorCylinder.h +++ b/Core/FormFactors/inc/FormFactorCylinder.h @@ -29,7 +29,7 @@ public: virtual int getNumberOfStochasticParameters() { return 2; } protected: - virtual complex_t evaluate_for_q(cvector_t q) const; + virtual complex_t evaluate_for_q(const cvector_t &q) const; private: //! copy constructor and assignment operator are hidden since there is a clone method diff --git a/Core/FormFactors/inc/FormFactorDecoratorPositionFactor.h b/Core/FormFactors/inc/FormFactorDecoratorPositionFactor.h index 6aeeb57213d..0ac0ca8a757 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorPositionFactor.h +++ b/Core/FormFactors/inc/FormFactorDecoratorPositionFactor.h @@ -27,7 +27,7 @@ public: virtual ~FormFactorDecoratorPositionFactor() {} virtual FormFactorDecoratorPositionFactor *clone() const; - virtual complex_t evaluate(cvector_t k_i, cvector_t k_f, double alpha_i, double alpha_f) const; + virtual complex_t evaluate(const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) const; virtual int getNumberOfStochasticParameters() const { return mp_form_factor->getNumberOfStochasticParameters(); @@ -48,8 +48,8 @@ inline FormFactorDecoratorPositionFactor* FormFactorDecoratorPositionFactor::clo return new FormFactorDecoratorPositionFactor(*mp_form_factor, m_position); } -inline complex_t FormFactorDecoratorPositionFactor::evaluate(cvector_t k_i, - cvector_t k_f, double alpha_i, double alpha_f) const +inline complex_t FormFactorDecoratorPositionFactor::evaluate(const cvector_t &k_i, + const cvector_t &k_f, double alpha_i, double alpha_f) const { cvector_t q = k_i - k_f; complex_t qr = q.x()*m_position.x() + q.y()*m_position.y() + q.z()*m_position.z(); diff --git a/Core/FormFactors/inc/FormFactorFullSphere.h b/Core/FormFactors/inc/FormFactorFullSphere.h index 5261d3588be..63c784c80b9 100644 --- a/Core/FormFactors/inc/FormFactorFullSphere.h +++ b/Core/FormFactors/inc/FormFactorFullSphere.h @@ -31,7 +31,7 @@ public: double getRadius() const { return m_radius; } protected: - virtual complex_t evaluate_for_q(cvector_t q) const; + virtual complex_t evaluate_for_q(const cvector_t &q) const; private: diff --git a/Core/FormFactors/inc/FormFactorGauss.h b/Core/FormFactors/inc/FormFactorGauss.h index 3f5edfa604c..da29ddaf30c 100644 --- a/Core/FormFactors/inc/FormFactorGauss.h +++ b/Core/FormFactors/inc/FormFactorGauss.h @@ -29,7 +29,7 @@ public: virtual int getNumberOfStochasticParameters() { return 2; } protected: - virtual complex_t evaluate_for_q(cvector_t q) const; + virtual complex_t evaluate_for_q(const cvector_t &q) const; private: //! copy constructor and assignment operator are hidden since there is a clone method diff --git a/Core/FormFactors/inc/FormFactorLorentz.h b/Core/FormFactors/inc/FormFactorLorentz.h index f29f8f735b5..5a33743c719 100644 --- a/Core/FormFactors/inc/FormFactorLorentz.h +++ b/Core/FormFactors/inc/FormFactorLorentz.h @@ -29,7 +29,7 @@ public: virtual int getNumberOfStochasticParameters() { return 2; } protected: - virtual complex_t evaluate_for_q(cvector_t q) const; + virtual complex_t evaluate_for_q(const cvector_t &q) const; private: //! copy constructor and assignment operator are hidden since there is a clone method diff --git a/Core/FormFactors/inc/FormFactorPrism3.h b/Core/FormFactors/inc/FormFactorPrism3.h index 75528585f16..24054de2c93 100644 --- a/Core/FormFactors/inc/FormFactorPrism3.h +++ b/Core/FormFactors/inc/FormFactorPrism3.h @@ -29,7 +29,7 @@ public: virtual int getNumberOfStochasticParameters() { return 2; } protected: - virtual complex_t evaluate_for_q(cvector_t q) const; + virtual complex_t evaluate_for_q(const cvector_t &q) const; private: //! copy constructor and assignment operator are hidden since there is a clone method diff --git a/Core/FormFactors/inc/FormFactorPyramid.h b/Core/FormFactors/inc/FormFactorPyramid.h index 4aa70244068..129d8f9b219 100644 --- a/Core/FormFactors/inc/FormFactorPyramid.h +++ b/Core/FormFactors/inc/FormFactorPyramid.h @@ -37,7 +37,7 @@ public: virtual int getNumberOfStochasticParameters() { return 3; } protected: - virtual complex_t evaluate_for_q(cvector_t q) const; + virtual complex_t evaluate_for_q(const cvector_t &q) const; private: //! copy constructor and assignment operator are hidden since there is a clone method diff --git a/Core/FormFactors/inc/FormFactorSphereGaussianRadius.h b/Core/FormFactors/inc/FormFactorSphereGaussianRadius.h index 9239bdb05d8..938c605271f 100644 --- a/Core/FormFactors/inc/FormFactorSphereGaussianRadius.h +++ b/Core/FormFactors/inc/FormFactorSphereGaussianRadius.h @@ -23,7 +23,7 @@ public: virtual int getNumberOfStochasticParameters() const; protected: - virtual complex_t evaluate_for_q(cvector_t q) const; + virtual complex_t evaluate_for_q(const cvector_t &q) const; private: double calculateMeanR3() const; double m_mean; //!< This is the mean radius @@ -58,7 +58,7 @@ inline int FormFactorSphereGaussianRadius::getNumberOfStochasticParameters() con return 2; } -inline complex_t FormFactorSphereGaussianRadius::evaluate_for_q(cvector_t q) const +inline complex_t FormFactorSphereGaussianRadius::evaluate_for_q(const cvector_t &q) const { double q2 = std::norm(q.x()) + std::norm(q.y()) + std::norm(q.z()); double dw = std::exp(-q2*m_sigma*m_sigma/2.0); diff --git a/Core/FormFactors/inc/IFormFactor.h b/Core/FormFactors/inc/IFormFactor.h index 0795c775a99..ac21c1b0945 100644 --- a/Core/FormFactors/inc/IFormFactor.h +++ b/Core/FormFactors/inc/IFormFactor.h @@ -77,7 +77,7 @@ public: protected: /// evaluate scattering amplitude for complex wavevector /// @param q wavevector transfer \f$q\equiv k_i-k_f\f$ - virtual complex_t evaluate_for_q(cvector_t q) const=0; + virtual complex_t evaluate_for_q(const cvector_t &q) const=0; }; inline complex_t IFormFactorBorn::evaluate(const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) const diff --git a/Core/FormFactors/src/FormFactorCrystal.cpp b/Core/FormFactors/src/FormFactorCrystal.cpp index 764bc563563..9617255590e 100644 --- a/Core/FormFactors/src/FormFactorCrystal.cpp +++ b/Core/FormFactors/src/FormFactorCrystal.cpp @@ -38,7 +38,7 @@ void FormFactorCrystal::setAmbientRefractiveIndex( mp_basis_form_factor->setAmbientRefractiveIndex(refractive_index); } -complex_t FormFactorCrystal::evaluate_for_q(cvector_t q) const +complex_t FormFactorCrystal::evaluate_for_q(const cvector_t &q) const { // construct a real reciprocal vector kvector_t q_real(q.x().real(), q.y().real(), q.z().real()); diff --git a/Core/FormFactors/src/FormFactorCylinder.cpp b/Core/FormFactors/src/FormFactorCylinder.cpp index 86824b4714b..69ddd7094bb 100644 --- a/Core/FormFactors/src/FormFactorCylinder.cpp +++ b/Core/FormFactors/src/FormFactorCylinder.cpp @@ -44,7 +44,7 @@ FormFactorCylinder* FormFactorCylinder::clone() const // return new FormFactorCylinder(mp_height->clone(), mp_radius->clone()); } -complex_t FormFactorCylinder::evaluate_for_q(cvector_t q) const +complex_t FormFactorCylinder::evaluate_for_q(const cvector_t &q) const { // double R = mp_radius->getCurrent(); // double H = mp_height->getCurrent(); diff --git a/Core/FormFactors/src/FormFactorFullSphere.cpp b/Core/FormFactors/src/FormFactorFullSphere.cpp index f1e1c3c0ca8..12823d1312e 100644 --- a/Core/FormFactors/src/FormFactorFullSphere.cpp +++ b/Core/FormFactors/src/FormFactorFullSphere.cpp @@ -38,7 +38,7 @@ FormFactorFullSphere* FormFactorFullSphere::clone() const // return new FormFactorFullSphere(mp_radius->clone()); } -complex_t FormFactorFullSphere::evaluate_for_q(cvector_t q) const +complex_t FormFactorFullSphere::evaluate_for_q(const cvector_t &q) const { // double R = mp_radius->getCurrent(); complex_t qz = q.z(); diff --git a/Core/FormFactors/src/FormFactorGauss.cpp b/Core/FormFactors/src/FormFactorGauss.cpp index d21215a77c5..a1db00a1818 100644 --- a/Core/FormFactors/src/FormFactorGauss.cpp +++ b/Core/FormFactors/src/FormFactorGauss.cpp @@ -54,7 +54,7 @@ FormFactorGauss* FormFactorGauss::clone() const // return new FormFactorGauss(mp_height->clone(), mp_radius->clone()); } -complex_t FormFactorGauss::evaluate_for_q(cvector_t q) const +complex_t FormFactorGauss::evaluate_for_q(const cvector_t &q) const { // double R = mp_width->getCurrent(); // double H = mp_height->getCurrent(); diff --git a/Core/FormFactors/src/FormFactorLorentz.cpp b/Core/FormFactors/src/FormFactorLorentz.cpp index 25612178869..2770146df3f 100644 --- a/Core/FormFactors/src/FormFactorLorentz.cpp +++ b/Core/FormFactors/src/FormFactorLorentz.cpp @@ -54,7 +54,7 @@ FormFactorLorentz* FormFactorLorentz::clone() const // return new FormFactorLorentz(mp_height->clone(), mp_radius->clone()); } -complex_t FormFactorLorentz::evaluate_for_q(cvector_t q) const +complex_t FormFactorLorentz::evaluate_for_q(const cvector_t &q) const { // double R = mp_radius->getCurrent(); // double H = mp_height->getCurrent(); diff --git a/Core/FormFactors/src/FormFactorPrism3.cpp b/Core/FormFactors/src/FormFactorPrism3.cpp index 8cfe79602e3..3974e75af22 100644 --- a/Core/FormFactors/src/FormFactorPrism3.cpp +++ b/Core/FormFactors/src/FormFactorPrism3.cpp @@ -45,7 +45,7 @@ FormFactorPrism3* FormFactorPrism3::clone() const // return new FormFactorPrism3(mp_height->clone(), mp_half_side->clone()); } -complex_t FormFactorPrism3::evaluate_for_q(cvector_t q) const +complex_t FormFactorPrism3::evaluate_for_q(const cvector_t &q) const { // double R = mp_half_side->getCurrent(); // double H = mp_height->getCurrent(); diff --git a/Core/FormFactors/src/FormFactorPyramid.cpp b/Core/FormFactors/src/FormFactorPyramid.cpp index 8242619e66c..2359d39cd8a 100644 --- a/Core/FormFactors/src/FormFactorPyramid.cpp +++ b/Core/FormFactors/src/FormFactorPyramid.cpp @@ -51,7 +51,7 @@ FormFactorPyramid* FormFactorPyramid::clone() const // return new FormFactorPyramid(mp_height->clone(), mp_half_side->clone(), mp_alpha->clone()); } -complex_t FormFactorPyramid::evaluate_for_q(cvector_t q) const +complex_t FormFactorPyramid::evaluate_for_q(const cvector_t &q) const { // double H = mp_height->getCurrent(); // double R = mp_half_side->getCurrent(); diff --git a/Core/PythonAPI/src/PythonInterface_classes_1.cpp b/Core/PythonAPI/src/PythonInterface_classes_1.cpp index daa9bbf1894..90c71f278be 100644 --- a/Core/PythonAPI/src/PythonInterface_classes_1.cpp +++ b/Core/PythonAPI/src/PythonInterface_classes_1.cpp @@ -446,9 +446,9 @@ struct IFormFactorBorn_wrapper : IFormFactorBorn, bp::wrapper< IFormFactorBorn > return IFormFactorBorn::evaluate( boost::ref(k_i), boost::ref(k_f), alpha_i, alpha_f ); } - virtual ::complex_t evaluate_for_q( ::cvector_t q ) const { + virtual ::complex_t evaluate_for_q( ::cvector_t const & q ) const { bp::override func_evaluate_for_q = this->get_override( "evaluate_for_q" ); - return func_evaluate_for_q( q ); + return func_evaluate_for_q( boost::ref(q) ); } virtual ::ParameterPool * createParameterTree( ) { @@ -1545,7 +1545,7 @@ void register_classes_1(){ , ( bp::arg("k_i"), bp::arg("k_f"), bp::arg("alpha_i"), bp::arg("alpha_f") ) ) .def( "evaluate_for_q" - , (::complex_t ( IFormFactorBorn_wrapper::* )( ::cvector_t ) const)(&IFormFactorBorn_wrapper::evaluate_for_q) + , (::complex_t ( IFormFactorBorn_wrapper::* )( ::cvector_t const & ) const)(&IFormFactorBorn_wrapper::evaluate_for_q) , ( bp::arg("q") ) ) .def( "createParameterTree" diff --git a/Core/PythonAPI/src/PythonInterface_classes_3.cpp b/Core/PythonAPI/src/PythonInterface_classes_3.cpp index 50f1f60c280..2511355a76e 100644 --- a/Core/PythonAPI/src/PythonInterface_classes_3.cpp +++ b/Core/PythonAPI/src/PythonInterface_classes_3.cpp @@ -131,9 +131,9 @@ struct IInterferenceFunction_wrapper : IInterferenceFunction, bp::wrapper< IInte return func_clone( ); } - virtual double evaluate( ::cvector_t q ) const { + virtual double evaluate( ::cvector_t const & q ) const { bp::override func_evaluate = this->get_override( "evaluate" ); - return func_evaluate( q ); + return func_evaluate( boost::ref(q) ); } virtual ::ParameterPool * createParameterTree( ) { @@ -183,16 +183,16 @@ struct InterferenceFunction1DParaCrystal_wrapper : InterferenceFunction1DParaCry return InterferenceFunction1DParaCrystal::clone( ); } - virtual double evaluate( ::cvector_t q ) const { + virtual double evaluate( ::cvector_t const & q ) const { if( bp::override func_evaluate = this->get_override( "evaluate" ) ) - return func_evaluate( q ); + return func_evaluate( boost::ref(q) ); else{ - return this->InterferenceFunction1DParaCrystal::evaluate( q ); + return this->InterferenceFunction1DParaCrystal::evaluate( boost::ref(q) ); } } - double default_evaluate( ::cvector_t q ) const { - return InterferenceFunction1DParaCrystal::evaluate( q ); + double default_evaluate( ::cvector_t const & q ) const { + return InterferenceFunction1DParaCrystal::evaluate( boost::ref(q) ); } virtual ::ParameterPool * createParameterTree( ) { @@ -242,16 +242,16 @@ struct InterferenceFunctionNone_wrapper : InterferenceFunctionNone, bp::wrapper< return InterferenceFunctionNone::clone( ); } - virtual double evaluate( ::cvector_t q ) const { + virtual double evaluate( ::cvector_t const & q ) const { if( bp::override func_evaluate = this->get_override( "evaluate" ) ) - return func_evaluate( q ); + return func_evaluate( boost::ref(q) ); else{ - return this->InterferenceFunctionNone::evaluate( q ); + return this->InterferenceFunctionNone::evaluate( boost::ref(q) ); } } - double default_evaluate( ::cvector_t q ) const { - return InterferenceFunctionNone::evaluate( q ); + double default_evaluate( ::cvector_t const & q ) const { + return InterferenceFunctionNone::evaluate( boost::ref(q) ); } virtual ::ParameterPool * createParameterTree( ) { @@ -986,7 +986,7 @@ void register_classes_3(){ , bp::return_value_policy< bp::manage_new_object >() ) .def( "evaluate" - , bp::pure_virtual( (double ( ::IInterferenceFunction::* )( ::cvector_t ) const)(&::IInterferenceFunction::evaluate) ) + , bp::pure_virtual( (double ( ::IInterferenceFunction::* )( ::cvector_t const & ) const)(&::IInterferenceFunction::evaluate) ) , ( bp::arg("q") ) ) .def( "createParameterTree" @@ -1013,8 +1013,8 @@ void register_classes_3(){ , bp::return_value_policy< bp::manage_new_object >() ) .def( "evaluate" - , (double ( ::InterferenceFunction1DParaCrystal::* )( ::cvector_t ) const)(&::InterferenceFunction1DParaCrystal::evaluate) - , (double ( InterferenceFunction1DParaCrystal_wrapper::* )( ::cvector_t ) const)(&InterferenceFunction1DParaCrystal_wrapper::default_evaluate) + , (double ( ::InterferenceFunction1DParaCrystal::* )( ::cvector_t const & ) const)(&::InterferenceFunction1DParaCrystal::evaluate) + , (double ( InterferenceFunction1DParaCrystal_wrapper::* )( ::cvector_t const & ) const)(&InterferenceFunction1DParaCrystal_wrapper::default_evaluate) , ( bp::arg("q") ) ) .def( "createParameterTree" @@ -1034,8 +1034,8 @@ void register_classes_3(){ , bp::return_value_policy< bp::manage_new_object >() ) .def( "evaluate" - , (double ( ::InterferenceFunctionNone::* )( ::cvector_t ) const)(&::InterferenceFunctionNone::evaluate) - , (double ( InterferenceFunctionNone_wrapper::* )( ::cvector_t ) const)(&InterferenceFunctionNone_wrapper::default_evaluate) + , (double ( ::InterferenceFunctionNone::* )( ::cvector_t const & ) const)(&::InterferenceFunctionNone::evaluate) + , (double ( InterferenceFunctionNone_wrapper::* )( ::cvector_t const & ) const)(&InterferenceFunctionNone_wrapper::default_evaluate) , ( bp::arg("q") ) ) .def( "createParameterTree" diff --git a/Core/Samples/inc/IInterferenceFunction.h b/Core/Samples/inc/IInterferenceFunction.h index 6e7ccf54010..1ab59e7f314 100644 --- a/Core/Samples/inc/IInterferenceFunction.h +++ b/Core/Samples/inc/IInterferenceFunction.h @@ -22,7 +22,7 @@ class IInterferenceFunction : public ISample public: virtual ~IInterferenceFunction() {} - virtual double evaluate(cvector_t q) const=0; + virtual double evaluate(const cvector_t &q) const=0; virtual IInterferenceFunction *clone() const=0; }; diff --git a/Core/Samples/inc/InterferenceFunction1DParaCrystal.h b/Core/Samples/inc/InterferenceFunction1DParaCrystal.h index 9d701ed52cc..7f09ee323ad 100644 --- a/Core/Samples/inc/InterferenceFunction1DParaCrystal.h +++ b/Core/Samples/inc/InterferenceFunction1DParaCrystal.h @@ -25,7 +25,7 @@ public: return new InterferenceFunction1DParaCrystal(m_peak_distance, m_width, m_corr_length); } - virtual double evaluate(cvector_t q) const; + virtual double evaluate(const cvector_t &q) const; protected: double m_peak_distance; double m_width; diff --git a/Core/Samples/inc/InterferenceFunctionNone.h b/Core/Samples/inc/InterferenceFunctionNone.h index 460e62855e7..f0ace79950f 100644 --- a/Core/Samples/inc/InterferenceFunctionNone.h +++ b/Core/Samples/inc/InterferenceFunctionNone.h @@ -23,7 +23,7 @@ public: virtual ~InterferenceFunctionNone() {} virtual InterferenceFunctionNone *clone() const { return new InterferenceFunctionNone(); } - virtual double evaluate(cvector_t q) const { (void)q; return 1.0; } + virtual double evaluate(const cvector_t &q) const { (void)q; return 1.0; } private: //! copy constructor and assignment operator are hidden since there is a clone method diff --git a/Core/Samples/src/Crystal.cpp b/Core/Samples/src/Crystal.cpp index fbcaad8be7a..9967d7a3400 100644 --- a/Core/Samples/src/Crystal.cpp +++ b/Core/Samples/src/Crystal.cpp @@ -85,8 +85,10 @@ std::vector<DiffuseParticleInfo*>* Crystal::createDiffuseParticleInfo( for (size_t j=0; j<nbr_heights; ++j) { // double particle_depth = depth - height*MathFunctions::GenerateUniformRandom(); double particle_depth = depth - j*height/(nbr_heights-1); + Geometry::Transform3D *p_new_transform(0); + if(p_parent_transform) p_new_transform = new Geometry::Transform3D(*p_parent_transform); p_new_np_info = new DiffuseParticleInfo(particle.clone(), - new Geometry::Transform3D(*p_parent_transform), particle_depth, particle_weight); + p_new_transform, particle_depth, particle_weight); p_new_np_info->setNumberPerMeso(np_density*particle_weight); p_infos->push_back(p_new_np_info); } diff --git a/Core/Samples/src/InterferenceFunction1DParaCrystal.cpp b/Core/Samples/src/InterferenceFunction1DParaCrystal.cpp index 93b3e1634da..aa81769838a 100644 --- a/Core/Samples/src/InterferenceFunction1DParaCrystal.cpp +++ b/Core/Samples/src/InterferenceFunction1DParaCrystal.cpp @@ -23,7 +23,7 @@ void InterferenceFunction1DParaCrystal::init_parameters() } -double InterferenceFunction1DParaCrystal::evaluate(cvector_t q) const +double InterferenceFunction1DParaCrystal::evaluate(const cvector_t &q) const { double qpar = q.magxy().real(); complex_t p_transformed = FTGaussianCorrLength(qpar); diff --git a/Examples/Performance/perf_history.txt b/Examples/Performance/perf_history.txt index f804bf6b653..76dcf6b873b 100644 --- a/Examples/Performance/perf_history.txt +++ b/Examples/Performance/perf_history.txt @@ -51,9 +51,18 @@ # debug is off, current state of the art 2012-08-20 13:16:30 | jcnsopc73 | macosx64, 2800 MHz | 266667 | 13.1579 | 13.0719 | 0.93896 | -# after Walter's refactoring (debug=on) +# after Walter's refactoring +# (debug=on) 2012-09-13 10:43:41 | jcnsopc73 | macosx64, 2800 MHz | 80971.7 | 4.58716 | 3.83877 | 0.05608 | # (debug=off) 2012-09-13 17:19:44 | jcnsopc73 | macosx64, 2800 MHz | 259740 | 15.1515 | 14.5985 | 0.29585 | +# kvector, cvector to const_reference +2012-09-13 18:00:16 | jcnsopc73 | macosx64, 2800 MHz | 77519.4 | 4.5977 | 4.10678 | 0.07485 | +# (debug=off) +2012-09-14 10:06:30 | jcnsopc73 | macosx64, 2800 MHz | 266667 | 14.4928 | 14.7059 | 0.32733 | +2012-09-14 10:07:00 | jcnsopc73 | macosx64, 2800 MHz | 266667 | 15.0376 | 14.9254 | 0.32362 | +# (debug=on) +2012-09-14 10:11:13 | jcnsopc73 | macosx64, 2800 MHz | 75188 | 4.61894 | 4.17537 | 0.07581 | +2012-09-14 10:12:34 | jcnsopc73 | macosx64, 2800 MHz | 73529.4 | 4.68384 | 4.0568 | 0.07654 | diff --git a/shared.pri b/shared.pri index 946258a3b68..279688c7ecf 100644 --- a/shared.pri +++ b/shared.pri @@ -12,7 +12,7 @@ lessThan(QT_VERSION, 4.5) { #CONFIG += GPERFTOOLS # uncomment to compile in debug mode -#CONFIG += debug +CONFIG += debug # #QMAKE_STRIP=: -- GitLab