README.md (3118B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # minabs 22 23 > Return the minimum absolute value. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var minabs = require( '@stdlib/math/base/special/minabs' ); 41 ``` 42 43 #### minabs( \[x\[, y\[, ...args]]] ) 44 45 Returns the minimum absolute value. 46 47 ```javascript 48 var v = minabs( -4.2, 3.14 ); 49 // returns 3.14 50 51 v = minabs( +0.0, -0.0 ); 52 // returns +0.0 53 54 v = minabs( 4.2, 3.14, -1.0, 6.8 ); 55 // returns 1.0 56 ``` 57 58 If any argument is `NaN`, the function returns `NaN`. 59 60 ```javascript 61 var v = minabs( 4.2, NaN ); 62 // returns NaN 63 64 v = minabs( NaN, 3.14 ); 65 // returns NaN 66 ``` 67 68 If not provided any arguments, the function returns `+infinity`. 69 70 ```javascript 71 var v = minabs(); 72 // returns Infinity 73 ``` 74 75 </section> 76 77 <!-- /.usage --> 78 79 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 80 81 <section class="notes"> 82 83 ## Notes 84 85 - When an empty set is considered a subset of the extended reals (all real numbers, including positive and negative infinity), positive infinity is the greatest lower bound. Similar to zero being the identity element for the sum of an empty set and to one being the identity element for the product of an empty set, positive infinity is the identity element for the minimum, and thus, `minabs() = +infinity`. 86 87 </section> 88 89 <!-- /.notes --> 90 91 <!-- Package usage examples. --> 92 93 <section class="examples"> 94 95 ## Examples 96 97 <!-- eslint no-undef: "error" --> 98 99 ```javascript 100 var randu = require( '@stdlib/random/base/randu' ); 101 var minabs = require( '@stdlib/math/base/special/minabs' ); 102 103 var x; 104 var y; 105 var v; 106 var i; 107 108 for ( i = 0; i < 100; i++ ) { 109 x = ( randu()*1000.0 ) - 500.0; 110 y = ( randu()*1000.0 ) - 500.0; 111 v = minabs( x, y ); 112 console.log( 'minabs(%d,%d) = %d', x, y, v ); 113 } 114 ``` 115 116 </section> 117 118 <!-- /.examples --> 119 120 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 121 122 <section class="references"> 123 124 </section> 125 126 <!-- /.references --> 127 128 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 129 130 <section class="links"> 131 132 </section> 133 134 <!-- /.links -->