Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEigenValues3D.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <fstream>
4 #include <iomanip>
5 #include <vector>
6 
9 
10 #include "Jeep/JPrint.hh"
11 #include "Jeep/JParser.hh"
12 #include "Jeep/JMessage.hh"
13 
14 namespace {
15 
16  /**
17  * Write vector to output stream.
18  *
19  * \param out output stream
20  * \param vector vector
21  * \return output stream
22  */
23  inline std::ostream& operator<<(std::ostream& out, const JGEOMETRY3D::JVector3D& vector)
24  {
25  using namespace std;
26  using namespace JPP;
27 
28  out << "("
29  << FIXED(7,3) << vector.getX() << ", "
30  << FIXED(7,3) << vector.getY() << ", "
31  << FIXED(7,3) << vector.getZ()
32  << ")";
33 
34  return out;
35  }
36 }
37 
38 
39 /**
40  * \file
41  *
42  * Example program to print eigen values in 3D.
43  * \author mdejong
44  */
45 int main(int argc, char **argv)
46 {
47  using namespace std;
48  using namespace JPP;
49 
50  string inputFile;
51  int debug;
52 
53  try {
54 
55  JParser<> zap("Example program to print eigen values in 3D.");
56 
57  zap['f'] = make_field(inputFile);
58  zap['d'] = make_field(debug) = 1;
59 
60  zap(argc, argv);
61  }
62  catch(const exception& error) {
63  FATAL(error.what() << endl);
64  }
65 
66 
67  vector<JVector3D> buffer;
68 
69  if (inputFile != "") {
70 
71  ifstream in(inputFile.c_str());
72 
73  for (double x, y, z; in >> x >> y >> z; ) {
74 
75  buffer.push_back(JVector3D(x,y,z));
76  }
77 
78  in.close();
79  }
80 
81  const JEigenValues3D eigen(buffer.begin(), buffer.end());
82 
83  for (JEigenValues3D::const_iterator i = eigen.begin(); i != eigen.end(); ++i) {
84  cout << FIXED(7,3) << i->first << ' ' << i->second << endl;
85  }
86 }
Utility class to parse command line options.
Definition: JParser.hh:1711
int main(int argc, char *argv[])
Definition: Main.cc:15
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
I/O formatting auxiliaries.
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
double getY() const
Get y position.
Definition: JVector3D.hh:104
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Utility class to parse command line options.
double getX() const
Get x position.
Definition: JVector3D.hh:94
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
double getZ() const
Get z position.
Definition: JVector3D.hh:115
int debug
debug level