pymor.vectorarrays.block
¶
Module Contents¶
- class pymor.vectorarrays.block.BlockVectorArray(space, impl, base=None, ind=None, _len=None)[source]¶
Bases:
pymor.vectorarrays.interface.VectorArray
VectorArray
where each vector is a direct sum of sub-vectors.Given a list of equal length
VectorArrays
blocks
, thisVectorArray
represents the direct sums of the vectors contained in the arrays. The associatedVectorSpace
isBlockVectorSpace
.BlockVectorArray
can be used in conjunction withBlockOperator
.
- class pymor.vectorarrays.block.BlockVectorArrayImpl(blocks, space)[source]¶
Bases:
pymor.vectorarrays.interface.VectorArrayImpl
Implementation of a
VectorArray
.The
VectorArray
base class defers all calls to interface methods to an internalimpl
object of this type. Indexing, error checking or non-standard inner products are handled byVectorArray
. Possible indices are passed to the methods ofVectorArrayImpl
asind
,oind
orxind
parameters. These can either beNone
, in case the array has not been indexed, aslice
object, or a Python list of non-negative numbers.Methods
- class pymor.vectorarrays.block.BlockVectorSpace(subspaces)[source]¶
Bases:
pymor.vectorarrays.interface.VectorSpace
VectorSpace
ofBlockVectorArrays
.A
BlockVectorSpace
is defined by theVectorSpaces
of the individual subblocks which constitute a given array. In particular for a given :class`BlockVectorArray`U
, we have the identity(U.blocks[0].space, U.blocks[1].space, ..., U.blocks[-1].space) == U.space.
Parameters
- subspaces
The tuple defined above.
Methods
Create a
VectorArray
from aNumPy array
.Create a
VectorArray
from raw data.Create a
VectorArray
of null vectors.- from_numpy(data, ensure_copy=False)[source]¶
Create a
VectorArray
from aNumPy array
.Note that this method will not be supported by all vector space implementations.
Parameters
- data
NumPy
array of shape(len, dim)
wherelen
is the number of vectors anddim
their dimension.- ensure_copy
If
False
, modifying the returnedVectorArray
might alter the originalNumPy array
. IfTrue
always a copy of the array data is made.
Returns
A
VectorArray
withdata
as data.
- make_array(obj)[source]¶
Create a
VectorArray
from raw data.This method is used in the implementation of
Operators
andModels
to create newVectorArrays
from raw data of the underlying solver backends. The ownership of the data is transferred to the newly created array.The exact signature of this method depends on the wrapped solver backend.
- zeros(count=1, reserve=0)[source]¶
Create a
VectorArray
of null vectors.Parameters
- count
The number of vectors.
- reserve
Hint for the backend to which length the array will grow.
Returns
A
VectorArray
containingcount
vectors with each component zero.