time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

main.js (2452B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2020 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 iterMap2 = require( './../../../../iter/tools/map2' );
     24 var atan2 = require( './../../../../base/special/atan2' );
     25 
     26 
     27 // MAIN //
     28 
     29 /**
     30 * Returns an iterator which iteratively computes the angle in the plane (in radians) between the positive x-axis and the ray from `(0,0)` to the point `(x,y)`.
     31 *
     32 * ## Notes
     33 *
     34 * -   If provided a numeric value as an iterator argument, the value is broadcast as an **infinite** iterator which **always** returns the provided value.
     35 * -   If an iterated value is non-numeric (including `NaN`), the returned iterator returns `NaN`. If non-numeric iterated values are possible, you are advised to provide an iterator which type checks and handles non-numeric values accordingly.
     36 * -   The length of the returned iterator is equal to the length of the shortest provided iterator. In other words, the returned iterator ends once **one** of the provided iterators ends.
     37 * -   If an environment supports `Symbol.iterator` and all provided iterators are iterable, the returned iterator is iterable.
     38 *
     39 * @param {(Iterator|number)} y - input iterator
     40 * @param {(Iterator|number)} x - input iterator
     41 * @throws {TypeError} first argument must be either an iterator protocol-compliant object or a number
     42 * @throws {TypeError} second argument must be either an iterator protocol-compliant object or a number
     43 * @returns {Iterator} iterator
     44 *
     45 * @example
     46 * var uniform = require( '@stdlib/random/iter/uniform' );
     47 *
     48 * var x = uniform( -2.0, 2.0 );
     49 * var y = uniform( -2.0, 2.0 );
     50 *
     51 * var iter = iterAtan2( y, x );
     52 *
     53 * var r = iter.next().value;
     54 * // returns <number>
     55 *
     56 * r = iter.next().value;
     57 * // returns <number>
     58 *
     59 * r = iter.next().value;
     60 * // returns <number>
     61 *
     62 * // ...
     63 */
     64 function iterAtan2( y, x ) {
     65 	return iterMap2( y, x, atan2 );
     66 }
     67 
     68 
     69 // EXPORTS //
     70 
     71 module.exports = iterAtan2;