Beispiel #1
0
 def __call__(self, data, state):
     data = state['data']
     data_shape = state['data_shape']
     compression = self.compression
     if compression is None or compression == "" or compression == "no":
         C = lo.identity(2 * (data.size, ))
         factor = 1
     else:
         C = compression(data_shape, self.factor)
     # compress data
     data = compress(data, C, self.factor)
     # update pipeline state
     state['data'] = data
     state['compression'] = C
     state['compression_factor'] = self.factor
     state['compressed_data_shape'] = data.shape
     return data
Beispiel #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
Beispiel #3
0
def identity(tod, factor):
    shape = tod.shape
    return lo.identity(2 * (np.prod(shape),), dtype=np.float64)
Beispiel #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,
]

Beispiel #5
0
def identity(tod, factor):
    shape = tod.shape
    return lo.identity(2 * (np.prod(shape), ), dtype=np.float64)
Beispiel #6
0
#!/usr/bin/env python
"""
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:
#!/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):