Jpp  18.4.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEigenValues2D.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 JGEOMETRY2D::JVector2D& 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  << ")";
32 
33  return out;
34  }
35 }
36 
37 
38 /**
39  * \file
40  *
41  * Example program to print eigen values in 2D.
42  * \author mdejong
43  */
44 int main(int argc, char **argv)
45 {
46  using namespace std;
47  using namespace JPP;
48 
49  string inputFile;
50  int debug;
51 
52  try {
53 
54  JParser<> zap("Example program to print eigen values in 2D.");
55 
56  zap['f'] = make_field(inputFile);
57  zap['d'] = make_field(debug) = 1;
58 
59  zap(argc, argv);
60  }
61  catch(const exception& error) {
62  FATAL(error.what() << endl);
63  }
64 
65 
66  vector<JVector2D> buffer;
67 
68  if (inputFile != "") {
69 
70  ifstream in(inputFile.c_str());
71 
72  for (double x, y; in >> x >> y; ) {
73 
74  buffer.push_back(JVector2D(x,y));
75  }
76 
77  in.close();
78  }
79 
80  const JEigenValues2D eigen(buffer.begin(), buffer.end());
81 
82  for (JEigenValues2D::const_iterator i = eigen.begin(); i != eigen.end(); ++i) {
83  cout << FIXED(7,3) << i->first << ' ' << i->second << endl;
84  }
85 }
Data structure for vector in two dimensions.
Definition: JVector2D.hh:32
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
double getY() const
Get y position.
Definition: JVector2D.hh:74
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
double getX() const
Get x position.
Definition: JVector2D.hh:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] 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.
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
int debug
debug level