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

Function generaterotation

src/rotations.cpp:306–347  ·  view source on GitHub ↗

The subroutine generates the elementary rotation, so that: [ CS SN ] . [ F ] = [ R ] [ -SN CS ] [ G ] [ 0 ] CS**2 + SN**2 = 1 *************************************************************************/

Source from the content-addressed store, hash-verified

304CS**2 + SN**2 = 1
305*************************************************************************/
306void generaterotation(double f, double g, double& cs, double& sn, double& r)
307{
308 double f1;
309 double g1;
310
311 if( ap::fp_eq(g,0) )
312 {
313 cs = 1;
314 sn = 0;
315 r = f;
316 }
317 else
318 {
319 if( ap::fp_eq(f,0) )
320 {
321 cs = 0;
322 sn = 1;
323 r = g;
324 }
325 else
326 {
327 f1 = f;
328 g1 = g;
329 if( ap::fp_greater(fabs(f1),fabs(g1)) )
330 {
331 r = fabs(f1)*sqrt(1+ap::sqr(g1/f1));
332 }
333 else
334 {
335 r = fabs(g1)*sqrt(1+ap::sqr(f1/g1));
336 }
337 cs = f1/r;
338 sn = g1/r;
339 if( ap::fp_greater(fabs(f),fabs(g))&&ap::fp_less(cs,0) )
340 {
341 cs = -cs;
342 sn = -sn;
343 r = -r;
344 }
345 }
346 }
347}
348
349
350

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected