def computeOnMasterNode(): global R, serializedData # Create an algorithm to compute QR decomposition on the master node algorithm = qr.Distributed(step2Master) for i in range(nBlocks): # Deserialize partial results from step 1 dataArch = OutputDataArchive(serializedData[i]) dataForStep2FromStep1 = DataCollection() dataForStep2FromStep1.deserialize(dataArch) algorithm.input.add(qr.inputOfStep2FromStep1, i, dataForStep2FromStep1) # Compute QR decomposition pres = algorithm.compute() inputForStep3FromStep2 = pres.getCollection(qr.outputOfStep2ForStep3) for i in range(nBlocks): # Serialize partial results to transfer to local nodes for step 3 dataArch = InputDataArchive() inputForStep3FromStep2[i].serialize(dataArch) length = dataArch.getSizeOfArchive() serializedData[i] = np.empty(length, dtype=np.uint8) dataArch.copyArchiveToArray(serializedData[i]) # Result class from qr res = algorithm.getResult() R = res.get(qr.matrixR)
def computeOnMasterNode(): global serializedData, Sigma, V # Create an algorithm to compute SVD on the master node algorithm = svd.Distributed(step2Master) for i in range(nBlocks): # Deserialize partial results from step 1 dataArch = OutputDataArchive(serializedData[i]) dataForStep2FromStep1 = DataCollection() dataForStep2FromStep1.deserialize(dataArch) algorithm.input.add(svd.inputOfStep2FromStep1, i, dataForStep2FromStep1) # Compute SVD # DistributedPartialResult class from svd pres = algorithm.compute() inputForStep3FromStep2 = pres.getCollection(svd.outputOfStep2ForStep3) for i in range(nBlocks): # Serialize partial results to transfer to local nodes for step 3 dataArch = InputDataArchive() inputForStep3FromStep2[i].serialize(dataArch) length = dataArch.getSizeOfArchive() serializedData[i] = np.empty(length, dtype=np.uint8) dataArch.copyArchiveToArray(serializedData[i]) # DistributedPartialResult class from svd res = algorithm.getResult() Sigma = res.get(svd.singularValues) V = res.get(svd.rightSingularMatrix)