• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2002 The Trustees of Indiana University.
2 
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 //  Boost.MultiArray Library
8 //  Authors: Ronald Garcia
9 //           Jeremy Siek
10 //           Andrew Lumsdaine
11 //  See http://www.boost.org/libs/multi_array for documentation.
12 
13 #include "boost/multi_array.hpp"
14 #include "for_each.hpp"
15 #include <algorithm>
16 
17 struct times_five {
operator ()times_five18   double operator()(const int& val) { return val*5.0; }
19 };
20 
21 
main()22 int main() {
23 
24   typedef boost::multi_array<double,1> array;
25 
26   double data[] = {
27     1.0, 2.0, 3.0,
28     4.0, 5.0, 6.0,
29     7.0, 8.0, 9.0
30   };
31   const int data_size=9;
32 
33   array A(boost::extents[9]);
34   A.assign(data,data+data_size);
35 
36 #if 0
37   std::copy(A.begin(),A.end(),
38             std::ostream_iterator<double>(std::cout,","));
39 
40   std::cout << "\n";
41 #endif
42 
43   for_each(A,times_five());
44 
45 #if 0
46   std::copy(A.begin(),A.end(),
47             std::ostream_iterator<double>(std::cout,","));
48 
49   std::cout << "\n";
50 #endif
51   return 0;
52 }
53