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.Methods
Attributes
DiskVectorArray
data
,dim
,subtype
VectorArrayInterface
space
BasicInterface
locked
,logger
,logging_disabled
,name
,uid

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 fromother
. For listlike 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 samex
vector is used for all vectors inself
. Otherwise, the lengths ofself
(ind
) andx
(x_ind
) have to agree. Ifalpha
is a scalar, eachx
vector is multiplied with the same factoralpha
. Otherwise,alpha
has to be a onedimensionalNumPy array
of the same length asself
(ind
) containing the coefficients for eachx
vector.Parameters
 alpha
 The scalar coefficient or onedimensional
NumPy array
of coefficients with which the vectors inx
are multiplied.  x
 A
VectorArray
containing the xsummands.  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 thatresult[i, j]
is thecomponent_indices[j]
th component of theind[i]
th vector of the array.

copy
(ind=None)[source]¶ Returns a copy of a subarray.
All
VectorArray
implementations in pyMOR have copyonwrite semantics: if not specified otherwise by settingdeep
toTrue
, 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).

l1_norm
(ind=None)[source]¶ The l1norms 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 thatresult[i]
contains the norm ofself[ind[i]]
.

l2_norm
(ind=None)[source]¶ The l2norms 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 thatresult[i]
contains the norm ofself[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 withlen(self)
.  ind
 Indices of the vectors which are linear combined (see class documentation).
Returns
A
VectorArray
result
such thatresult[i] = ∑ self[j] * coefficients[i,j]in case
coefficients
is of dimension 2, otherwiselen(result) == 1
andresult[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).

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 withlen(o_ind)
. Repeated indices are allowed.  remove_from_other
 If
True
, the new vectors are removed fromother
. For listlike implementations this can be used to prevent unnecessary copies of the involved vectors.

scal
(alpha, ind=None)[source]¶ BLAS SCAL operation (inplace 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 onedimensionalNumPy array
of the same length asself
(ind
) containing the factors for each vector.Parameters
 alpha
 The scalar coefficient or onedimensional
NumPy array
of coefficients with which the vectors inself
are multiplied.  ind
 Indices of the vectors of
self
that are to be scaled (see class documentation). Repeated indices are forbidden.
