libflame revision_anchor
Functions
FLA_Bsvd_compute_shift.c File Reference

(r)

Functions

FLA_Error FLA_Bsvd_compute_shift (FLA_Obj tol, FLA_Obj sminl, FLA_Obj smax, FLA_Obj d, FLA_Obj e, FLA_Obj shift)
 
FLA_Error FLA_Bsvd_compute_shift_ops (int m_A, float tol, float sminl, float smax, float *buff_d, int inc_d, float *buff_e, int inc_e, float *shift)
 
FLA_Error FLA_Bsvd_compute_shift_opd (int m_A, double tol, double sminl, double smax, double *buff_d, int inc_d, double *buff_e, int inc_e, double *shift)
 

Function Documentation

◆ FLA_Bsvd_compute_shift()

FLA_Error FLA_Bsvd_compute_shift ( FLA_Obj  tol,
FLA_Obj  sminl,
FLA_Obj  smax,
FLA_Obj  d,
FLA_Obj  e,
FLA_Obj  shift 
)
14{
15 FLA_Datatype datatype;
16 int m_A;
17 int inc_d;
18 int inc_e;
19
20 datatype = FLA_Obj_datatype( d );
21
23
26
27 switch ( datatype )
28 {
29 case FLA_FLOAT:
30 {
31 float* buff_tol = FLA_FLOAT_PTR( tol );
32 float* buff_sminl = FLA_FLOAT_PTR( sminl );
33 float* buff_smax = FLA_FLOAT_PTR( smax );
34 float* buff_d = FLA_FLOAT_PTR( d );
35 float* buff_e = FLA_FLOAT_PTR( e );
36 float* buff_shift = FLA_FLOAT_PTR( shift );
37
39 *buff_tol,
41 *buff_smax,
44 buff_shift );
45
46 break;
47 }
48
49 case FLA_DOUBLE:
50 {
51 double* buff_tol = FLA_DOUBLE_PTR( tol );
52 double* buff_sminl = FLA_DOUBLE_PTR( sminl );
53 double* buff_smax = FLA_DOUBLE_PTR( smax );
54 double* buff_d = FLA_DOUBLE_PTR( d );
55 double* buff_e = FLA_DOUBLE_PTR( e );
56 double* buff_shift = FLA_DOUBLE_PTR( shift );
57
59 *buff_tol,
61 *buff_smax,
64 buff_shift );
65
66 break;
67 }
68 }
69
70 return FLA_SUCCESS;
71}
FLA_Error FLA_Bsvd_compute_shift_opd(int m_A, double tol, double sminl, double smax, double *buff_d, int inc_d, double *buff_e, int inc_e, double *shift)
Definition FLA_Bsvd_compute_shift.c:130
FLA_Error FLA_Bsvd_compute_shift_ops(int m_A, float tol, float sminl, float smax, float *buff_d, int inc_d, float *buff_e, int inc_e, float *shift)
Definition FLA_Bsvd_compute_shift.c:75
dim_t FLA_Obj_vector_inc(FLA_Obj obj)
Definition FLA_Query.c:145
dim_t FLA_Obj_vector_dim(FLA_Obj obj)
Definition FLA_Query.c:137
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

References FLA_Bsvd_compute_shift_opd(), FLA_Bsvd_compute_shift_ops(), FLA_Obj_datatype(), FLA_Obj_vector_dim(), FLA_Obj_vector_inc(), and i.

◆ FLA_Bsvd_compute_shift_opd()

FLA_Error FLA_Bsvd_compute_shift_opd ( int  m_A,
double  tol,
double  sminl,
double  smax,
double buff_d,
int  inc_d,
double buff_e,
int  inc_e,
double shift 
)
137{
138 double hndrth = 0.01;
139 double eps;
140 double* d_first;
141 double* e_last;
142 double* d_last_m1;
143 double* d_last;
144 double sll, temp;
145
147
148 d_first = buff_d + (0 )*inc_d;
149 e_last = buff_e + (m_A-2)*inc_e;
150 d_last_m1 = buff_d + (m_A-2)*inc_d;
151 d_last = buff_d + (m_A-1)*inc_d;
152
153 // If the shift would ruin relative accuracy, set it to zero.
154 if ( m_A * tol * ( sminl / smax ) <= max( eps, hndrth * tol ) )
155 {
156#ifdef PRINTF
157 printf( "FLA_Bsvd_compute_shift_opd: shift would ruin accuracy; setting shift to 0.\n" );
158 printf( " m_A = %d \n", m_A );
159 printf( " tol = %20.15e\n", tol );
160 printf( " sminl = %20.15e\n", sminl );
161 printf( " smax = %20.15e\n", smax );
162 printf( " LHS = %20.15e\n", m_A * tol * ( sminl / smax ) );
163 printf( " max(eps,0.01*tol)= %20.15e\n", max( eps, hndrth * tol ) );
164#endif
165 *shift = 0.0;
166 }
167 else
168 {
169 // Compute the shift from the last 2x2 matrix.
171 e_last,
172 d_last,
173 shift,
174 &temp );
175
176 sll = fabs( *d_first );
177
178 // Check if the shift is negligible; if so, set it to zero.
179 if ( sll > 0.0 )
180 {
181 temp = ( *shift / sll );
182 if ( temp * temp < eps )
183 {
184#ifdef PRINTF
185 printf( "FLA_Bsvd_compute_shift_opd: shift is negligible; setting shift to 0.\n" );
186#endif
187 *shift = 0.0;
188 }
189 }
190 }
191
192 return FLA_SUCCESS;
193}
double FLA_Mach_params_opd(FLA_Machval machval)
Definition FLA_Mach_params.c:74
FLA_Error FLA_Sv_2x2_opd(double *alpha11, double *alpha12, double *alpha22, double *sigma1, double *sigma2)
Definition FLA_Sv_2x2.c:166
dcomplex temp
Definition bl1_axpyv2b.c:301

References FLA_Mach_params_opd(), FLA_Sv_2x2_opd(), i, and temp.

Referenced by FLA_Bsvd_compute_shift(), and FLA_Bsvd_sinval_v_opd_var1().

◆ FLA_Bsvd_compute_shift_ops()

FLA_Error FLA_Bsvd_compute_shift_ops ( int  m_A,
float  tol,
float  sminl,
float  smax,
float buff_d,
int  inc_d,
float buff_e,
int  inc_e,
float shift 
)
82{
83 float hndrth = 0.01;
84 float eps;
85 float* d_first;
86 float* e_last;
87 float* d_last_m1;
88 float* d_last;
89 float sll, temp;
90
92
93 d_first = buff_d + (0 )*inc_d;
94 e_last = buff_e + (m_A-2)*inc_e;
95 d_last_m1 = buff_d + (m_A-2)*inc_d;
96 d_last = buff_d + (m_A-1)*inc_d;
97
98 // If the shift would ruin relative accuracy, set it to zero.
99 if ( m_A * tol * ( sminl / smax ) <= max( eps, hndrth * tol ) )
100 {
101 *shift = 0.0;
102 }
103 else
104 {
105 // Compute the shift from the last 2x2 matrix.
107 e_last,
108 d_last,
109 shift,
110 &temp );
111
112 sll = fabsf( *d_first );
113
114 // Check if the shift is negligible; if so, set it to zero.
115 if ( sll > 0.0F )
116 {
117 temp = ( *shift / sll );
118 if ( temp * temp < eps )
119 {
120 *shift = 0.0F;
121 }
122 }
123 }
124
125 return FLA_SUCCESS;
126}
float FLA_Mach_params_ops(FLA_Machval machval)
Definition FLA_Mach_params.c:47
FLA_Error FLA_Sv_2x2_ops(float *alpha11, float *alpha12, float *alpha22, float *sigma1, float *sigma2)
Definition FLA_Sv_2x2.c:83

References FLA_Mach_params_ops(), FLA_Sv_2x2_ops(), i, and temp.

Referenced by FLA_Bsvd_compute_shift(), and FLA_Bsvd_sinval_v_ops_var1().