ra-4.cc 937 B

1234567891011121314151617181920212223242526272829303132333435
  1. // -*- mode: c++; coding: utf-8 -*-
  2. /// @file ra-4.cc
  3. /// @brief Regresion tests for attempt at simplification.
  4. // (c) Daniel Llorens - 2014
  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/complex.hh"
  12. #include "ra/test.hh"
  13. #include "ra/big.hh"
  14. using std::cout, std::endl, std::flush, ra::TestRecorder;
  15. using complex = std::complex<double>;
  16. template <class AA>
  17. double sqrm_ai(AA && a)
  18. {
  19. double c(0.);
  20. ply(ra::expr([&c](complex const a) { c += sqrm(a); }, a));
  21. return c;
  22. }
  23. int main()
  24. {
  25. TestRecorder tr;
  26. ra::Unique<complex, 1> a({3}, {1, 2, 3});
  27. tr.test_eq(14, sqrm_ai(ra::expr([](complex a) { return a; }, a.iter())));
  28. return tr.summary();
  29. }