2 * @file compare_histo.cpp
12 typedef std::map
<long,double> Vector
;
13 typedef std::pair
<long,double> Element
;
16 operator<< (std::ostream
&os
,
17 const Vector::value_type
&p
)
19 return os
<< p
.first
<< " " << p
.second
;
24 load_file (Vector
&vector
,
27 std::ifstream
is (filename
);
29 throw "Cannot open file";
31 while (is
&& !is
.eof ())
35 Vector::value_type
e (i
, v
);
41 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
44 load_file (X
, argv
[1]);
46 load_file (Y
, argv
[2]);
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
);
56 Z
.insert (Element (ki
, p
));
62 for (Vector::iterator i
= Z
.begin (); i
!= Z
.end (); ++i
)
64 std::cout
<< (*i
) << "\n";