block_vector
Implementation of a general “block vector”
The pyomo.contrib.pynumero.sparse.block_vector module includes methods that extend linear algebra operations in numpy for case of structured problems where linear algebra operations present an inherent block structure. This interface consider vectors of the form:
where v_i are numpy arrays of dimension 1
Contents
Methods specific to BlockVector
:
get_block_size()
is_block_defined()
Attributes specific to BlockVector
:
NumPy compatible methods:
For example,
>>> import numpy as np
>>> from pyomo.contrib.pynumero.sparse import BlockVector
>>> v = BlockVector(2)
>>> v.set_block(0, np.random.normal(size=100))
>>> v.set_block(1, np.random.normal(size=30))
>>> avg = v.mean()
NumPy compatible functions:
log10()
sin()
cos()
exp()
ceil()
floor()
tan()
arctan()
arcsin()
arccos()
sinh()
cosh()
abs()
tanh()
arccosh()
arcsinh()
arctanh()
fabs()
sqrt()
log()
log2()
absolute()
isfinite()
isinf()
isnan()
log1p()
logical_not()
expm1()
exp2()
sign()
rint()
square()
positive()
negative()
rad2deg()
deg2rad()
conjugate()
reciprocal()
signbit()
add()
multiply()
divide()
subtract()
greater()
greater_equal()
less()
less_equal()
not_equal()
maximum()
minimum()
fmax()
fmin()
equal()
logical_and()
logical_or()
logical_xor()
logaddexp()
logaddexp2()
remainder()
heaviside()
hypot()
For example,
>>> import numpy as np
>>> from pyomo.contrib.pynumero.sparse import BlockVector
>>> v = BlockVector(2)
>>> v.set_block(0, np.random.normal(size=100))
>>> v.set_block(1, np.random.normal(size=30))
>>> inf_norm = np.max(np.abs(v))
|
Structured vector interface. |
|
Set a block. |
Access a block. |
|
|
Returns 1D-Array with sizes of individual blocks in this BlockVector |
|
|
|
|
|
Copy entries of other vector into this vector |
|
Copy entries of this BlockVector into other |
Returns a copy of the BlockVector structure filled with zeros |
|
|
Assigns vectors in blocks |
Prints BlockVector in pretty format |
|
Returns the number of blocks. |
|
Returns the number of blocks in this BlockVector in a tuple. |
|
Indicate if this BlockVector has any none entries. |
Classes
|
Structured vector interface. |
Exceptions
Functions