Ginkgo: gko::span Struct Reference

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
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>`

Inheritance diagram for gko::span:
[legend]

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

## 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]

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

  point | the point which the span represents

References span().

Referenced by span().

## ◆ span() [2/2]

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

Creates a span.

Parameters

  begin | the beginning of the span
  end | the end of the span

References begin, and end.

## Member Function Documentation

## ◆ is_valid()

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()

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:

- ginkgo/core/base/range.hpp