Skip to content

Commit 4470ae0

Browse files
committed
Auto-generated commit
1 parent a88c27e commit 4470ae0

File tree

12 files changed

+192
-41
lines changed

12 files changed

+192
-41
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-07-09)
7+
## Unreleased (2024-07-10)
88

99
<section class="packages">
1010

@@ -1375,6 +1375,7 @@ This release closes the following issue:
13751375

13761376
##### Features
13771377

1378+
- [`96f2299`](https://github.com/stdlib-js/stdlib/commit/96f22991788a808caa052cb3d1e1c9618091e3d3) - add support for specifying integer size
13781379
- [`d1cbb09`](https://github.com/stdlib-js/stdlib/commit/d1cbb0973d127cf391ecce4efefd1390d6aab0e1) - add `blas/base/srot` [(#1844)](https://github.com/stdlib-js/stdlib/pull/1844)
13791380

13801381
</section>
@@ -2480,6 +2481,9 @@ A total of 35 people contributed to this release. Thank you to the following con
24802481

24812482
<details>
24822483

2484+
- [`f35cb6e`](https://github.com/stdlib-js/stdlib/commit/f35cb6eb2dddc6fdcc904ef165b92970f4a50698) - **docs:** fix description _(by Athan Reines)_
2485+
- [`96f2299`](https://github.com/stdlib-js/stdlib/commit/96f22991788a808caa052cb3d1e1c9618091e3d3) - **feat:** add support for specifying integer size _(by Athan Reines)_
2486+
- [`d9dfc21`](https://github.com/stdlib-js/stdlib/commit/d9dfc219d84a0418eae579a882ba4fc9b841aecd) - **refactor:** use common implementation and document C API _(by Athan Reines)_
24832487
- [`85ffc1a`](https://github.com/stdlib-js/stdlib/commit/85ffc1a73bdcabdfc4c2a550e398a285eae49ebb) - **feat:** add `blas/base/zaxpy` [(#2468)](https://github.com/stdlib-js/stdlib/pull/2468) _(by Aman Bhansali, Athan Reines)_
24842488
- [`08eaa1b`](https://github.com/stdlib-js/stdlib/commit/08eaa1b176d0e510b0af53d7b7a02d5c63090e1f) - **feat:** add `blas/base/dznrm2` [(#2271)](https://github.com/stdlib-js/stdlib/pull/2271) _(by Aman Bhansali, Athan Reines)_
24852489
- [`72a5a6c`](https://github.com/stdlib-js/stdlib/commit/72a5a6cd80794d51bbb0489c0eab5b8bf4839c27) - **style:** use consistent spacing _(by Athan Reines)_

base/drot/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ The function accepts the following arguments:
221221
- **N**: `[in] CBLAS_INT` number of indexed elements.
222222
- **X**: `[inout] double*` first input array.
223223
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
224-
- **Y**: `[inout] double*` first input array.
224+
- **Y**: `[inout] double*` second input array.
225225
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
226226
- **c**: `[in] double` cosine of the angle of rotation.
227227
- **s**: `[in] double` sine of the angle of rotation.

base/srot/README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,113 @@ console.log( y );
179179

180180
<!-- /.examples -->
181181

182+
<!-- C interface documentation. -->
183+
184+
* * *
185+
186+
<section class="c">
187+
188+
## C APIs
189+
190+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
191+
192+
<section class="intro">
193+
194+
</section>
195+
196+
<!-- /.intro -->
197+
198+
<!-- C usage documentation. -->
199+
200+
<section class="usage">
201+
202+
### Usage
203+
204+
```c
205+
#include "stdlib/blas/base/srot.h"
206+
```
207+
208+
#### c_srot( N, \*X, strideX, \*Y, strideY, c, s )
209+
210+
Applies a plane rotation.
211+
212+
```c
213+
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
214+
float y[] = { 6.0f, 7.0f, 8.0f, 9.0f, 10.0f };
215+
216+
c_drot( 5, x, 1, y, 1, 0.8f, 0.6f );
217+
```
218+
219+
The function accepts the following arguments:
220+
221+
- **N**: `[in] CBLAS_INT` number of indexed elements.
222+
- **X**: `[inout] float*` first input array.
223+
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
224+
- **Y**: `[inout] float*` second input array.
225+
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
226+
- **c**: `[in] float` cosine of the angle of rotation.
227+
- **s**: `[in] float` sine of the angle of rotation.
228+
229+
```c
230+
void c_drot( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s );
231+
```
232+
233+
</section>
234+
235+
<!-- /.usage -->
236+
237+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
238+
239+
<section class="notes">
240+
241+
</section>
242+
243+
<!-- /.notes -->
244+
245+
<!-- C API usage examples. -->
246+
247+
<section class="examples">
248+
249+
### Examples
250+
251+
```c
252+
#include "stdlib/blas/base/drot.h"
253+
#include <stdio.h>
254+
255+
int main( void ) {
256+
// Create strided arrays:
257+
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
258+
float y[] = { 6.0f, 7.0f, 8.0f, 9.0f, 10.0f };
259+
260+
// Specify the number of elements:
261+
const int N = 5;
262+
263+
// Specify stride lengths:
264+
const int strideX = 1;
265+
const int strideY = 1;
266+
267+
// Specify angle of rotation:
268+
const float c = 0.8f;
269+
const float s = 0.6f;
270+
271+
// Apply plane rotation:
272+
c_drot( N, x, strideX, y, strideY, c, s );
273+
274+
// Print the result:
275+
for ( int i = 0; i < 5; i++ ) {
276+
printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] );
277+
}
278+
}
279+
```
280+
281+
</section>
282+
283+
<!-- /.examples -->
284+
285+
</section>
286+
287+
<!-- /.c -->
288+
182289
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
183290
184291
<section class="related">

base/srot/include/stdlib/blas/base/srot.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef SROT_H
2323
#define SROT_H
2424

25+
#include "stdlib/blas/base/shared.h"
26+
2527
/*
2628
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
2729
*/
@@ -32,7 +34,7 @@ extern "C" {
3234
/**
3335
* Applies a plane rotation.
3436
*/
35-
void c_srot( const int N, float *X, const int strideX, float *Y, const int strideY, const float c, const float s );
37+
void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s );
3638

3739
#ifdef __cplusplus
3840
}

base/srot/include/stdlib/blas/base/srot_cblas.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef SROT_CBLAS_H
2323
#define SROT_CBLAS_H
2424

25+
#include "stdlib/blas/base/shared.h"
26+
2527
/*
2628
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
2729
*/
@@ -32,7 +34,7 @@ extern "C" {
3234
/**
3335
* Applies a plane rotation.
3436
*/
35-
void cblas_srot( const int N, float *X, const int strideX, float *Y, const int strideY, const float c, const float s );
37+
void API_SUFFIX(cblas_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s );
3638

3739
#ifdef __cplusplus
3840
}

base/srot/lib/ndarray.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
'use strict';
2020

21+
// MODULES //
22+
23+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
24+
25+
2126
// MAIN //
2227

2328
/**
@@ -53,12 +58,13 @@ function srot( N, x, strideX, offsetX, y, strideY, offsetY, c, s ) {
5358
if ( N <= 0 ) {
5459
return y;
5560
}
61+
c = f32( c );
62+
s = f32( s );
5663
ix = offsetX;
5764
iy = offsetY;
58-
5965
for ( i = 0; i < N; i++ ) {
60-
tmp = ( c * x[ ix ] ) + ( s * y[ iy ] );
61-
y[ iy ] = ( c * y[ iy ] ) - ( s * x[ ix ] );
66+
tmp = f32( c * x[ ix ] ) + f32( s * y[ iy ] );
67+
y[ iy ] = f32( c * y[ iy ] ) - f32( s * x[ ix ] );
6268
x[ ix ] = tmp;
6369
ix += strideX;
6470
iy += strideY;

base/srot/lib/srot.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,16 @@ var ndarray = require( './ndarray.js' );
4141
* @example
4242
* var Float32Array = require( '@stdlib/array/float32' );
4343
*
44-
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
45-
* var y = new Float32Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
44+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
45+
* var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
4646
*
47-
* srot( 3, x, 2, y, 2, 0.8, 0.6 );
48-
* // x => <Float32Array>[ 5.0, 2.0, ~7.8, 4.0, ~10.6, 6.0 ]
49-
* // y => <Float32Array>[ 5.0, 8.0, ~5.4, 10.0, ~5.8, 12.0 ]
47+
* srot( x.length, x, 1, y, 1, 0.8, 0.6 );
48+
* // x => <Float32Array>[ ~4.4, ~5.8, ~7.2, ~8.6, 10.0 ]
49+
* // y => <Float32Array>[ ~4.2, 4.4, 4.6, 4.8, 5.0 ]
5050
*/
5151
function srot( N, x, strideX, y, strideY, c, s ) {
52-
var ix;
53-
var iy;
54-
55-
if ( N <= 0 ) {
56-
return y;
57-
}
58-
ix = stride2offset( N, strideX );
59-
iy = stride2offset( N, strideY );
52+
var ix = stride2offset( N, strideX );
53+
var iy = stride2offset( N, strideY );
6054
return ndarray( N, x, strideX, ix, y, strideY, iy, c, s );
6155
}
6256

0 commit comments

Comments
 (0)