Skip to content

Commit 78f0e15

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 42664da + a187bfc commit 78f0e15

File tree

34 files changed

+714
-368
lines changed

34 files changed

+714
-368
lines changed

lib/node_modules/@stdlib/blas/base/srotm/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,33 @@ The function accepts the following arguments:
223223
void c_srotm( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float *param );
224224
```
225225

226+
#### c_srotm_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY, param )
227+
228+
Applies a modified Givens plane rotation using alternative indexing semantics.
229+
230+
```c
231+
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
232+
float y[] = { 6.0f, 7.0f, 8.0f, 9.0f, 10.0f };
233+
const float param[5] = { 0.0f, 0.0f, 2.0f, -3.0f, 0.0f };
234+
235+
c_srotm_ndarray( 5, x, 1, 0, y, 1, 0, param );
236+
```
237+
238+
The function accepts the following arguments:
239+
240+
- **N**: `[in] CBLAS_INT` number of indexed elements.
241+
- **X**: `[inout] float*` first input array.
242+
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
243+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
244+
- **Y**: `[inout] float*` second input array.
245+
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
246+
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
247+
- **param**: `[in] float` parameters for the modified Givens transformation.
248+
249+
```c
250+
void c_srotm_ndarray( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float *param );
251+
```
252+
226253
</section>
227254

228255
<!-- /.usage -->
@@ -267,6 +294,14 @@ int main( void ) {
267294
for ( int i = 0; i < 5; i++ ) {
268295
printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] );
269296
}
297+
298+
// Apply plane rotation:
299+
c_srotm_ndarray( N, x, -strideX, N-1, y, -strideY, N-1, param );
300+
301+
// Print the result:
302+
for ( int i = 0; i < 5; i++ ) {
303+
printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] );
304+
}
270305
}
271306
```
272307

lib/node_modules/@stdlib/blas/base/srotm/benchmark/c/benchmark.length.c

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static float rand_float( void ) {
9494
* @param len array length
9595
* @return elapsed time in seconds
9696
*/
97-
static double benchmark( int iterations, int len ) {
97+
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
9999
float x[ len ];
100100
float y[ len ];
@@ -122,6 +122,41 @@ static double benchmark( int iterations, int len ) {
122122
return elapsed;
123123
}
124124

125+
/**
126+
* Runs a benchmark.
127+
*
128+
* @param iterations number of iterations
129+
* @param len array length
130+
* @return elapsed time in seconds
131+
*/
132+
static double benchmark2( int iterations, int len ) {
133+
double elapsed;
134+
float x[ len ];
135+
float y[ len ];
136+
double t;
137+
int i;
138+
139+
const float param[5] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
140+
for ( i = 0; i < len; i++ ) {
141+
x[ i ] = ( rand_float()*200.0f ) - 100.0f;
142+
y[ i ] = ( rand_float()*200.0f ) - 100.0f;
143+
}
144+
145+
t = tic();
146+
for ( i = 0; i < iterations; i++ ) {
147+
c_srotm_ndarray( len, x, 1, 0, y, 1, 0, param );
148+
if ( y[ 0 ] != y[ 0 ] ) {
149+
printf( "should not return NaN\n" );
150+
break;
151+
}
152+
}
153+
elapsed = tic() - t;
154+
if ( y[ 0 ] != y[ 0 ] ) {
155+
printf( "should not return NaN\n" );
156+
}
157+
return elapsed;
158+
}
159+
125160
/**
126161
* Main execution sequence.
127162
*/
@@ -144,7 +179,14 @@ int main( void ) {
144179
for ( j = 0; j < REPEATS; j++ ) {
145180
count += 1;
146181
printf( "# c::%s:len=%d\n", NAME, len );
147-
elapsed = benchmark( iter, len );
182+
elapsed = benchmark1( iter, len );
183+
print_results( iter, elapsed );
184+
printf( "ok %d benchmark finished\n", count );
185+
}
186+
for ( j = 0; j < REPEATS; j++ ) {
187+
count += 1;
188+
printf( "# c::%s:ndarray:len=%d\n", NAME, len );
189+
elapsed = benchmark2( iter, len );
148190
print_results( iter, elapsed );
149191
printf( "ok %d benchmark finished\n", count );
150192
}

lib/node_modules/@stdlib/blas/base/srotm/examples/c/example.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ int main( void ) {
4141
for ( int i = 0; i < 5; i++ ) {
4242
printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] );
4343
}
44+
45+
// Apply plane rotation:
46+
c_srotm_ndarray( N, x, -strideX, N-1, y, -strideY, N-1, param );
47+
48+
// Print the result:
49+
for ( int i = 0; i < 5; i++ ) {
50+
printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] );
51+
}
4452
}

lib/node_modules/@stdlib/blas/base/srotm/include/stdlib/blas/base/srotm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ extern "C" {
3636
*/
3737
void API_SUFFIX(c_srotm)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float *param );
3838

39+
/**
40+
* Applies a modified Givens plane rotation using alternative indexing semantics.
41+
*/
42+
void API_SUFFIX(c_srotm_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float *param );
43+
3944
#ifdef __cplusplus
4045
}
4146
#endif

lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ var f32 = require( '@stdlib/number/float64/base/to-float32' );
3131
* @param {PositiveInteger} N - number of indexed elements
3232
* @param {Float32Array} x - first input array
3333
* @param {integer} strideX - `x` stride length
34-
* @param {NonNegativeInteger} offsetX - starting `x` index
34+
* @param {NonNegativeInteger} offsetX - starting index for `x`
3535
* @param {Float32Array} y - second input array
3636
* @param {integer} strideY - `y` stride length
37-
* @param {NonNegativeInteger} offsetY - starting `y` index
37+
* @param {NonNegativeInteger} offsetY - starting index for `y`
3838
* @param {Float32Array} param - parameters for the modified Givens transformation
3939
* @returns {Float32Array} `y`
4040
*

lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.native.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
// MODULES //
2222

23-
var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
24-
var offsetView = require( '@stdlib/strided/base/offset-view' );
25-
var addon = require( './srotm.native.js' );
23+
var addon = require( './../src/addon.node' );
2624

2725

2826
// MAIN //
@@ -33,10 +31,10 @@ var addon = require( './srotm.native.js' );
3331
* @param {PositiveInteger} N - number of indexed elements
3432
* @param {Float32Array} x - first input array
3533
* @param {integer} strideX - `x` stride length
36-
* @param {NonNegativeInteger} offsetX - starting `x` index
34+
* @param {NonNegativeInteger} offsetX - starting index for `x`
3735
* @param {Float32Array} y - second input array
3836
* @param {integer} strideY - `y` stride length
39-
* @param {NonNegativeInteger} offsetY - starting `y` index
37+
* @param {NonNegativeInteger} offsetY - starting index for `y`
4038
* @param {Float32Array} param - parameters for the modified Givens transformation
4139
* @returns {Float32Array} `y`
4240
*
@@ -52,16 +50,7 @@ var addon = require( './srotm.native.js' );
5250
* // y => <Float32Array>[ ~1.7, ~-0.9, ~0.5, ~0.7, ~-1.6, ~0.2, ~2.4 ]
5351
*/
5452
function srotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) {
55-
var viewX;
56-
var viewY;
57-
58-
offsetX = minViewBufferIndex( N, strideX, offsetX );
59-
offsetY = minViewBufferIndex( N, strideY, offsetY );
60-
61-
viewX = offsetView( x, offsetX );
62-
viewY = offsetView( y, offsetY );
63-
64-
addon( N, viewX, strideX, viewY, strideY, param );
53+
addon.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, param );
6554
return y;
6655
}
6756

lib/node_modules/@stdlib/blas/base/srotm/lib/srotm.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,8 @@ var ndarray = require( './ndarray.js' );
4949
* // y => <Float32Array>[ ~1.7, ~-0.9, ~0.5, ~0.7, ~-1.6, ~0.2, ~2.4 ]
5050
*/
5151
function srotm( N, x, strideX, y, strideY, param ) {
52-
var sflag;
53-
var ix;
54-
var iy;
55-
56-
sflag = param[ 0 ];
57-
if ( N <= 0 || sflag === -2.0 ) {
58-
return y;
59-
}
60-
ix = stride2offset( N, strideX );
61-
iy = stride2offset( N, strideY );
52+
var ix = stride2offset( N, strideX );
53+
var iy = stride2offset( N, strideY );
6254
return ndarray( N, x, strideX, ix, y, strideY, iy, param );
6355
}
6456

0 commit comments

Comments
 (0)