QUGaR 0.0.4
Loading...
Searching...
No Matches
qugar::TensorIndexTP< dim > Class Template Reference

Class representing a dim-dimensional tensor-product indices. More...

#include <tensor_index_tp.hpp>

Inheritance diagram for qugar::TensorIndexTP< dim >:
[legend]
Collaboration diagram for qugar::TensorIndexTP< dim >:
[legend]

Public Member Functions

Constructors
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 0)
 TensorIndexTP ()
 Default constructor. Initializes indices to zero.
 
template<int aux_dim = dim>
requires (aux_dim == dim && dim == 0)
 TensorIndexTP ()
 
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 0)
 TensorIndexTP (int ind)
 Constructs a new TensorIndexTP object from an index.
 
 TensorIndexTP (const Vector< int, dim > &indices)
 Constructs a new TensorIndexTP object from its indices.
 
 TensorIndexTP (const TensorSizeTP< dim > &indices)
 Constructs a new TensorIndexTP object from its indices.
 
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 0)
 TensorIndexTP (int flat_index, const TensorIndexTP< dim > &size)
 Constructs a new TensorIndexTP object from a flat index and an associated tensor size following the lexicographical ordering convention (i.e., lower indices run faster than higher ones).
 
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 0)
 TensorIndexTP (int flat_index, const TensorSizeTP< dim > &size)
 Constructs a new TensorIndexTP object from a flat index and an associated tensor size following the lexicographical ordering convention (i.e., lower indices run faster than higher ones).
 
template<typename... T>
requires (dim > 1 && sizeof...(T) == dim && std::conjunction_v<std::is_same<int, T>...>)
 TensorIndexTP (T... indices)
 Constructs the tensor index from an argument list.
 
const Vector< int, dim > & as_Vector () const
 Returns the tensor index casted as a Vector.
 
Vector< int, dim > & as_Vector ()
 Returns the tensor index casted as a Vector.
 
template<typename S >
int flat (const S &size) const
 Gets the flat index associated to the current tensor index for a given tensor size.
 
bool operator== (const TensorIndexTP< dim > &rhs) const
 Checks if two tensor indices are equal by comparing all its components. They are equal if all the components are equal.
 
bool operator!= (const TensorIndexTP< dim > &rhs) const
 Checks if two tensor indices are different by comparing all its components. They are different if at least one component is different.
 
bool operator< (const TensorIndexTP< dim > &rhs) const
 Checks if the current tensor index is smaller than rhs. To determine if one is smaller than the other, all the componets are compared starting from the last one.
 
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 1)
TensorIndexTP< dim - 1 > remove_component (int comp) const
 Creates a new index by removing one of its component.
 
std::size_t hash () const
 Computes a hash value for the tensor index.
 

Detailed Description

template<int dim>
class qugar::TensorIndexTP< dim >

Class representing a dim-dimensional tensor-product indices.

Template Parameters
dimDimension of the indices.

Constructor & Destructor Documentation

◆ TensorIndexTP() [1/8]

template<int dim>
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 0)
qugar::TensorIndexTP< dim >::TensorIndexTP ( )
inline

Default constructor. Initializes indices to zero.

◆ TensorIndexTP() [2/8]

template<int dim>
template<int aux_dim = dim>
requires (aux_dim == dim && dim == 0)
qugar::TensorIndexTP< dim >::TensorIndexTP ( )
inline

◆ TensorIndexTP() [3/8]

template<int dim>
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 0)
qugar::TensorIndexTP< dim >::TensorIndexTP ( int ind)
inlineexplicit

Constructs a new TensorIndexTP object from an index.

Parameters
indAll the indices are set to this values.
Note
Not available for 0-dimensional case.

◆ TensorIndexTP() [4/8]

template<int dim>
qugar::TensorIndexTP< dim >::TensorIndexTP ( const Vector< int, dim > & indices)
explicit

Constructs a new TensorIndexTP object from its indices.

Parameters
indicesIndices along the parametric directions.

◆ TensorIndexTP() [5/8]

template<int dim>
qugar::TensorIndexTP< dim >::TensorIndexTP ( const TensorSizeTP< dim > & indices)
explicit

Constructs a new TensorIndexTP object from its indices.

Parameters
indicesIndices along the parametric directions.

◆ TensorIndexTP() [6/8]

template<int dim>
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 0)
qugar::TensorIndexTP< dim >::TensorIndexTP ( int flat_index,
const TensorIndexTP< dim > & size )
inline

Constructs a new TensorIndexTP object from a flat index and an associated tensor size following the lexicographical ordering convention (i.e., lower indices run faster than higher ones).

Parameters
flat_indexFlat index.
sizeTensor size the flat_index is associated to.
Note
Not available for 0-dimensional case.
Here is the call graph for this function:

◆ TensorIndexTP() [7/8]

template<int dim>
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 0)
qugar::TensorIndexTP< dim >::TensorIndexTP ( int flat_index,
const TensorSizeTP< dim > & size )
inline

Constructs a new TensorIndexTP object from a flat index and an associated tensor size following the lexicographical ordering convention (i.e., lower indices run faster than higher ones).

Parameters
flat_indexFlat index.
sizeTensor size the flat_index is associated to.
Note
Not available for 0-dimensional case.

◆ TensorIndexTP() [8/8]

template<int dim>
template<typename... T>
requires (dim > 1 && sizeof...(T) == dim && std::conjunction_v<std::is_same<int, T>...>)
qugar::TensorIndexTP< dim >::TensorIndexTP ( T... indices)
inlineexplicit

Constructs the tensor index from an argument list.

Parameters
indicesInput arguments for the indices.

Member Function Documentation

◆ as_Vector() [1/2]

template<int dim>
Vector< int, dim > & qugar::TensorIndexTP< dim >::as_Vector ( )

Returns the tensor index casted as a Vector.

Returns
A constant reference to a Vector.
Note
Non-constant version.

◆ as_Vector() [2/2]

template<int dim>
const Vector< int, dim > & qugar::TensorIndexTP< dim >::as_Vector ( ) const
inline

Returns the tensor index casted as a Vector.

Returns
A constant reference to a Vector.
Note
Constant version.
Here is the caller graph for this function:

◆ flat()

template<int dim>
template<typename S >
int qugar::TensorIndexTP< dim >::flat ( const S & size) const
nodiscard

Gets the flat index associated to the current tensor index for a given tensor size.

Parameters
sizeTensor size the current index is associated to.
Returns
Computed flat index.
Template Parameters
SSize type.

◆ hash()

template<int dim>
std::size_t qugar::TensorIndexTP< dim >::hash ( ) const
nodiscard

Computes a hash value for the tensor index.

This function generates a hash value that uniquely identifies the tensor index. The hash value can be used for efficient lookups and comparisons.

Returns
A std::size_t value representing the hash of the tensor index.

◆ operator!=()

template<int dim>
bool qugar::TensorIndexTP< dim >::operator!= ( const TensorIndexTP< dim > & rhs) const
nodiscard

Checks if two tensor indices are different by comparing all its components. They are different if at least one component is different.

Returns
Whether they are different or not.

◆ operator<()

template<int dim>
bool qugar::TensorIndexTP< dim >::operator< ( const TensorIndexTP< dim > & rhs) const
nodiscard

Checks if the current tensor index is smaller than rhs. To determine if one is smaller than the other, all the componets are compared starting from the last one.

Returns
Whether the current tensor is smaller than rhs.

◆ operator==()

template<int dim>
bool qugar::TensorIndexTP< dim >::operator== ( const TensorIndexTP< dim > & rhs) const
nodiscard

Checks if two tensor indices are equal by comparing all its components. They are equal if all the components are equal.

Returns
Whether they are equal or not.

◆ remove_component()

template<int dim>
template<int aux_dim = dim>
requires (aux_dim == dim && dim > 1)
TensorIndexTP< dim - 1 > qugar::TensorIndexTP< dim >::remove_component ( int comp) const

Creates a new index by removing one of its component.

Parameters
compIndex of the component to be removed.
Returns
New generated index.

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