Changeset 63b9f7


Ignore:
Timestamp:
Dec 19, 2012, 3:25:31 PM (12 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
371c8b
Parents:
76e63d
git-author:
Frederik Heber <heber@…> (10/07/12 15:24:51)
git-committer:
Frederik Heber <heber@…> (12/19/12 15:25:31)
Message:

REFACTOR: Split off prepareModel() and prepareOutput() from FunctionApproximatio::operator().

Location:
src/FunctionApproximation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/FunctionApproximation/FunctionApproximation.cpp

    r76e63d r63b9f7  
    112112}
    113113
    114 
    115 void FunctionApproximation::operator()(const enum JacobianMode mode)
    116 {
    117   // let levmar optimize
    118   register int i, j;
    119   int ret;
    120   double *p;
    121   double *x; // we set zero vector by giving NULL
    122   int m, n;
    123   double opts[LM_OPTS_SZ], info[LM_INFO_SZ];
    124 
    125   opts[0]=LM_INIT_MU; opts[1]=1E-15; opts[2]=1E-15; opts[3]=1E-20;
    126   opts[4]= LM_DIFF_DELTA; // relevant only if the Jacobian is approximated using finite differences; specifies forward differencing
    127   //opts[4]=-LM_DIFF_DELTA; // specifies central differencing to approximate Jacobian; more accurate but more expensive to compute!
    128 
     114void FunctionApproximation::prepareParameters(double *&p, int &m) const
     115{
    129116  m = model.getParameterDimension();
    130   n = output_data.size();
    131117  const FunctionModel::parameters_t params = model.getParameters();
    132118  {
     
    139125    }
    140126  }
     127}
     128
     129void FunctionApproximation::prepareOutput(double *&x, int &n) const
     130{
     131  n = output_data.size();
    141132  {
    142133    x = new double[n];
     
    148139    }
    149140  }
     141}
     142
     143void FunctionApproximation::operator()(const enum JacobianMode mode)
     144{
     145  // let levmar optimize
     146  register int i, j;
     147  int ret;
     148  double *p;
     149  double *x;
     150  int m, n;
     151  double opts[LM_OPTS_SZ], info[LM_INFO_SZ];
     152
     153  opts[0]=LM_INIT_MU; opts[1]=1E-15; opts[2]=1E-15; opts[3]=1E-20;
     154  opts[4]= LM_DIFF_DELTA; // relevant only if the Jacobian is approximated using finite differences; specifies forward differencing
     155  //opts[4]=-LM_DIFF_DELTA; // specifies central differencing to approximate Jacobian; more accurate but more expensive to compute!
     156
     157  prepareParameters(p,m);
     158  prepareOutput(x,n);
    150159
    151160  {
  • src/FunctionApproximation/FunctionApproximation.hpp

    r76e63d r63b9f7  
    135135  void prepareModel(double *p, int m);
    136136
     137  void prepareParameters(double *&p, int &m) const;
     138
     139  void prepareOutput(double *&x, int &n) const;
     140
    137141private:
    138142  //!> input dimension (is fixed from construction)
Note: See TracChangeset for help on using the changeset viewer.