Page MenuHomec4science

sampling_multi_point.py
No OneTemporary

File Metadata

Created
Sun, May 5, 03:22

sampling_multi_point.py

# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import numpy as np
import scipy.sparse as sp
from rrompy.hfengines.base import MatrixEngineBase as MEB
from rrompy.sampling.linear_problem import (SamplingEngineLagrange,
SamplingEngineLagrangePOD)
def test_lagrange():
N = 100
mus = np.linspace(5, 15, 11) + .5j
solver = MEB(verbosity = 0)
solver.nAs = 2
solver.As = [sp.spdiags([np.arange(1, 1 + N)], [0], N, N),
- sp.eye(N)]
solver.nbs = 1
solver.bs = {False: [np.exp(1.j * np.linspace(0, -np.pi, N))]}
samplingEngine = SamplingEngineLagrange(solver, verbosity = 0)
samples = samplingEngine.iterSample(mus)
assert samples.shape == (100, 11)
assert np.isclose(np.linalg.norm(samples), 8.59778606421386)
def test_lagrange_pod():
N = 100
mus = np.linspace(5, 15, 11) + .5j
solver = MEB(verbosity = 0)
solver.nAs = 2
solver.As = [sp.spdiags([np.arange(1, 1 + N)], [0], N, N),
- sp.eye(N)]
solver.nbs = 1
solver.bs = {False: [np.exp(1.j * np.linspace(0, -np.pi, N))]}
samplingEngine = SamplingEngineLagrangePOD(solver, verbosity = 0)
samples = samplingEngine.iterSample(mus)
assert samples.shape == (100, 11)
assert np.isclose(np.linalg.norm(samples), 3.3166247903553994)
assert np.isclose(np.linalg.cond(samples.conj().T.dot(samples)), 1.)

Event Timeline