iterator-as-ravel.cc 1.3 KB

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