def run(self): for col in range(0, self.matrix1.col_blocks()): for row in range(0,self.matrix1.row_blocks()): comm = cmd.build_command(cmd.BINARYMATRIXOP, self.matrix1.block_name(row, col), self.matrix2.block_name(row, col), self.expr, self.context.key_manager.get_block_name(self.result_name, row, col)) self.add_subjob(comm) self.execute()
def run(self): for col in range(0, self.matrix.col_blocks()): key = self.output_prefix + str(col) for row in range(0, self.matrix.row_blocks()): count_cmd = cmd.build_command(cmd.COUNT, self.matrix.block_name(row, col), key) self.add_subjob(count_cmd) self.execute()
def run(self): for col in range(0, self.matrix.col_blocks()): for row in range(0,self.matrix.row_blocks()): mult_cmd = cmd.build_command(cmd.MATRIXSCALAROP, str(self.scalar), self.operation, self.matrix.block_name(row, col), self.context.key_manager.get_block_name(self.result_name, row, col)) self.add_subjob(mult_cmd) self.execute()
def run(self): for col in range(0, self.matrix.col_blocks()): for row in range(0,self.matrix.row_blocks()): transp_cmd = cmd.build_command(cmd.TRANSPOSE, self.matrix.block_name(row, col), self.context.key_manager.get_block_name(self.result_name, col, row)) self.add_subjob(transp_cmd) self.execute()
def run(self): num_centers = self.distance_matrix.dimension()[1] for row in range(0, self.data.row_blocks()): recalc_cmd = cmd.build_command( "RECALC", self.data.block_name(row, 0), self.distance_matrix.block_name(row, 0), self.center_prefix + "_0_", self.count_prefix, ) self.add_subjob(recalc_cmd) for col in range(1, self.data.col_blocks()): recalc_cmd = cmd.build_command( "RECALC", self.data.block_name(row, col), self.distance_matrix.block_name(row, 0), self.center_prefix + "_" + str(col) + "_", ) self.add_subjob(recalc_cmd) self.execute()
def run(self): # modifiers are used to negate or transpose a matrix "on-the-fly" which saves commands modifiers = ["t", "-"] mod1 = self.__build_modifier_string([self.transpose_m1, self.negate_m1], modifiers) mod2 = self.__build_modifier_string([self.transpose_m2, self.negate_m2], modifiers) mod = mod1 + ";" + mod2 for col in range(0, self.matrix1.col_blocks()): for row in range(0,self.matrix1.row_blocks()): for col2 in range(0,self.matrix1.row_blocks()): m1_block_name = self.matrix1.block_name(col, row) if self.transpose_m1 else self.matrix1.block_name(row, col) m2_block_name = self.matrix2.block_name(col2, col) if self.transpose_m2 else self.matrix2.block_name(col, col2) mult_cmd = cmd.build_command(cmd.MATRIXMULT, mod, m1_block_name, m2_block_name, self.result_name_format.format(self.context.key_manager.get_slave(col, row, col2), col, row, col2)) self.add_subjob(mult_cmd) self.execute()
def __inner_aggr(self, aggr_op, expr, axis): """ Helper method for different aggregation functions """ aggr_job = jobs.Job(self.context) prefix = 'aggr_' + aggr_op + '(' + self.__name + ',' + str(axis) + ')' # First sum up each block for col in range(0, self.col_blocks()): for row in range(0,self.row_blocks()): mname = self.context.key_manager.get_block_name(prefix, col, row) aggr_cmd = cmd.build_command(cmd.AGGREGATEOP, self.block_name(row, col), cmd.escape_expression(expr), axis, aggr_op, mname) aggr_job.add_subjob(aggr_cmd) try: aggr_job.execute() except exceptions.JobException as e: raise exceptions.MatrixOperationException(str(e), cmd.AGGREGATEOP) return prefix
def run(self): numcols = self.cols / self.context.block_size if self.cols % self.context.block_size != 0: numcols += 1 numrows = self.rows / self.context.block_size if self.rows % self.context.block_size != 0: numrows += 1 for col in range(0, numcols): for row in range(0, numrows): cols = self.context.block_size rows = self.context.block_size # In case the matrix size is not a multiple of the block size if (row+1) * self.context.block_size > self.rows: rows = self.rows % self.context.block_size if (col+1) * self.context.block_size > self.cols: cols = self.cols % self.context.block_size comm = cmd.build_command(cmd.CREATE, self.content, rows, cols, self.context.key_manager.get_block_name(self.result_name, row, col)) self.add_subjob(comm) self.execute()
def run(self): for k in range(0, self.matrix.row_blocks()): trace_cmd = cmd.build_command(cmd.TRACE, self.matrix.block_name(k, k), self.output_key) self.add_subjob(trace_cmd) self.execute()
def run(self): for row in range(0, self.matrix1.row_blocks()): for col in range(0, self.matrix1.col_blocks()): equal_cmd = cmd.build_command(cmd.EQUALS, self.matrix1.block_name(row, col), self.matrix2.block_name(row, col), self.result_key) self.add_subjob(equal_cmd) self.execute()