libflame revision_anchor
Functions
FLA_Pythag2.c File Reference

(r)

Functions

FLA_Error FLA_Pythag2 (FLA_Obj chi, FLA_Obj psi, FLA_Obj rho)
 
FLA_Error FLA_Pythag2_ops (float *chi, float *psi, float *rho)
 
FLA_Error FLA_Pythag2_opd (double *chi, double *psi, double *rho)
 

Function Documentation

◆ FLA_Pythag2()

FLA_Error FLA_Pythag2 ( FLA_Obj  chi,
FLA_Obj  psi,
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_rho = FLA_FLOAT_PTR( rho );
26
29 buff_rho );
30
31 break;
32 }
33
34 case FLA_DOUBLE:
35 {
36 double* buff_chi = FLA_DOUBLE_PTR( chi );
37 double* buff_psi = FLA_DOUBLE_PTR( psi );
38 double* buff_rho = FLA_DOUBLE_PTR( rho );
39
42 buff_rho );
43
44 break;
45 }
46
47 case FLA_COMPLEX:
48 {
50
51 break;
52 }
53
55 {
57
58 break;
59 }
60 }
61
62 return FLA_SUCCESS;
63}
FLA_Error FLA_Pythag2_opd(double *chi, double *psi, double *rho)
Definition FLA_Pythag2.c:99
FLA_Error FLA_Pythag2_ops(float *chi, float *psi, float *rho)
Definition FLA_Pythag2.c:67
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_Pythag2_opd(), FLA_Pythag2_ops(), i, and rho.

◆ FLA_Pythag2_opd()

FLA_Error FLA_Pythag2_opd ( double chi,
double psi,
double rho 
)
102{
103 double zero = bl1_d0();
104 double one = bl1_d1();
105
106 double xabs, yabs;
107 double w, z;
108 double zdivw;
109
110 xabs = fabs( *chi );
111 yabs = fabs( *psi );
112 w = max( xabs, yabs );
113 z = min( xabs, yabs );
114
115 if ( z == zero )
116 {
117 *rho = w;
118 }
119 else
120 {
121 zdivw = z / w;
122
123 *rho = w * sqrt( one + zdivw * zdivw );
124 }
125
126 return FLA_SUCCESS;
127}
double bl1_d0(void)
Definition bl1_constants.c:118
double bl1_d1(void)
Definition bl1_constants.c:54

References bl1_d0(), bl1_d1(), i, and rho.

Referenced by FLA_Pythag2().

◆ FLA_Pythag2_ops()

FLA_Error FLA_Pythag2_ops ( float chi,
float psi,
float rho 
)
70{
71 float zero = bl1_s0();
72 float one = bl1_s1();
73
74 float xabs, yabs;
75 float w, z;
76 float zdivw;
77
78 xabs = fabsf( *chi );
79 yabs = fabsf( *psi );
80 w = max( xabs, yabs );
81 z = min( xabs, yabs );
82
83 if ( z == zero )
84 {
85 *rho = w;
86 }
87 else
88 {
89 zdivw = z / w;
90
91 *rho = w * sqrt( one + zdivw * zdivw );
92 }
93
94 return FLA_SUCCESS;
95}
float bl1_s0(void)
Definition bl1_constants.c:111
float bl1_s1(void)
Definition bl1_constants.c:47

References bl1_s0(), bl1_s1(), i, and rho.

Referenced by FLA_Pythag2().