-
Notifications
You must be signed in to change notification settings - Fork 5
/
ra-4.cc
32 lines (27 loc) · 868 Bytes
/
ra-4.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// -*- mode: c++; coding: utf-8 -*-
// ra-ra/test - Regresion tests (1).
// (c) Daniel Llorens - 2014
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option) any
// later version.
#include <iostream>
#include <iterator>
#include "ra/test.hh"
using std::cout, std::endl, std::flush, ra::TestRecorder;
using complex = std::complex<double>;
using ra::sqrm;
template <class AA>
double sqrm_ai(AA && a)
{
double c(0.);
ply(ra::expr([&c](complex const a) { c += sqrm(a); }, a));
return c;
}
int main()
{
TestRecorder tr;
ra::Unique<complex, 1> a({3}, {1, 2, 3});
tr.test_eq(14, sqrm_ai(ra::expr([](complex a) { return a; }, a.iter())));
return tr.summary();
}