libflame revision_anchor
Functions
FLA_Pythag3.c File Reference

(r)

Functions

FLA_Error FLA_Pythag3 (FLA_Obj chi, FLA_Obj psi, FLA_Obj zeta, FLA_Obj rho)
 
FLA_Error FLA_Pythag3_ops (float *chi, float *psi, float *zeta, float *rho)
 
FLA_Error FLA_Pythag3_opd (double *chi, double *psi, double *zeta, double *rho)
 

Function Documentation

◆ FLA_Pythag3()

FLA_Error FLA_Pythag3 ( FLA_Obj  chi,
FLA_Obj  psi,
FLA_Obj  zeta,
FLA_Obj  rho 
)
14{
15 FLA_Datatype datatype;
16
17 datatype = FLA_Obj_datatype( chi );
18
19 switch ( datatype )
20 {
21 case FLA_FLOAT:
22 {
23 float* buff_chi = FLA_FLOAT_PTR( chi );
24 float* buff_psi = FLA_FLOAT_PTR( psi );
25 float* buff_zeta = FLA_FLOAT_PTR( zeta );
26 float* buff_rho = FLA_FLOAT_PTR( rho );
27
31 buff_rho );
32
33 break;
34 }
35
36 case FLA_DOUBLE:
37 {
38 double* buff_chi = FLA_DOUBLE_PTR( chi );
39 double* buff_psi = FLA_DOUBLE_PTR( psi );
40 double* buff_zeta = FLA_DOUBLE_PTR( zeta );
41 double* buff_rho = FLA_DOUBLE_PTR( rho );
42
46 buff_rho );
47
48 break;
49 }
50
51 case FLA_COMPLEX:
52 {
54
55 break;
56 }
57
59 {
61
62 break;
63 }
64 }
65
66 return FLA_SUCCESS;
67}
FLA_Error FLA_Pythag3_opd(double *chi, double *psi, double *zeta, double *rho)
Definition FLA_Pythag3.c:112
FLA_Error FLA_Pythag3_ops(float *chi, float *psi, float *zeta, float *rho)
Definition FLA_Pythag3.c:71
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition FLA_Query.c:13
int FLA_Datatype
Definition FLA_type_defs.h:49
int i
Definition bl1_axmyv2.c:145
* rho
Definition bl1_axpyv2bdotaxpy.c:322

References FLA_Obj_datatype(), FLA_Pythag3_opd(), FLA_Pythag3_ops(), i, and rho.

◆ FLA_Pythag3_opd()

FLA_Error FLA_Pythag3_opd ( double chi,
double psi,
double zeta,
double rho 
)
116{
117 double zero = bl1_d0();
118
119 double xabs, yabs, zabs;
120 double w;
121 double xabsdivw;
122 double yabsdivw;
123 double zabsdivw;
124
125 xabs = fabs( *chi );
126 yabs = fabs( *psi );
127 zabs = fabs( *zeta );
128 w = max( xabs, max( yabs, zabs ) );
129
130 if ( w == zero )
131 {
132 // From netlib dlapy3:
133 // W can be zero for max(0,nan,0). Adding all three entries
134 // together will make sure NaN will not disappear.
135 *rho = xabs + yabs + zabs;
136 }
137 else
138 {
139 xabsdivw = xabs / w;
140 yabsdivw = yabs / w;
141 zabsdivw = zabs / w;
142
143 *rho = w * sqrt( xabsdivw * xabsdivw +
145 zabsdivw * zabsdivw );
146 }
147
148 return FLA_SUCCESS;
149}
double bl1_d0(void)
Definition bl1_constants.c:118

References bl1_d0(), i, and rho.

Referenced by FLA_Pythag3().

◆ FLA_Pythag3_ops()

FLA_Error FLA_Pythag3_ops ( float chi,
float psi,
float zeta,
float rho 
)
75{
76 float zero = bl1_s0();
77
78 float xabs, yabs, zabs;
79 float w;
80 float xabsdivw;
81 float yabsdivw;
82 float zabsdivw;
83
84 xabs = fabsf( *chi );
85 yabs = fabsf( *psi );
86 zabs = fabsf( *zeta );
87 w = max( xabs, max( yabs, zabs ) );
88
89 if ( w == zero )
90 {
91 // From netlib dlapy3:
92 // W can be zero for max(0,nan,0). Adding all three entries
93 // together will make sure NaN will not disappear.
94 *rho = xabs + yabs + zabs;
95 }
96 else
97 {
98 xabsdivw = xabs / w;
99 yabsdivw = yabs / w;
100 zabsdivw = zabs / w;
101
102 *rho = w * sqrt( xabsdivw * xabsdivw +
104 zabsdivw * zabsdivw );
105 }
106
107 return FLA_SUCCESS;
108}
float bl1_s0(void)
Definition bl1_constants.c:111

References bl1_s0(), i, and rho.

Referenced by FLA_Pythag3().