op_paren.cpp 896 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2002 The Trustees of Indiana University.
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Boost.MultiArray Library
  6. // Authors: Ronald Garcia
  7. // Jeremy Siek
  8. // Andrew Lumsdaine
  9. // See http://www.boost.org/libs/multi_array for documentation.
  10. #include <cassert>
  11. #include "boost/multi_array.hpp"
  12. #include "boost/array.hpp"
  13. #include "boost/cstdlib.hpp"
  14. int main () {
  15. // Create a 3D array that is 3 x 4 x 2
  16. boost::array<int, 3> shape = {{ 3, 4, 2 }};
  17. boost::multi_array<double, 3> A(shape);
  18. typedef boost::multi_array<double, 3>::index index;
  19. // Assign a value to an element in the array
  20. boost::array<index, 3> idx = {{ 0, 0, 0 }};
  21. A(idx) = 3.14;
  22. assert(A(idx) == 3.14);
  23. return boost::exit_success;
  24. }