|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# smax |
| 22 | + |
| 23 | +> Compute the maximum value of a one-dimensional single-precision floating-point ndarray. |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +</section> |
| 28 | + |
| 29 | +<!-- /.intro --> |
| 30 | + |
| 31 | +<section class="usage"> |
| 32 | + |
| 33 | +## Usage |
| 34 | + |
| 35 | +```javascript |
| 36 | +var smax = require( '@stdlib/stats/base/ndarray/smax' ); |
| 37 | +``` |
| 38 | + |
| 39 | +#### smax( arrays ) |
| 40 | + |
| 41 | +Computes the maximum value of a one-dimensional single-precision floating-point ndarray. |
| 42 | + |
| 43 | +```javascript |
| 44 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 45 | +var ndarray = require( '@stdlib/ndarray/base/ctor' ); |
| 46 | + |
| 47 | +var xbuf = new Float32Array( [ 1.0, 3.0, 4.0, 2.0 ] ); |
| 48 | +var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); |
| 49 | + |
| 50 | +var v = smax( [ x ] ); |
| 51 | +// returns 4.0 |
| 52 | +``` |
| 53 | + |
| 54 | +The function has the following parameters: |
| 55 | + |
| 56 | +- **arrays**: array-like object containing a one-dimensional input ndarray. |
| 57 | + |
| 58 | +</section> |
| 59 | + |
| 60 | +<!-- /.usage --> |
| 61 | + |
| 62 | +<section class="notes"> |
| 63 | + |
| 64 | +## Notes |
| 65 | + |
| 66 | +- If provided an empty one-dimensional ndarray, the function returns `NaN`. |
| 67 | + |
| 68 | +</section> |
| 69 | + |
| 70 | +<!-- /.notes --> |
| 71 | + |
| 72 | +<section class="examples"> |
| 73 | + |
| 74 | +## Examples |
| 75 | + |
| 76 | +<!-- eslint no-undef: "error" --> |
| 77 | + |
| 78 | +```javascript |
| 79 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 80 | +var ndarray = require( '@stdlib/ndarray/base/ctor' ); |
| 81 | +var ndarray2array = require( '@stdlib/ndarray/to-array' ); |
| 82 | +var smax = require( '@stdlib/stats/base/ndarray/smax' ); |
| 83 | + |
| 84 | +var xbuf = discreteUniform( 10, -50, 50, { |
| 85 | + 'dtype': 'float32' |
| 86 | +}); |
| 87 | +var x = new ndarray( 'float32', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); |
| 88 | +console.log( ndarray2array( x ) ); |
| 89 | + |
| 90 | +var v = smax( [ x ] ); |
| 91 | +console.log( v ); |
| 92 | +``` |
| 93 | + |
| 94 | +</section> |
| 95 | + |
| 96 | +<!-- /.examples --> |
| 97 | + |
| 98 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 99 | + |
| 100 | +<section class="related"> |
| 101 | + |
| 102 | +</section> |
| 103 | + |
| 104 | +<!-- /.related --> |
| 105 | + |
| 106 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 107 | + |
| 108 | +<section class="links"> |
| 109 | + |
| 110 | +</section> |
| 111 | + |
| 112 | +<!-- /.links --> |
0 commit comments