Blame thirdparty/openblas/xianyi-OpenBLAS-e6e87a2/interface/rotg.c
|
kusano |
2b45e8 |
#include <math.h></math.h>
|
|
kusano |
2b45e8 |
#include "common.h"
|
|
kusano |
2b45e8 |
#ifdef FUNCTION_PROFILE
|
|
kusano |
2b45e8 |
#include "functable.h"
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef CBLAS
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
void NAME(FLOAT *DA, FLOAT *DB, FLOAT *C, FLOAT *S){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
void CNAME(FLOAT *DA, FLOAT *DB, FLOAT *C, FLOAT *S){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#if defined(__i386__) || defined(__x86_64__) || defined(__ia64__)
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
long double da = *DA;
|
|
kusano |
2b45e8 |
long double db = *DB;
|
|
kusano |
2b45e8 |
long double c;
|
|
kusano |
2b45e8 |
long double s;
|
|
kusano |
2b45e8 |
long double r, roe, z;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
long double ada = fabs(da);
|
|
kusano |
2b45e8 |
long double adb = fabs(db);
|
|
kusano |
2b45e8 |
long double scale = ada + adb;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef CBLAS
|
|
kusano |
2b45e8 |
PRINT_DEBUG_NAME;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
PRINT_DEBUG_CNAME;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
roe = db;
|
|
kusano |
2b45e8 |
if (ada > adb) roe = da;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (scale == ZERO) {
|
|
kusano |
2b45e8 |
*C = ONE;
|
|
kusano |
2b45e8 |
*S = ZERO;
|
|
kusano |
2b45e8 |
*DA = ZERO;
|
|
kusano |
2b45e8 |
*DB = ZERO;
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
r = sqrt(da * da + db * db);
|
|
kusano |
2b45e8 |
if (roe < 0) r = -r;
|
|
kusano |
2b45e8 |
c = da / r;
|
|
kusano |
2b45e8 |
s = db / r;
|
|
kusano |
2b45e8 |
z = ONE;
|
|
kusano |
2b45e8 |
if (da != ZERO) {
|
|
kusano |
2b45e8 |
if (ada > adb){
|
|
kusano |
2b45e8 |
z = s;
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
z = ONE / c;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
*C = c;
|
|
kusano |
2b45e8 |
*S = s;
|
|
kusano |
2b45e8 |
*DA = r;
|
|
kusano |
2b45e8 |
*DB = z;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
FLOAT da = *DA;
|
|
kusano |
2b45e8 |
FLOAT db = *DB;
|
|
kusano |
2b45e8 |
FLOAT c = *C;
|
|
kusano |
2b45e8 |
FLOAT s = *S;
|
|
kusano |
2b45e8 |
FLOAT r, roe, z;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
FLOAT ada = fabs(da);
|
|
kusano |
2b45e8 |
FLOAT adb = fabs(db);
|
|
kusano |
2b45e8 |
FLOAT scale = ada + adb;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef CBLAS
|
|
kusano |
2b45e8 |
PRINT_DEBUG_NAME;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
PRINT_DEBUG_CNAME;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
roe = db;
|
|
kusano |
2b45e8 |
if (ada > adb) roe = da;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (scale == ZERO) {
|
|
kusano |
2b45e8 |
*C = ONE;
|
|
kusano |
2b45e8 |
*S = ZERO;
|
|
kusano |
2b45e8 |
*DA = ZERO;
|
|
kusano |
2b45e8 |
*DB = ZERO;
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
FLOAT aa = da / scale;
|
|
kusano |
2b45e8 |
FLOAT bb = db / scale;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
r = scale * sqrt(aa * aa + bb * bb);
|
|
kusano |
2b45e8 |
if (roe < 0) r = -r;
|
|
kusano |
2b45e8 |
c = da / r;
|
|
kusano |
2b45e8 |
s = db / r;
|
|
kusano |
2b45e8 |
z = ONE;
|
|
kusano |
2b45e8 |
if (ada > adb) z = s;
|
|
kusano |
2b45e8 |
if ((ada < adb) && (c != ZERO)) z = ONE / c;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
*C = c;
|
|
kusano |
2b45e8 |
*S = s;
|
|
kusano |
2b45e8 |
*DA = r;
|
|
kusano |
2b45e8 |
*DB = z;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
return;
|
|
kusano |
2b45e8 |
}
|