robust_internal.js (1400B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 // MODULES // 22 23 var internalCompreal = require( './internal_compreal.js' ); 24 25 26 // MAIN // 27 28 /** 29 * Computes the complex division. 30 * 31 * ## Notes 32 * 33 * - See figure 10 of [reference][@baudin:2012]. 34 * 35 * [@baudin:2012]: https://arxiv.org/abs/1210.4539 36 * 37 * @private 38 * @param {(Array|TypedArray|Object)} out - output array 39 * @param {number} re1 - real component 40 * @param {number} im1 - imaginary component 41 * @param {number} re2 - real component 42 * @param {number} im2 - imaginary component 43 */ 44 function robustInternal( out, re1, im1, re2, im2 ) { 45 var r; 46 var t; 47 48 r = im2 / re2; 49 t = 1.0 / ( re2 + (im2*r) ); 50 51 out[ 0 ] = internalCompreal( re1, im1, re2, im2, r, t ); 52 out[ 1 ] = internalCompreal( im1, -re1, re2, im2, r, t ); 53 } 54 55 56 // EXPORTS // 57 58 module.exports = robustInternal;