From: yu.dongliang Date: Sun, 22 Nov 2020 11:50:56 +0000 (+0800) Subject: opt X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=61d46e0f3c6c54d9d61f809e8c02b9e24523f84c;p=mat.git opt --- diff --git a/mat.c b/mat.c index 65eb0f2..c873b4d 100644 --- a/mat.c +++ b/mat.c @@ -182,7 +182,6 @@ void mat_mul_strassen(mat_t* m, mat_t* m0, mat_t* m1, int n_min) mat_t* p1 = mat_alloc(0, 0, n, NULL); mat_t* p2 = mat_alloc(0, 0, n, NULL); mat_t* p3 = mat_alloc(0, 0, n, NULL); - mat_t* p4 = mat_alloc(0, 0, n, NULL); // tmp mat t0 mat_t* t0 = mat_alloc(0, 0, n, NULL); @@ -199,7 +198,12 @@ void mat_mul_strassen(mat_t* m, mat_t* m0, mat_t* m1, int n_min) // p3 = (c + d) * e mat_add(t0, c, d); mat_mul_strassen(p3, t0, e, n_min); + + mat_sub(u, p1, p3); + mat_free(p1); + // p4 = d * (g - e) + mat_t* p4 = mat_alloc(0, 0, n, NULL); mat_sub(t0, g, e); mat_mul_strassen(p4, d, t0, n_min); // t = p3 + p4 @@ -207,11 +211,9 @@ void mat_mul_strassen(mat_t* m, mat_t* m0, mat_t* m1, int n_min) mat_sub(r, p4, p2); mat_free(p2); + mat_free(p3); mat_free(p4); - mat_sub(u, p1, p3); - mat_free(p1); - mat_free(p3); // tmp mat t1 mat_t* t1 = mat_alloc(0, 0, n, NULL);