31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <vector>
|
|
6 |
#include <numeric>
|
|
7 |
#include <iostream>
|
|
8 |
#include <iterator>
|
|
9 |
#include <string>
|
|
10 |
|
|
11 |
#ifdef MAIN
|
|
12 |
#define inrprod1_test main
|
|
13 |
#endif
|
|
14 |
|
|
15 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
16 |
using namespace std;
|
|
17 |
#endif
|
|
18 |
int inrprod1_test(int, char**)
|
|
19 |
{
|
|
20 |
cout<<"Results of inrprod1_test:"<<endl;
|
|
21 |
vector <int> v1(3);
|
|
22 |
vector <int> v2(v1.size());
|
|
23 |
for(int i = 0; i < v1.size(); i++)
|
|
24 |
{
|
|
25 |
v1[i] = i + 1;
|
|
26 |
v2[i] = v1.size() - i;
|
|
27 |
}
|
|
28 |
ostream_iterator<int> iter(cout, " ");
|
|
29 |
cout << "Inner product(sum of products) of:\n\t";
|
|
30 |
copy(v1.begin(), v1.end(), iter);
|
|
31 |
cout << "\n\t";
|
|
32 |
copy(v2.begin(), v2.end(), iter);
|
|
33 |
int result = inner_product(v1.begin(), v1.end(), v2.begin(), 0);
|
|
34 |
cout << "\nis: " << result << endl;
|
|
35 |
if(result == 10)
|
|
36 |
return 0;
|
|
37 |
else
|
|
38 |
return 1;
|
|
39 |
}
|