Example #1
0
	def test3(self):
		'''
		Test the case where alpha=0.
		'''
		random.seed(13)
		m, n = 33, 77 
		transA, transB = False, False
		alpha, beta = 0.0, 0.5
		sparsityA, sparsityB = 0.0, 0.0
		protocolA, protocolB = MatrixWrapper.RAW, MatrixWrapper.RAW
		dfsDirA, dfsDirB = None, None
		maxCoresA, maxCoresB = 7, 5
		maxTotalBlocks = 7 
		# instantiate A
		A = randomSparseMatrix(m, n, sparsityA)
		Awrap = MatrixWrapper.wrapMatrix(A, protocolA, dfsDirA, maxCoresA)
		# instantiate B
		B = randomSparseMatrix(m, n, sparsityB)
		Bwrap = MatrixWrapper.wrapMatrix(B, protocolB, dfsDirB, maxCoresB)
		# add
		Zwrap = dgema(disco, transA, transB, m, n, alpha, Awrap, Bwrap, beta, maxTotalBlocks)
		Z = Zwrap.unwrapMatrix(m, n).todense()
		# clean up
		disco.purge(jobname(Zwrap.urls[0]))
		# validate
		self.validate(alpha, beta, transA, transB, A, B, Z)
Example #2
0
	def test1(self):
		'''
		Test the case where size of matrix is smaller than the number of inputs for A and B.
		'''
		random.seed(13)
		m, n = 3, 3
		transA, transB = False, False
		alpha, beta = -1.2, 0.8
		sparsityA, sparsityB = 0.0, 0.0
		protocolA, protocolB = MatrixWrapper.RAW, MatrixWrapper.RAW
		dfsDirA, dfsDirB = None, None
		maxCoresA, maxCoresB = 13, 11
		maxTotalBlocks = 10
		# instantiate A
		A = randomSparseMatrix(m, n, sparsityA)
		Awrap = MatrixWrapper.wrapMatrix(A, protocolA, dfsDirA, maxCoresA)
		# instantiate B
		B = randomSparseMatrix(m, n, sparsityB)
		Bwrap = MatrixWrapper.wrapMatrix(B, protocolB, dfsDirB, maxCoresB)
		# add
		Zwrap = dgema(disco, transA, transB, m, n, alpha, Awrap, Bwrap, beta, maxTotalBlocks)
		Z = Zwrap.unwrapMatrix(m, n).todense()
		# clean up
		disco.purge(jobname(Zwrap.urls[0]))
		# validate
		self.validate(alpha, beta, transA, transB, A, B, Z)
Example #3
0
	def test2(self):
		'''
		Test transpose. 
		'''
		random.seed(13)
		m, n = 33, 3
		transA, transB = True, True
		alpha, beta = 0.2, 0.4
		sparsityA, sparsityB = 0.1, 0.1
		protocolA, protocolB = MatrixWrapper.RAW, MatrixWrapper.RAW
		dfsDirA, dfsDirB = None, None
		maxCoresA, maxCoresB = 5, 5 
		maxTotalBlocks = 3
		# instantiate A
		A = randomSparseMatrix(n, m, sparsityA)
		Awrap = MatrixWrapper.wrapMatrix(A, protocolA, dfsDirA, maxCoresA)
		# instantiate B
		B = randomSparseMatrix(n, m, sparsityB)
		Bwrap = MatrixWrapper.wrapMatrix(B, protocolB, dfsDirB, maxCoresB)
		# add
		Zwrap = dgema(disco, transA, transB, m, n, alpha, Awrap, Bwrap, beta, maxTotalBlocks)
		Z = Zwrap.unwrapMatrix(m, n).todense()
		# clean up
		disco.purge(jobname(Zwrap.urls[0]))
		# validate
		self.validate(alpha, beta, transA, transB, A, B, Z)
Example #4
0
	def test0(self):
		'''
		Test normal basic usage.
		'''
		random.seed(13)
		m, n = 30, 30
		transA, transB = False, False
		alpha, beta = 1.0, 1.0
		sparsityA, sparsityB = 0.3, 0.0
		protocolA, protocolB = MatrixWrapper.RAW, MatrixWrapper.RAW
		dfsDirA, dfsDirB = None, None
		maxCoresA, maxCoresB = 13, 11
		maxTotalBlocks = 10
		# instantiate A
		A = randomSparseMatrix(m, n, sparsityA)
		Awrap = MatrixWrapper.wrapMatrix(A, protocolA, dfsDirA, maxCoresA)
		# instantiate B
		B = randomSparseMatrix(m, n, sparsityB)
		Bwrap = MatrixWrapper.wrapMatrix(B, protocolB, dfsDirB, maxCoresB)
		# add 
		Zwrap = dgema(disco, transA, transB, m, n, alpha, Awrap, Bwrap, beta, maxTotalBlocks)
		Z = Zwrap.unwrapMatrix(m, n).todense()
		# clean up
		disco.purge(jobname(Zwrap.urls[0]))
		# validate
		self.validate(alpha, beta, transA, transB, A, B, Z)