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

Unbounded dense matrix holding floating-point values of type double. More...

+ Inheritance diagram for CDPL.Math.DMatrix:

Public Member Functions

None __init__ ()
 Constructs an empty matrix (zero rows and zero columns).
 
None __init__ (DMatrix m)
 Constructs a copy of the matrix m. More...
 
None __init__ (int m, int n)
 Constructs an m×n matrix with default-initialized elements. More...
 
None __init__ (int m, int n, float v)
 Constructs an m×n matrix with every element initialized to v. More...
 
None __init__ (ConstFMatrixExpression e)
 Constructs the matrix from the matrix expression e (materializing the expression result). More...
 
None __init__ (ConstDMatrixExpression e)
 Constructs the matrix from the matrix expression e (materializing the expression result). More...
 
None __init__ (ConstLMatrixExpression e)
 Constructs the matrix from the matrix expression e (materializing the expression result). More...
 
None __init__ (ConstULMatrixExpression e)
 Constructs the matrix from the matrix expression e (materializing the expression result). More...
 
None __init__ (object a)
 Constructs the matrix from the 2D numpy.ndarray object a. More...
 
None resize (int m, int n, bool preserve=True, float v=0.0)
 Resizes the matrix to m×n elements. More...
 
None clear (float v=0.0)
 Sets every element of the matrix to the value v. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
DMatrix assign (ConstFMatrixExpression e)
 Assigns the matrix expression e to this matrix (via a temporary to handle aliasing). More...
 
DMatrix assign (ConstDMatrixExpression e)
 Assigns the matrix expression e to this matrix (via a temporary to handle aliasing). More...
 
DMatrix assign (ConstLMatrixExpression e)
 Assigns the matrix expression e to this matrix (via a temporary to handle aliasing). More...
 
DMatrix assign (ConstULMatrixExpression e)
 Assigns the matrix expression e to this matrix (via a temporary to handle aliasing). More...
 
DMatrix assign (DMatrix m)
 Copy-assigns the contents of m to this matrix. More...
 
DMatrix assign (object a)
 Assigns the contents of the 2D numpy.ndarray object a to this matrix. More...
 
int getSize1 ()
 Returns the number of rows. More...
 
int getSize2 ()
 Returns the number of columns. More...
 
bool isEmpty ()
 Tells whether the matrix is empty. More...
 
float getElement (int i, int j)
 Returns the element at (i, j). More...
 
object toArray ()
 Converts the DMatrix instance into a corresponding numpy.ndarray object. More...
 
None swap (DMatrix m)
 Swaps the contents of this matrix with those of m. More...
 
None setElement (int i, int j, float v)
 Sets the value of the element (i, j) to v. More...
 
float __call__ (int i, int j)
 Returns the element at (i, j). More...
 
float __getitem__ (tuple ij)
 Returns the element at (i, j). More...
 
int __len__ ()
 Returns the number of rows. More...
 
bool __eq__ (DMatrix m)
 Returns the result of the comparison operation self == m. More...
 
bool __eq__ (ConstDMatrixExpression e)
 Returns the result of the comparison operation self == e. More...
 
bool __ne__ (DMatrix m)
 Returns the result of the comparison operation self != m. More...
 
bool __ne__ (ConstDMatrixExpression e)
 Returns the result of the comparison operation self != e. More...
 
str __str__ ()
 Returns a string representation of the DMatrix instance. More...
 
DMatrix __pos__ ()
 Returns self. More...
 
ConstDMatrixExpression __neg__ ()
 Returns the result of the operation self * -1. More...
 
ConstDMatrixExpression __add__ (ConstDMatrixExpression e)
 Returns the result of the addition operation self + e. More...
 
ConstDMatrixExpression __sub__ (ConstDMatrixExpression e)
 Returns the result of the subtraction operation self - e. More...
 
ConstDMatrixExpression __mul__ (float t)
 Returns the result of the multiplication operation self * t. More...
 
ConstDMatrixExpression __mul__ (ConstDMatrixExpression e)
 Returns the result of the multiplication operation self * e. More...
 
ConstDVectorExpression __mul__ (ConstDVectorExpression e)
 Returns the result of the multiplication operation self * e. More...
 
ConstDMatrixExpression __div__ (float t)
 Returns the result of the division operation self // t. More...
 
ConstDMatrixExpression __truediv__ (float t)
 Returns the result of the true division operation self / t. More...
 
ConstDMatrixExpression __rmul__ (float t)
 Returns the result of the multiplication operation t * self. More...
 
None __setitem__ (tuple ij, float v)
 Sets the value of the element (i, j) to v. More...
 
DMatrix __iadd__ (DMatrix m)
 Adds the contents of the matrix m element-wise to this matrix (no alias check needed). More...
 
DMatrix __iadd__ (ConstDMatrixExpression e)
 Adds the matrix expression e element-wise to this matrix (via a temporary to handle aliasing). More...
 
DMatrix __isub__ (DMatrix m)
 Subtracts the contents of the matrix m element-wise from this matrix (no alias check needed). More...
 
DMatrix __isub__ (ConstDMatrixExpression e)
 Subtracts the matrix expression e element-wise from this matrix (via a temporary to handle aliasing). More...
 
DMatrix __imul__ (float t)
 Multiplies every element by the scalar t. More...
 
DMatrix __idiv__ (float t)
 Divides every element by the scalar t. More...
 
DMatrix __itruediv__ (float t)
 Divides every element by the scalar t. More...
 

Properties

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

Detailed Description

Unbounded dense matrix holding floating-point values of type double.

Constructor & Destructor Documentation

◆ __init__() [1/8]

None CDPL.Math.DMatrix.__init__ ( DMatrix  m)

Constructs a copy of the matrix m.

Parameters
mThe matrix to copy.

◆ __init__() [2/8]

None CDPL.Math.DMatrix.__init__ ( int  m,
int  n 
)

Constructs an m×n matrix with default-initialized elements.

Parameters
mThe number of rows.
nThe number of columns.

◆ __init__() [3/8]

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

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

Parameters
mThe number of rows.
nThe number of columns.
vThe value used for element initialization.

◆ __init__() [4/8]

None CDPL.Math.DMatrix.__init__ ( ConstFMatrixExpression  e)

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

Parameters
eThe matrix expression to materialize.

◆ __init__() [5/8]

None CDPL.Math.DMatrix.__init__ ( ConstDMatrixExpression  e)

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

Parameters
eThe matrix expression to materialize.

◆ __init__() [6/8]

None CDPL.Math.DMatrix.__init__ ( ConstLMatrixExpression  e)

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

Parameters
eThe matrix expression to materialize.

◆ __init__() [7/8]

None CDPL.Math.DMatrix.__init__ ( ConstULMatrixExpression  e)

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

Parameters
eThe matrix expression to materialize.

◆ __init__() [8/8]

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

Constructs the matrix from the 2D numpy.ndarray object a.

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

Member Function Documentation

◆ resize()

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

Resizes the matrix to m×n elements.

Parameters
mThe new row count.
nThe new column count.
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 (or for all elements when preserve is False).

◆ clear()

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

Sets every element of the matrix to the value v.

Parameters
vThe fill value.

◆ getObjectID()

int CDPL.Math.DMatrix.getObjectID ( )

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

Different Python DMatrix 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 DMatrix 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/6]

DMatrix CDPL.Math.DMatrix.assign ( ConstFMatrixExpression  e)

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

Parameters
eThe source matrix expression.
Returns
self.

◆ assign() [2/6]

DMatrix CDPL.Math.DMatrix.assign ( ConstDMatrixExpression  e)

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

Parameters
eThe source matrix expression.
Returns
self.

◆ assign() [3/6]

DMatrix CDPL.Math.DMatrix.assign ( ConstLMatrixExpression  e)

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

Parameters
eThe source matrix expression.
Returns
self.

◆ assign() [4/6]

DMatrix CDPL.Math.DMatrix.assign ( ConstULMatrixExpression  e)

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

Parameters
eThe source matrix expression.
Returns
self.

◆ assign() [5/6]

DMatrix CDPL.Math.DMatrix.assign ( DMatrix  m)

Copy-assigns the contents of m to this matrix.

Parameters
mThe source matrix.
Returns
self.

◆ assign() [6/6]

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

Assigns the contents of the 2D numpy.ndarray object a to this matrix.

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

◆ getSize1()

int CDPL.Math.DMatrix.getSize1 ( )

Returns the number of rows.

Returns
The number of rows.

◆ getSize2()

int CDPL.Math.DMatrix.getSize2 ( )

Returns the number of columns.

Returns
The number of columns.

◆ isEmpty()

bool CDPL.Math.DMatrix.isEmpty ( )

Tells whether the matrix is empty.

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

◆ getElement()

float CDPL.Math.DMatrix.getElement ( int  i,
int  j 
)

Returns the element at (i, j).

Parameters
iThe zero-based row index.
jThe zero-based column index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif either index is out of range.

◆ toArray()

object CDPL.Math.DMatrix.toArray ( )

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

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

◆ swap()

None CDPL.Math.DMatrix.swap ( DMatrix  m)

Swaps the contents of this matrix with those of m.

Parameters
mThe matrix to swap with.

◆ setElement()

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

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

Parameters
iThe zero-based row index.
jThe zero-based column index.
vThe new value of the element.
Exceptions
Base.IndexErrorif any of the indices is out of range.

◆ __call__()

float CDPL.Math.DMatrix.__call__ ( int  i,
int  j 
)

Returns the element at (i, j).

Parameters
iThe zero-based row index.
jThe zero-based column index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif either index is out of range.

◆ __getitem__()

float CDPL.Math.DMatrix.__getitem__ ( tuple  ij)

Returns the element at (i, j).

Parameters
iThe zero-based row index.
jThe zero-based column index.
Returns
The value of the element.
Exceptions
Base.IndexErrorif either index is out of range.

◆ __len__()

int CDPL.Math.DMatrix.__len__ ( )

Returns the number of rows.

Returns
The number of rows.

◆ __eq__() [1/2]

bool CDPL.Math.DMatrix.__eq__ ( DMatrix  m)

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

Parameters
mThe DMatrix instance to be compared with.
Returns
The result of the comparison operation.

◆ __eq__() [2/2]

bool CDPL.Math.DMatrix.__eq__ ( ConstDMatrixExpression  e)

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

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

◆ __ne__() [1/2]

bool CDPL.Math.DMatrix.__ne__ ( DMatrix  m)

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

Parameters
mThe DMatrix instance to be compared with.
Returns
The result of the comparison operation.

◆ __ne__() [2/2]

bool CDPL.Math.DMatrix.__ne__ ( ConstDMatrixExpression  e)

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

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

◆ __str__()

str CDPL.Math.DMatrix.__str__ ( )

Returns a string representation of the DMatrix instance.

Returns
The generated string representation.

◆ __pos__()

DMatrix CDPL.Math.DMatrix.__pos__ ( )

Returns self.

Returns
self.

◆ __neg__()

ConstDMatrixExpression CDPL.Math.DMatrix.__neg__ ( )

Returns the result of the operation self * -1.

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

◆ __add__()

ConstDMatrixExpression CDPL.Math.DMatrix.__add__ ( ConstDMatrixExpression  e)

Returns the result of the addition operation self + e.

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

◆ __sub__()

ConstDMatrixExpression CDPL.Math.DMatrix.__sub__ ( ConstDMatrixExpression  e)

Returns the result of the subtraction operation self - e.

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

◆ __mul__() [1/3]

ConstDMatrixExpression CDPL.Math.DMatrix.__mul__ ( float  t)

Returns the result of the multiplication operation self * t.

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

◆ __mul__() [2/3]

ConstDMatrixExpression CDPL.Math.DMatrix.__mul__ ( ConstDMatrixExpression  e)

Returns the result of the multiplication operation self * e.

Parameters
eSpecifies the multiplier.
Returns
A ConstDMatrixExpression instance holding the result of the multiplication.

◆ __mul__() [3/3]

ConstDVectorExpression CDPL.Math.DMatrix.__mul__ ( ConstDVectorExpression  e)

Returns the result of the multiplication operation self * e.

Parameters
eSpecifies the multiplier.
Returns
A ConstDVectorExpression instance holding the result of the multiplication.

◆ __div__()

ConstDMatrixExpression CDPL.Math.DMatrix.__div__ ( float  t)

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

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

◆ __truediv__()

ConstDMatrixExpression CDPL.Math.DMatrix.__truediv__ ( float  t)

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

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

◆ __rmul__()

ConstDMatrixExpression CDPL.Math.DMatrix.__rmul__ ( float  t)

Returns the result of the multiplication operation t * self.

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

◆ __setitem__()

None CDPL.Math.DMatrix.__setitem__ ( tuple  ij,
float  v 
)

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

Parameters
iThe zero-based row index.
jThe zero-based column index.
vThe new value of the element.
Exceptions
Base.IndexErrorif any of the indices is out of range.

◆ __iadd__() [1/2]

DMatrix CDPL.Math.DMatrix.__iadd__ ( DMatrix  m)

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

Parameters
mThe source matrix.
Returns
self.

◆ __iadd__() [2/2]

DMatrix CDPL.Math.DMatrix.__iadd__ ( ConstDMatrixExpression  e)

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

Parameters
eThe source matrix expression.
Returns
self.

◆ __isub__() [1/2]

DMatrix CDPL.Math.DMatrix.__isub__ ( DMatrix  m)

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

Parameters
mThe source matrix.
Returns
self.

◆ __isub__() [2/2]

DMatrix CDPL.Math.DMatrix.__isub__ ( ConstDMatrixExpression  e)

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

Parameters
eThe source matrix expression.
Returns
self.

◆ __imul__()

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

Multiplies every element by the scalar t.

Parameters
tThe scalar multiplier.
Returns
self.

◆ __idiv__()

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

Divides every element by the scalar t.

Parameters
tThe scalar divisor.
Returns
self.

◆ __itruediv__()

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

Divides every element by the scalar t.

Parameters
tThe scalar divisor.
Returns
self.