import numpy as np m = 4 n = 3 k = 5 C = np.matrix( np.random.random( (m, n) ) ) print( 'C = ' ) print( C ) Cold = np.matrix( np.zeros( (m,n ) ) ) Cold = np.matrix( np.copy( C ) ) # an alternative way of doing a "hard" copy, in this case of a matrix A = np.matrix( np.random.random( (m, k) ) ) print( 'A = ' ) print( A ) B = np.matrix( np.random.random( (k, n) ) ) print( 'B = ' ) print( B ) import flame import laff as laff def Gemm_nn_unb_var2(A, B, C): AT, \ AB = flame.part_2x1(A, \ 0, 'TOP') CT, \ CB = flame.part_2x1(C, \ 0, 'TOP') while AT.shape[0] < A.shape[0]: A0, \ a1t, \ A2 = flame.repart_2x1_to_3x1(AT, \ AB, \ 1, 'BOTTOM') C0, \ c1t, \ C2 = flame.repart_2x1_to_3x1(CT, \ CB, \ 1, 'BOTTOM') #------------------------------------------------------------# laff.gemv( 'Transpose', 1.0, B, a1t, 1.0, c1t ) #------------------------------------------------------------# AT, \ AB = flame.cont_with_3x1_to_2x1(A0, \ a1t, \ A2, \ 'TOP') CT, \ CB = flame.cont_with_3x1_to_2x1(C0, \ c1t, \ C2, \ 'TOP') flame.merge_2x1(CT, \ CB, C) C = np.matrix( np.copy( Cold ) ) # restore C Gemm_nn_unb_var2( A, B, C ) print( 'C - ( Cold + A * B )' ) print( C - ( Cold + A * B ) )