File: wsqrt.f

package info (click to toggle)
scilab 2.2-4
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 31,472 kB
  • ctags: 21,963
  • sloc: fortran: 110,983; ansic: 89,717; makefile: 3,016; sh: 1,892; csh: 150; cpp: 101
file content (14 lines) | stat: -rw-r--r-- 444 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
      subroutine wsqrt(xr,xi,yr,yi)
      double precision xr,xi,yr,yi,s,tr,ti,pythag
c     y = sqrt(x) with yr .ge. 0.0 and sign(yi) .eq. sign(xi)
c
      tr = xr
      ti = xi
      s = sqrt(0.50d+0*(pythag(tr,ti) + abs(tr)))
      if (tr .ge. 0.0d+0) yr = s
      if (ti .lt. 0.0d+0) s = -s
      if (tr .le. 0.0d+0) yi = s
      if (tr .lt. 0.0d+0) yr = 0.50d+0*(ti/yi)
      if (tr .gt. 0.0d+0) yi = 0.50d+0*(ti/yr)
      return
      end