Commit 25a99cef authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[pymortests.to_matrix] test DuneXTMatrixOperator

parent 13e161c3
......@@ -7,6 +7,7 @@ import scipy.linalg as spla
import scipy.sparse as sps
from pymor.algorithms.to_matrix import to_matrix
from pymor.core.config import config
from pymor.operators.block import BlockOperator, BlockDiagonalOperator
from pymor.operators.constructions import (AdjointOperator, ComponentProjectionOperator, IdentityOperator,
LowRankOperator, LowRankUpdatedOperator, VectorArrayOperator, ZeroOperator)
......@@ -255,3 +256,25 @@ def test_to_matrix_ZeroOperator():
Zop = ZeroOperator(NumpyVectorSpace(n), NumpyVectorSpace(m))
assert_type_and_allclose(Z, Zop, 'sparse')
if config.HAVE_DUNEGDT:
from import IstlSparseMatrix, SparsityPatternDefault
from pymor.bindings.dunegdt import DuneXTMatrixOperator
def test_to_matrix_DuneXTMatrixOperator():
A = np.random.randn(2, 2)
pattern = SparsityPatternDefault(2)
for ii in range(2):
for jj in range(2):
pattern.insert(ii, jj)
mat = IstlSparseMatrix(2, 2, pattern)
for ii in range(2):
for jj in range(2):
mat.set_entry(ii, jj, A[ii][jj])
Aop = DuneXTMatrixOperator(mat)
assert_type_and_allclose(A, Aop, 'sparse')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment