MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / div

Method div

src/org/opensourcephysics/numerics/Complex.java:286–303  ·  view source on GitHub ↗

Returns the result of dividing this complex number by the parameter.

(Complex b)

Source from the content-addressed store, hash-verified

284 * Returns the result of dividing this complex number by the parameter.
285 */
286 public Complex div(Complex b) {
287 // Adapted from Numerical Recipes in C - The Art of Scientific Computing
288 // ISBN 0-521-43108-5
289 double resRe, resIm;
290 double r, den;
291 if(Math.abs(b.re)>=Math.abs(b.im)) {
292 r = b.im/b.re;
293 den = b.re+r*b.im;
294 resRe = (re+r*im)/den;
295 resIm = (im-r*re)/den;
296 } else {
297 r = b.re/b.im;
298 den = b.im+r*b.re;
299 resRe = (re*r+im)/den;
300 resIm = (im*r-re)/den;
301 }
302 return new Complex(resRe, resIm);
303 }
304
305 /**
306

Callers 11

tanMethod · 0.95
atanMethod · 0.95
tanhMethod · 0.95
atanhMethod · 0.95
cxhessMethod · 0.95
cxeig2cMethod · 0.95
solveMethod · 0.80
invertMethod · 0.80
determinantMethod · 0.80
schur2Method · 0.80
twobytwoMethod · 0.80

Calls 1

absMethod · 0.80

Tested by

no test coverage detected