xmasked_view

Defined in xtensor/xmasked_view.hpp

template<class CTD, class CTM>
class xmasked_view : public xt::xview_semantic<xmasked_view<CTD, CTM>>, private xt::xaccessible<xmasked_view<CTD, CTM>>, private xt::xiterable<xmasked_view<CTD, CTM>>

View on an xoptional_assembly or xoptional_assembly_adaptor hiding values depending on a given mask.

The xmasked_view class implements a view on an xoptional_assembly or xoptional_assembly_adaptor, it takes this xoptional_assembly and a mask as input. The mask is an xexpression containing boolean values, whenever the value of the mask is false, the optional value of xmasked_view is considered missing, otherwise it depends on the underlying xoptional_assembly.

Template Parameters
  • CTD: The type of expression holding the values.

  • CTM: The type of expression holding the mask.

Constructors

template<class D, class M>
xmasked_view(D &&data, M &&mask)

Creates an xmasked_view, given the xoptional_assembly or xoptional_assembly_adaptor and the mask.

Parameters

Size and shape

auto size() const

Returns the number of elements in the xmasked_view.

auto shape() const

Returns the shape of the xmasked_view.

auto strides() const

Returns the strides of the xmasked_view.

auto backstrides() const

Returns the backstrides of the xmasked_view.

Data

template<class ...Args>
auto operator()(Args... args)

Returns a reference to the element at the specified position in the xmasked_view.

Parameters
  • args: a list of indices specifying the position in the xmasked_view. Indices must be unsigned integers, the number of indices should be equal or greater than the number of dimensions of the xmasked_view.

template<class ...Args>
auto operator()(Args... args) const

Returns a constant reference to the element at the specified position in the xmasked_view.

Parameters
  • args: a list of indices specifying the position in the xmasked_view. Indices must be unsigned integers, the number of indices should be equal or greater than the number of dimensions of the xmasked_view.

template<class ...Args>
auto unchecked(Args... args)

Returns a reference to the element at the specified position in the xmasked_view.

Warning

This method is meant for performance, for expressions with a dynamic number of dimensions (i.e. not known at compile time). Since it may have undefined behavior (see parameters), operator() should be prefered whenever it is possible.

Warning

This method is NOT compatible with broadcasting, meaning the following code has undefined behavior:

xt::xarray<double> a = {{0, 1}, {2, 3}};
xt::xarray<double> b = {0, 1};
auto fd = a + b;
double res = fd.uncheked(0, 1);

Parameters
  • args: a list of indices specifying the position in the xmasked_view. Indices must be unsigned integers, the number of indices must be equal to the number of dimensions of the xmasked_view, else the behavior is undefined.

template<class ...Args>
auto unchecked(Args... args) const

Returns a constant reference to the element at the specified position in the xmasked_view.

Warning

This method is meant for performance, for expressions with a dynamic number of dimensions (i.e. not known at compile time). Since it may have undefined behavior (see parameters), operator() should be prefered whenever it is possible.

Warning

This method is NOT compatible with broadcasting, meaning the following code has undefined behavior:

xt::xarray<double> a = {{0, 1}, {2, 3}};
xt::xarray<double> b = {0, 1};
auto fd = a + b;
double res = fd.uncheked(0, 1);

Parameters
  • args: a list of indices specifying the position in the xmasked_view. Indices must be unsigned integers, the number of indices must be equal to the number of dimensions of the xmasked_view, else the behavior is undefined.

template<class It>
auto element(It first, It last)

Returns a reference to the element at the specified position in the xmasked_view.

Parameters
  • first: iterator starting the sequence of indices

  • last: iterator ending the sequence of indices The number of indices in the sequence should be equal to or greater than the number of dimensions of the xmasked_view.

template<class It>
auto element(It first, It last) const

Returns a constant reference to the element at the specified position in the xmasked_view.

Parameters
  • first: iterator starting the sequence of indices

  • last: iterator ending the sequence of indices The number of indices in the sequence should be equal to or greater than the number of dimensions of the xmasked_view.

Public Functions

layout_type layout() const

Return the layout_type of the xmasked_view.

Return

layout_type of the xmasked_view

template<class T>
void fill(const T &value)

Fills the data with the given value.

Parameters
  • value: the value to fill the data with.

auto value()

Return an expression for the values of the xmasked_view.

auto value() const

Return a constant expression for the values of the xmasked_view.

auto visible()

Return an expression for the mask of the xmasked_view.

auto visible() const

Return a constant expression for the mask of the xmasked_view.