You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the maximum value of every other element in `x`,
58
+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the maximum value of every other element in `x`,
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
82
78
83
-
varN=floor( x0.length/2 );
84
-
85
-
var v =dmax( N, x1, 2 );
79
+
var v =dmax( 4, x1, 2 );
86
80
// returns 4.0
87
81
```
88
82
89
-
#### dmax.ndarray( N, x, stride, offset )
83
+
#### dmax.ndarray( N, x, strideX, offsetX )
90
84
91
85
Computes the maximum value of a double-precision floating-point strided array using alternative indexing semantics.
92
86
@@ -102,18 +96,16 @@ var v = dmax.ndarray( N, x, 1, 0 );
102
96
103
97
The function has the following additional parameters:
104
98
105
-
-**offset**: starting index for `x`.
99
+
-**offsetX**: starting index for `x`.
106
100
107
-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the maximum value for every other value in `x` starting from the second value
101
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the maximum value for every other value in `x` starting from the second value
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
144
134
var dmax =require( '@stdlib/stats/base/dmax' );
145
135
146
-
var x;
147
-
var i;
148
-
149
-
x =newFloat64Array( 10 );
150
-
for ( i =0; i <x.length; i++ ) {
151
-
x[ i ] =round( (randu()*100.0) -50.0 );
152
-
}
136
+
var x =discreteUniform( 10, -50, 50, {
137
+
'dtype':'float64'
138
+
});
153
139
console.log( x );
154
140
155
141
var v =dmax( x.length, x, 1 );
@@ -160,6 +146,123 @@ console.log( v );
160
146
161
147
<!-- /.examples -->
162
148
149
+
<!-- C interface documentation. -->
150
+
151
+
* * *
152
+
153
+
<sectionclass="c">
154
+
155
+
## C APIs
156
+
157
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
158
+
159
+
<sectionclass="intro">
160
+
161
+
</section>
162
+
163
+
<!-- /.intro -->
164
+
165
+
<!-- C usage documentation. -->
166
+
167
+
<sectionclass="usage">
168
+
169
+
### Usage
170
+
171
+
```c
172
+
#include"stdlib/stats/base/dmax.h"
173
+
```
174
+
175
+
#### stdlib_strided_dmax( N, \*X, strideX )
176
+
177
+
Computes the maximum value of a double-precision floating-point strided array.
178
+
179
+
```c
180
+
constdouble x[] = { 1.0, -2.0, 3.0, -4.0 };
181
+
182
+
double v = stdlib_strided_dmax( 4, x, 1 );
183
+
// returns 3.0
184
+
```
185
+
186
+
The function accepts the following arguments:
187
+
188
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
189
+
- **X**: `[in] double*` input array.
190
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
0 commit comments