pymor.vectorarrays.list

Classes

ComplexifiedListVectorSpace

ComplexifiedVector

CopyOnWriteVector

ListVectorArray

VectorArray implemented as a Python list of vectors.

ListVectorArrayImpl

ListVectorSpace

VectorSpace of ListVectorArrays.

NumpyListVectorSpace

NumpyVector

Vector stored in a NumPy 1D-array.

Vector

Interface for vectors used in conjunction with ListVectorArray.

class pymor.vectorarrays.list.ComplexifiedListVectorSpace[source]

Bases: ListVectorSpace

real_vector_type[source]

alias of Vector

vector_type[source]

alias of ComplexifiedVector

full_vector(value)[source]
make_vector(obj)[source]
random_vector(distribution, **kwargs)[source]
real_full_vector(value)[source]
abstractmethod real_make_vector(obj)[source]
real_random_vector(distribution, **kwargs)[source]
real_vector_from_numpy(data, ensure_copy=False)[source]
abstractmethod real_zero_vector()[source]
vector_from_numpy(data, ensure_copy=False)[source]
zero_vector()[source]
class pymor.vectorarrays.list.ComplexifiedVector(real_part, imag_part)[source]

Bases: Vector

amax()[source]
axpy(alpha, x)[source]
conj()[source]
copy(deep=False)[source]
dofs(dof_indices)[source]
inner(other)[source]
norm()[source]
norm2()[source]
scal(alpha)[source]
sup_norm()[source]
to_numpy(ensure_copy=False)[source]
property imag[source]
property real[source]
class pymor.vectorarrays.list.CopyOnWriteVector[source]

Bases: Vector

abstractmethod classmethod from_instance(instance)[source]
axpy(alpha, x)[source]
copy(deep=False)[source]
scal(alpha)[source]
class pymor.vectorarrays.list.ListVectorArray(space, impl, base=None, ind=None, _len=None)[source]

Bases: 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, NGSolveVector and NGSolveVectorSpace.

impl_type[source]

alias of ListVectorArrayImpl

property vectors[source]
class pymor.vectorarrays.list.ListVectorArrayImpl(vectors, space)[source]

Bases: VectorArrayImpl

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

Bases: VectorSpace

VectorSpace of ListVectorArrays.

vector_type[source]

alias of Vector

classmethod space_from_dim(dim)[source]
classmethod space_from_vector_obj(vec)[source]
from_numpy(data, 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 (dim, len) 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(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(value)[source]
make_array(obj)[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.

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

ones_vector()[source]
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 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).

  • reserve – Hint for the backend to which length the array will grow.

random_vector(distribution, **kwargs)[source]
vector_from_numpy(data, ensure_copy=False)[source]
abstractmethod zero_vector()[source]
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 containing count vectors with each component zero.

dim = None[source]

The dimension (number of degrees of freedom) of the vectors contained in the space.

class pymor.vectorarrays.list.NumpyListVectorSpace(dim)[source]

Bases: ListVectorSpace

vector_type[source]

alias of NumpyVector

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

Bases: CopyOnWriteVector

Vector stored in a NumPy 1D-array.

classmethod from_instance(instance)[source]
amax()[source]
conj()[source]
dofs(dof_indices)[source]
inner(other)[source]
norm()[source]
norm2()[source]
to_numpy(ensure_copy=False)[source]
property dim[source]
property imag[source]
property real[source]
class pymor.vectorarrays.list.Vector[source]

Bases: 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.

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