xmasked_view¶
Defined in xtensor/xmasked_view.hpp
- template <class CTD, class CTM>
-
class
xt::xmasked_view¶ 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.
Inherits from xt::xview_semantic< xmasked_view< CTD, CTM > >, xt::xaccessible< xmasked_view< CTD, CTM > >, xt::xiterable< xmasked_view< CTD, CTM > >
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
data: the underlying xoptional_assembly or xoptional_assembly_adaptormask: the mask.
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.
-
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.
Data
-
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.
- 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 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>
-
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 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>
-
auto
at(Args... args) 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>
-
auto
at(Args... args) const 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>
-
auto
periodic(Args... args) 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>
-
auto
periodic(Args... args) const 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.