basic2.cpp 804 B

123456789101112131415161718192021222324252627
  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. // Assign a value to an element in the array
  19. A[0][0][0] = 3.14;
  20. assert(A[0][0][0] == 3.14);
  21. return boost::exit_success;
  22. }