46template <
typename TA,
typename TB>
50 blas::real_type<TA, TB> *c,
51 blas::real_type<TA, TB> *s )
53 typedef real_type<TA, TB> real_t;
58 const real_t zero = 0;
61 const real_t safmin = safe_min<real_t>();
62 const real_t safmax = safe_max<real_t>();
65 const real_t anorm = abs(*a);
66 const real_t bnorm = abs(*b);
74 else if (anorm == zero) {
81 real_t scl = min( safmax, max(safmin, anorm, bnorm) );
82 real_t sigma = (anorm > bnorm)
85 real_t r = sigma * scl * sqrt( (*a/scl) * (*a/scl) + (*b/scl) * (*b/scl) );
129template <
typename TA,
typename TB>
133 blas::real_type<TA, TB> *c,
134 blas::complex_type<TA, TB> *s )
136 typedef real_type<TA, TB> real_t;
137 typedef complex_type<TA, TB> scalar_t;
140 #define BLAS_ABSSQ(t_) real(t_)*real(t_) + imag(t_)*imag(t_)
143 const real_t r_one = 1;
144 const real_t r_zero = 0;
145 const scalar_t zero = 0;
146 const std::complex<TA> zero_ta = 0;
147 const std::complex<TB> zero_tb = 0;
150 const real_t safmin = safe_min<real_t>();
151 const real_t safmax = safe_max<real_t>();
152 const real_t rtmin = root_min<real_t>();
153 const real_t rtmax = root_max<real_t>();
164 real_t g1 = max( abs(real(*b)), abs(imag(*b)) );
165 if (g1 > rtmin && g1 < rtmax) {
167 real_t g2 = BLAS_ABSSQ( *b );
168 real_t d = sqrt( g2 );
174 real_t u = min( safmax, max( safmin, g1 ) );
175 real_t uu = r_one / u;
176 scalar_t gs = (*b)*uu;
177 real_t g2 = BLAS_ABSSQ( gs );
178 real_t d = sqrt( g2 );
184 real_t f1 = max( abs(real(*a)), abs(imag(*a)) );
185 real_t g1 = max( abs(real(*b)), abs(imag(*b)) );
186 if (f1 > rtmin && f1 < rtmax
187 && g1 > rtmin && g1 < rtmax) {
189 real_t f2 = BLAS_ABSSQ( *a );
190 real_t g2 = BLAS_ABSSQ( *b );
192 real_t d = ( f2 > rtmin && h2 < rtmax )
194 : sqrt( f2 )*sqrt( h2 );
195 real_t p = r_one / d;
197 *s = conj( *b )*( (*a)*p );
202 real_t u = min( safmax, max( safmin, f1, g1 ) );
203 real_t uu = r_one / u;
204 scalar_t gs = (*b)*uu;
205 real_t g2 = BLAS_ABSSQ( gs );
210 real_t v = min( safmax, max( safmin, f1 ) );
211 real_t vv = r_one / v;
214 f2 = BLAS_ABSSQ( fs );
221 f2 = BLAS_ABSSQ( fs );
224 real_t d = ( f2 > rtmin && h2 < rtmax )
226 : sqrt( f2 )*sqrt( h2 );
227 real_t p = r_one / d;
229 *s = conj( gs )*( fs*p );
230 *a = ( fs*( h2*p ) )*u;
void rotg(TA *a, TB *b, blas::real_type< TA, TB > *c, blas::real_type< TA, TB > *s)
Construct plane rotation that eliminates b, such that:
Definition rotg.hh:47