ra-4.C 936 B

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