class ngraph::CoordinateIterator

Overview

A useful class that allows to iterate over the tensor coordinates. For example, for tensor with dimensions {2, 3} this iterator produces the following coordinates: {0,0}, {0,1}, {0,2}, {1,0}, {1,1}, {2,2}. More…

#include <coordinate_transform.hpp>

class CoordinateIterator
{
public:
    // construction

    CoordinateIterator(const Shape& target_shape);

    // methods

    void operator ++ ();
    CoordinateIterator operator ++ (int);
    void operator += (size_t n);
    const Coordinate& operator\* () const;
    bool operator != (const CoordinateIterator& it) const;
    bool operator == (const CoordinateIterator& it) const;
    size_t advance(size_t axis);
    static const CoordinateIterator& end();
};

Detailed Documentation

A useful class that allows to iterate over the tensor coordinates. For example, for tensor with dimensions {2, 3} this iterator produces the following coordinates: {0,0}, {0,1}, {0,2}, {1,0}, {1,1}, {2,2}.

Deprecated

Construction

CoordinateIterator(const Shape& target_shape)

Coordinates iterator constructor.

Parameters:

target_shape

The target shape for coordinates iteration

Methods

void operator ++ ()

The postfix operation increment the iterator by one.

CoordinateIterator operator ++ (int)

The prefix operation increment the iterator by one.

void operator += (size_t n)

Increments iterator n times.

Parameters:

n

number of elements it should be advanced

const Coordinate& operator\* () const

Iterator dereferencing operator returns reference to current pointed coordinate.

bool operator != (const CoordinateIterator& it) const

Checks for iterator inequality.

Parameters:

it

second iterator to compare

bool operator == (const CoordinateIterator& it) const

Checks for iterator equality.

Parameters:

it

second iterator to compare

size_t advance(size_t axis)

Increments iterator using specified axis of the shape n times.

Parameters:

axis

index used for iteration

static const CoordinateIterator& end()

Useful function to build the last iterator. Returns a singleton that points to the last iterator.