Skip to content

Commit 34a206e

Browse files
committed
feat: add support for specifying integer size
1 parent 0d7489e commit 34a206e

File tree

7 files changed

+175
-23
lines changed

7 files changed

+175
-23
lines changed

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

+95
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,101 @@ console.log( out );
160160

161161
<!-- /.examples -->
162162

163+
<!-- C interface documentation. -->
164+
165+
* * *
166+
167+
<section class="c">
168+
169+
## C APIs
170+
171+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
172+
173+
<section class="intro">
174+
175+
</section>
176+
177+
<!-- /.intro -->
178+
179+
<!-- C usage documentation. -->
180+
181+
<section class="usage">
182+
183+
### Usage
184+
185+
```c
186+
#include "stdlib/blas/base/dnrm2.h"
187+
```
188+
189+
#### c_dnrm2( N, X, stride )
190+
191+
Computes the L2-norm of a double-precision floating-point vector.
192+
193+
```c
194+
const double x[] = { 1.0, -2.0, 2.0 };
195+
196+
double v = c_dnrm2( 3, x, 1 );
197+
// returns 3.0
198+
```
199+
200+
The function accepts the following arguments:
201+
202+
- **N**: `[in] CBLAS_INT` number of indexed elements.
203+
- **X**: `[in] double*` input array.
204+
- **stride**: `[in] CBLAS_INT` index increment for `X`.
205+
206+
```c
207+
double c_dnrm2( const CBLAS_INT N, const double *X, const CBLAS_INT stride );
208+
```
209+
210+
</section>
211+
212+
<!-- /.usage -->
213+
214+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
215+
216+
<section class="notes">
217+
218+
</section>
219+
220+
<!-- /.notes -->
221+
222+
<!-- C API usage examples. -->
223+
224+
<section class="examples">
225+
226+
### Examples
227+
228+
```c
229+
#include "stdlib/blas/base/dnrm2.h"
230+
#include <stdio.h>
231+
232+
int main( void ) {
233+
// Create a strided array:
234+
const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 };
235+
236+
// Specify the number of elements:
237+
const int N = 8;
238+
239+
// Specify a stride:
240+
const int strideX = 1;
241+
242+
// Compute the L2-norm:
243+
double l2 = c_dnrm2( N, x, strideX );
244+
245+
// Print the result:
246+
printf( "L2-norm: %lf\n", l2 );
247+
}
248+
```
249+
250+
</section>
251+
252+
<!-- /.examples -->
253+
254+
</section>
255+
256+
<!-- /.c -->
257+
163258
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
164259
165260
<section class="related">

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef DNRM2_H
2323
#define DNRM2_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
* Computes the L2-norm of a double-precision floating-point vector.
3436
*/
35-
double c_dnrm2( const int N, const double *X, const int stride );
37+
double c_dnrm2( const CBLAS_INT N, const double *X, const CBLAS_INT stride );
3638

3739
#ifdef __cplusplus
3840
}

lib/node_modules/@stdlib/blas/base/dnrm2/include/stdlib/blas/base/dnrm2_cblas.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef DNRM2_CBLAS_H
2323
#define DNRM2_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
* Computes the L2-norm of a double-precision floating-point vector.
3436
*/
35-
double cblas_dnrm2( const int N, const double *X, const int stride );
37+
double cblas_dnrm2( const CBLAS_INT N, const double *X, const CBLAS_INT stride );
3638

3739
#ifdef __cplusplus
3840
}

lib/node_modules/@stdlib/blas/base/dnrm2/manifest.json

+62-14
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"libraries": [],
4545
"libpath": [],
4646
"dependencies": [
47+
"@stdlib/blas/base/shared",
4748
"@stdlib/napi/export",
4849
"@stdlib/napi/argv",
4950
"@stdlib/napi/argv-int64",
@@ -66,7 +67,11 @@
6667
"-lm"
6768
],
6869
"libpath": [],
69-
"dependencies": []
70+
"dependencies": [
71+
"@stdlib/blas/base/shared",
72+
"@stdlib/math/base/special/abs",
73+
"@stdlib/math/base/special/sqrt"
74+
]
7075
},
7176
{
7277
"task": "examples",
@@ -83,7 +88,11 @@
8388
"-lm"
8489
],
8590
"libpath": [],
86-
"dependencies": []
91+
"dependencies": [
92+
"@stdlib/blas/base/shared",
93+
"@stdlib/math/base/special/abs",
94+
"@stdlib/math/base/special/sqrt"
95+
]
8796
},
8897

8998
{
@@ -103,6 +112,7 @@
103112
],
104113
"libpath": [],
105114
"dependencies": [
115+
"@stdlib/blas/base/shared",
106116
"@stdlib/napi/export",
107117
"@stdlib/napi/argv",
108118
"@stdlib/napi/argv-int64",
@@ -126,7 +136,9 @@
126136
"-lpthread"
127137
],
128138
"libpath": [],
129-
"dependencies": []
139+
"dependencies": [
140+
"@stdlib/blas/base/shared"
141+
]
130142
},
131143
{
132144
"task": "examples",
@@ -144,7 +156,9 @@
144156
"-lpthread"
145157
],
146158
"libpath": [],
147-
"dependencies": []
159+
"dependencies": [
160+
"@stdlib/blas/base/shared"
161+
]
148162
},
149163

150164
{
@@ -163,6 +177,7 @@
163177
"libraries": [],
164178
"libpath": [],
165179
"dependencies": [
180+
"@stdlib/blas/base/shared",
166181
"@stdlib/napi/export",
167182
"@stdlib/napi/argv",
168183
"@stdlib/napi/argv-int64",
@@ -185,7 +200,11 @@
185200
"-lm"
186201
],
187202
"libpath": [],
188-
"dependencies": []
203+
"dependencies": [
204+
"@stdlib/blas/base/shared",
205+
"@stdlib/math/base/special/abs",
206+
"@stdlib/math/base/special/sqrt"
207+
]
189208
},
190209
{
191210
"task": "examples",
@@ -202,7 +221,11 @@
202221
"-lm"
203222
],
204223
"libpath": [],
205-
"dependencies": []
224+
"dependencies": [
225+
"@stdlib/blas/base/shared",
226+
"@stdlib/math/base/special/abs",
227+
"@stdlib/math/base/special/sqrt"
228+
]
206229
},
207230

208231
{
@@ -221,6 +244,7 @@
221244
],
222245
"libpath": [],
223246
"dependencies": [
247+
"@stdlib/blas/base/shared",
224248
"@stdlib/napi/export",
225249
"@stdlib/napi/argv",
226250
"@stdlib/napi/argv-int64",
@@ -243,7 +267,9 @@
243267
"-lblas"
244268
],
245269
"libpath": [],
246-
"dependencies": []
270+
"dependencies": [
271+
"@stdlib/blas/base/shared"
272+
]
247273
},
248274
{
249275
"task": "examples",
@@ -260,7 +286,9 @@
260286
"-lblas"
261287
],
262288
"libpath": [],
263-
"dependencies": []
289+
"dependencies": [
290+
"@stdlib/blas/base/shared"
291+
]
264292
},
265293

266294
{
@@ -280,6 +308,7 @@
280308
],
281309
"libpath": [],
282310
"dependencies": [
311+
"@stdlib/blas/base/shared",
283312
"@stdlib/napi/export",
284313
"@stdlib/napi/argv",
285314
"@stdlib/napi/argv-int64",
@@ -303,7 +332,9 @@
303332
"-lpthread"
304333
],
305334
"libpath": [],
306-
"dependencies": []
335+
"dependencies": [
336+
"@stdlib/blas/base/shared"
337+
]
307338
},
308339
{
309340
"task": "examples",
@@ -321,7 +352,9 @@
321352
"-lpthread"
322353
],
323354
"libpath": [],
324-
"dependencies": []
355+
"dependencies": [
356+
"@stdlib/blas/base/shared"
357+
]
325358
},
326359

327360
{
@@ -340,11 +373,14 @@
340373
],
341374
"libpath": [],
342375
"dependencies": [
376+
"@stdlib/blas/base/shared",
343377
"@stdlib/napi/export",
344378
"@stdlib/napi/argv",
345379
"@stdlib/napi/argv-int64",
346380
"@stdlib/napi/argv-strided-float64array",
347-
"@stdlib/napi/create-double"
381+
"@stdlib/napi/create-double",
382+
"@stdlib/math/base/special/abs",
383+
"@stdlib/math/base/special/sqrt"
348384
]
349385
},
350386
{
@@ -362,7 +398,11 @@
362398
"-lm"
363399
],
364400
"libpath": [],
365-
"dependencies": []
401+
"dependencies": [
402+
"@stdlib/blas/base/shared",
403+
"@stdlib/math/base/special/abs",
404+
"@stdlib/math/base/special/sqrt"
405+
]
366406
},
367407
{
368408
"task": "examples",
@@ -379,7 +419,11 @@
379419
"-lm"
380420
],
381421
"libpath": [],
382-
"dependencies": []
422+
"dependencies": [
423+
"@stdlib/blas/base/shared",
424+
"@stdlib/math/base/special/abs",
425+
"@stdlib/math/base/special/sqrt"
426+
]
383427
},
384428

385429
{
@@ -397,7 +441,11 @@
397441
"-lm"
398442
],
399443
"libpath": [],
400-
"dependencies": []
444+
"dependencies": [
445+
"@stdlib/blas/base/shared",
446+
"@stdlib/math/base/special/abs",
447+
"@stdlib/math/base/special/sqrt"
448+
]
401449
}
402450
]
403451
}

lib/node_modules/@stdlib/blas/base/dnrm2/src/dnrm2.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
*/
1818

1919
#include "stdlib/blas/base/dnrm2.h"
20+
#include "stdlib/blas/base/shared.h"
21+
#include "stdlib/math/base/special/abs.h"
22+
#include "stdlib/math/base/special/sqrt.h"
2023
#include <math.h>
2124

2225
/**
@@ -27,23 +30,23 @@
2730
* @param stride stride length
2831
* @return L2-norm
2932
*/
30-
double c_dnrm2( const int N, const double *X, const int stride ) {
33+
double c_dnrm2( const CBLAS_INT N, const double *X, const CBLAS_INT stride ) {
3134
double scale;
3235
double ssq;
3336
double ax;
34-
int i;
37+
CBLAS_INT i;
3538

3639
if ( N <= 0 || stride <= 0 ) {
3740
return 0.0;
3841
}
3942
if ( N == 1 ) {
40-
return fabs( X[ 0 ] );
43+
return stdlib_base_abs( X[ 0 ] );
4144
}
4245
scale = 0.0;
4346
ssq = 1.0;
4447
for ( i = 0; i < N*stride; i += stride ) {
4548
if ( X[ i ] != 0.0 ) {
46-
ax = fabs( X[ i ] );
49+
ax = stdlib_base_abs( X[ i ] );
4750
if ( scale < ax ) {
4851
ssq = 1.0 + ( ssq * pow( scale/ax, 2 ) );
4952
scale = ax;
@@ -52,5 +55,5 @@ double c_dnrm2( const int N, const double *X, const int stride ) {
5255
}
5356
}
5457
}
55-
return scale * sqrt( ssq );
58+
return scale * stdlib_base_sqrt( ssq );
5659
}

0 commit comments

Comments
 (0)