Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / performance-tests / RTEvent / Colocated_Roundtrip / compare_histo.cpp
blob0931ba606b01cd28674979701855c4af899b7ee1
1 /**
2 * @file compare_histo.cpp
3 */
5 #include <utility>
6 #include <iostream>
7 #include <fstream>
8 #include <algorithm>
9 #include <iterator>
10 #include <map>
12 typedef std::map<long,double> Vector;
13 typedef std::pair<long,double> Element;
15 std::ostream &
16 operator<< (std::ostream &os,
17 const Vector::value_type &p)
19 return os << p.first << " " << p.second;
23 void
24 load_file (Vector &vector,
25 const char *filename)
27 std::ifstream is (filename);
28 if (!is)
29 throw "Cannot open file";
31 while (is && !is.eof ())
33 long i; double v;
34 is >> i >> v;
35 Vector::value_type e (i, v);
36 vector.insert (e);
40 int
41 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
43 Vector X;
44 load_file (X, argv[1]);
45 Vector Y;
46 load_file (Y, argv[2]);
48 Vector Z;
49 for (Vector::iterator i = X.begin (); i != X.end (); ++i) {
50 for (Vector::iterator j = Y.begin (); j != Y.end (); ++j) {
51 long ki = (*i).first - (*j).first;
52 double p = (*i).second * (*j).second;
54 Vector::iterator k = Z.find (ki);
55 if (k == Z.end ())
56 Z.insert (Element (ki, p));
57 else
58 Z[ki] += p;
62 for (Vector::iterator i = Z.begin (); i != Z.end (); ++i)
64 std::cout << (*i) << "\n";
67 return 0;