pymor.algorithms.basic

Module containing some basic but generic linear algebra algorithms.

Module Contents

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:
  • UVectorArrays to be compared.

  • VVectorArrays 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.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

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

Orthogonal projection of VectorArray onto subspace.

Parameters:
  • U – The VectorArray to project.

  • basisVectorArray 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.relative_error(U, V, product=None)[source]

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