|
|
1.1 ! root 1: /* ! 2: * "@(#)c_sqrtf.c 1.1" ! 3: */ ! 4: ! 5: #include "complex" ! 6: ! 7: /* THIS IS BASED ON TAHOE FLOATING POINT REPR. */ ! 8: #include <FP.h> ! 9: ! 10: c_sqrt(r, z) ! 11: register complex *r, *z; ! 12: { ! 13: float mag, cabs(); ! 14: fortran float sqrt(); ! 15: ! 16: if( (mag = cabs(z->real, z->imag)) == 0.) ! 17: r->real = r->imag = 0.; ! 18: else if(z->real > 0) ! 19: { ! 20: r->real = sqrt(0.5 * (mag + z->real) ); ! 21: r->imag = z->imag / r->real / 2; ! 22: } ! 23: else ! 24: { ! 25: r->imag = sqrt(0.5 * (mag - z->real) ); ! 26: if(z->imag < 0) ! 27: *(unsigned long*)&(r->imag) ^= SIGN_BIT; ! 28: r->real = z->imag / r->imag /2; ! 29: } ! 30: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.