I'm currently using xtensor for an application, and I wanted to wrap over the tensors to make a class called BitArray
.
#include <iostream>
#include "xtensor/xarray.hpp"
#include "xtensor/xio.hpp"
#include "xtensor/xview.hpp"
#include "xtensor/xindex_view.hpp"
xt::xarray<double> arr {1, 2, 3};
template <typename E>
class BitArray{
public:
BitArray(const xt::xexpression<E>& _array, float _alpha) :
b(xt::cast<std::int8_t>(_array.derived_cast())), alpha(_alpha) {}
xt::xarray<E> b;
float alpha;
};
template <class E>
auto make_bitarray(xt::xexpression<E>& expr, float alpha)
{
return BitArray<E>(expr, alpha);
}
auto a = make_bitarray(arr, 3); // Error
I get the error message below:
Standard Exception: Precondition violation!
Internal error: trivial_assigner called with unrelated types.
/srv/conda/include/xtensor/xassign.hpp(505)
What does this mean and what can I do to resolve this?