pymor.playground.vectorarrays package

Submodules

disk module


class pymor.playground.vectorarrays.disk.DiskVectorArray(vectors, subtype=())[source]

Bases: pymor.vectorarrays.interfaces.VectorArrayInterface

VectorArray implementation via a list of vectors stored in temporary files.

__len__()[source]

The number of vectors in the array.

__str__() <==> str(x)[source]
amax(ind=None)[source]

The maximum absolute value of the vectors contained in the array.

Parameters

ind
Indices of the vectors whose maximum absolute value is to be calculated (see class documentation).

Returns

max_ind
NumPy array containing for each vector an index at which the maximum is attained.
max_val
NumPy array containing for each vector the maximum absolute value of its components.
append(other, o_ind=None, remove_from_other=False)[source]

Append vectors to the array.

Parameters

other
A VectorArray containing the vectors to be appended.
o_ind
Indices of the vectors that are to be appended (see class documentation).
remove_from_other
If True, the appended vectors are removed from other. For list-like implementations this can be used to prevent unnecessary copies of the involved vectors.
axpy(alpha, x, ind=None, x_ind=None)[source]

BLAS AXPY operation.

This method forms the sum

self[ind] = alpha*x[x_ind] + self[ind]

If the length of x (x_ind) is 1, the same x vector is used for all vectors in self. Otherwise, the lengths of self (ind) and x (x_ind) have to agree. If alpha is a scalar, each x vector is multiplied with the same factor alpha. Otherwise, alpha has to be a one-dimensional NumPy array of the same length as self (ind) containing the coefficients for each x vector.

Parameters

alpha
The scalar coefficient or one-dimensional NumPy array of coefficients with which the vectors in x are multiplied.
x
A VectorArray containing the x-summands.
ind
Indices of the vectors of self that are to be added (see class documentation). Repeated indices are forbidden.
x_ind
Indices of the vectors in x that are to be added (see class documentation). Repeated indices are allowed.
components(component_indices, ind=None)[source]

Extract components of the vectors contained in the array.

Parameters

component_indices
List or 1D NumPy array of indices of the vector components that are to be returned.
ind
Indices of the vectors whose components are to be retrieved (see class documentation).

Returns

A NumPy array result such that result[i, j] is the component_indices[j]-th component of the ind[i]-th vector of the array.

copy(ind=None)[source]

Returns a copy of a subarray.

All VectorArray implementations in pyMOR have copy-on-write semantics: if not specified otherwise by setting deep to True, the returned copy will hold a handle to the same array data as the original array, and a deep copy of the data will only be performed when one of the arrays is modified.

Note that for NumpyVectorArray, a deep copy is always performed when only some vectors in array are copied (i.e. ind is specified).

Parameters

ind
Indices of the vectors that are to be copied (see class documentation).
deep
Ensure that an actual copy of the array data is made (see above).

Returns

A copy of the VectorArray.

dot(other, ind=None, o_ind=None)[source]

Returns the inner products between VectorArray elements.

Parameters

other
A VectorArray containing the second factors.
ind
Indices of the vectors whose inner products are to be taken (see class documentation).
o_ind
Indices of the vectors in other whose inner products are to be taken (see class documentation).

Returns

A NumPy array result such that

result[i, j] = ( self[ind[i]], other[o_ind[j]] ).
gramian(ind=None)[source]

Shorthand for self.dot(self, ind=ind, o_ind=ind).

l1_norm(ind=None)[source]

The l1-norms of the vectors contained in the array.

Parameters

ind
Indices of the vectors whose norms are to be calculated (see class documentation).

Returns

A NumPy array result such that result[i] contains the norm of self[ind[i]].

l2_norm(ind=None)[source]

The l2-norms of the vectors contained in the array.

Parameters

ind
Indices of the vectors whose norms are to be calculated (see class documentation).

Returns

A NumPy array result such that result[i] contains the norm of self[ind[i]].

lincomb(coefficients, ind=None)[source]

Returns linear combinations of the vectors contained in the array.

Parameters

coefficients
A NumPy array of dimension 1 or 2 containing the linear coefficients. coefficients.shape[-1] has to agree with len(self).
ind
Indices of the vectors which are linear combined (see class documentation).

Returns

A VectorArray result such that

result[i] = ∑ self[j] * coefficients[i,j]

in case coefficients is of dimension 2, otherwise len(result) == 1 and

result[0] = ∑ self[j] * coefficients[j].
pairwise_dot(other, ind=None, o_ind=None)[source]

Returns the pairwise inner products between VectorArray elements.

Parameters

other
A VectorArray containing the second factors.
ind
Indices of the vectors whose inner products are to be taken (see class documentation).
o_ind
Indices of the vectors in other whose inner products are to be taken (see class documentation).

Returns

A NumPy array result such that

result[i] = ( self[ind[i]], other[o_ind[i]] ).
remove(ind=None)[source]

Remove vectors from the array.

Parameters

ind
Indices of the vectors that are to be removed (see class documentation).
replace(other, ind=None, o_ind=None, remove_from_other=False)[source]

Replace vectors of the array.

Parameters

other
A VectorArray containing the replacement vectors.
ind
Indices of the vectors that are to be replaced (see class documentation). Repeated indices are forbidden.
o_ind
Indices of the replacement vectors (see class documentation). len(ind) has to agree with len(o_ind). Repeated indices are allowed.
remove_from_other
If True, the new vectors are removed from other. For list-like implementations this can be used to prevent unnecessary copies of the involved vectors.
scal(alpha, ind=None)[source]

BLAS SCAL operation (in-place scalar multiplication).

This method calculates

self[ind] = alpha*self[ind]

If alpha is a scalar, each vector is multiplied by this scalar. Otherwise, alpha has to be a one-dimensional NumPy array of the same length as self (ind) containing the factors for each vector.

Parameters

alpha
The scalar coefficient or one-dimensional NumPy array of coefficients with which the vectors in self are multiplied.
ind
Indices of the vectors of self that are to be scaled (see class documentation). Repeated indices are forbidden.

pymor.playground.vectorarrays.disk.basedir(path='/tmp/pymor.diskarray.docs')[source]

pymor.playground.vectorarrays.disk.cleanup()[source]

mpi module


pymor.playground.vectorarrays.mpi.random_array(dims, length, seed)[source]

pymor.playground.vectorarrays.mpi.random_list_array(dims, length, seed)[source]