pymor.vectorarrays.list

Module Contents

class pymor.vectorarrays.list.ComplexifiedListVectorSpace[source]

Bases: ListVectorSpace

VectorSpace of ListVectorArrays.

real_vector_type[source]
vector_type[source]
full_vector(self, value)[source]
make_vector(self, obj)[source]
random_vector(self, distribution, random_state, **kwargs)[source]
real_full_vector(self, value)[source]
abstract real_make_vector(self, obj)[source]
real_random_vector(self, distribution, random_state, **kwargs)[source]
abstract real_vector_from_numpy(self, data, ensure_copy=False)[source]
abstract real_zero_vector(self)[source]
vector_from_numpy(self, data, ensure_copy=False)[source]
zero_vector(self)[source]
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 by ListVectorArray. All interface methods have a direct counterpart in the VectorArray interface.

amax(self)[source]
axpy(self, alpha, x)[source]
conj(self)[source]
copy(self, deep=False)[source]
dofs(self, dof_indices)[source]
property imag(self)[source]
inner(self, other)[source]
norm(self)[source]
norm2(self)[source]
property real(self)[source]
scal(self, alpha)[source]
sup_norm(self)[source]
to_numpy(self, ensure_copy=False)[source]
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 by ListVectorArray. All interface methods have a direct counterpart in the VectorArray interface.

axpy(self, alpha, x)[source]
copy(self, deep=False)[source]
classmethod from_instance(cls, instance)[source]
scal(self, alpha)[source]
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 of Vector has to be provided on which the implementation of ListVectorArray will operate. The associated VectorSpace is a subclass of ListVectorSpace.

For an example, see NumpyVector and NumpyListVectorSpace, FenicsVector and FenicsVectorSpace, DuneXTVector and DuneXTVectorSpace, NGSolveVector and NGSolveVectorSpace.

Methods

vectors

impl_type[source]
property vectors(self)[source]
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 internal impl object of this type. Indexing, error checking or non-standard inner products are handled by VectorArray. Possible indices are passed to the methods of VectorArrayImpl as ind, oind or xind parameters. These can either be None, in case the array has not been indexed, a slice object, or a Python list of non-negative numbers.

amax(self, ind)[source]
append(self, other, remove_from_other, oind)[source]
axpy(self, alpha, x, ind, xind)[source]
conj(self, ind)[source]
copy(self, deep, ind)[source]
delete(self, ind)[source]
dofs(self, dof_indices, ind)[source]
gramian(self, ind)[source]
imag(self, ind)[source]
inner(self, other, ind, oind)[source]
lincomb(self, coefficients, ind)[source]
norm(self, ind)[source]
norm2(self, ind)[source]
pairwise_inner(self, other, ind, oind)[source]
real(self, ind)[source]
scal(self, alpha, ind)[source]
to_numpy(self, ensure_copy, ind)[source]
class pymor.vectorarrays.list.ListVectorSpace[source]

Bases: pymor.vectorarrays.interface.VectorSpace

VectorSpace of ListVectorArrays.

Methods

from_numpy

Create a VectorArray from a NumPy array

full

Create a VectorArray of vectors with all DOFs set to the same value.

full_vector

make_array

Create a VectorArray from raw data.

make_vector

ones

Create a VectorArray of vectors with all DOFs set to one.

ones_vector

random

Create a VectorArray of vectors with random entries.

random_vector

space_from_dim

space_from_vector_obj

vector_from_numpy

zero_vector

zeros

Create a VectorArray of null vectors

dim[source]
vector_type[source]
from_numpy(cls, data, id=None, ensure_copy=False)[source]

Create a VectorArray from a NumPy array

Note that this method will not be supported by all vector space implementations.

Parameters

data

NumPy array of shape (len, dim) where len is the number of vectors and dim their dimension.

ensure_copy

If False, modifying the returned VectorArray might alter the original NumPy array. If True always a copy of the array data is made.

Returns

A VectorArray with data as data.

full(self, 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 containing count vectors with each DOF set to value.

full_vector(self, value)[source]
make_array(cls, obj, id=None)[source]

Create a VectorArray from raw data.

This method is used in the implementation of Operators and Models to create new VectorArrays 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.

abstract make_vector(self, obj)[source]
ones(self, 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 containing count vectors with each DOF set to one.

ones_vector(self)[source]
random(self, count=1, distribution='uniform', random_state=None, seed=None, 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 to 0).

high

Upper bound for 'uniform' distribution (defaults to 1).

loc

Mean for 'normal' distribution (defaults to 0).

scale

Standard deviation for 'normal' distribution (defaults to 1).

random_state

RandomState to use for sampling. If None, a new random state is generated using seed as random seed, or the default random state is used.

seed

If not None, a new random state with this seed is used.

reserve

Hint for the backend to which length the array will grow.

random_vector(self, distribution, random_state, **kwargs)[source]
abstract classmethod space_from_dim(cls, dim, id)[source]
abstract classmethod space_from_vector_obj(cls, vec, id)[source]
abstract vector_from_numpy(self, data, ensure_copy=False)[source]
abstract zero_vector(self)[source]
zeros(self, 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 containing count vectors with each component zero.

class pymor.vectorarrays.list.NumpyListVectorSpace(dim, id=None)[source]

Bases: ListVectorSpace

VectorSpace of ListVectorArrays.

vector_type[source]
full_vector(self, value)[source]
make_vector(self, obj)[source]
ones_vector(self)[source]
classmethod space_from_dim(cls, dim, id)[source]
classmethod space_from_vector_obj(cls, vec, id)[source]
vector_from_numpy(self, data, ensure_copy=False)[source]
zero_vector(self)[source]
class pymor.vectorarrays.list.NumpyVector(array)[source]

Bases: CopyOnWriteVector

Vector stored in a NumPy 1D-array.

amax(self)[source]
conj(self)[source]
property dim(self)[source]
dofs(self, dof_indices)[source]
classmethod from_instance(cls, instance)[source]
property imag(self)[source]
inner(self, other)[source]
norm(self)[source]
norm2(self)[source]
property real(self)[source]
to_numpy(self, ensure_copy=False)[source]
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 by ListVectorArray. All interface methods have a direct counterpart in the VectorArray interface.

abstract amax(self)[source]
abstract axpy(self, alpha, x)[source]
conj(self)[source]
abstract copy(self, deep=False)[source]
abstract dofs(self, dof_indices)[source]
property imag(self)[source]
abstract inner(self, other)[source]
abstract norm(self)[source]
abstract norm2(self)[source]
property real(self)[source]
abstract scal(self, alpha)[source]
sup_norm(self)[source]