Ginkgo  Generated from pipelines/1068515030 branch based on master. Ginkgo version 1.7.0
A numerical linear algebra library targeting many-core architectures
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
gko::dim< Dimensionality, DimensionType > Struct Template Reference

A type representing the dimensions of a multidimensional object. More...

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

Inheritance diagram for gko::dim< Dimensionality, DimensionType >:
[legend]

Public Types

using dimension_type = DimensionType
 

Public Member Functions

constexpr dim (const dimension_type &size=dimension_type{})
 Creates a dimension object with all dimensions set to the same value. More...
 
template<typename... Rest>
constexpr dim (const dimension_type &first, const Rest &... rest)
 Creates a dimension object with the specified dimensions. More...
 
constexpr const dimension_type & operator[] (const size_type &dimension) const noexcept
 Returns the requested dimension. More...
 
dimension_type & operator[] (const size_type &dimension) noexcept
 
constexpr operator bool () const
 Checks if all dimensions evaluate to true. More...
 

Static Public Attributes

static constexpr size_type dimensionality = Dimensionality
 

Friends

struct dim< dimensionality+1 >
 
constexpr friend bool operator== (const dim &x, const dim &y)
 Checks if two dim objects are equal. More...
 
constexpr friend dim operator* (const dim &x, const dim &y)
 Multiplies two dim objects. More...
 
std::ostream & operator<< (std::ostream &os, const dim &x)
 A stream operator overload for dim. More...
 

Detailed Description

template<size_type Dimensionality, typename DimensionType = size_type>
struct gko::dim< Dimensionality, DimensionType >

A type representing the dimensions of a multidimensional object.

Template Parameters
Dimensionalitynumber of dimensions of the object
DimensionTypedatatype used to represent each dimension

Constructor & Destructor Documentation

◆ dim() [1/2]

template<size_type Dimensionality, typename DimensionType = size_type>
constexpr gko::dim< Dimensionality, DimensionType >::dim ( const dimension_type &  size = dimension_type{})
inlineconstexpr

Creates a dimension object with all dimensions set to the same value.

Parameters
sizethe size of each dimension

◆ dim() [2/2]

template<size_type Dimensionality, typename DimensionType = size_type>
template<typename... Rest>
constexpr gko::dim< Dimensionality, DimensionType >::dim ( const dimension_type &  first,
const Rest &...  rest 
)
inlineconstexpr

Creates a dimension object with the specified dimensions.

If the number of dimensions given is less than the dimensionality of the object, the remaining dimensions are set to the same value as the last value given.

For example, in the context of matrices dim<2>{2, 3} creates the dimensions for a 2-by-3 matrix.

Parameters
firstfirst dimension
restother dimensions

Member Function Documentation

◆ operator bool()

template<size_type Dimensionality, typename DimensionType = size_type>
constexpr gko::dim< Dimensionality, DimensionType >::operator bool ( ) const
inlineexplicitconstexpr

Checks if all dimensions evaluate to true.

For standard arithmetic types, this is equivalent to all dimensions being different than zero.

Returns
true if and only if all dimensions evaluate to true
Note
This operator is explicit to avoid implicit dim-to-int casts. It will still be used in contextual conversions (if, &&, ||, !)

◆ operator[]() [1/2]

template<size_type Dimensionality, typename DimensionType = size_type>
constexpr const dimension_type& gko::dim< Dimensionality, DimensionType >::operator[] ( const size_type dimension) const
inlineconstexprnoexcept

Returns the requested dimension.

For example, if d is a dim<2> object representing matrix dimensions, d[0] returns the number of rows, and d[1] returns the number of columns.

Parameters
dimensionthe requested dimension
Returns
the dimension-th dimension

◆ operator[]() [2/2]

template<size_type Dimensionality, typename DimensionType = size_type>
dimension_type& gko::dim< Dimensionality, DimensionType >::operator[] ( const size_type dimension)
inlinenoexcept

Friends And Related Function Documentation

◆ operator*

template<size_type Dimensionality, typename DimensionType = size_type>
constexpr friend dim operator* ( const dim< Dimensionality, DimensionType > &  x,
const dim< Dimensionality, DimensionType > &  y 
)
friend

Multiplies two dim objects.

Parameters
xfirst object
ysecond object
Returns
a dim object representing the size of the tensor product x * y

◆ operator<<

template<size_type Dimensionality, typename DimensionType = size_type>
std::ostream& operator<< ( std::ostream &  os,
const dim< Dimensionality, DimensionType > &  x 
)
friend

A stream operator overload for dim.

Parameters
osstream object
xdim object
Returns
a stream object appended with the dim output

◆ operator==

template<size_type Dimensionality, typename DimensionType = size_type>
constexpr friend bool operator== ( const dim< Dimensionality, DimensionType > &  x,
const dim< Dimensionality, DimensionType > &  y 
)
friend

Checks if two dim objects are equal.

Parameters
xfirst object
ysecond object
Returns
true if and only if all dimensions of both objects are equal.

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