def get_quarters(self): ''' Get all 4 quarters of the matrix - get the left-right split Then split each part into top and bottom Return the 4 parts - topleft, topright, bottomleft, bottomright - in that order ''' first_half_mat = [] second_half_mat = [] for vector in self.mat_values: vector_obj6 = Vector(vector , zero_test = lambda x : (x == 0)) (first , last) = vector_obj6.split() first_half_mat.append(first) second_half_mat.append(last) vector_obj7 = Vector(first_half_mat , zero_test = lambda x : (x == 0)) (topleft , topright) = vector_obj7.split() vector_obj8 = Vector(first_half_mat , zero_test = lambda x : (x == 0)) (bottomleft , bottomright) = vector_obj8.split() return topleft , topright , bottomleft , bottomright
def left_right_split(self): ''' Split the matrix into two halves - left and right - and return the two matrices Split each row (use the split method of Vector) and put them together into the left and right matrices Use the make_matrix method for forming the new matrices ''' first_half_mat = [] second_half_mat = [] for vector in self.rows: vector_obj = Vector(vector, zero_test = lambda x : (x == 0)) (first , last) = vector_obj.split() first_half_mat.append(first) second_half_mat.append(last) make_matrix(first_half_mat) make_matrix(second_half_mat)
def left_right_split(self): ''' Split the matrix into two halves - left and right - and return the two matrices Split each row (use the split method of Vector) and put them together into the left and right matrices Use the make_matrix method for forming the new matrices ''' # Your Code ref=0 mat_left=[] mat_right=[] var=len(self.row) while(ref<var): obj=Vector(self.row[ref],zero_test) split=obj.split() mat_left.append(make_matrix(split[0])) mat_right.append(make_matrix(split[1])) ref+=1 return mat_left,mat_right