This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I2fa1987f25d1ca275ffd7c3a79d83a565a36b0d0
- Loading branch information
Showing
22 changed files
with
561 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathD.h" | ||
|
||
CONSTATTR double2 | ||
MATH_MANGLE(cacos)(double2 z) | ||
{ | ||
double2 a = MATH_MANGLE(cacosh)(z); | ||
bool b = AS_INT2(z.y).hi < 0; | ||
return (double2)(b ? -a.y : a.y, b ? a.x : -a.x); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathF.h" | ||
|
||
CONSTATTR float2 | ||
MATH_MANGLE(cacos)(float2 z) | ||
{ | ||
float2 a = MATH_MANGLE(cacosh)(z); | ||
bool b = AS_INT(z.y) < 0; | ||
return (float2)(b ? -a.y : a.y, b ? a.x : -a.x); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathD.h" | ||
|
||
#define DOUBLE_SPECIALIZATION | ||
#include "ep.h" | ||
|
||
extern CONSTATTR double4 MATH_PRIVATE(epcsqrtep)(double4 z); | ||
extern CONSTATTR double MATH_PRIVATE(lnep)(double2 a, int ea); | ||
|
||
CONSTATTR double2 | ||
MATH_MANGLE(cacosh)(double2 z) | ||
{ | ||
double x = BUILTIN_ABS_F64(z.x); | ||
double y = BUILTIN_ABS_F64(z.y); | ||
|
||
double2 l2, t; | ||
int e = 0; | ||
bool b = true; | ||
|
||
if (x < 0x1.0p+54 && y < 0x1.0p+54) { | ||
if (x >= 1.0 || y >= 0x1.0p-53 || y > (1.0 - x)*0x1.0p-26) { | ||
double4 z2p1 = (double4)(add(mul(add(y,x), sub(y,x)), 1.0), mul(y,x)*2.0); | ||
double4 rz2m1 = MATH_PRIVATE(epcsqrtep)(z2p1); | ||
rz2m1 = (double4)(csgn(rz2m1.hi, (double2)z.x), csgn(rz2m1.lo, (double2)z.y)); | ||
double4 s = (double4)(add(rz2m1.lo, z.x), add(rz2m1.hi, z.y)); | ||
l2 = add(sqr(s.lo), sqr(s.hi)); | ||
t = (double2)(s.s1, z.y == 0.0 ? z.y : s.s3); | ||
} else { | ||
b = false; | ||
double r = MATH_FAST_SQRT(BUILTIN_FMA_F64(-x, x, 1.0)); | ||
l2 = con(MATH_DIV(y, r), 0.0); | ||
t = (double2)(z.x, BUILTIN_COPYSIGN_F64(r, z.y)); | ||
} | ||
} else { | ||
e = BUILTIN_FREXP_EXP_F64(BUILTIN_MAX_F64(x,y)); | ||
x = BUILTIN_FLDEXP_F64(x, -e); | ||
y = BUILTIN_FLDEXP_F64(y, -e); | ||
l2 = add(sqr(x), sqr(y)); | ||
e = 2*e + 2; | ||
t = z; | ||
} | ||
|
||
double rr; | ||
if (b) { | ||
rr = 0.5 * MATH_PRIVATE(lnep)(l2, e); | ||
} else { | ||
rr = l2.hi; | ||
} | ||
|
||
double ri = MATH_MANGLE(atan2)(t.y, t.x); | ||
|
||
if (!FINITE_ONLY_OPT()) { | ||
rr = (BUILTIN_ISINF_F64(z.x) | BUILTIN_ISINF_F64(z.y)) ? AS_DOUBLE(PINFBITPATT_DP64) : rr; | ||
} | ||
|
||
return (double2)(rr, ri); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathF.h" | ||
|
||
#define FLOAT_SPECIALIZATION | ||
#include "ep.h" | ||
|
||
extern CONSTATTR float4 MATH_PRIVATE(epcsqrtep)(float4 z); | ||
extern CONSTATTR float MATH_PRIVATE(lnep)(float2 a, int ea); | ||
|
||
CONSTATTR float2 | ||
MATH_MANGLE(cacosh)(float2 z) | ||
{ | ||
float x = BUILTIN_ABS_F32(z.x); | ||
float y = BUILTIN_ABS_F32(z.y); | ||
|
||
float2 l2, t; | ||
int e = 0; | ||
bool b = true; | ||
|
||
if (x < 0x1.0p+25f && y < 0x1.0p+25f) { | ||
if (x >= 1.0f || y >= 0x1.0p-24f || y > (1.0f - x)*0x1.0p-12f) { | ||
float4 z2p1 = (float4)(add(mul(add(y,x), sub(y,x)), 1.0f), mul(y,x)*2.0f); | ||
float4 rz2m1 = MATH_PRIVATE(epcsqrtep)(z2p1); | ||
rz2m1 = (float4)(csgn(rz2m1.hi, (float2)z.x), csgn(rz2m1.lo, (float2)z.y)); | ||
float4 s = (float4)(add(rz2m1.lo, z.x), add(rz2m1.hi, z.y)); | ||
l2 = add(sqr(s.lo), sqr(s.hi)); | ||
t = (float2)(s.s1, z.y == 0.0f ? z.y : s.s3); | ||
} else { | ||
b = false; | ||
float r = MATH_SQRT(BUILTIN_FMA_F32(-x, x, 1.0f)); | ||
l2 = con(MATH_DIV(y, r), 0.0f); | ||
t = (float2)(z.x, BUILTIN_COPYSIGN_F32(r, z.y)); | ||
} | ||
} else { | ||
e = BUILTIN_FREXP_EXP_F32(AS_FLOAT(BUILTIN_MAX_U32(AS_UINT(x), AS_UINT(y)))); | ||
x = BUILTIN_FLDEXP_F32(x, -e); | ||
y = BUILTIN_FLDEXP_F32(y, -e); | ||
l2 = add(sqr(x), sqr(y)); | ||
e = 2*e + 2; | ||
t = z; | ||
} | ||
|
||
float rr; | ||
if (b) { | ||
rr = 0.5f * MATH_PRIVATE(lnep)(l2, e); | ||
} else { | ||
rr = l2.hi; | ||
} | ||
|
||
float ri = MATH_MANGLE(atan2)(t.y, t.x); | ||
|
||
if (!FINITE_ONLY_OPT()) { | ||
rr = (BUILTIN_ISINF_F32(z.x) | BUILTIN_ISINF_F32(z.y)) ? AS_FLOAT(PINFBITPATT_SP32) : rr; | ||
} | ||
|
||
return (float2)(rr, ri); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathD.h" | ||
|
||
CONSTATTR double2 | ||
MATH_MANGLE(casin)(double2 z) | ||
{ | ||
double2 a = MATH_MANGLE(casinh)((double2)(-z.y, z.x)); | ||
return (double2)(a.y, -a.x); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathF.h" | ||
|
||
CONSTATTR float2 | ||
MATH_MANGLE(casin)(float2 z) | ||
{ | ||
float2 a = MATH_MANGLE(casinh)((float2)(-z.y, z.x)); | ||
return (float2)(a.y, -a.x); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathD.h" | ||
|
||
#define DOUBLE_SPECIALIZATION | ||
#include "ep.h" | ||
|
||
extern CONSTATTR double4 MATH_PRIVATE(epcsqrtep)(double4 z); | ||
extern CONSTATTR double MATH_PRIVATE(lnep)(double2 a, int ea); | ||
|
||
CONSTATTR double2 | ||
MATH_MANGLE(casinh)(double2 z) | ||
{ | ||
double x = BUILTIN_ABS_F64(z.x); | ||
double y = BUILTIN_ABS_F64(z.y); | ||
|
||
double2 l2, t; | ||
int e = 0; | ||
bool b = true; | ||
|
||
if (x < 0x1.0p+54 && y < 0x1.0p+54) { | ||
if (y >= 1.0 || x >= 0x1.0p-53 || x > (1.0 - y)*0x1.0p-26f) { | ||
double4 z2p1 = (double4)(add(mul(add(x,y), sub(x,y)), 1.0), mul(y,x)*2.0); | ||
double4 rz2p1 = MATH_PRIVATE(epcsqrtep)(z2p1); | ||
double4 s = (double4)(add(rz2p1.lo, x), add(rz2p1.hi, y)); | ||
l2 = add(sqr(s.lo), sqr(s.hi)); | ||
t = (double2)(s.s1, s.s3); | ||
} else { | ||
b = false; | ||
double r = MATH_SQRT(BUILTIN_FMA_F64(-y, y, 1.0)); | ||
l2 = con(MATH_DIV(x, r), 0.0); | ||
t = (double2)(r, y); | ||
} | ||
} else { | ||
t = (double2)(x, y); | ||
e = BUILTIN_FREXP_EXP_F64(BUILTIN_MAX_F64(x, y)); | ||
x = BUILTIN_FLDEXP_F64(x, -e); | ||
y = BUILTIN_FLDEXP_F64(y, -e); | ||
l2 = add(sqr(x), sqr(y)); | ||
e = 2*e + 2; | ||
} | ||
|
||
double rr; | ||
if (b) { | ||
rr = 0.5 * MATH_PRIVATE(lnep)(l2, e); | ||
} else { | ||
rr = l2.hi; | ||
} | ||
|
||
rr = BUILTIN_COPYSIGN_F64(rr, z.x); | ||
double ri = BUILTIN_COPYSIGN_F64(MATH_MANGLE(atan2)(t.y, t.x), z.y); | ||
|
||
if (!FINITE_ONLY_OPT()) { | ||
double i = BUILTIN_COPYSIGN_F64(AS_DOUBLE(PINFBITPATT_DP64), z.x); | ||
rr = (BUILTIN_ISINF_F64(z.x) | BUILTIN_ISINF_F64(z.y)) ? i : rr; | ||
} | ||
|
||
return (double2)(rr, ri); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathF.h" | ||
|
||
#define FLOAT_SPECIALIZATION | ||
#include "ep.h" | ||
|
||
extern CONSTATTR float4 MATH_PRIVATE(epcsqrtep)(float4 z); | ||
extern CONSTATTR float MATH_PRIVATE(lnep)(float2 a, int ea); | ||
|
||
CONSTATTR float2 | ||
MATH_MANGLE(casinh)(float2 z) | ||
{ | ||
float x = BUILTIN_ABS_F32(z.x); | ||
float y = BUILTIN_ABS_F32(z.y); | ||
|
||
float2 l2, t; | ||
int e = 0; | ||
bool b = true; | ||
|
||
if (x < 0x1.0p+25f && y < 0x1.0p+25f) { | ||
if (y >= 1.0f || x >= 0x1.0p-24f || x > (1.0f - y)*0x1.0p-12f) { | ||
float4 z2p1 = (float4)(add(mul(add(x,y), sub(x,y)), 1.0f), mul(y,x)*2.0f); | ||
float4 rz2p1 = MATH_PRIVATE(epcsqrtep)(z2p1); | ||
float4 s = (float4)(add(rz2p1.lo, x), add(rz2p1.hi, y)); | ||
l2 = add(sqr(s.lo), sqr(s.hi)); | ||
t = (float2)(s.s1, s.s3); | ||
} else { | ||
b = false; | ||
float r = MATH_SQRT(BUILTIN_FMA_F32(-y, y, 1.0f)); | ||
l2 = con(MATH_DIV(x, r), 0.0f); | ||
t = (float2)(r, y); | ||
} | ||
} else { | ||
t = (float2)(x, y); | ||
e = BUILTIN_FREXP_EXP_F32(AS_FLOAT(BUILTIN_MAX_U32(AS_UINT(x), AS_UINT(y)))); | ||
x = BUILTIN_FLDEXP_F32(x, -e); | ||
y = BUILTIN_FLDEXP_F32(y, -e); | ||
l2 = add(sqr(x), sqr(y)); | ||
e = 2*e + 2; | ||
} | ||
|
||
float rr; | ||
if (b) { | ||
rr = 0.5f * MATH_PRIVATE(lnep)(l2, e); | ||
} else { | ||
rr = l2.hi; | ||
} | ||
|
||
rr = BUILTIN_COPYSIGN_F32(rr, z.x); | ||
float ri = BUILTIN_COPYSIGN_F32(MATH_MANGLE(atan2)(t.y, t.x), z.y); | ||
|
||
if (!FINITE_ONLY_OPT()) { | ||
float i = BUILTIN_COPYSIGN_F32(AS_FLOAT(PINFBITPATT_SP32), z.x); | ||
rr = (BUILTIN_ISINF_F32(z.x) | BUILTIN_ISINF_F32(z.y)) ? i : rr; | ||
} | ||
|
||
return (float2)(rr, ri); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*===-------------------------------------------------------------------------- | ||
* ROCm Device Libraries | ||
* | ||
* This file is distributed under the University of Illinois Open Source | ||
* License. See LICENSE.TXT for details. | ||
*===------------------------------------------------------------------------*/ | ||
|
||
#include "mathD.h" | ||
|
||
CONSTATTR double2 | ||
MATH_MANGLE(catan)(double2 z) | ||
{ | ||
double2 a = MATH_MANGLE(catanh)((double2)(-z.y, z.x)); | ||
return (double2)(a.y, -a.x); | ||
} | ||
|
Oops, something went wrong.