From: wernsaar Date: Tue, 12 Aug 2014 06:35:42 +0000 (+0200) Subject: modified algorithm for better numerical stability X-Git-Tag: v0.2.11^2~2^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=07c66b196093b3bc124f674a341ce304939eccde;p=platform%2Fupstream%2Fopenblas.git modified algorithm for better numerical stability --- diff --git a/kernel/x86_64/zgemv_n.c b/kernel/x86_64/zgemv_n.c index 141cb35..75e40ec 100644 --- a/kernel/x86_64/zgemv_n.c +++ b/kernel/x86_64/zgemv_n.c @@ -48,8 +48,7 @@ static void zgemv_kernel_16x4(BLASLONG n, FLOAT **ap, FLOAT *x, FLOAT *y) for ( i=0; i< 2*n; i+=2 ) { -#if !defined(CONJ) -#if !defined(XCONJ) +#if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) ) y[i] += a0[i]*x[0] - a0[i+1] * x[1]; y[i+1] += a0[i]*x[1] + a0[i+1] * x[0]; y[i] += a1[i]*x[2] - a1[i+1] * x[3]; @@ -68,29 +67,6 @@ static void zgemv_kernel_16x4(BLASLONG n, FLOAT **ap, FLOAT *x, FLOAT *y) y[i] += a3[i]*x[6] + a3[i+1] * x[7]; y[i+1] += a3[i]*x[7] - a3[i+1] * x[6]; #endif -#else -#if !defined(XCONJ) - y[i] += a0[i]*x[0] + a0[i+1] * x[1]; - y[i+1] -= a0[i]*x[1] - a0[i+1] * x[0]; - y[i] += a1[i]*x[2] + a1[i+1] * x[3]; - y[i+1] -= a1[i]*x[3] - a1[i+1] * x[2]; - y[i] += a2[i]*x[4] + a2[i+1] * x[5]; - y[i+1] -= a2[i]*x[5] - a2[i+1] * x[4]; - y[i] += a3[i]*x[6] + a3[i+1] * x[7]; - y[i+1] -= a3[i]*x[7] - a3[i+1] * x[6]; - -#else - y[i] += a0[i]*x[0] - a0[i+1] * x[1]; - y[i+1] -= a0[i]*x[1] + a0[i+1] * x[0]; - y[i] += a1[i]*x[2] - a1[i+1] * x[3]; - y[i+1] -= a1[i]*x[3] + a1[i+1] * x[2]; - y[i] += a2[i]*x[4] - a2[i+1] * x[5]; - y[i+1] -= a2[i]*x[5] + a2[i+1] * x[4]; - y[i] += a3[i]*x[6] - a3[i+1] * x[7]; - y[i+1] -= a3[i]*x[7] + a3[i+1] * x[6]; - -#endif -#endif } } @@ -104,24 +80,13 @@ static void zgemv_kernel_16x1(BLASLONG n, FLOAT *ap, FLOAT *x, FLOAT *y) for ( i=0; i< 2*n; i+=2 ) { -#if !defined(CONJ) -#if !defined(XCONJ) +#if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) ) y[i] += a0[i]*x[0] - a0[i+1] * x[1]; y[i+1] += a0[i]*x[1] + a0[i+1] * x[0]; #else y[i] += a0[i]*x[0] + a0[i+1] * x[1]; y[i+1] += a0[i]*x[1] - a0[i+1] * x[0]; #endif -#else -#if !defined(XCONJ) - y[i] += a0[i]*x[0] + a0[i+1] * x[1]; - y[i+1] -= a0[i]*x[1] - a0[i+1] * x[0]; - -#else - y[i] += a0[i]*x[0] - a0[i+1] * x[1]; - y[i+1] -= a0[i]*x[1] + a0[i+1] * x[0]; -#endif -#endif } } @@ -139,17 +104,24 @@ static void zero_y(BLASLONG n, FLOAT *dest) -static void add_y(BLASLONG n, FLOAT *src, FLOAT *dest, BLASLONG inc_dest) +static void add_y(BLASLONG n, FLOAT *src, FLOAT *dest, BLASLONG inc_dest,FLOAT alpha_r, FLOAT alpha_i) { BLASLONG i; + FLOAT temp_r; + FLOAT temp_i; for ( i=0; i