def Set_to_zero_unb_var2(A): """ Set_to_zero_unb_var2(matrix) Sets the input matrix to zeros. Traverses input matrix from TOP to BOTTOM and sets results column-wise. """ AT, \ AB = flame.part_2x1(A, \ 0, 'TOP') while AT.shape[0] < A.shape[0]: A0, \ a1t, \ A2 = flame.repart_2x1_to_3x1(AT, \ AB, \ 1, 'BOTTOM') laff.zerov(a1t) AT, \ AB = flame.cont_with_3x1_to_2x1(A0, \ a1t, \ A2, \ 'TOP') flame.merge_2x1(AT, \ AB, A)
def Set_to_zero_unb_var1(A): """ Set_to_zero_unb_var1(matrix) Sets the input matrix to zeros. Traverses input matrix from LEFT to RIGHT and sets results column-wise. """ AL, \ AR = flame.part_1x2(A, \ 0, 'LEFT') while AL.shape[1] < A.shape[1]: A0, \ a1, \ A2 = flame.repart_1x2_to_1x3(AL, \ AR, \ 1, 'RIGHT') laff.zerov(a1) AL, \ AR = flame.cont_with_1x3_to_1x2(A0, \ a1, \ A2, 'LEFT') flame.merge_1x2(AL, \ AR, A)
def Set_to_lower_triangular_matrix_unb_var1(A): """ Set_to_lower_triangular_matrix_unb_var1(matrix) Sets the above diagonal elements of A to zero. Traverses matrix A from TOP-LEFT to BOTTOM-RIGHT, and sets results column-wise. """ ATL, ATR, \ ABL, ABR = flame.part_2x2(A, \ 0, 0, 'TL') while ATL.shape[0] < A.shape[0]: A00, a01, A02, \ a10t, alpha11, a12t, \ A20, a21, A22 = flame.repart_2x2_to_3x3(ATL, ATR, \ ABL, ABR, \ 1, 1, 'BR') laff.zerov(a01) ATL, ATR, \ ABL, ABR = flame.cont_with_3x3_to_2x2(A00, a01, A02, \ a10t, alpha11, a12t, \ A20, a21, A22, \ 'TL') flame.merge_2x2(ATL, ATR, \ ABL, ABR, A)
def Set_to_identity_unb_var1(A): """ Set_to_identity_unb_var1(matrix) Sets the input matrix to the Identity matrix. Traverses input matrix from TOP-LEFT to BOTTOM-RIGHT and sets results column-wise. """ ATL, ATR, \ ABL, ABR = flame.part_2x2(A, \ 0, 0, 'TL') while ATL.shape[0] < A.shape[0]: A00, a01, A02, \ a10t, alpha11, a12t, \ A20, a21, A22 = flame.repart_2x2_to_3x3(ATL, ATR, \ ABL, ABR, \ 1, 1, 'BR') laff.zerov(a01) laff.onev(alpha11) laff.zerov(a21) ATL, ATR, \ ABL, ABR = flame.cont_with_3x3_to_2x2(A00, a01, A02, \ a10t, alpha11, a12t, \ A20, a21, A22, \ 'TL') flame.merge_2x2(ATL, ATR, \ ABL, ABR, A)
def Set_to_diagonal_matrix_unb_var2(d, A): """ Set_to_diagonal_matrix_unb_var2(vector, matrix) Sets the diagonal elements of A to the components of vector d. Traverses matrix A from TOP-LEFT to BOTTOM-RIGHT, traverses vector d from TOP to BOTTOM and sets results row-wise. """ dT, \ dB = flame.part_2x1(d, \ 0, 'TOP') ATL, ATR, \ ABL, ABR = flame.part_2x2(A, \ 0, 0, 'TL') while dT.shape[0] < d.shape[0]: d0, \ delta1, \ d2 = flame.repart_2x1_to_3x1(dT, \ dB, \ 1, 'BOTTOM') A00, a01, A02, \ a10t, alpha11, a12t, \ A20, a21, A22 = flame.repart_2x2_to_3x3(ATL, ATR, \ ABL, ABR, \ 1, 1, 'BR') laff.zerov(a10t) laff.copy(delta1, alpha11) laff.zerov(a12t) dT, \ dB = flame.cont_with_3x1_to_2x1(d0, \ delta1, \ d2, \ 'TOP') ATL, ATR, \ ABL, ABR = flame.cont_with_3x3_to_2x2(A00, a01, A02, \ a10t, alpha11, a12t, \ A20, a21, A22, \ 'TL') flame.merge_2x1(dT, \ dB, d) flame.merge_2x2(ATL, ATR, \ ABL, ABR, A)
def Set_to_lower_triangular_matrix_unb_var1(A): """ Set_to_lower_triangular_matrix_unb_var1(matrix) Sets the above diagonal elements of A to zero. Traverses matrix A from TOP-LEFT to BOTTOM-RIGHT, and sets results column-wise. """ ATL, ATR, ABL, ABR = flame.part_2x2(A, 0, 0, "TL") while ATL.shape[0] < A.shape[0]: A00, a01, A02, a10t, alpha11, a12t, A20, a21, A22 = flame.repart_2x2_to_3x3(ATL, ATR, ABL, ABR, 1, 1, "BR") laff.zerov(a01) ATL, ATR, ABL, ABR = flame.cont_with_3x3_to_2x2(A00, a01, A02, a10t, alpha11, a12t, A20, a21, A22, "TL") flame.merge_2x2(ATL, ATR, ABL, ABR, A)