파이썬에서 ctypes를 사용하여 BLAS에서 sgemm
함수를 사용하려고합니다. 잘 C = A X B 다음 코드를 해결하기 위해 노력하고 시도 :BLAS sgemm/dgemm은 어떻게 작동합니까?
no_trans = c_char("n")
m = c_int(number_of_rows_of_A)
n = c_int(number_of_columns_of_B)
k = c_int(number_of_columns_of_A)
one = c_float(1.0)
zero = c_float(0.0)
blaslib.sgemm_(byref(no_trans), byref(no_trans), byref(m), byref(n), byref(k),
byref(one), A, byref(m), B, byref(k), byref(zero), C, byref(m))
내가하고 싶은 것은이 방정식 해결하기 위해 : C = A의 전치 'X를 A가 어디'다음 코드는 예외없이 실행되지만 리턴 된 결과가 잘못 : I 매트릭스 A = [1 2 삽입
trans = c_char("t")
no_trans = c_char("n")
m = c_int(number_of_rows_of_A)
n = c_int(number_of_columns_of_A)
one = c_float(1.0)
zero = c_float(0.0)
blaslib.sgemm_(byref(trans), byref(no_trans), byref(n), byref(n), byref(m),
byref(one), A, byref(m), A, byref(m), byref(zero), C, byref(n))
테스트와; 3 4]. 올바른 결과는 C = [10 14; 14 20] 그러나 sgemm
루틴은 뱉어 내기 C = [5 11; 11 25].
내가 이해하는 한, 알고리즘 은 알고리즘이 처리해주기 때문에 전치되어 있지 않아도됩니다. 두 번째 경우에서 매개 변수 전달에 문제가 있습니까?
도움, 링크, 기사, 조언을 부탁드립니다!