def __init__(self): n, p = 500, 3 self.n = n self.p = p self.btrid=BlockTridMatrix(diagonal=random.random([n,p,p]),\ upper=random.random([n-1,p,p]),lower=random.random([n-1,p,p])) self.strid = ScalarTridMatrix(diagonal=random.random(n), upper=random.random(n - 1), lower=random.random(n - 1))
class TestParse(object): def __init__(self): n, p = 500, 3 self.n = n self.p = p self.btrid=BlockTridMatrix(diagonal=random.random([n,p,p]),\ upper=random.random([n-1,p,p]),lower=random.random([n-1,p,p])) self.strid = ScalarTridMatrix(diagonal=random.random(n), upper=random.random(n - 1), lower=random.random(n - 1)) def test_a2trid(self): #for scalar print 'Testing for conversion between ScalarTridMatrix and array.' a = self.strid.toarray() smat = arr2trid(a) a2 = smat.toarray() assert_allclose(a, a2, atol=1e-10) #for block print 'Testing for conversion between BlockTridMatrix and array.' a = self.btrid.toarray() smat = arr2trid(a, p=self.p) a2 = smat.toarray() assert_allclose(a, a2, atol=1e-10) def test_csr2trid(self): #for scalar print 'Testing for conversion between ScalarTridMatrix and CSR.' a = self.strid.tocsr() smat = sr2trid(a) smat2 = arr2trid(self.strid.toarray()) a2 = smat.toarray() assert_allclose(a.toarray(), a2, atol=1e-10) #for block print 'Testing for conversion between BlockTridMatrix and CSR.' a = self.btrid.tocsr() smat = sr2trid(a, p=self.p) a2 = smat.toarray() assert_allclose(a.toarray(), a2, atol=1e-10) def test_bsr2trid(self): print 'Testing for conversion between BlockTridMatrix and BSR.' a = self.btrid.tobsr() smat = sr2trid(a, p=self.p) a2 = smat.toarray() assert_allclose(a.toarray(), a2, atol=1e-10) def test_all(self): self.test_a2trid() self.test_csr2trid() self.test_bsr2trid()
class TestParse(object): def __init__(self): n,p=500,3 self.n=n self.p=p self.btrid=BlockTridMatrix(diagonal=random.random([n,p,p]),\ upper=random.random([n-1,p,p]),lower=random.random([n-1,p,p])) self.strid=ScalarTridMatrix(diagonal=random.random(n),upper=random.random(n-1),lower=random.random(n-1)) def test_a2trid(self): #for scalar print 'Testing for conversion between ScalarTridMatrix and array.' a=self.strid.toarray() smat=arr2trid(a) a2=smat.toarray() assert_allclose(a,a2,atol=1e-10) #for block print 'Testing for conversion between BlockTridMatrix and array.' a=self.btrid.toarray() smat=arr2trid(a,p=self.p) a2=smat.toarray() assert_allclose(a,a2,atol=1e-10) def test_csr2trid(self): #for scalar print 'Testing for conversion between ScalarTridMatrix and CSR.' a=self.strid.tocsr() smat=sr2trid(a) smat2=arr2trid(self.strid.toarray()) a2=smat.toarray() assert_allclose(a.toarray(),a2,atol=1e-10) #for block print 'Testing for conversion between BlockTridMatrix and CSR.' a=self.btrid.tocsr() smat=sr2trid(a,p=self.p) a2=smat.toarray() assert_allclose(a.toarray(),a2,atol=1e-10) def test_bsr2trid(self): print 'Testing for conversion between BlockTridMatrix and BSR.' a=self.btrid.tobsr() smat=sr2trid(a,p=self.p) a2=smat.toarray() assert_allclose(a.toarray(),a2,atol=1e-10) def test_all(self): self.test_a2trid() self.test_csr2trid() self.test_bsr2trid()
def __init__(self): n,p=500,3 self.n=n self.p=p self.btrid=BlockTridMatrix(diagonal=random.random([n,p,p]),\ upper=random.random([n-1,p,p]),lower=random.random([n-1,p,p])) self.strid=ScalarTridMatrix(diagonal=random.random(n),upper=random.random(n-1),lower=random.random(n-1))