xmasked_view¶
Defined in xtensor/xmasked_view.hpp
-
template<class
CTD, classCTM>
classxt::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, classM>xmasked_view(D &&data, M &&mask)¶ Creates an xmasked_view, given the xoptional_assembly or xoptional_assembly_adaptor and the mask.
- Parameters
data: the underlying xoptional_assembly or xoptional_assembly_adaptormask: the mask.
Size and shape
-
size_type
size() const noexcept¶ Returns the number of elements in the xmasked_view.
-
const inner_shape_type &
shape() const noexcept¶ Returns the shape of the xmasked_view.
-
const inner_strides_type &
strides() const noexcept¶ Returns the strides of the xmasked_view.
-
const inner_backstrides_type &
backstrides() const noexcept¶ Returns the backstrides of the xmasked_view.
-
layout_type
layout() const noexcept¶ Return the layout_type of the xmasked_view.
- Return
layout_type of the xmasked_view
Data
-
data_type &
value() noexcept¶ Return an expression for the values of the xmasked_view.
-
const data_type &
value() const noexcept¶ Return a constant expression for the values of the xmasked_view.
-
mask_type &
visible() noexcept¶ Return an expression for the mask of the xmasked_view.
-
const mask_type &
visible() const noexcept¶ Return a constant expression for the mask of the xmasked_view.
-
template<class ...
Args>
autooperator()(Args... args) -> reference¶ 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>
autooperator()(Args... args) const -> const_reference¶ 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>
autounchecked(Args... args) -> reference¶ 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>
autounchecked(Args... args) const -> const_reference¶ 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>
autoelement(It first, It last) -> reference¶ Returns a reference to the element at the specified position in the xmasked_view.
- Parameters
first: iterator starting the sequence of indiceslast: 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>
autoelement(It first, It last) const -> const_reference¶ Returns a constant reference to the element at the specified position in the xmasked_view.
- Parameters
first: iterator starting the sequence of indiceslast: 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
-
template<class ...
Args>
autoat(Args... args) -> reference¶ Returns a reference to the element at the specified position in the expression, after dimension and bounds checking.
- Parameters
args: a list of indices specifying the position in the expression. Indices must be unsigned integers, the number of indices should be equal to the number of dimensions of the expression.
- Exceptions
std::out_of_range: if the number of argument is greater than the number of dimensions or if indices are out of bounds.
-
template<class ...
Args>
autoat(Args... args) const -> const_reference¶ Returns a constant reference to the element at the specified position in the expression, after dimension and bounds checking.
- Parameters
args: a list of indices specifying the position in the expression. Indices must be unsigned integers, the number of indices should be equal to the number of dimensions of the expression.
- Exceptions
std::out_of_range: if the number of argument is greater than the number of dimensions or if indices are out of bounds.
-
template<class ...
Args>
autoperiodic(Args... args) -> reference¶ Returns a reference to the element at the specified position in the expression, after applying periodicity to the indices (negative and ‘overflowing’ indices are changed).
- Parameters
args: a list of indices specifying the position in the expression. Indices must be integers, the number of indices should be equal to the number of dimensions of the expression.
-
template<class ...
Args>
autoperiodic(Args... args) const -> const_reference¶ Returns a constant reference to the element at the specified position in the expression, after applying periodicity to the indices (negative and ‘overflowing’ indices are changed).
- Parameters
args: a list of indices specifying the position in the expression. Indices must be integers, the number of indices should be equal to the number of dimensions of the expression.