Exemplo n.º 1
0
"""
Testing of the lo package
"""

import nose
from numpy.testing import *
import numpy as np
import linear_operators as lo
from linear_operators.iterative import utils

n = 128
k = n - 1
nk = 3
# collection of linear operators to test
I = lo.identity((n, n))
D = lo.diag(1. + np.arange(n))
C = lo.convolve((n,), kernel=1. + np.arange(nk))
lo_list = [I, D, C.T * C]

# collection of vectors
ones16 = np.ones(n)


def check_cond(A):
    Adec = utils.eigendecomposition(A, k=k, which='BE')
    assert_almost_equal(Adec.cond(), np.linalg.cond(A.todense()))

def test_cond():
    for A in lo_list:
        yield check_cond, A
Exemplo n.º 2
0
"""
Testing of the lo package
"""

import nose
from numpy.testing import *
import numpy as np
import linear_operators as lo
from linear_operators.iterative import utils

n = 128
k = n - 1
nk = 3
# collection of linear operators to test
I = lo.identity((n, n))
D = lo.diag(1. + np.arange(n))
C = lo.convolve((n, ), kernel=1. + np.arange(nk))
lo_list = [I, D, C.T * C]

# collection of vectors
ones16 = np.ones(n)


def check_cond(A):
    Adec = utils.eigendecomposition(A, k=k, which='BE')
    assert_almost_equal(Adec.cond(), np.linalg.cond(A.todense()))


def test_cond():
    for A in lo_list:
        yield check_cond, A
Exemplo n.º 3
0
#!/usr/bin/env python
"""
Testing of the lo.iterative module
"""

import nose
from numpy.testing import *
import numpy as np
import linear_operators as lo
from linear_operators import iterative

# collection of linear operators to test
mat16 = lo.aslinearoperator(np.random.rand(16, 16))
id16 = lo.identity((16, 16))
diag16 = lo.diag(np.random.rand(16))
conv16 = lo.convolve(16, np.random.rand(4), mode="same")
lo_list = [mat16, id16, diag16, conv16]

# collection of vectors
ones16 = np.ones(16)
zeros16 = np.zeros(16)
rand16 = np.random.rand(16)

v_list = [ones16, zeros16, rand16]

# collection of methods
methods = [
    iterative.acg,
]

Exemplo n.º 4
0
#!/usr/bin/env python

"""
Testing of the lo.iterative module
"""

import nose
from numpy.testing import *
import numpy as np
import linear_operators as lo
from linear_operators import iterative

# collection of linear operators to test
mat16 = lo.aslinearoperator(np.random.rand(16, 16))
id16 = lo.identity((16, 16))
diag16 = lo.diag(np.random.rand(16))
conv16 = lo.convolve(16, np.random.rand(4), mode="same")
lo_list = [mat16, id16, diag16, conv16]

# collection of vectors
ones16 = np.ones(16)
zeros16 = np.zeros(16)
rand16 = np.random.rand(16)

v_list = [ones16, zeros16, rand16 ]

# collection of methods
methods = [iterative.acg, ]

# tests
def check_inv(method, A, x):