MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / svd2x2

Function svd2x2

src/bdsvd.cpp:1042–1111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1040
1041
1042static void svd2x2(double f,
1043 double g,
1044 double h,
1045 double& ssmin,
1046 double& ssmax)
1047{
1048 double aas;
1049 double at;
1050 double au;
1051 double c;
1052 double fa;
1053 double fhmn;
1054 double fhmx;
1055 double ga;
1056 double ha;
1057
1058 fa = fabs(f);
1059 ga = fabs(g);
1060 ha = fabs(h);
1061 fhmn = ap::minreal(fa, ha);
1062 fhmx = ap::maxreal(fa, ha);
1063 if( ap::fp_eq(fhmn,0) )
1064 {
1065 ssmin = 0;
1066 if( ap::fp_eq(fhmx,0) )
1067 {
1068 ssmax = ga;
1069 }
1070 else
1071 {
1072 ssmax = ap::maxreal(fhmx, ga)*sqrt(1+ap::sqr(ap::minreal(fhmx, ga)/ap::maxreal(fhmx, ga)));
1073 }
1074 }
1075 else
1076 {
1077 if( ap::fp_less(ga,fhmx) )
1078 {
1079 aas = 1+fhmn/fhmx;
1080 at = (fhmx-fhmn)/fhmx;
1081 au = ap::sqr(ga/fhmx);
1082 c = 2/(sqrt(aas*aas+au)+sqrt(at*at+au));
1083 ssmin = fhmn*c;
1084 ssmax = fhmx/c;
1085 }
1086 else
1087 {
1088 au = fhmx/ga;
1089 if( ap::fp_eq(au,0) )
1090 {
1091
1092 //
1093 // Avoid possible harmful underflow if exponent range
1094 // asymmetric (true SSMIN may not underflow even if
1095 // AU underflows)
1096 //
1097 ssmin = fhmn*fhmx/ga;
1098 ssmax = ga;
1099 }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected