def test_kron_large(self): n = 2**16 a = construct.eye(1, n, n - 1) b = construct.eye(n, 1, 1 - n) construct.kron(a, a) construct.kron(b, b)
def test_eye_one(self): assert_equal(construct.eye(1).toarray(), [[1]]) assert_equal(construct.eye(2).toarray(), [[1,0],[0,1]]) I = construct.eye(3, dtype='int8', format='dia') assert_equal(I.dtype, np.dtype('int8')) assert_equal(I.format, 'dia') for fmt in sparse_formats: I = construct.eye(3, format=fmt) assert_equal(I.format, fmt) assert_equal(I.toarray(), [[1,0,0],[0,1,0],[0,0,1]])
def test_eye_one(self): assert_equal(construct.eye(1).toarray(), [[1]]) assert_equal(construct.eye(2).toarray(), [[1, 0], [0, 1]]) I = construct.eye(3, dtype="int8", format="dia") assert_equal(I.dtype, np.dtype("int8")) assert_equal(I.format, "dia") for fmt in sparse_formats: I = construct.eye(3, format=fmt) assert_equal(I.format, fmt) assert_equal(I.toarray(), [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
def test_eye_one(self): assert_equal(construct.eye(1).toarray(), [[1]]) assert_equal(construct.eye(2).toarray(), [[1, 0], [0, 1]]) I = construct.eye(3, dtype='int8', format='dia') assert_equal(I.dtype, np.dtype('int8')) assert_equal(I.format, 'dia') for fmt in sparse_formats: I = construct.eye(3, format=fmt) assert_equal(I.format, fmt) assert_equal(I.toarray(), [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
def create_Q_matrix(kappa, folder, ridge=1e-6): GiCG = loadmat(folder + "GiCG.mat")["GiCG"] G = loadmat(folder + "G.mat")["G"] C0 = loadmat(folder + "C0.mat")["C0"] Q = GiCG + 2 * (kappa ** 2) * G + (kappa ** 4) * C0 return Q + eye(Q.shape[0], Q.shape[1]) * ridge
def create_Q_matrix(self, kappa): folder = OzonePosterior.get_data_folder() GiCG = loadmat(folder + "GiCG.mat")["GiCG"] G = loadmat(folder + "G.mat")["G"] C0 = loadmat(folder + "C0.mat")["C0"] Q = GiCG + 2 * (kappa ** 2) * G + (kappa ** 4) * C0 return Q + eye(Q.shape[0], Q.shape[1]) * OzonePosterior.ridge
def create_Q_matrix(self, kappa): folder = OzonePosterior.get_data_folder() GiCG = loadmat(folder + "GiCG.mat")["GiCG"] G = loadmat(folder + "G.mat")["G"] C0 = loadmat(folder + "C0.mat")["C0"] Q = GiCG + 2 * (kappa**2) * G + (kappa**4) * C0 return Q + eye(Q.shape[0], Q.shape[1]) * OzonePosterior.ridge
def test_eye(self): assert_equal(construct.eye(1,1).toarray(), [[1]]) assert_equal(construct.eye(2,3).toarray(), [[1,0,0],[0,1,0]]) assert_equal(construct.eye(3,2).toarray(), [[1,0],[0,1],[0,0]]) assert_equal(construct.eye(3,3).toarray(), [[1,0,0],[0,1,0],[0,0,1]]) assert_equal(construct.eye(3,3,dtype='int16').dtype, np.dtype('int16')) for m in [3, 5]: for n in [3, 5]: for k in range(-5,6): assert_equal(construct.eye(m, n, k=k).toarray(), np.eye(m, n, k=k)) if m == n: assert_equal(construct.eye(m, k=k).toarray(), np.eye(m, n, k=k))
''' Created on Jul 31, 2012 @author: Paolo ''' from scipy.sparse.construct import eye v = eye(100000, 100000, 0, 'd') v.T