iterator-as-ravel.cc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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/test.hh"
  11. using std::cout, std::endl, std::flush;
  12. int main()
  13. {
  14. ra::TestRecorder tr;
  15. // this is trivial since Big::begin() is a raw pointer.
  16. tr.section("not driving, order I");
  17. {
  18. ra::Big<int, 2> a = {{1, 2}, {3, 4}, {5, 6}};
  19. // same rank
  20. auto x = concrete(ra::ptr(a.begin()) * ra::Small<int, 5> { 1, 2, 3, 4, 5 });
  21. cout << x << endl;
  22. // rank extension
  23. auto y = concrete(ra::ptr(a.begin()) * ra::Small<int, 2, 3> { {1, 2, 3}, {4, 5, 6} });
  24. cout << y << endl;
  25. }
  26. // // the interesting part [FIXME We are missing advance() on stl-like iterators & also += [] secondarily].
  27. // tr.section("not driving, order II");
  28. // {
  29. // ra::Big<int, 2> a_ = {{1, 2}, {3, 4}, {5, 6}};
  30. // auto a = transpose<1, 0>(a_);
  31. // // same rank
  32. // cout << (ra::ptr(a.begin()) * ra::Small<int, 5> { 1, 2, 3, 4, 5 }) << endl;
  33. // }
  34. return tr.summary();
  35. }