8.7.2. Matrix friendly functions¶
MindOpt Python SDK Matrix friendly functions
Methods
Stack a tuple of matrices in sequence horizontally
Stack a tuple of matrices in sequence vertically
Concatenate a tuple of matrices along an axis
- hstack(tup)¶
Stack a tuple of matrices in sequence horizontally. It has the same the same behavior as numpy.hstack .
- Parameters
tup –
A tuple of matrices to stack. Supported element types include:
MVar
MLinExpr
MQuadExpr
MConstr
MQConstr
example:
x = model.addMVar((3, 3)) y = model.addMVar((3, 3)) hstack((x, y))
- vstack(tup)¶
Stack a tuple of matrices in sequence vertically. It has the same the same behavior as numpy.vstack .
- Parameters
tup –
A tuple of matrices to stack. Supported element types include:
MVar
MLinExpr
MQuadExpr
MConstr
MQConstr
example:
x = model.addMVar((3, 3)) y = model.addMVar((3, 3)) vstack((x, y))
- concatenate(tup, axis)¶
Concatenate a tuple of matrices along an axis. It has the same the same behavior as numpy.concatenate .
- Parameters
tup –
A tuple of matrices to concatenate. Supported element types include:
MVar
MLinExpr
MQuadExpr
MConstr
MQConstr
axis – The axis along which the matrices will be concatenated.
example:
x = model.addMVar((3, 3)) y = model.addMVar((3, 3)) concatenate((x, y), 1)