|
| 1 | +#include <iostream> |
| 2 | +#include <xtensor/xtensor.hpp> |
| 3 | +#include <xtensor/xfixed.hpp> |
| 4 | +#include "xtensor/xio.hpp" |
| 5 | + |
| 6 | +xt::xtensor<float, 2> copy_array(const xt::xtensor<float, 2>& input); |
| 7 | +xt::xtensor<float, 2> twice(const xt::xtensor<float, 2>& x); |
| 8 | + |
| 9 | +xt::xtensor<float, 2> prg(const xt::xtensor<float, 2>& arr) { |
| 10 | + xt::xtensor<float, 2> otpt = xt::xtensor<float, 2>({arr.shape(0), arr.shape(1)}); |
| 11 | + otpt = copy_array(twice(copy_array(arr))); |
| 12 | + return otpt; |
| 13 | +} |
| 14 | + |
| 15 | +xt::xtensor<float, 2> twice(const xt::xtensor<float, 2>& x) { |
| 16 | + xt::xtensor<float, 2> y = xt::empty<float>({x.shape(0), x.shape(1)}); |
| 17 | + y = 2.0*x; |
| 18 | + return y; |
| 19 | +} |
| 20 | + |
| 21 | +xt::xtensor<float, 2> copy_array(const xt::xtensor<float, 2>& input) { |
| 22 | + xt::xtensor<float, 2> output = xt::empty<float>({input.shape(0), input.shape(1)}); |
| 23 | + output = input; |
| 24 | + return output; |
| 25 | +} |
| 26 | + |
| 27 | +int main() { |
| 28 | + |
| 29 | +xt::xtensor<float, 2> array = xt::empty<float>({10, 10}); |
| 30 | +xt::xtensor<float, 2> output = xt::empty<float>({10, 10}); |
| 31 | + |
| 32 | +array.fill(3.0); |
| 33 | + |
| 34 | +output = prg(array); |
| 35 | +std::cout << output << std::endl; |
| 36 | +if( xt::any(xt::not_equal(output, 6.0)) ) { |
| 37 | + exit(2); |
| 38 | +} |
| 39 | + |
| 40 | +} |
0 commit comments