matrix_slice.cpp 797 B

1234567891011121314151617181920212223242526
  1. //
  2. // Copyright (c) 2000-2002
  3. // Joerg Walter, Mathias Koch
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // The authors gratefully acknowledge the support of
  10. // GeNeSys mbH & Co. KG in producing this work.
  11. //
  12. #include <boost/numeric/ublas/matrix.hpp>
  13. #include <boost/numeric/ublas/matrix_proxy.hpp>
  14. #include <boost/numeric/ublas/io.hpp>
  15. int main () {
  16. using namespace boost::numeric::ublas;
  17. matrix<double> m (3, 3);
  18. matrix_slice<matrix<double> > ms (m, slice (0, 1, 3), slice (0, 1, 3));
  19. for (unsigned i = 0; i < ms.size1 (); ++ i)
  20. for (unsigned j = 0; j < ms.size2 (); ++ j)
  21. ms (i, j) = 3 * i + j;
  22. std::cout << ms << std::endl;
  23. }