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_var3(A, B, C): AL, AR = flame.part_1x2(A, \ 0, 'LEFT') BT, \ BB = flame.part_2x1(B, \ 0, 'TOP') while AL.shape[1] < A.shape[1]: A0, a1, A2 = flame.repart_1x2_to_1x3(AL, AR, \ 1, 'RIGHT') B0, \ b1t, \ B2 = flame.repart_2x1_to_3x1(BT, \ BB, \ 1, 'BOTTOM') #------------------------------------------------------------# laff.ger( 1.0, a1, b1t, C ) #------------------------------------------------------------# AL, AR = flame.cont_with_1x3_to_1x2(A0, a1, A2, \ 'LEFT') BT, \ BB = flame.cont_with_3x1_to_2x1(B0, \ b1t, \ B2, \ 'TOP') C = np.matrix( np.copy( Cold ) ) # restore C Gemm_nn_unb_var3( A, B, C ) print( 'C - ( Cold + A * B )' ) print( C - ( Cold + A * B ) )