modelparameters.sympy.matrices.expressions package

Submodules

modelparameters.sympy.matrices.expressions.adjoint module

class modelparameters.sympy.matrices.expressions.adjoint.Adjoint(*args, **kwargs)[source]

Bases: MatrixExpr

The Hermitian adjoint of a matrix expression.

This is a symbolic object that simply stores its argument without evaluating it. To actually compute the adjoint, use the adjoint() function.

Examples

>>> from ...matrices import MatrixSymbol, Adjoint
>>> from ...functions import adjoint
>>> A = MatrixSymbol('A', 3, 5)
>>> B = MatrixSymbol('B', 5, 3)
>>> Adjoint(A*B)
Adjoint(A*B)
>>> adjoint(A*B)
Adjoint(B)*Adjoint(A)
>>> adjoint(A*B) == Adjoint(A*B)
False
>>> adjoint(A*B) == Adjoint(A*B).doit()
True
property arg
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(**hints)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
is_Adjoint = True
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape

modelparameters.sympy.matrices.expressions.blockmatrix module

class modelparameters.sympy.matrices.expressions.blockmatrix.BlockDiagMatrix(*mats)[source]

Bases: BlockMatrix

A BlockDiagMatrix is a BlockMatrix with matrices only along the diagonal

>>> from ... import MatrixSymbol, BlockDiagMatrix, symbols, Identity
>>> n,m,l = symbols('n m l')
>>> X = MatrixSymbol('X', n, n)
>>> Y = MatrixSymbol('Y', m ,m)
>>> BlockDiagMatrix(X, Y)
Matrix([
[X, 0],
[0, Y]])
property blocks
property blockshape
property colblocksizes
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
property diag
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property rowblocksizes
property shape
class modelparameters.sympy.matrices.expressions.blockmatrix.BlockMatrix(*args)[source]

Bases: MatrixExpr

A BlockMatrix is a Matrix composed of other smaller, submatrices

The submatrices are stored in a SymPy Matrix object but accessed as part of a Matrix Expression

>>> from ... import (MatrixSymbol, BlockMatrix, symbols,
...     Identity, ZeroMatrix, block_collapse)
>>> n,m,l = symbols('n m l')
>>> X = MatrixSymbol('X', n, n)
>>> Y = MatrixSymbol('Y', m ,m)
>>> Z = MatrixSymbol('Z', n, m)
>>> B = BlockMatrix([[X, Z], [ZeroMatrix(m,n), Y]])
>>> print(B)
Matrix([
[X, Z],
[0, Y]])
>>> C = BlockMatrix([[Identity(n), Z]])
>>> print(C)
Matrix([[I, Z]])
>>> print(block_collapse(C*B))
Matrix([[X, Z*Y + Z]])
as_real_imag()[source]
property blocks
property blockshape
property colblocksizes
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
equals(other)[source]

Test elementwise equality between matrices, potentially of different types

>>> from ... import Identity, eye
>>> Identity(3).equals(eye(3))
True
property is_Identity
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
property is_structurally_symmetric
is_transcendental = False
is_zero = False
property rowblocksizes
property shape
structurally_equal(other)[source]
transpose()[source]

Return transpose of matrix.

Examples

>>> from ... import MatrixSymbol, BlockMatrix, ZeroMatrix
>>> from ...abc import l, m, n
>>> X = MatrixSymbol('X', n, n)
>>> Y = MatrixSymbol('Y', m ,m)
>>> Z = MatrixSymbol('Z', n, m)
>>> B = BlockMatrix([[X, Z], [ZeroMatrix(m,n), Y]])
>>> B.transpose()
Matrix([
[X.T,  0],
[Z.T, Y.T]])
>>> _.transpose()
Matrix([
[X, Z],
[0, Y]])
modelparameters.sympy.matrices.expressions.blockmatrix.bc_block_plus_ident(expr)[source]
modelparameters.sympy.matrices.expressions.blockmatrix.bc_dist(expr)[source]

Turn a*[X, Y] into [a*X, a*Y]

modelparameters.sympy.matrices.expressions.blockmatrix.bc_inverse(expr)[source]
modelparameters.sympy.matrices.expressions.blockmatrix.bc_matadd(expr)[source]
modelparameters.sympy.matrices.expressions.blockmatrix.bc_matmul(expr)[source]
modelparameters.sympy.matrices.expressions.blockmatrix.bc_transpose(expr)[source]
modelparameters.sympy.matrices.expressions.blockmatrix.bc_unpack(expr)[source]
modelparameters.sympy.matrices.expressions.blockmatrix.block_collapse(expr)[source]

Evaluates a block matrix expression

>>> from ... import MatrixSymbol, BlockMatrix, symbols,                           Identity, Matrix, ZeroMatrix, block_collapse
>>> n,m,l = symbols('n m l')
>>> X = MatrixSymbol('X', n, n)
>>> Y = MatrixSymbol('Y', m ,m)
>>> Z = MatrixSymbol('Z', n, m)
>>> B = BlockMatrix([[X, Z], [ZeroMatrix(m, n), Y]])
>>> print(B)
Matrix([
[X, Z],
[0, Y]])
>>> C = BlockMatrix([[Identity(n), Z]])
>>> print(C)
Matrix([[I, Z]])
>>> print(block_collapse(C*B))
Matrix([[X, Z*Y + Z]])
modelparameters.sympy.matrices.expressions.blockmatrix.blockcut(expr, rowsizes, colsizes)[source]

Cut a matrix expression into Blocks

>>> from ... import ImmutableMatrix, blockcut
>>> M = ImmutableMatrix(4, 4, range(16))
>>> B = blockcut(M, (1, 3), (1, 3))
>>> type(B).__name__
'BlockMatrix'
>>> ImmutableMatrix(B.blocks[0, 1])
Matrix([[1, 2, 3]])
modelparameters.sympy.matrices.expressions.blockmatrix.blockinverse_1x1(expr)[source]
modelparameters.sympy.matrices.expressions.blockmatrix.blockinverse_2x2(expr)[source]
modelparameters.sympy.matrices.expressions.blockmatrix.bounds(sizes)[source]

Convert sequence of numbers into pairs of low-high pairs

>>> from .blockmatrix import bounds
>>> bounds((1, 10, 50))
[(0, 1), (1, 11), (11, 61)]
modelparameters.sympy.matrices.expressions.blockmatrix.deblock(B)[source]

Flatten a BlockMatrix of BlockMatrices

modelparameters.sympy.matrices.expressions.blockmatrix.reblock_2x2(B)[source]

Reblock a BlockMatrix so that it has 2x2 blocks of block matrices

modelparameters.sympy.matrices.expressions.determinant module

class modelparameters.sympy.matrices.expressions.determinant.Determinant(mat)[source]

Bases: Expr

Matrix Determinant

Represents the determinant of a matrix expression.

>>> from ... import MatrixSymbol, Determinant, eye
>>> A = MatrixSymbol('A', 3, 3)
>>> Determinant(A)
Determinant(A)
>>> Determinant(eye(3)).doit()
1
property arg
default_assumptions = {}
doit(expand=False)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
modelparameters.sympy.matrices.expressions.determinant.det(matexpr)[source]

Matrix Determinant

>>> from ... import MatrixSymbol, det, eye
>>> A = MatrixSymbol('A', 3, 3)
>>> det(A)
Determinant(A)
>>> det(eye(3))
1
modelparameters.sympy.matrices.expressions.determinant.refine_Determinant(expr, assumptions)[source]
>>> from ... import MatrixSymbol, Q, assuming, refine, det
>>> X = MatrixSymbol('X', 2, 2)
>>> det(X)
Determinant(X)
>>> with assuming(Q.orthogonal(X)):
...     print(refine(det(X)))
1

modelparameters.sympy.matrices.expressions.diagonal module

class modelparameters.sympy.matrices.expressions.diagonal.DiagonalMatrix(*args, **kwargs)[source]

Bases: MatrixExpr

DiagonalMatrix(M) will create a matrix expression that behaves as though all off-diagonal elements, M[i, j] where i != j, are zero.

Examples

>>> from ... import MatrixSymbol, DiagonalMatrix, Symbol
>>> n = Symbol('n', integer=True)
>>> m = Symbol('m', integer=True)
>>> D = DiagonalMatrix(MatrixSymbol('x', 2, 3))
>>> D[1, 2]
0
>>> D[1, 1]
x[1, 1]

The length of the diagonal – the lesser of the two dimensions of M – is accessed through the diagonal_length property:

>>> D.diagonal_length
2
>>> DiagonalMatrix(MatrixSymbol('x', n + 1, n)).diagonal_length
n

When one of the dimensions is symbolic the other will be treated as though it is smaller:

>>> tall = DiagonalMatrix(MatrixSymbol('x', n, 3))
>>> tall.diagonal_length
3
>>> tall[10, 1]
0

When the size of the diagonal is not known, a value of None will be returned:

>>> DiagonalMatrix(MatrixSymbol('x', n, m)).diagonal_length is None
True
property arg
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
property diagonal_length
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape
class modelparameters.sympy.matrices.expressions.diagonal.DiagonalOf(*args, **kwargs)[source]

Bases: MatrixExpr

DiagonalOf(M) will create a matrix expression that is equivalent to the diagonal of M, represented as a single column matrix.

Examples

>>> from ... import MatrixSymbol, DiagonalOf, Symbol
>>> n = Symbol('n', integer=True)
>>> m = Symbol('m', integer=True)
>>> x = MatrixSymbol('x', 2, 3)
>>> diag = DiagonalOf(x)
>>> diag.shape
(2, 1)

The diagonal can be addressed like a matrix or vector and will return the corresponding element of the original matrix:

>>> diag[1, 0] == diag[1] == x[1, 1]
True

The length of the diagonal – the lesser of the two dimensions of M – is accessed through the diagonal_length property:

>>> diag.diagonal_length
2
>>> DiagonalOf(MatrixSymbol('x', n + 1, n)).diagonal_length
n

When only one of the dimensions is symbolic the other will be treated as though it is smaller:

>>> dtall = DiagonalOf(MatrixSymbol('x', n, 3))
>>> dtall.diagonal_length
3

When the size of the diagonal is not known, a value of None will be returned:

>>> DiagonalOf(MatrixSymbol('x', n, m)).diagonal_length is None
True
property arg
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
property diagonal_length
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape

modelparameters.sympy.matrices.expressions.dotproduct module

class modelparameters.sympy.matrices.expressions.dotproduct.DotProduct(arg1, arg2)[source]

Bases: MatrixExpr

Dot product of vector matrices

The input should be two 1 x n or n x 1 matrices. The output represents the scalar dotproduct.

This is similar to using MatrixElement and MatMul, except DotProduct does not require that one vector to be a row vector and the other vector to be a column vector.

>>> from ... import MatrixSymbol, DotProduct
>>> A = MatrixSymbol('A', 1, 3)
>>> B = MatrixSymbol('B', 1, 3)
>>> DotProduct(A, B)
DotProduct(A, B)
>>> DotProduct(A, B).doit()
A[0, 0]*B[0, 0] + A[0, 1]*B[0, 1] + A[0, 2]*B[0, 2]
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(expand=False)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False

modelparameters.sympy.matrices.expressions.factorizations module

class modelparameters.sympy.matrices.expressions.factorizations.EigenValues(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.diagonal,)
class modelparameters.sympy.matrices.expressions.factorizations.EigenVectors(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.orthogonal,)
class modelparameters.sympy.matrices.expressions.factorizations.Factorization(*args, **kwargs)[source]

Bases: MatrixExpr

property arg
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape
class modelparameters.sympy.matrices.expressions.factorizations.LofCholesky(*args, **kwargs)[source]

Bases: LofLU

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
class modelparameters.sympy.matrices.expressions.factorizations.LofLU(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.lower_triangular,)
class modelparameters.sympy.matrices.expressions.factorizations.QofQR(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.orthogonal,)
class modelparameters.sympy.matrices.expressions.factorizations.RofQR(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.upper_triangular,)
class modelparameters.sympy.matrices.expressions.factorizations.SofSVD(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.diagonal,)
class modelparameters.sympy.matrices.expressions.factorizations.UofCholesky(*args, **kwargs)[source]

Bases: UofLU

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
class modelparameters.sympy.matrices.expressions.factorizations.UofLU(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.upper_triangular,)
class modelparameters.sympy.matrices.expressions.factorizations.UofSVD(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.orthogonal,)
class modelparameters.sympy.matrices.expressions.factorizations.VofSVD(*args, **kwargs)[source]

Bases: Factorization

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
predicates = (Q.orthogonal,)
modelparameters.sympy.matrices.expressions.factorizations.eig(expr)[source]
modelparameters.sympy.matrices.expressions.factorizations.lu(expr)[source]
modelparameters.sympy.matrices.expressions.factorizations.qr(expr)[source]
modelparameters.sympy.matrices.expressions.factorizations.svd(expr)[source]

modelparameters.sympy.matrices.expressions.fourier module

class modelparameters.sympy.matrices.expressions.fourier.DFT(*args, **kwargs)[source]

Bases: MatrixExpr

Discrete Fourier Transform

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property n
property shape
class modelparameters.sympy.matrices.expressions.fourier.IDFT(*args, **kwargs)[source]

Bases: DFT

Inverse Discrete Fourier Transform

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False

modelparameters.sympy.matrices.expressions.funcmatrix module

class modelparameters.sympy.matrices.expressions.funcmatrix.FunctionMatrix(rows, cols, lamda)[source]

Bases: MatrixExpr

Represents a Matrix using a function (Lambda)

This class is an alternative to SparseMatrix

>>> from ... import FunctionMatrix, symbols, Lambda, MatMul, Matrix
>>> i, j = symbols('i,j')
>>> X = FunctionMatrix(3, 3, Lambda((i, j), i + j))
>>> Matrix(X)
Matrix([
[0, 1, 2],
[1, 2, 3],
[2, 3, 4]])
>>> Y = FunctionMatrix(1000, 1000, Lambda((i, j), i + j))
>>> isinstance(Y*Y, MatMul) # this is an expression object
True
>>> (Y**2)[10,10] # So this is evaluated lazily
342923500
as_real_imag()[source]
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property lamda
property shape

modelparameters.sympy.matrices.expressions.hadamard module

class modelparameters.sympy.matrices.expressions.hadamard.HadamardProduct(*args, **kwargs)[source]

Bases: MatrixExpr

Elementwise product of matrix expressions

This is a symbolic object that simply stores its argument without evaluating it. To actually compute the product, use the function hadamard_product().

>>> from ...matrices import hadamard_product, HadamardProduct, MatrixSymbol
>>> A = MatrixSymbol('A', 5, 5)
>>> B = MatrixSymbol('B', 5, 5)
>>> isinstance(hadamard_product(A, B), HadamardProduct)
True
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(**ignored)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
is_HadamardProduct = True
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape
modelparameters.sympy.matrices.expressions.hadamard.hadamard_product(*matrices)[source]

Return the elementwise (aka Hadamard) product of matrices.

Examples

>>> from ...matrices import hadamard_product, MatrixSymbol
>>> A = MatrixSymbol('A', 2, 3)
>>> B = MatrixSymbol('B', 2, 3)
>>> hadamard_product(A)
A
>>> hadamard_product(A, B)
A.*B
>>> hadamard_product(A, B)[0, 1]
A[0, 1]*B[0, 1]
modelparameters.sympy.matrices.expressions.hadamard.validate(*args)[source]

modelparameters.sympy.matrices.expressions.inverse module

class modelparameters.sympy.matrices.expressions.inverse.Inverse(mat)[source]

Bases: MatPow

The multiplicative inverse of a matrix expression

This is a symbolic object that simply stores its argument without evaluating it. To actually compute the inverse, use the .inverse() method of matrices.

Examples

>>> from ... import MatrixSymbol, Inverse
>>> A = MatrixSymbol('A', 3, 3)
>>> B = MatrixSymbol('B', 3, 3)
>>> Inverse(A)
A^-1
>>> A.inverse() == Inverse(A)
True
>>> (A*B).inverse()
B^-1*A^-1
>>> Inverse(A*B)
(A*B)^-1
property arg
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(**hints)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
exp = -1
is_Inverse = True
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape
modelparameters.sympy.matrices.expressions.inverse.refine_Inverse(expr, assumptions)[source]
>>> from ... import MatrixSymbol, Q, assuming, refine
>>> X = MatrixSymbol('X', 2, 2)
>>> X.I
X^-1
>>> with assuming(Q.orthogonal(X)):
...     print(refine(X.I))
X.T

modelparameters.sympy.matrices.expressions.matadd module

class modelparameters.sympy.matrices.expressions.matadd.MatAdd(*args, **kwargs)[source]

Bases: MatrixExpr, AssocOp

A Sum of Matrix Expressions

MatAdd inherits from and operates like SymPy Add

>>> from ... import MatAdd, MatrixSymbol
>>> A = MatrixSymbol('A', 5, 5)
>>> B = MatrixSymbol('B', 5, 5)
>>> C = MatrixSymbol('C', 5, 5)
>>> MatAdd(A, B, C)
A + B + C
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(**kwargs)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
is_MatAdd = True
is_algebraic = False
is_commutative
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape
modelparameters.sympy.matrices.expressions.matadd.combine(cnt, mat)[source]
modelparameters.sympy.matrices.expressions.matadd.factor_of(arg)
modelparameters.sympy.matrices.expressions.matadd.matrix_of(arg)
modelparameters.sympy.matrices.expressions.matadd.merge_explicit(matadd)[source]

Merge explicit MatrixBase arguments

>>> from ... import MatrixSymbol, eye, Matrix, MatAdd, pprint
>>> from .matadd import merge_explicit
>>> A = MatrixSymbol('A', 2, 2)
>>> B = eye(2)
>>> C = Matrix([[1, 2], [3, 4]])
>>> X = MatAdd(A, B, C)
>>> pprint(X)
    [1  0]   [1  2]
A + [    ] + [    ]
    [0  1]   [3  4]
>>> pprint(merge_explicit(X))
    [2  2]
A + [    ]
    [3  5]
modelparameters.sympy.matrices.expressions.matadd.validate(*args)[source]

modelparameters.sympy.matrices.expressions.matexpr module

class modelparameters.sympy.matrices.expressions.matexpr.Identity(n)[source]

Bases: MatrixExpr

The Matrix Identity I - multiplicative identity

>>> from ...matrices import Identity, MatrixSymbol
>>> A = MatrixSymbol('A', 3, 5)
>>> I = Identity(3)
>>> I*A
A
property cols
conjugate()[source]
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_Identity = True
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property rows
property shape
class modelparameters.sympy.matrices.expressions.matexpr.MatrixElement(name, n, m)[source]

Bases: Expr

default_assumptions = {'commutative': True}
doit(**kwargs)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
property i
is_commutative = True
is_symbol = True
property j
property parent
class modelparameters.sympy.matrices.expressions.matexpr.MatrixExpr(*args, **kwargs)[source]

Bases: Basic

Superclass for Matrix Expressions

MatrixExprs represent abstract matrices, linear transformations represented within a particular basis.

Examples

>>> from ... import MatrixSymbol
>>> A = MatrixSymbol('A', 3, 3)
>>> y = MatrixSymbol('y', 3, 1)
>>> x = (A.T*A).I * A * y
property I
property T

Matrix transposition.

adjoint()[source]
as_coeff_Mul(rational=False)[source]

Efficiently extract the coefficient of a product.

as_coeff_mmul()[source]
as_explicit()[source]

Returns a dense Matrix with elements represented explicitly

Returns an object of type ImmutableDenseMatrix.

Examples

>>> from ... import Identity
>>> I = Identity(3)
>>> I
I
>>> I.as_explicit()
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])

See also

as_mutable

returns mutable Matrix type

as_mutable()[source]

Returns a dense, mutable matrix with elements represented explicitly

Examples

>>> from ... import Identity
>>> I = Identity(3)
>>> I
I
>>> I.shape
(3, 3)
>>> I.as_mutable()
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])

See also

as_explicit

returns ImmutableDenseMatrix

as_real_imag()[source]
canonicalize()[source]
property cols
conjugate()[source]
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
equals(other)[source]

Test elementwise equality between matrices, potentially of different types

>>> from ... import Identity, eye
>>> Identity(3).equals(eye(3))
True
inverse()[source]
is_Identity = None
is_Inverse = False
is_MatAdd = False
is_MatMul = False
is_Matrix = True
is_MatrixExpr = True
is_Transpose = False
is_ZeroMatrix = False
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
property is_square
is_transcendental = False
is_zero = False
property rows
transpose()[source]
valid_index(i, j)[source]
class modelparameters.sympy.matrices.expressions.matexpr.MatrixSymbol(name, n, m)[source]

Bases: MatrixExpr

Symbolic representation of a Matrix object

Creates a SymPy Symbol to represent a Matrix. This matrix has a shape and can be included in Matrix Expressions

>>> from ... import MatrixSymbol, Identity
>>> A = MatrixSymbol('A', 3, 4) # A 3 by 4 Matrix
>>> B = MatrixSymbol('B', 4, 3) # A 4 by 3 Matrix
>>> A.shape
(3, 4)
>>> 2*A*B + Identity(3)
I + 2*A*B
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(**hints)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
property free_symbols

Return from the atoms of self those which are free symbols.

For most expressions, all symbols are free symbols. For some classes this is not true. e.g. Integrals use Symbols for the dummy variables which are bound variables, so Integral has a method to return all symbols except those. Derivative keeps track of symbols with respect to which it will perform a derivative; those are bound variables, too, so it has its own free_symbols method.

Any other method that uses bound variables should implement a free_symbols method.

is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property name
property shape
class modelparameters.sympy.matrices.expressions.matexpr.ZeroMatrix(m, n)[source]

Bases: MatrixExpr

The Matrix Zero 0 - additive identity

>>> from ... import MatrixSymbol, ZeroMatrix
>>> A = MatrixSymbol('A', 3, 5)
>>> Z = ZeroMatrix(3, 5)
>>> A+Z
A
>>> Z*A.T
0
conjugate()[source]
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_ZeroMatrix = True
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape
modelparameters.sympy.matrices.expressions.matexpr.matrix_symbols(expr)[source]

modelparameters.sympy.matrices.expressions.matmul module

class modelparameters.sympy.matrices.expressions.matmul.MatMul(*args, **kwargs)[source]

Bases: MatrixExpr

A product of matrix expressions

Examples

>>> from ... import MatMul, MatrixSymbol
>>> A = MatrixSymbol('A', 5, 4)
>>> B = MatrixSymbol('B', 4, 3)
>>> C = MatrixSymbol('C', 3, 6)
>>> MatMul(A, B, C)
A*B*C
args_cnc(**kwargs)[source]
as_coeff_matrices()[source]
as_coeff_mmul()[source]
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(**kwargs)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
is_MatMul = True
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape
modelparameters.sympy.matrices.expressions.matmul.any_zeros(mul)[source]
modelparameters.sympy.matrices.expressions.matmul.factor_in_front(mul)[source]
modelparameters.sympy.matrices.expressions.matmul.merge_explicit(matmul)[source]

Merge explicit MatrixBase arguments

>>> from ... import MatrixSymbol, eye, Matrix, MatMul, pprint
>>> from .matmul import merge_explicit
>>> A = MatrixSymbol('A', 2, 2)
>>> B = Matrix([[1, 1], [1, 1]])
>>> C = Matrix([[1, 2], [3, 4]])
>>> X = MatMul(A, B, C)
>>> pprint(X)
  [1  1] [1  2]
A*[    ]*[    ]
  [1  1] [3  4]
>>> pprint(merge_explicit(X))
  [4  6]
A*[    ]
  [4  6]
>>> X = MatMul(B, A, C)
>>> pprint(X)
[1  1]   [1  2]
[    ]*A*[    ]
[1  1]   [3  4]
>>> pprint(merge_explicit(X))
[1  1]   [1  2]
[    ]*A*[    ]
[1  1]   [3  4]
modelparameters.sympy.matrices.expressions.matmul.newmul(*args)[source]
modelparameters.sympy.matrices.expressions.matmul.only_squares(*matrices)[source]

factor matrices only if they are square

modelparameters.sympy.matrices.expressions.matmul.refine_MatMul(expr, assumptions)[source]
>>> from ... import MatrixSymbol, Q, assuming, refine
>>> X = MatrixSymbol('X', 2, 2)
>>> expr = X * X.T
>>> print(expr)
X*X.T
>>> with assuming(Q.orthogonal(X)):
...     print(refine(expr))
I
modelparameters.sympy.matrices.expressions.matmul.remove_ids(mul)[source]

Remove Identities from a MatMul

This is a modified version of sympy.strategies.rm_id. This is necesssary because MatMul may contain both MatrixExprs and Exprs as args.

modelparameters.sympy.matrices.expressions.matmul.validate(*matrices)[source]

Checks for valid shapes for args of MatMul

modelparameters.sympy.matrices.expressions.matmul.xxinv(mul)[source]

Y * X * X.I -> Y

modelparameters.sympy.matrices.expressions.matpow module

class modelparameters.sympy.matrices.expressions.matpow.MatPow(base, exp)[source]

Bases: MatrixExpr

property base
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(**kwargs)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
property exp
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape

modelparameters.sympy.matrices.expressions.slice module

class modelparameters.sympy.matrices.expressions.slice.MatrixSlice(parent, rowslice, colslice)[source]

Bases: MatrixExpr

A MatrixSlice of a Matrix Expression

Examples

>>> from ... import MatrixSlice, ImmutableMatrix
>>> M = ImmutableMatrix(4, 4, range(16))
>>> M
Matrix([
[ 0,  1,  2,  3],
[ 4,  5,  6,  7],
[ 8,  9, 10, 11],
[12, 13, 14, 15]])
>>> B = MatrixSlice(M, (0, 2), (2, 4))
>>> ImmutableMatrix(B)
Matrix([
[2, 3],
[6, 7]])
property colslice
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property on_diag
property parent
property rowslice
property shape
modelparameters.sympy.matrices.expressions.slice.mat_slice_of_slice(parent, rowslice, colslice)[source]

Collapse nested matrix slices

>>> from ... import MatrixSymbol
>>> X = MatrixSymbol('X', 10, 10)
>>> X[:, 1:5][5:8, :]
X[5:8, 1:5]
>>> X[1:9:2, 2:6][1:3, 2]
X[3:7:2, 4]
modelparameters.sympy.matrices.expressions.slice.normalize(i, parentsize)[source]
modelparameters.sympy.matrices.expressions.slice.slice_of_slice(s, t)[source]

modelparameters.sympy.matrices.expressions.trace module

class modelparameters.sympy.matrices.expressions.trace.Trace(mat)[source]

Bases: Expr

Matrix Trace

Represents the trace of a matrix expression.

>>> from ... import MatrixSymbol, Trace, eye
>>> A = MatrixSymbol('A', 3, 3)
>>> Trace(A)
Trace(A)

See also

trace

property arg
default_assumptions = {}
doit(**kwargs)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
is_Trace = True
modelparameters.sympy.matrices.expressions.trace.trace(expr)[source]

Trace of a Matrix. Sum of the diagonal elements

>>> from ... import trace, Symbol, MatrixSymbol, pprint, eye
>>> n = Symbol('n')
>>> X = MatrixSymbol('X', n, n)  # A square matrix
>>> trace(2*X)
2*Trace(X)
>>> trace(eye(3))
3

See also

Trace

modelparameters.sympy.matrices.expressions.transpose module

class modelparameters.sympy.matrices.expressions.transpose.Transpose(*args, **kwargs)[source]

Bases: MatrixExpr

The transpose of a matrix expression.

This is a symbolic object that simply stores its argument without evaluating it. To actually compute the transpose, use the transpose() function, or the .T attribute of matrices.

Examples

>>> from ...matrices import MatrixSymbol, Transpose
>>> from ...functions import transpose
>>> A = MatrixSymbol('A', 3, 5)
>>> B = MatrixSymbol('B', 5, 3)
>>> Transpose(A)
A.T
>>> A.T == transpose(A) == Transpose(A)
True
>>> Transpose(A*B)
(A*B).T
>>> transpose(A*B)
B.T*A.T
property arg
default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
doit(**hints)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
is_Transpose = True
is_algebraic = False
is_commutative = False
is_complex = False
is_composite = False
is_even = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real = False
is_transcendental = False
is_zero = False
property shape
modelparameters.sympy.matrices.expressions.transpose.refine_Transpose(expr, assumptions)[source]
>>> from ... import MatrixSymbol, Q, assuming, refine
>>> X = MatrixSymbol('X', 2, 2)
>>> X.T
X.T
>>> with assuming(Q.symmetric(X)):
...     print(refine(X.T))
X
modelparameters.sympy.matrices.expressions.transpose.transpose(expr)[source]

Matrix transpose

Module contents

A module which handles Matrix Expressions