Skip to content

Commit 642d583

Browse files
committed
Revert generic interface and only support float64 ndarrays
1 parent 18eb60b commit 642d583

8 files changed

Lines changed: 49 additions & 666 deletions

File tree

lib/node_modules/@stdlib/blas/ddot/README.md

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ The [dot product][dot-product] (or scalar product) is defined as
4747
var ddot = require( '@stdlib/blas/ddot' );
4848
```
4949

50-
#### ddot( x, y\[, options] )
50+
#### ddot( x, y )
5151

52-
Calculates the dot product of vectors `x` and `y`.
52+
Calculates the dot product of two double-precision floating-point vectors `x` and `y`.
5353

5454
```javascript
5555
var Float64Array = require( '@stdlib/array/float64' );
@@ -64,35 +64,8 @@ var z = ddot( x, y );
6464

6565
The function has the following parameters:
6666

67-
- **x**: a 1-dimensional [`ndarray`][@stdlib/ndarray/array] or an array-like object. If provided an array-like object or [`ndarray`][@stdlib/ndarray/array] whose underlying data type is **not** `float64`, the value is cast to a 1-dimensional [`ndarray`][@stdlib/ndarray/array] whose data type is `float64`.
68-
- **y**: a 1-dimensional [`ndarray`][@stdlib/ndarray/array] or an array-like object. If provided an array-like object or [`ndarray`][@stdlib/ndarray/array] whose underlying data type is **not** `float64`, the value is cast to a 1-dimensional [`ndarray`][@stdlib/ndarray/array] whose data type is `float64`.
69-
70-
The function accepts the following `options`:
71-
72-
- `casting`: specifies the casting rule used to determine acceptable casts. The option may be one of the following values:
73-
74-
- `none`: only allow casting between identical types.
75-
- `equiv`: allow casting between identical and byte swapped types.
76-
- `safe`: only allow ["safe"][@stdlib/ndarray/safe-casts] casts.
77-
- `same-kind`: allow ["safe"][@stdlib/ndarray/safe-casts] casts and casts within the same kind (e.g., between signed integers or between floats).
78-
- `unsafe`: allow casting between all types (including between integers and floats).
79-
80-
Default: `'safe'`.
81-
82-
- `codegen`: `boolean` indicating whether to use code generation. Default: `true`.
83-
84-
Provided vectors may be either [`ndarrays`][@stdlib/ndarray/array] or array-like objects. By default, however, only array-like objects which can be [safely cast][@stdlib/ndarray/safe-casts] to `float64` are supported. In order to operate on numeric data stored in array-like objects which cannot be [safely cast][@stdlib/ndarray/safe-casts], one must explicitly set the `casting` option to `'unsafe'`. For example, because generic arrays can contain arbitrary data (including non-numeric types), thus allowing for potentially "unsafe" casts (e.g., strings representing integer values, such as "big integers", which cannot be accurately stored as double-precision floating-point numbers), one must explicitly set the `casting` option.
85-
86-
```javascript
87-
var x = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
88-
var y = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
89-
90-
var opts = {
91-
'casting': 'unsafe'
92-
};
93-
var z = ddot( x, y, opts );
94-
// returns -5.0
95-
```
67+
- **x**: a 1-dimensional [`ndarray`][@stdlib/ndarray/array] whose underlying data type is `float64`.
68+
- **y**: a 1-dimensional [`ndarray`][@stdlib/ndarray/array] whose underlying data type is `float64`.
9669

9770
If provided empty vectors, the function returns `0.0`.
9871

@@ -116,9 +89,6 @@ var z = ddot( x, y );
11689
## Notes
11790

11891
- `ddot()` provides a higher-level interface to the [BLAS][blas] level 1 function [`ddot`][@stdlib/blas/base/ddot].
119-
- For best performance, provide 1-dimensional [`ndarrays`][@stdlib/ndarray/array] whose underlying data type is `float64`.
120-
- Options are only applicable when either `x` or `y` is not already an `ndarray` whose underlying data type is `float64`.
121-
- Code generation can boost performance, but may be problematic in browser contexts enforcing a strict [content security policy][mdn-csp] (CSP). If running in or targeting an environment with a CSP, set the `codegen` option to `false`.
12292

12393
</section>
12494

@@ -162,16 +132,12 @@ console.log( z );
162132

163133
[dot-product]: https://en.wikipedia.org/wiki/Dot_product
164134

165-
[mdn-csp]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
166-
167135
[blas]: http://www.netlib.org/blas
168136

169137
[@stdlib/blas/base/ddot]: https://github.com/stdlib-js/stdlib
170138

171139
[@stdlib/ndarray/array]: https://github.com/stdlib-js/stdlib
172140

173-
[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/stdlib
174-
175141
</section>
176142

177143
<!-- /.links -->

lib/node_modules/@stdlib/blas/ddot/benchmark/benchmark.cast.js

Lines changed: 0 additions & 102 deletions
This file was deleted.
Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,29 @@
11

2-
{{alias}}( x, y[, options] )
2+
{{alias}}( x, y )
33
Computes the dot product of two double-precision floating-point vectors.
44

5-
For best performance, provide 1-dimensional ndarrays whose underlying data
6-
type is 'float64'.
7-
85
If provided empty vectors, the function returns `0.0`.
96

107
Parameters
118
----------
12-
x: ndarray|ArrayLikeObject
13-
First input array. If provided an array-like object or ndarray whose
14-
underlying data type is *not* 'float64', the value is cast to a
15-
1-dimensional ndarray whose data type is 'float64'.
16-
17-
y: ndarray|ArrayLikeObject
18-
Second input array. If provided an array-like object or ndarray whose
19-
underlying data type is *not* 'float64', the value is cast to a
20-
1-dimensional ndarray whose data type is 'float64'.
21-
22-
options: Object (optional)
23-
Options. This parameter is only applicable when either `x` or `y` is not
24-
already an ndarray whose underlying data type is 'float64'.
25-
26-
options.codegen: boolean (optional)
27-
Boolean indicating whether to use code generation. Code generation can
28-
boost performance, but may be problematic in browser contexts enforcing
29-
a strict content security policy (CSP). This option is only applicable
30-
when either `x` or `y` is not already an ndarray whose underlying data
31-
type is 'float64'. Default: true.
9+
x: ndarray
10+
First input array whose underlying data type is 'float64'.
3211

33-
options.casting: string (optional)
34-
Specifies the casting rule used to determine acceptable casts. The
35-
option may be one of the following values:
36-
37-
- 'none': only allow casting between identical types.
38-
- 'equiv': allow casting between identical and byte swapped types.
39-
- 'safe': only allow "safe" casts.
40-
- 'same-kind': allow "safe" casts and casts within the same kind (e.g.,
41-
between signed integers or between floats).
42-
- 'unsafe': allow casting between all types (including between integers
43-
and floats).
44-
45-
This option is only applicable when either `x` or `y` is not already an
46-
ndarray whose underlying data type is 'float64'. Default: 'safe'.
12+
y: ndarray
13+
Second input array whose underlying data type is 'float64'.
4714

4815
Returns
4916
-------
5017
dot: number
51-
The dot product of `x` and `y`.
18+
The dot product.
5219

5320
Examples
5421
--------
55-
// Using ndarrays...
5622
> var x = {{alias:@stdlib/ndarray/array}}( new {{alias:@stdlib/array/float64}}( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
5723
> var y = {{alias:@stdlib/ndarray/array}}( new {{alias:@stdlib/array/float64}}( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
5824
> {{alias}}( x, y )
5925
-5.0
6026

61-
// Using array-like objects...
62-
> x = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
63-
> y = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
64-
> {{alias}}( x, y, { 'casting': 'unsafe' } )
65-
-5.0
66-
6727
See Also
6828
--------
6929

lib/node_modules/@stdlib/blas/ddot/docs/types/index.d.ts

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,17 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { NumericArray } from '@stdlib/types/array';
2423
import { ndarray } from '@stdlib/types/ndarray';
2524

2625
/**
27-
* Interface describing options.
28-
*/
29-
interface Options {
30-
/**
31-
* Boolean indicating whether to use code generation.
32-
*/
33-
codegen?: boolean;
34-
35-
/**
36-
* Casting rule used to determine acceptable casts.
37-
*/
38-
casting?: 'none' | 'equiv' | 'safe' | 'same-kind' | 'unsafe';
39-
}
40-
41-
/**
42-
* Computes the dot product of `x` and `y`.
43-
*
44-
* ## Notes
45-
*
46-
* - For best performance, provide 1-dimensional `ndarrays` whose underlying data type is `float64`.
47-
* - Options are only applicable when either `x` or `y` is not already an `ndarray` whose underlying data type is `float64`.
26+
* Computes the dot product of two double-precision floating-point vectors.
4827
*
4928
* @param x - first input array
5029
* @param y - second input array
51-
* @param options - options
52-
* @param options.codegen - boolean indicating whether to use code generation (default: `true`)
53-
* @param options.casting - casting rule used to determine acceptable casts (default: 'safe')
54-
* @throws first argument must be either an array-like object or a 1-dimensional `ndarray`
55-
* @throws second argument must be either an array-like object or a 1-dimensional `ndarray`
56-
* @throws first argument must be either an array-like object or ndarray which can be cast to a 1-dimensional ndarray
57-
* @throws second argument must be either an array-like object or ndarray which can be cast to a 1-dimensional ndarray
30+
* @throws first argument must be a 1-dimensional `ndarray` containing double-precision floating-point numbers
31+
* @throws second argument must be a 1-dimensional `ndarray` containing double-precision floating-point numbers
5832
* @throws input arrays must be the same length
59-
* @throws casting not allowed
60-
* @throws must provide valid options
61-
* @returns dot product of `x` and `y`
33+
* @returns dot product
6234
*
6335
* @example
6436
* var Float64Array = require( `@stdlib/array/float64` );
@@ -69,18 +41,8 @@ interface Options {
6941
*
7042
* var z = ddot( x, y );
7143
* // returns -5.0
72-
*
73-
* @example
74-
* var x = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
75-
* var y = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
76-
*
77-
* var opts = {
78-
* 'casting': 'unsafe'
79-
* };
80-
* var z = ddot( x, y, opts );
81-
* // returns -5.0
8244
*/
83-
declare function ddot( x: ndarray | NumericArray, y: ndarray | NumericArray, options?: Options ): number; // tslint:disable-line:max-line-length
45+
declare function ddot( x: ndarray, y: ndarray ): number;
8446

8547

8648
// EXPORTS //

0 commit comments

Comments
 (0)