pymor.algorithms.basic

Module containing some basic but generic linear algebra algorithms.

Module Contents

Functions

almost_equal

Compare U and V for almost equality.

relative_error

Compute error between U and V relative to norm of U.

project_array

Orthogonal projection of VectorArray onto subspace.

contains_zero_vector

Return True iff any vector in the array float_compares to 0s of the same dim.

pymor.algorithms.basic.almost_equal(U, V, product=None, sup_norm=False, rtol=1e-14, atol=1e-14)[source]

Compare U and V for almost equality.

The vectors of U and V are compared in pairs for almost equality. Two vectors u and v are considered almost equal iff

||u - v|| <= atol + ||v|| * rtol.

The norm to be used can be specified via the product or sup_norm parameters.

If the length of U resp. V is 1, the single specified vector is compared to all vectors of the other array. Otherwise, the lengths of both indexed arrays have to agree.

Parameters

U, V

VectorArrays to be compared.

product

If specified, use this inner product Operator to compute the norm. Otherwise, the Euclidean norm is used.

sup_norm

If True, use the sup norm to compute the error.

rtol

The relative tolerance.

atol

The absolute tolerance.

pymor.algorithms.basic.relative_error(U, V, product=None)[source]

Compute error between U and V relative to norm of U.

pymor.algorithms.basic.project_array(U, basis, product=None, orthonormal=True)[source]

Orthogonal projection of VectorArray onto subspace.

Parameters

U

The VectorArray to project.

basis

VectorArray of basis vectors for the subspace onto which to project.

product

Inner product Operator w.r.t. which to project.

orthonormal

If True, the vectors in basis are assumed to be orthonormal w.r.t. product.

Returns

The projected VectorArray.

pymor.algorithms.basic.contains_zero_vector(vector_array, rtol=None, atol=None)[source]

Return True iff any vector in the array float_compares to 0s of the same dim.

Parameters

vector_array

a VectorArray implementation

rtol

relative tolerance for float_cmp

atol

absolute tolerance for float_cmp