source: src/FunctionApproximation/writeDistanceEnergyTable.hpp@ 440ac3

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 440ac3 was 04cc7e, checked in by Frederik Heber <heber@…>, 12 years ago

Added pretty printer for distance-energy tables.

  • added TrainingData::getDistanceEnergyTable() for obtaining data in unified table.
  • added pretty printer writeDistanceEnergyTable() in header file in namespace _detail.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 * writeDistanceEnergyTable.hpp
3 *
4 * Created on: Nov 20, 2012
5 * Author: heber
6 */
7
8#ifndef WRITEDISTANCEENERGYTABLE_HPP_
9#define WRITEDISTANCEENERGYTABLE_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <vector>
18#include <sstream>
19#include <string>
20
21namespace _detail {
22
23 typedef std::vector<double> values_t;
24 typedef std::vector< values_t > DistanceEnergyTable_t;
25
26 /** Gets the number of column entries, i.e. number of rows.
27 *
28 * \note ASSERT's that all columns have equal number of entries
29 *
30 * @param table table to check
31 * @return number of column entries
32 */
33 const size_t checkNumberOfColumnEntries(const DistanceEnergyTable_t &table)
34 {
35 size_t index = table[0].size();
36 for (DistanceEnergyTable_t::const_iterator coliter = table.begin();
37 coliter != table.end(); ++coliter)
38 ASSERT( (*coliter).size() == index,
39 "writeDistanceEnergyTable() - mismatch in column sizes.");
40 return index;
41 }
42
43 /** Pretty prints the given distance-energy table.
44 *
45 * @param table table to print
46 * @return string containing pretty-printed table
47 */
48 const std::string writeDistanceEnergyTable(const DistanceEnergyTable_t &table)
49 {
50 std::stringstream returnstream;
51
52 if (table.size() > 0) {
53 /// check each column for equal number of entries
54 const size_t indices = checkNumberOfColumnEntries(table);
55
56 /// print header line
57 for (size_t index = 0; index < indices-1; ++index)
58 returnstream << "distance" << index+1 << "\t";
59 returnstream << "energy" << std::endl;
60
61 /// print each row
62 for (DistanceEnergyTable_t::const_iterator coliter = table.begin();
63 coliter != table.end(); ++coliter) {
64 for (DistanceEnergyTable_t::value_type::const_iterator rowiter = (*coliter).begin();
65 rowiter != (*coliter).end(); ++rowiter) {
66 returnstream << (*rowiter) << "\t";
67 }
68 returnstream << std::endl;
69 }
70 }
71
72 return returnstream.str();
73 }
74
75}; /* namespace _detail */
76
77#endif /* WRITEDISTANCEENERGYTABLE_HPP_ */
Note: See TracBrowser for help on using the repository browser.