# `pymor.algorithms.projection`¶

## Module Contents¶

### Classes¶

 `ProjectRules` `RuleTable` for the `project` algorithm. `ProjectToSubbasisRules` `RuleTable` for the `project_to_subbasis` algorithm.

### Functions¶

 `project` Petrov-Galerkin projection of a given `Operator`. `project_to_subbasis` Project already projected `Operator` to a subbasis.
pymor.algorithms.projection.project(op, range_basis, source_basis, product=None)[source]

Petrov-Galerkin projection of a given `Operator`.

Given an inner product `( ⋅, ⋅)`, source vectors `b_1, ..., b_N` and range vectors `c_1, ..., c_M`, the projection `op_proj` of `op` is defined by

```[ op_proj(e_j) ]_i = ( c_i, op(b_j) )
```

for all i,j, where `e_j` denotes the j-th canonical basis vector of R^N.

In particular, if the `c_i` are orthonormal w.r.t. the given product, then `op_proj` is the coordinate representation w.r.t. the `b_i/c_i` bases of the restriction of `op` to `span(b_i)` concatenated with the orthogonal projection onto `span(c_i)`.

From another point of view, if `op` is viewed as a bilinear form (see `apply2`) and `( ⋅, ⋅ )` is the Euclidean inner product, then `op_proj` represents the matrix of the bilinear form restricted to `span(b_i) / span(c_i)` (w.r.t. the `b_i/c_i` bases).

How the projection is realized will depend on the given `Operator`. While a projected `NumpyMatrixOperator` will again be a `NumpyMatrixOperator`, only a generic `ProjectedOperator` can be returned in general. The exact algorithm is specified in `ProjectRules`.

Parameters

range_basis

The vectors `c_1, ..., c_M` as a `VectorArray`. If `None`, no projection in the range space is performed.

source_basis

The vectors `b_1, ..., b_N` as a `VectorArray` or `None`. If `None`, no restriction of the source space is performed.

product

An `Operator` representing the inner product. If `None`, the Euclidean inner product is chosen.

Returns

The projected `Operator` `op_proj`.

class pymor.algorithms.projection.ProjectRules(range_basis, source_basis)[source]

`RuleTable` for the `project` algorithm.

action_no_bases(self, op)[source]
action_ZeroOperator(self, op)[source]
action_ConstantOperator(self, op)[source]
action_apply_basis(self, op)[source]
action_ConcatenationOperator(self, op)[source]
action_EmpiricalInterpolatedOperator(self, op)[source]
action_AffineOperator(self, op)[source]
action_LincombOperator(self, op)[source]
action_SelectionOperator(self, op)[source]
action_BlockOperatorBase(self, op)[source]
pymor.algorithms.projection.project_to_subbasis(op, dim_range=None, dim_source=None)[source]

Project already projected `Operator` to a subbasis.

The purpose of this method is to further project an operator that has been obtained through `project` to subbases of the original projection bases, i.e.

```project_to_subbasis(project(op, r_basis, s_basis, prod), dim_range, dim_source)
```

should be the same as

```project(op, r_basis[:dim_range], s_basis[:dim_source], prod)
```

For a `NumpyMatrixOperator` this amounts to extracting the upper-left (dim_range, dim_source) corner of its matrix.

The subbasis projection algorithm is specified in `ProjectToSubbasisRules`.

Parameters

dim_range

Dimension of the range subbasis.

dim_source

Dimension of the source subbasis.

Returns

The projected `Operator`.

class pymor.algorithms.projection.ProjectToSubbasisRules(dim_range, dim_source)[source]

`RuleTable` for the `project_to_subbasis` algorithm.

action_recurse(self, op)[source]
action_NumpyMatrixOperator(self, op)[source]
action_ConstantOperator(self, op)[source]
action_IdentityOperator(self, op)[source]
action_ZeroOperator(self, op)[source]
action_ProjectedEmpiciralInterpolatedOperator(self, op)[source]
action_VectorArrayOperator(self, op)[source]
action_BlockColumnOperator(self, op)[source]
action_BlockRowOperator(self, op)[source]
action_ProjectedOperator(self, op)[source]