dladiv.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* dladiv.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Subroutine */ int _starpu_dladiv_(doublereal *a, doublereal *b, doublereal *c__,
  14. doublereal *d__, doublereal *p, doublereal *q)
  15. {
  16. doublereal e, f;
  17. /* -- LAPACK auxiliary routine (version 3.2) -- */
  18. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  19. /* November 2006 */
  20. /* .. Scalar Arguments .. */
  21. /* .. */
  22. /* Purpose */
  23. /* ======= */
  24. /* DLADIV performs complex division in real arithmetic */
  25. /* a + i*b */
  26. /* p + i*q = --------- */
  27. /* c + i*d */
  28. /* The algorithm is due to Robert L. Smith and can be found */
  29. /* in D. Knuth, The art of Computer Programming, Vol.2, p.195 */
  30. /* Arguments */
  31. /* ========= */
  32. /* A (input) DOUBLE PRECISION */
  33. /* B (input) DOUBLE PRECISION */
  34. /* C (input) DOUBLE PRECISION */
  35. /* D (input) DOUBLE PRECISION */
  36. /* The scalars a, b, c, and d in the above expression. */
  37. /* P (output) DOUBLE PRECISION */
  38. /* Q (output) DOUBLE PRECISION */
  39. /* The scalars p and q in the above expression. */
  40. /* ===================================================================== */
  41. /* .. Local Scalars .. */
  42. /* .. */
  43. /* .. Intrinsic Functions .. */
  44. /* .. */
  45. /* .. Executable Statements .. */
  46. if (abs(*d__) < abs(*c__)) {
  47. e = *d__ / *c__;
  48. f = *c__ + *d__ * e;
  49. *p = (*a + *b * e) / f;
  50. *q = (*b - *a * e) / f;
  51. } else {
  52. e = *c__ / *d__;
  53. f = *d__ + *c__ * e;
  54. *p = (*b + *a * e) / f;
  55. *q = (-(*a) + *b * e) / f;
  56. }
  57. return 0;
  58. /* End of DLADIV */
  59. } /* _starpu_dladiv_ */