KADATH
Kadath::Index Class Reference

Class that gives the position inside a multi-dimensional Array. More...

#include <index.hpp>

Inheritance diagram for Kadath::Index:

Public Types

using Data_type = Memory_mapped_array< int >
 Type of data. More...
 

Public Member Functions

 Index (const Dim_array &dim)
 Standard constructor. More...
 
 Index (const Tensor &so)
 Copy constructor. More...
 
void swap (Index &so)
 Sylvain's stuff. More...
 
int & set (int i)
 Read/write of the position in a given dimension. More...
 
int operator() (int i) const
 Read/write of the position in a given dimension. More...
 
int get_ndim () const
 Returns the number of dimensions. More...
 
Dim_array const & get_sizes () const
 Returns all the dimensions. More...
 
void set_start ()
 Sets the position to zero in all dimensions. More...
 
bool inc (int increm, int var=0)
 Increments the position of the Index. More...
 
bool inc1 (int var)
 Increment on one dimension. More...
 
bool inc ()
 Increment on the first dimension. More...
 
bool inc_vanilla (int increm, int var)
 General increment. More...
 
void operator= (const Index &so)
 Assignment operator. More...
 
bool operator== (const Index &xx) const
 Comparison operator. More...
 

Protected Attributes

Dim_array sizes
 Sizes of the associated Array. More...
 
Data_type coord
 Value of each index. More...
 

Friends

template<class >
class Array
 
ostream & operator<< (ostream &, const Index &)
 Operator<<. More...
 

Detailed Description

Class that gives the position inside a multi-dimensional Array.

It can also be used to give the indexes of a given component of a Tensor.

It simply consists of a list of integers.

Definition at line 38 of file index.hpp.

Member Typedef Documentation

◆ Data_type

using Kadath::Index::Data_type = Memory_mapped_array<int>

Type of data.

Definition at line 41 of file index.hpp.

Constructor & Destructor Documentation

◆ Index() [1/2]

Kadath::Index::Index ( const Dim_array dim)
inlineexplicit

Standard constructor.

All the positions are set to zero.

Parameters
dim[input] Sizes in each dimensions.

Definition at line 57 of file index.hpp.

References coord, and Kadath::Dim_array::get_ndim().

◆ Index() [2/2]

Kadath::Index::Index ( const Tensor so)

Copy constructor.

Parameters
sosource to be copied. Constructor for looping on components of a tensor

Definition at line 26 of file index.cpp.

References coord, get_ndim(), Kadath::Tensor::get_ndim(), Kadath::Dim_array::set(), and sizes.

Member Function Documentation

◆ get_ndim()

int Kadath::Index::get_ndim ( ) const
inline

Returns the number of dimensions.

Definition at line 81 of file index.hpp.

References Kadath::Dim_array::get_ndim(), and sizes.

◆ get_sizes()

Dim_array const& Kadath::Index::get_sizes ( ) const
inline

Returns all the dimensions.

Definition at line 85 of file index.hpp.

References sizes.

◆ inc() [1/2]

bool Kadath::Index::inc ( )
inline

Increment on the first dimension.

Definition at line 130 of file index.hpp.

References inc1().

◆ inc() [2/2]

bool Kadath::Index::inc ( int  increm,
int  var = 0 
)
inline

Increments the position of the Index.

If one reaches the last point of a dimension, then the next one is increased.

Parameters
increm[input] value of the increment.
var[input] dimension to be incremented.
Returns
false if the result is outside the Array and true otherwise.

Definition at line 99 of file index.hpp.

References coord, get_ndim(), and sizes.

◆ inc1()

bool Kadath::Index::inc1 ( int  var)
inline

Increment on one dimension.

Definition at line 114 of file index.hpp.

References coord, get_ndim(), and sizes.

◆ inc_vanilla()

bool Kadath::Index::inc_vanilla ( int  increm,
int  var 
)
inline

General increment.

Definition at line 134 of file index.hpp.

References coord, get_ndim(), and sizes.

◆ operator()()

int Kadath::Index::operator() ( int  i) const
inline

Read/write of the position in a given dimension.

Parameters
i[input] dimension.

Definition at line 77 of file index.hpp.

References coord, and get_ndim().

◆ operator=()

void Kadath::Index::operator= ( const Index so)
inline

Assignment operator.

Parameters
sosource to copy from.

Definition at line 152 of file index.hpp.

References coord, get_ndim(), and sizes.

◆ operator==()

bool Kadath::Index::operator== ( const Index xx) const
inline

Comparison operator.

Definition at line 155 of file index.hpp.

References coord, and get_ndim().

◆ set()

int& Kadath::Index::set ( int  i)
inline

Read/write of the position in a given dimension.

Parameters
i[input] dimension.

Definition at line 72 of file index.hpp.

References coord, and get_ndim().

◆ set_start()

void Kadath::Index::set_start ( )
inline

Sets the position to zero in all dimensions.

Definition at line 88 of file index.hpp.

References coord, and get_ndim().

◆ swap()

void Kadath::Index::swap ( Index so)
inline

Sylvain's stuff.

Definition at line 66 of file index.hpp.

References coord, sizes, and Kadath::Dim_array::swap().

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  o,
const Index so 
)
friend

Operator<<.

Definition at line 36 of file index.cpp.

Member Data Documentation

◆ coord

Data_type Kadath::Index::coord
protected

Value of each index.

Definition at line 49 of file index.hpp.

◆ sizes

Dim_array Kadath::Index::sizes
protected

Sizes of the associated Array.

When used with a Tensor, it is the dimension, for each tensorial index.

Definition at line 48 of file index.hpp.


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