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
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/blas/ddot/README.md
+31-5Lines changed: 31 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ The [dot product][dot-product] (or scalar product) is defined as
47
47
var ddot =require( '@stdlib/blas/ddot' );
48
48
```
49
49
50
-
#### ddot( x, y )
50
+
#### ddot( x, y\[, options] )
51
51
52
52
Calculates the dot product of vectors `x` and `y`.
53
53
@@ -67,20 +67,43 @@ The function has the following parameters:
67
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
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
69
70
-
Provided vectors may be either [`ndarrays`][@stdlib/ndarray/array] and array-like objects. For example, the function accepts generic arrays.
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. However, by default, 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.
71
85
72
86
```javascript
73
87
var x = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
74
88
var y = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
75
89
76
-
var z =ddot( x, y );
90
+
var opts = {
91
+
'casting':'unsafe'
92
+
};
93
+
var z =ddot( x, y, opts );
77
94
// returns -5.0
78
95
```
79
96
80
97
If provided empty vectors, the function returns `0.0`.
-`ddot()` provides a higher-level interface to the [BLAS][blas] level 1 function [`ddot`][@stdlib/blas/base/ddot].
96
-
- Casting is **not**[safe][@stdlib/ndarray/safe-casts] in order to accommodate generic arrays and array-like objects.
97
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`.
0 commit comments