pymor.vectorarrays.list
¶
Module Contents¶
- class pymor.vectorarrays.list.ComplexifiedListVectorSpace[source]¶
Bases:
ListVectorSpace
VectorSpace
ofListVectorArrays
.Methods
- class pymor.vectorarrays.list.ComplexifiedVector(real_part, imag_part)[source]¶
Bases:
Vector
Interface for vectors used in conjunction with
ListVectorArray
.This interface must be satisfied by the individual entries of the vector
list
managed byListVectorArray
. All interface methods have a direct counterpart in theVectorArray
interface.
- class pymor.vectorarrays.list.CopyOnWriteVector[source]¶
Bases:
Vector
Interface for vectors used in conjunction with
ListVectorArray
.This interface must be satisfied by the individual entries of the vector
list
managed byListVectorArray
. All interface methods have a direct counterpart in theVectorArray
interface.Methods
- class pymor.vectorarrays.list.ListVectorArray(space, impl, base=None, ind=None, _len=None)[source]¶
Bases:
pymor.vectorarrays.interface.VectorArray
VectorArray
implemented as a Python list of vectors.This
VectorArray
implementation is the first choice when creating pyMOR wrappers for external solvers which are based on single vector objects. In order to do so, a wrapping subclass ofVector
has to be provided on which the implementation ofListVectorArray
will operate. The associatedVectorSpace
is a subclass ofListVectorSpace
.For an example, see
NumpyVector
andNumpyListVectorSpace
,FenicsVector
andFenicsVectorSpace
,DuneXTVector
andDuneXTVectorSpace
,NGSolveVector
andNGSolveVectorSpace
.Methods
- class pymor.vectorarrays.list.ListVectorArrayImpl(vectors, 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.list.ListVectorSpace[source]¶
Bases:
pymor.vectorarrays.interface.VectorSpace
VectorSpace
ofListVectorArrays
.Methods
Create a
VectorArray
from aNumPy array
Create a
VectorArray
of vectors with all DOFs set to the same value.Create a
VectorArray
from raw data.Create a
VectorArray
of vectors with all DOFs set to one.Create a
VectorArray
of vectors with random entries.Create a
VectorArray
of null vectors- from_numpy(data, id=None, 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.
- full(value, count=1, reserve=0)[source]¶
Create a
VectorArray
of vectors with all DOFs set to the same value.Parameters
- value
The value each DOF should be set to.
- count
The number of vectors.
- reserve
Hint for the backend to which length the array will grow.
Returns
A
VectorArray
containingcount
vectors with each DOF set tovalue
.
- make_array(obj, id=None)[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.
- ones(count=1, reserve=0)[source]¶
Create a
VectorArray
of vectors with all DOFs set to one.This is a shorthand for
self.full(1., count, reserve)
.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 DOF set to one.
- random(count=1, distribution='uniform', reserve=0, **kwargs)[source]¶
Create a
VectorArray
of vectors with random entries.Supported random distributions:
'uniform': Uniform distribution in half-open interval [`low`, `high`). 'normal': Normal (Gaussian) distribution with mean `loc` and standard deviation `scale`.
Note that not all random distributions are necessarily implemented by all
VectorSpace
implementations.Parameters
- count
The number of vectors.
- distribution
Random distribution to use (
'uniform'
,'normal'
).- low
Lower bound for
'uniform'
distribution (defaults to0
).- high
Upper bound for
'uniform'
distribution (defaults to1
).- loc
Mean for
'normal'
distribution (defaults to0
).- scale
Standard deviation for
'normal'
distribution (defaults to1
).- reserve
Hint for the backend to which length the array will grow.
- zeros(count=1, reserve=0)[source]¶
Create a
VectorArray
of null vectorsParameters
- 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.
- class pymor.vectorarrays.list.NumpyListVectorSpace(dim, id=None)[source]¶
Bases:
ListVectorSpace
VectorSpace
ofListVectorArrays
.Methods
- class pymor.vectorarrays.list.NumpyVector(array)[source]¶
Bases:
CopyOnWriteVector
Vector stored in a NumPy 1D-array.
- class pymor.vectorarrays.list.Vector[source]¶
Bases:
pymor.core.base.BasicObject
Interface for vectors used in conjunction with
ListVectorArray
.This interface must be satisfied by the individual entries of the vector
list
managed byListVectorArray
. All interface methods have a direct counterpart in theVectorArray
interface.