trplearn.trpalg module#
- class trplearn.trpalg.Manipulation(data)[source]#
Bases:
objectBasic common manipulation for TropicalAlgebra classes.
- property T#
Getting the transposed array.
- property ndim#
Number of array dimensions.
- class trplearn.trpalg.MaxPlus(data)[source]#
Bases:
TropicalAlgebra,ManipulationMax-plus double semiring.
Max-plus double semiring is the following algebraic system: \((\double{R}\cup{\pm\infty},-\infty,0,\max,+, +\infty,0,\min,+,-a)\), where set, zero, unit, add, mult, dualzero, dualunit, dualadd, dualmult, conjugate, from left to right.
- Parameters:
data (array-like) – An array.
- property C#
Getting the conjugation array.
- Returns:
The conjugate of the current MaxPlus object.
- Return type:
- property H#
Getting the Hermitian array.
- Returns:
The Hermitian of the current MaxPlus object.
- Return type:
- add(other)[source]#
Max-plus addition defined by \(a\oplus b=\max(a,b)\).
- Parameters:
other (int, float, MaxPlus) – Addition.
- Returns:
Result of max-plus addition by other.
- Return type:
Examples
>>> a = MaxPlus(3) >>> b = MaxPlus(5) >>> a.add(b) MaxPlus(5)
>>> c = MaxPlus([1, 5, 3]) >>> d = MaxPlus([4, 2, 6]) >>> c.add(d) MaxPlus([4 5 6])
>>> A = MaxPlus([[1, 3], [5, 7]]) >>> B = MaxPlus([[2, 6], [4, 8]]) >>> A.add(B) MaxPlus([[2 6] [5 8]])
- dualpow(n)[source]#
Max-plus dual matrix power.
- Parameters:
n (int) – The power to raise the matrix to.
- Returns:
Result of max-plus dual matrix power.
- Return type:
- Raises:
ValueError – If n is negative.
- class trplearn.trpalg.MinPlus(data)[source]#
Bases:
TropicalAlgebra,ManipulationMin-plus double semiring.
Min-plus double semiring is the following algebraic system: \((\double{R}\cup{\pm\infty},+\infty,0,\min,+, -\infty,0,\max,+,-a)\), where set, zero, unit, add, mult, dualzero, dualunit, dualadd, dualmult, conjugate, from left to right.
- Parameters:
data (array-like) – An array.
- property C#
Getting the conjugation array.
- Returns:
The conjugate of the current MinPlus object.
- Return type:
- property H#
Getting the Hermitian array.
- Returns:
The Hermitian of the current MinPlus object.
- Return type:
- add(other)[source]#
Min-plus addition defined by \(a\oplus b=\min(a,b)\).
- Parameters:
other (int, float, MinPlus) – Addition.
- Returns:
Result of min-plus addition by other.
- Return type:
Examples
>>> a = MinPlus(3) >>> b = MinPlus(5) >>> a.add(b) MinPlus(3)
>>> c = MinPlus([1, 5, 3]) >>> d = MinPlus([4, 2, 6]) >>> c.add(d) MinPlus([1 2 3])
>>> A = MinPlus([[1, 3], [5, 7]]) >>> B = MinPlus([[2, 6], [4, 8]]) >>> A.add(B) MinPlus([[1 3] [4 7]])
- dualpow(n)[source]#
Min-plus dual matrix power.
- Parameters:
n (int) – The power to raise the matrix to.
- Returns:
Result of min-plus dual matrix power.
- Return type:
- Raises:
ValueError – If n is negative.