15 double b_xnrm2(
int n,
const double x[4],
int ix0 )
28 y = std::abs( x[ix0 - 1] );
32 scale = 3.3121686421112381E-170;
34 for( k = ix0; k <= kend; k++ )
36 absxk = std::abs( x[k - 1] );
50 y = scale * std::sqrt( y );
57 double xnrm2(
int n,
const double x[12],
int ix0 )
70 y = std::abs( x[ix0 - 1] );
74 scale = 3.3121686421112381E-170;
76 for( k = ix0; k <= kend; k++ )
78 absxk = std::abs( x[k - 1] );
92 y = scale * std::sqrt( y );
99 void b_xaxpy(
int n,
double a,
const double x[12],
int ix0,
double y[3],
int iy0 )
105 if( (n < 1) || (a == 0.0) )
113 for( k = 0; k <=
i1; k++ )
122 void c_xaxpy(
int n,
double a,
const double x[3],
int ix0,
double y[12],
int iy0 )
128 if( (n < 1) || (a == 0.0) )
136 for( k = 0; k <=
i2; k++ )
145 void xaxpy(
int n,
double a,
int ix0,
double y[12],
int iy0 )
151 if( (n < 1) || (a == 0.0) )
159 for( k = 0; k <= i0; k++ )
168 double xdotc(
int n,
const double x[12],
int ix0,
const double y[12],
int iy0 )
179 for( k = 0; k <
n; k++ )
181 d += x[ix - 1] * y[iy - 1];
190 void xrotg(
double * a,
double *
b,
double *
c,
double *
s )
199 absa = std::abs( *a );
200 absb = std::abs( *b );
218 scale *= std::sqrt( ads * ads + bds * bds );
245 inline bool rtIsNaN(
double value ) {
return (value != value); }
255 bool apply_transform;
271 memcpy( &b_A[0], &A[0], 12U *
sizeof(
double ) );
279 apply_transform =
false;
280 double nrm = xnrm2( 3, b_A, 1 );
283 apply_transform =
true;
289 if( std::abs( nrm ) >= 1.0020841800044864E-292 )
292 for( k = 1; k < 4; k++ )
299 for( k = 1; k < 4; k++ )
313 for( k = 2; k < 5; k++ )
316 if( apply_transform )
318 xaxpy( 3, -( xdotc( 3, b_A, 1, b_A, qjj + 1 ) / b_A[0] ), 1, b_A, qjj + 1 );
324 nrm = b_xnrm2( 3, e, 2 );
341 if( std::abs( e[0] ) >= 1.0020841800044864E-292 )
344 for( k = 2; k < 5; k++ )
351 for( k = 2; k < 5; k++ )
359 for( qjj = 2; qjj < 4; qjj++ )
364 for( k = 2; k < 5; k++ )
366 b_xaxpy( 2, e[k - 1], b_A, 3 * ( k - 1 ) + 2, work, 2 );
369 for( k = 2; k < 5; k++ )
371 c_xaxpy( 2, -e[k - 1] / e[1], work, 2, b_A, 3 * ( k - 1 ) + 2 );
375 apply_transform =
false;
376 nrm = xnrm2( 2, b_A, 5 );
379 apply_transform =
true;
385 if( std::abs( nrm ) >= 1.0020841800044864E-292 )
388 for( k = 5; k < 7; k++ )
395 for( k = 5; k < 7; k++ )
409 for( k = 3; k < 5; k++ )
411 qjj = 1 + 3 * ( k - 1 );
412 if( apply_transform )
414 xaxpy( 2, -( xdotc( 2, b_A, 5, b_A, qjj + 1 ) / b_A[4] ), 5, b_A, qjj + 1 );
420 nrm = b_xnrm2( 2, e, 3 );
437 if( std::abs( e[1] ) >= 1.0020841800044864E-292 )
440 for( k = 3; k < 5; k++ )
447 for( k = 3; k < 5; k++ )
455 for( qjj = 3; qjj < 4; qjj++ )
460 for( k = 3; k < 5; k++ )
462 b_xaxpy( 1, e[k - 1], b_A, 3 * ( k - 1 ) + 3, work, 3 );
465 for( k = 3; k < 5; k++ )
467 c_xaxpy( 1, -e[k - 1] / e[2], work, 3, b_A, 3 * ( k - 1 ) + 3 );
481 nrm = std::abs( s[0] );
489 b = std::abs( e[0] );
495 nrm = std::abs( nrm );
496 r = std::abs( e[0] );
497 if( ( nrm > r ) ||
rtIsNaN( r ) )
510 nrm = std::abs( s[1] );
518 b = std::abs( e[1] );
524 nrm = std::abs( nrm );
525 r = std::abs( e[1] );
526 if( ( nrm > r ) ||
rtIsNaN( r ) )
531 if( ( ! ( snorm > r ) ) && ( !
rtIsNaN( r ) ) )
539 nrm = std::abs( s[2] );
547 b = std::abs( e[2] );
553 nrm = std::abs( nrm );
554 r = std::abs( e[2] );
555 if( ( nrm > r ) ||
rtIsNaN( r ) )
560 if( ( ! ( snorm > r ) ) && ( !
rtIsNaN( r ) ) )
567 s[3] = std::numeric_limits< double >::quiet_NaN();
570 if( ! ( snorm > 0.0 ) )
575 while( ( m + 2 > 0 ) && ( iter < 75 ) )
588 nrm = std::abs( e[qjj] );
590 <= 2.2204460492503131E-16 * ( std::abs( s[qjj] ) + std::abs( s[qjj + 1] ) ) )
591 || ( nrm <= 1.0020841800044864E-292 )
592 || ( ( iter > 20 ) && ( nrm <= 2.2204460492503131E-16 * snorm ) ) )
602 }
while( exitg1 == 0 );
604 if( qjj + 1 == m + 1 )
613 while( ( ! exitg2 ) && ( k >= qjj + 1 ) )
625 nrm = std::abs( e[k - 1] );
630 nrm += std::abs( e[k - 2] );
633 r = std::abs( s[k - 1] );
634 if( ( r <= 2.2204460492503131E-16 * nrm ) || ( r <= 1.0020841800044864E-292 ) )
650 else if( qs == m + 2 )
667 for( k = qjj; k >= q + 1; k-- )
669 xrotg( &s[k - 1], &r, &sm, &sqds );
672 r = -sqds * e[k - 2];
681 for( k = q + 1; k <= m + 2; k++ )
683 xrotg( &s[k - 1], &r, &sm, &sqds );
692 scale = std::abs( s[m + 1] );
693 r = std::abs( s[m] );
694 if( ( ! ( scale > r ) ) && ( !
rtIsNaN( r ) ) )
699 r = std::abs( e[m] );
700 if( ( ! ( scale > r ) ) && ( !
rtIsNaN( r ) ) )
705 r = std::abs( s[q] );
706 if( ( ! ( scale > r ) ) && ( !
rtIsNaN( r ) ) )
711 r = std::abs( e[q] );
712 if( ( ! ( scale > r ) ) && ( !
rtIsNaN( r ) ) )
717 sm = s[m + 1] /
scale;
721 b = ( ( nrm + sm ) * ( nrm - sm ) + r *
r ) / 2.0;
724 if( ( b != 0.0 ) || ( nrm != 0.0 ) )
726 r = std::sqrt( b * b + nrm );
739 r += ( sqds + sm ) * ( sqds - sm );
740 nrm = sqds * ( e[
q] /
scale );
741 for( k = q + 1; k <= qjj; k++ )
743 xrotg( &r, &nrm, &sm, &sqds );
751 e[k - 1] = sm * b - sqds * nrm;
754 s[k - 1] = sm * nrm + sqds *
b;
755 xrotg( &s[k - 1], &r, &sm, &sqds );
757 r = sm * b + sqds * s[k];
758 s[k] = -sqds * b + sm * s[k];
774 while( ( q + 1 < 4 ) && ( s[q] < s[qjj] ) )
GLboolean GLboolean GLboolean b
GLenum GLenum GLenum GLenum GLenum scale
static bool rtIsNaN(double value)
GLboolean GLboolean GLboolean GLboolean a
GLdouble GLdouble GLdouble q
void svd_3x4(const double in[12], double out[3])