Chemical Data Processing Library Python API - Version 1.4.0
Public Member Functions | Properties | List of all members
CDPL.Math.DGrid Class Reference

Unbounded dense grid storing floating-point values of type double. More...

+ Inheritance diagram for CDPL.Math.DGrid:

Public Member Functions

None __init__ ()
 Constructs an empty grid (zero size on every axis).
 
None __init__ (DGrid g)
 Constructs a copy of the grid g. More...
 
None __init__ (int m, int n, int o)
 Constructs an m×n×o grid with default-initialized elements. More...
 
None __init__ (int m, int n, int o, float v)
 Constructs an m×n×o grid with every element initialized to v. More...
 
None __init__ (ConstFGridExpression e)
 Constructs the grid from the grid expression e (materializing the expression result). More...
 
None __init__ (ConstDGridExpression e)
 Constructs the grid from the grid expression e (materializing the expression result). More...
 
None __init__ (object a)
 Constructs the grid from the 3D numpy.ndarray object a. More...
 
None resize (int m, int n, int o, bool preserve=True, float v=0.0)
 Resizes the grid to m×n×o elements. More...
 
None clear (float v=0.0)
 Sets every element of the grid to the value v. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
DGrid assign (ConstFGridExpression e)
 Assigns the grid expression e to this grid (via a temporary to handle aliasing). More...
 
DGrid assign (ConstDGridExpression e)
 Assigns the grid expression e to this grid (via a temporary to handle aliasing). More...
 
DGrid assign (DGrid g)
 Copy-assigns the contents of g to this grid. More...
 
DGrid assign (object a)
 Assigns the contents of the 3D numpy.ndarray object a to this grid. More...
 
int getSize1 ()
 Returns the first-axis size. More...
 
int getSize2 ()
 Returns the second-axis size. More...
 
int getSize3 ()
 Returns the third-axis size. More...
 
bool isEmpty ()
 Tells whether the grid is empty. More...
 
float getElement (int i, int j, int k)
 Returns the element at (i, j, k). More...
 
float getElement (int i)
 Returns the element at linear index i. More...
 
object toArray ()
 Converts the DGrid instance into a corresponding numpy.ndarray object. More...
 
int getSize ()
 Returns the total element count \( \mathrm{size}_1 \cdot \mathrm{size}_2 \cdot \mathrm{size}_3 \). More...
 
None swap (DGrid g)
 Swaps the contents of this grid with those of g. More...
 
None setElement (int i, int j, int k, float v)
 Sets the value of the element (i, j, k) to v. More...
 
None setElement (int i, float v)
 Sets the value of the element at linear index i to v. More...
 
float __call__ (int i, int j, int k)
 Returns the element at (i, j, k). More...
 
float __call__ (int i)
 Returns the element at linear index i. More...
 
float __getitem__ (tuple ijk)
 Returns the element at (i, j, k). More...
 
float __getitem__ (int i)
 Returns the element at linear index i. More...
 
int __len__ ()
 Returns the total element count \( \mathrm{size}_1 \cdot \mathrm{size}_2 \cdot \mathrm{size}_3 \). More...
 
bool __eq__ (DGrid g)
 Returns the result of the comparison operation self == g. More...
 
bool __eq__ (ConstDGridExpression e)
 Returns the result of the comparison operation self == e. More...
 
bool __ne__ (DGrid g)
 Returns the result of the comparison operation self != g. More...
 
bool __ne__ (ConstDGridExpression e)
 Returns the result of the comparison operation self != e. More...
 
str __str__ ()
 Returns a string representation of the DGrid instance. More...
 
DGrid __pos__ ()
 Returns self. More...
 
ConstDGridExpression __neg__ ()
 Returns the result of the operation self * -1. More...
 
ConstDGridExpression __add__ (ConstDGridExpression e)
 Returns the result of the addition operation self + e. More...
 
ConstDGridExpression __sub__ (ConstDGridExpression e)
 Returns the result of the subtraction operation self - e. More...
 
ConstDGridExpression __mul__ (float t)
 Returns the result of the multiplication operation self * t. More...
 
ConstDGridExpression __div__ (float t)
 Returns the result of the division operation self // t. More...
 
ConstDGridExpression __truediv__ (float t)
 Returns the result of the true division operation self / t. More...
 
ConstDGridExpression __rmul__ (float t)
 Returns the result of the multiplication operation t * self. More...
 
None __setitem__ (tuple ijk, float v)
 Sets the value of the element (i, j, k) to v. More...
 
None __setitem__ (int i, float v)
 Sets the value of the element at linear index i to v. More...
 
DGrid __iadd__ (DGrid g)
 Adds the contents of the grid g element-wise to this grid (no alias check needed). More...
 
DGrid __iadd__ (ConstDGridExpression e)
 Adds the grid expression e element-wise to this grid (via a temporary to handle aliasing). More...
 
DGrid __isub__ (DGrid g)
 Subtracts the contents of the grid g element-wise from this grid (no alias check needed). More...
 
DGrid __isub__ (ConstDGridExpression e)
 Subtracts the grid expression e element-wise from this grid (via a temporary to handle aliasing). More...
 
DGrid __imul__ (float t)
 Multiplies every element by the scalar t. More...
 
DGrid __idiv__ (float t)
 Divides every element by the scalar t. More...
 
DGrid __itruediv__ (float t)
 Divides every element by the scalar t. More...
 

Properties

 objectID = property(getObjectID)
 
 size1 = property(getSize1)
 
 size2 = property(getSize2)
 
 size3 = property(getSize3)
 

Detailed Description

Unbounded dense grid storing floating-point values of type double.

Constructor & Destructor Documentation

◆ __init__() [1/6]

None CDPL.Math.DGrid.__init__ ( DGrid  g)

Constructs a copy of the grid g.

Parameters
gThe grid to copy.

◆ __init__() [2/6]

None CDPL.Math.DGrid.__init__ ( int  m,
int  n,
int  o 
)

Constructs an m×n×o grid with default-initialized elements.

Parameters
mThe size along the first axis.
nThe size along the second axis.
oThe size along the third axis.

◆ __init__() [3/6]

None CDPL.Math.DGrid.__init__ ( int  m,
int  n,
int  o,
float  v 
)

Constructs an m×n×o grid with every element initialized to v.

Parameters
mThe size along the first axis.
nThe size along the second axis.
oThe size along the third axis.
vThe value used for element initialization.

◆ __init__() [4/6]

None CDPL.Math.DGrid.__init__ ( ConstFGridExpression  e)

Constructs the grid from the grid expression e (materializing the expression result).

Parameters
eThe grid expression to materialize.

◆ __init__() [5/6]

None CDPL.Math.DGrid.__init__ ( ConstDGridExpression  e)

Constructs the grid from the grid expression e (materializing the expression result).

Parameters
eThe grid expression to materialize.

◆ __init__() [6/6]

None CDPL.Math.DGrid.__init__ ( object  a)

Constructs the grid from the 3D numpy.ndarray object a.

Parameters
aThe numpy.ndarray object.
See also
[NUMPY]

Member Function Documentation

◆ resize()

None CDPL.Math.DGrid.resize ( int  m,
int  n,
int  o,
bool   preserve = True,
float   v = 0.0 
)

Resizes the grid to m×n×o elements.

Parameters
mThe new first-axis size.
nThe new second-axis size.
oThe new third-axis size.
preserveIf True, existing element values at indices that remain valid are kept. If False, all elements are set to v.
vThe fill value for newly added elements (and for all elements when preserve is False).

◆ clear()

None CDPL.Math.DGrid.clear ( float   v = 0.0)

Sets every element of the grid to the value v.

Parameters
vThe fill value.

◆ getObjectID()

int CDPL.Math.DGrid.getObjectID ( )

Returns the numeric identifier (ID) of the wrapped C++ class instance.

Different Python DGrid instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two DGrid instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ assign() [1/4]

DGrid CDPL.Math.DGrid.assign ( ConstFGridExpression  e)

Assigns the grid expression e to this grid (via a temporary to handle aliasing).

Parameters
eThe source grid expression.
Returns
self.

◆ assign() [2/4]

DGrid CDPL.Math.DGrid.assign ( ConstDGridExpression  e)

Assigns the grid expression e to this grid (via a temporary to handle aliasing).

Parameters
eThe source grid expression.
Returns
self.

◆ assign() [3/4]

DGrid CDPL.Math.DGrid.assign ( DGrid  g)

Copy-assigns the contents of g to this grid.

Parameters
gThe source grid.
Returns
self.

◆ assign() [4/4]

DGrid CDPL.Math.DGrid.assign ( object  a)

Assigns the contents of the 3D numpy.ndarray object a to this grid.

Parameters
aThe numpy.ndarray object.
See also
[NUMPY]

◆ getSize1()

int CDPL.Math.DGrid.getSize1 ( )

Returns the first-axis size.

Returns
The size along the first axis.

◆ getSize2()

int CDPL.Math.DGrid.getSize2 ( )

Returns the second-axis size.

Returns
The size along the second axis.

◆ getSize3()

int CDPL.Math.DGrid.getSize3 ( )

Returns the third-axis size.

Returns
The size along the third axis.

◆ isEmpty()

bool CDPL.Math.DGrid.isEmpty ( )

Tells whether the grid is empty.

Returns
True if the underlying storage holds no elements, and False otherwise.

◆ getElement() [1/2]

float CDPL.Math.DGrid.getElement ( int  i,
int  j,
int  k 
)

Returns the element at (i, j, k).

Parameters
iThe zero-based first-axis index.
jThe zero-based second-axis index.
kThe zero-based third-axis index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif any of the indices is out of range.

◆ getElement() [2/2]

float CDPL.Math.DGrid.getElement ( int  i)

Returns the element at linear index i.

Parameters
iThe zero-based linear index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif i is out of range.

◆ toArray()

object CDPL.Math.DGrid.toArray ( )

Converts the DGrid instance into a corresponding numpy.ndarray object.

Returns
The generated numpy.ndarray object.
See also
[NUMPY]

◆ getSize()

int CDPL.Math.DGrid.getSize ( )

Returns the total element count \( \mathrm{size}_1 \cdot \mathrm{size}_2 \cdot \mathrm{size}_3 \).

Returns
The total number of elements.

◆ swap()

None CDPL.Math.DGrid.swap ( DGrid  g)

Swaps the contents of this grid with those of g.

Parameters
gThe grid to swap with.

◆ setElement() [1/2]

None CDPL.Math.DGrid.setElement ( int  i,
int  j,
int  k,
float  v 
)

Sets the value of the element (i, j, k) to v.

Parameters
iThe zero-based first-axis index.
jThe zero-based second-axis index.
kThe zero-based third-axis index.
vThe new value of the element.
Exceptions
Base.IndexErrorif any of the indices is out of range.

◆ setElement() [2/2]

None CDPL.Math.DGrid.setElement ( int  i,
float  v 
)

Sets the value of the element at linear index i to v.

Parameters
iThe zero-based linear index.
vThe new value of the element.

◆ __call__() [1/2]

float CDPL.Math.DGrid.__call__ ( int  i,
int  j,
int  k 
)

Returns the element at (i, j, k).

Parameters
iThe zero-based first-axis index.
jThe zero-based second-axis index.
kThe zero-based third-axis index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif any of the indices is out of range.

◆ __call__() [2/2]

float CDPL.Math.DGrid.__call__ ( int  i)

Returns the element at linear index i.

Parameters
iThe zero-based linear index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif i is out of range.

◆ __getitem__() [1/2]

float CDPL.Math.DGrid.__getitem__ ( tuple  ijk)

Returns the element at (i, j, k).

Parameters
iThe zero-based first-axis index.
jThe zero-based second-axis index.
kThe zero-based third-axis index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif any of the indices is out of range.

◆ __getitem__() [2/2]

float CDPL.Math.DGrid.__getitem__ ( int  i)

Returns the element at linear index i.

Parameters
iThe zero-based linear index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif i is out of range.

◆ __len__()

int CDPL.Math.DGrid.__len__ ( )

Returns the total element count \( \mathrm{size}_1 \cdot \mathrm{size}_2 \cdot \mathrm{size}_3 \).

Returns
The total number of elements.

◆ __eq__() [1/2]

bool CDPL.Math.DGrid.__eq__ ( DGrid  g)

Returns the result of the comparison operation self == g.

Parameters
gThe DGrid instance to be compared with.
Returns
The result of the comparison operation.

◆ __eq__() [2/2]

bool CDPL.Math.DGrid.__eq__ ( ConstDGridExpression  e)

Returns the result of the comparison operation self == e.

Parameters
eThe ConstDGridExpression instance to be compared with.
Returns
The result of the comparison operation.

◆ __ne__() [1/2]

bool CDPL.Math.DGrid.__ne__ ( DGrid  g)

Returns the result of the comparison operation self != g.

Parameters
gThe DGrid instance to be compared with.
Returns
The result of the comparison operation.

◆ __ne__() [2/2]

bool CDPL.Math.DGrid.__ne__ ( ConstDGridExpression  e)

Returns the result of the comparison operation self != e.

Parameters
eThe ConstDGridExpression instance to be compared with.
Returns
The result of the comparison operation.

◆ __str__()

str CDPL.Math.DGrid.__str__ ( )

Returns a string representation of the DGrid instance.

Returns
The generated string representation.

◆ __pos__()

DGrid CDPL.Math.DGrid.__pos__ ( )

Returns self.

Returns
self.

◆ __neg__()

ConstDGridExpression CDPL.Math.DGrid.__neg__ ( )

Returns the result of the operation self * -1.

Returns
A ConstDGridExpression instance holding the result of the element negation.

◆ __add__()

ConstDGridExpression CDPL.Math.DGrid.__add__ ( ConstDGridExpression  e)

Returns the result of the addition operation self + e.

Parameters
eSpecifies the second addend.
Returns
A ConstDGridExpression instance holding the result of the addition.

◆ __sub__()

ConstDGridExpression CDPL.Math.DGrid.__sub__ ( ConstDGridExpression  e)

Returns the result of the subtraction operation self - e.

Parameters
eSpecifies the subtrahend.
Returns
A DGrid instance holding the result of the subtraction.

◆ __mul__()

ConstDGridExpression CDPL.Math.DGrid.__mul__ ( float  t)

Returns the result of the multiplication operation self * t.

Parameters
tSpecifies the multiplier.
Returns
A ConstDGridExpression instance holding the result of the multiplication.

◆ __div__()

ConstDGridExpression CDPL.Math.DGrid.__div__ ( float  t)

Returns the result of the division operation self // t.

Parameters
tSpecifies the divisor.
Returns
A ConstDGridExpression instance holding the result of the division.

◆ __truediv__()

ConstDGridExpression CDPL.Math.DGrid.__truediv__ ( float  t)

Returns the result of the true division operation self / t.

Parameters
tSpecifies the divisor.
Returns
A ConstDGridExpression instance holding the result of the division.

◆ __rmul__()

ConstDGridExpression CDPL.Math.DGrid.__rmul__ ( float  t)

Returns the result of the multiplication operation t * self.

Parameters
tSpecifies the multiplicand.
Returns
A ConstDGridExpression instance holding the result of the multiplication.

◆ __setitem__() [1/2]

None CDPL.Math.DGrid.__setitem__ ( tuple  ijk,
float  v 
)

Sets the value of the element (i, j, k) to v.

Parameters
iThe zero-based first-axis index.
jThe zero-based second-axis index.
kThe zero-based third-axis index.
vThe new value of the element.
Exceptions
Base.IndexErrorif any of the indices is out of range.

◆ __setitem__() [2/2]

None CDPL.Math.DGrid.__setitem__ ( int  i,
float  v 
)

Sets the value of the element at linear index i to v.

Parameters
iThe zero-based linear index.
vThe new value of the element.

◆ __iadd__() [1/2]

DGrid CDPL.Math.DGrid.__iadd__ ( DGrid  g)

Adds the contents of the grid g element-wise to this grid (no alias check needed).

Parameters
gThe source grid.
Returns
self.

◆ __iadd__() [2/2]

DGrid CDPL.Math.DGrid.__iadd__ ( ConstDGridExpression  e)

Adds the grid expression e element-wise to this grid (via a temporary to handle aliasing).

Parameters
eThe source grid expression.
Returns
self.

◆ __isub__() [1/2]

DGrid CDPL.Math.DGrid.__isub__ ( DGrid  g)

Subtracts the contents of the grid g element-wise from this grid (no alias check needed).

Parameters
gThe source grid.
Returns
self.

◆ __isub__() [2/2]

DGrid CDPL.Math.DGrid.__isub__ ( ConstDGridExpression  e)

Subtracts the grid expression e element-wise from this grid (via a temporary to handle aliasing).

Parameters
eThe source grid expression.
Returns
self.

◆ __imul__()

DGrid CDPL.Math.DGrid.__imul__ ( float  t)

Multiplies every element by the scalar t.

Parameters
tThe scalar multiplier.
Returns
self.

◆ __idiv__()

DGrid CDPL.Math.DGrid.__idiv__ ( float  t)

Divides every element by the scalar t.

Parameters
tThe scalar divisor.
Returns
self.

◆ __itruediv__()

DGrid CDPL.Math.DGrid.__itruediv__ ( float  t)

Divides every element by the scalar t.

Parameters
tThe scalar divisor.
Returns
self.