9 using t_RefArray = t_Array&;
10 using t_ConstRefArray = t_Array
const;
12 SECTION(
"Square function") {
13 auto func = [](t_RefArray output, t_ConstRefArray
const &input) { output = input * 2 + 1; };
15 t_Array
const x = t_Array::Random(5);
16 auto const A = details::wrap<t_Array>(func);
18 t_Array
const expected = (x * 2 + 1).eval();
20 CHECK((A * x).matrix() == expected.matrix());
21 CHECK(A(x).matrix() == expected.matrix());
24 SECTION(
"Rectangular function") {
25 auto func = [](t_RefArray output, t_ConstRefArray
const &input) {
26 output = input.head(input.size() / 2) * 2 + 1;
29 t_Array
const x = t_Array::Random(5);
30 auto const A = details::wrap<t_Array>(func, {{1, 2, 0}});
32 t_Array
const expected = (x.head(x.size() / 2) * 2 + 1).eval();
34 CHECK((A * x).
cols() == 1);
35 CHECK((A * x).
rows() == 2);
36 CHECK((A * x).matrix() == expected.matrix());
37 CHECK(A(x).matrix() == expected.matrix());
40 SECTION(
"Fixed output-size functions") {
41 auto func = [](t_RefArray output, t_ConstRefArray
const &input) {
42 output = input.head(3) * 2 + 1;
45 t_Array
const x = t_Array::Random(5);
46 auto const A = details::wrap<t_Array>(func, {{0, 1, 3}});
48 t_Array
const expected = (x.head(3) * 2 + 1).eval();
50 CHECK((A * x).
cols() == 1);
51 CHECK((A * x).
rows() == 3);
52 CHECK((A * x).matrix() == expected.matrix());
53 CHECK(A(x).matrix() == expected.matrix());
Eigen::Array< T, Eigen::Dynamic, 1 > Array
A 1-dimensional list of elements of given type.