[simd.mask.nonmembers]

# 29 Numerics library [[numerics]](./#numerics)

## 29.10 Data-parallel types [[simd]](simd#mask.nonmembers)

### 29.10.10 basic_mask non-member operations [simd.mask.nonmembers]

#### [29.10.10.1](#simd.mask.binary) basic_mask binary operators [[simd.mask.binary]](simd.mask.binary)

[ð](#lib:operator&&,basic_mask)

`friend constexpr basic_mask
  operator&&(const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator||(const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator& (const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator| (const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator^ (const basic_mask& lhs, const basic_mask& rhs) noexcept;
`

[1](#simd.mask.binary-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20361)

Let *op* be the operator[.](#simd.mask.binary-1.sentence-1)

[2](#simd.mask.binary-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20364)

*Returns*: A basic_mask object initialized with the results of applying*op* to lhs and rhs as a binary element-wise
operation[.](#simd.mask.binary-2.sentence-1)

#### [29.10.10.2](#simd.mask.cassign) basic_mask compound assignment [[simd.mask.cassign]](simd.mask.cassign)

[ð](#lib:operator&=,basic_mask)

`friend constexpr basic_mask&
  operator&=(basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask&
  operator|=(basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask&
  operator^=(basic_mask& lhs, const basic_mask& rhs) noexcept;
`

[1](#simd.mask.cassign-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20386)

Let *op* be the operator[.](#simd.mask.cassign-1.sentence-1)

[2](#simd.mask.cassign-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20389)

*Effects*: These operators apply *op* to lhs and rhs as a
binary element-wise operation[.](#simd.mask.cassign-2.sentence-1)

[3](#simd.mask.cassign-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20394)

*Returns*: lhs[.](#simd.mask.cassign-3.sentence-1)

#### [29.10.10.3](#simd.mask.comparison) basic_mask comparisons [[simd.mask.comparison]](simd.mask.comparison)

[ð](#lib:operator==,basic_mask)

`friend constexpr basic_mask
  operator==(const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator!=(const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator>=(const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator<=(const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator>(const basic_mask& lhs, const basic_mask& rhs) noexcept;
friend constexpr basic_mask
  operator<(const basic_mask& lhs, const basic_mask& rhs) noexcept;
`

[1](#simd.mask.comparison-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20423)

Let *op* be the operator[.](#simd.mask.comparison-1.sentence-1)

[2](#simd.mask.comparison-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20426)

*Returns*: A basic_mask object initialized with the results of applying*op* to lhs and rhs as a binary element-wise
operation[.](#simd.mask.comparison-2.sentence-1)

#### [29.10.10.4](#simd.mask.cond) basic_mask exposition only conditional operators [[simd.mask.cond]](simd.mask.cond)

[ð](#simd.mask.cond-itemdecl:1)

`friend constexpr basic_mask simd-select-impl(
  const basic_mask& mask, const basic_mask& a, const basic_mask& b) noexcept;
`

[1](#simd.mask.cond-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20441)

*Returns*: A basic_mask object where the ith element equalsmask[i] ? a[i] : b[i] for all i in the range of
[0, size())[.](#simd.mask.cond-1.sentence-1)

[ð](#simd.mask.cond-itemdecl:2)

`friend constexpr basic_mask
simd-select-impl(const basic_mask& mask, [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<bool> auto a, [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<bool> auto b) noexcept;
`

[2](#simd.mask.cond-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20454)

*Returns*: A basic_mask object where the ith element equalsmask[i] ? a : b for all i in the range of [0, size())[.](#simd.mask.cond-2.sentence-1)

[ð](#simd.mask.cond-itemdecl:3)

`template<class T0, class T1>
  friend constexpr vec<see below, size()>
    simd-select-impl(const basic_mask& mask, const T0& a, const T1& b) noexcept;
`

[3](#simd.mask.cond-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20467)

*Constraints*: 

- [(3.1)](#simd.mask.cond-3.1)

same_as<T0, T1> is true,

- [(3.2)](#simd.mask.cond-3.2)

T0 is a vectorizable type, and

- [(3.3)](#simd.mask.cond-3.3)

sizeof(T0) == Bytes[.](#simd.mask.cond-3.sentence-1)

[4](#simd.mask.cond-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20478)

*Returns*: A vec<T0, size()> object where the ith element equalsmask[i] ? a : b for all i in the range of [0, size())[.](#simd.mask.cond-4.sentence-1)

#### [29.10.10.5](#simd.mask.reductions) basic_mask reductions [[simd.mask.reductions]](simd.mask.reductions)

[ð](#lib:all_of,simd)

`template<size_t Bytes, class Abi>
  constexpr bool all_of(const basic_mask<Bytes, Abi>& k) noexcept;
`

[1](#simd.mask.reductions-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20493)

*Returns*: true if all boolean elements in k are true, otherwisefalse[.](#simd.mask.reductions-1.sentence-1)

[ð](#lib:any_of,simd)

`template<size_t Bytes, class Abi>
  constexpr bool any_of(const basic_mask<Bytes, Abi>& k) noexcept;
`

[2](#simd.mask.reductions-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20506)

*Returns*: true if at least one boolean element in k is true,
otherwise false[.](#simd.mask.reductions-2.sentence-1)

[ð](#lib:none_of,simd)

`template<size_t Bytes, class Abi>
  constexpr bool none_of(const basic_mask<Bytes, Abi>& k) noexcept;
`

[3](#simd.mask.reductions-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20519)

*Returns*: !any_of(k)[.](#simd.mask.reductions-3.sentence-1)

[ð](#lib:reduce_count,simd)

`template<size_t Bytes, class Abi>
  constexpr simd-size-type reduce_count(const basic_mask<Bytes, Abi>& k) noexcept;
`

[4](#simd.mask.reductions-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20531)

*Returns*: The number of boolean elements in k that are true[.](#simd.mask.reductions-4.sentence-1)

[ð](#lib:reduce_min_index,simd)

`template<size_t Bytes, class Abi>
  constexpr simd-size-type reduce_min_index(const basic_mask<Bytes, Abi>& k);
`

[5](#simd.mask.reductions-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20543)

*Preconditions*: any_of(k) is true[.](#simd.mask.reductions-5.sentence-1)

[6](#simd.mask.reductions-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20547)

*Returns*: The lowest element index i where k[i] is true[.](#simd.mask.reductions-6.sentence-1)

[ð](#lib:reduce_max_index,simd)

`template<size_t Bytes, class Abi>
  constexpr simd-size-type reduce_max_index(const basic_mask<Bytes, Abi>& k);
`

[7](#simd.mask.reductions-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20559)

*Preconditions*: any_of(k) is true[.](#simd.mask.reductions-7.sentence-1)

[8](#simd.mask.reductions-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20563)

*Returns*: The greatest element index i where k[i] is true[.](#simd.mask.reductions-8.sentence-1)

[ð](#lib:all_of,simd_)

`constexpr bool all_of([same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<bool> auto x) noexcept;
constexpr bool any_of([same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<bool> auto x) noexcept;
constexpr simd-size-type reduce_count([same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<bool> auto x) noexcept;
`

[9](#simd.mask.reductions-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20578)

*Returns*: x[.](#simd.mask.reductions-9.sentence-1)

[ð](#lib:none_of,simd_)

`constexpr bool none_of([same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<bool> auto x) noexcept;
`

[10](#simd.mask.reductions-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20589)

*Returns*: !x[.](#simd.mask.reductions-10.sentence-1)

[ð](#lib:reduce_min_index,simd_)

`constexpr simd-size-type reduce_min_index([same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<bool> auto x);
constexpr simd-size-type reduce_max_index([same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<bool> auto x);
`

[11](#simd.mask.reductions-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20602)

*Preconditions*: x is true[.](#simd.mask.reductions-11.sentence-1)

[12](#simd.mask.reductions-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L20606)

*Returns*: 0[.](#simd.mask.reductions-12.sentence-1)
