iterator-as-ravel.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // -*- mode: c++; coding: utf-8 -*-
  2. /// @file iterator-as-ravel.cc
  3. /// @brief Using ptr(begin()) work as a lazy ravel (WIP)
  4. // (c) Daniel Llorens - 2019
  5. // This library is free software; you can redistribute it and/or modify it under
  6. // the terms of the GNU Lesser General Public License as published by the Free
  7. // Software Foundation; either version 3 of the License, or (at your option) any
  8. // later version.
  9. #include <iostream>
  10. #include <iterator>
  11. #include "ra/ra.hh"
  12. #include "ra/test.hh"
  13. using std::cout, std::endl, std::flush;
  14. int main()
  15. {
  16. TestRecorder tr;
  17. // this is trivial since Big::begin() is a raw pointer.
  18. tr.section("not driving, order I");
  19. {
  20. ra::Big<int, 2> a = {{1, 2}, {3, 4}, {5, 6}};
  21. // same rank
  22. auto x = concrete(ra::ptr(a.begin()) * ra::Small<int, 5> { 1, 2, 3, 4, 5 });
  23. cout << x << endl;
  24. // rank extension
  25. auto y = concrete(ra::ptr(a.begin()) * ra::Small<int, 2, 3> { {1, 2, 3}, {4, 5, 6} });
  26. cout << y << endl;
  27. }
  28. // // the interesting part [FIXME We are missing advance() on stl-like iterators & also += [] secondarily].
  29. // tr.section("not driving, order II");
  30. // {
  31. // ra::Big<int, 2> a_ = {{1, 2}, {3, 4}, {5, 6}};
  32. // auto a = transpose<1, 0>(a_);
  33. // // same rank
  34. // cout << (ra::ptr(a.begin()) * ra::Small<int, 5> { 1, 2, 3, 4, 5 }) << endl;
  35. // }
  36. return tr.summary();
  37. }