Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Public Member Functions | Public Attributes | List of all members
gko::span Struct Reference

A span is a lightweight structure used to create sub-ranges from other ranges. More...

#include <ginkgo/core/base/range.hpp>

Public Member Functions

constexpr span (size_type point) noexcept
 Creates a span representing a point point. More...
 
constexpr span (size_type begin, size_type end) noexcept
 Creates a span. More...
 
constexpr bool is_valid () const
 Checks if a span is valid. More...
 
constexpr size_type length () const
 Returns the length of a span. More...
 

Public Attributes

const size_type begin
 Beginning of the span.
 
const size_type end
 End of the span.
 

Detailed Description

A span is a lightweight structure used to create sub-ranges from other ranges.

A span s represents a contiguous set of indexes in one dimension of the range, starting on index s.begin (inclusive) and ending at index s.end (exclusive). A span is only valid if its starting index is smaller than its ending index.

Spans can be compared using the == and != operators. Two spans are identical if both their begin and end values are identical.

Spans also have two distinct partial orders defined on them:

  1. x < y (y > x) if and only if x.end < y.begin
  2. x <= y (y >= x) if and only if x.end <= y.begin

Note that the orders are in fact partial - there are spans x and y for which none of the following inequalities holds: x < y, x > y, x == y, x <= y, x >= y. An example are spans span{0, 2} and span{1, 3}.

In addition, <= is a distinct order from <, and not just an extension of the strict order to its weak equivalent. Thus, x <= y is not equivalent to x < y || x == y.

Constructor & Destructor Documentation

◆ span() [1/2]

constexpr gko::span::span ( size_type  point)
inlineconstexprnoexcept

Creates a span representing a point point.

The begin of this span is set to point, and the end to point + 1.

Parameters
pointthe point which the span represents

◆ span() [2/2]

constexpr gko::span::span ( size_type  begin,
size_type  end 
)
inlineconstexprnoexcept

Creates a span.

Parameters
beginthe beginning of the span
endthe end of the span

References begin.

Member Function Documentation

◆ is_valid()

constexpr bool gko::span::is_valid ( ) const
inlineconstexpr

Checks if a span is valid.

Returns
true if and only if this->begin <= this->end

References begin, and end.

Referenced by gko::accessor::row_major< ValueType, Dimensionality >::operator()().

◆ length()

constexpr size_type gko::span::length ( ) const
inlineconstexpr

Returns the length of a span.

Returns
this->end - this->begin

References begin, and end.


The documentation for this struct was generated from the following file: