| 162 | /* if y >= 1, and continuous from the left if y <= -1. */ |
| 163 | |
| 164 | inline Rcomplex complex__atan(Rcomplex z) |
| 165 | { |
| 166 | Rcomplex r; |
| 167 | double x, y; |
| 168 | x = z.r; |
| 169 | y = z.i; |
| 170 | r.r = 0.5 * ::atan(2 * x / ( 1 - x * x - y * y)); |
| 171 | r.i = 0.25 * ::log((x * x + (y + 1) * (y + 1)) / |
| 172 | (x * x + (y - 1) * (y - 1))); |
| 173 | if(x*x + y*y > 1) { |
| 174 | r.r += M_PI_2; |
| 175 | if(x < 0 || (x == 0 && y < 0)) r.r -= M_PI; |
| 176 | } |
| 177 | return r ; |
| 178 | } |
| 179 | |
| 180 | |
| 181 | inline Rcomplex complex__acosh(Rcomplex z){ |