Skip to content

Commit 472387b

Browse files
committed
Add namespace Typescript definition
1 parent 342dbb3 commit 472387b

3 files changed

Lines changed: 231 additions & 0 deletions

File tree

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/* tslint:disable:max-line-length */
22+
/* tslint:disable:max-file-line-count */
23+
24+
import base = require( '@stdlib/blas/base' );
25+
import ddot = require( '@stdlib/blas/ddot' );
26+
import dswap = require( '@stdlib/blas/dswap' );
27+
import ext = require( '@stdlib/blas/ext' );
28+
import gdot = require( '@stdlib/blas/gdot' );
29+
import gswap = require( '@stdlib/blas/gswap' );
30+
import sdot = require( '@stdlib/blas/sdot' );
31+
import sswap = require( '@stdlib/blas/sswap' );
32+
33+
/**
34+
* Interface describing the `blas` namespace.
35+
*/
36+
interface Namespace {
37+
/**
38+
* Standard library basic linear algebra subprograms (BLAS).
39+
*/
40+
base: typeof base;
41+
42+
/**
43+
* Computes the dot product of two double-precision floating-point vectors.
44+
*
45+
* @param x - first input array
46+
* @param y - second input array
47+
* @throws first argument must be a 1-dimensional `ndarray` containing double-precision floating-point numbers
48+
* @throws second argument must be a 1-dimensional `ndarray` containing double-precision floating-point numbers
49+
* @throws input arrays must be the same length
50+
* @returns dot product
51+
*
52+
* @example
53+
* var Float64Array = require( `@stdlib/array/float64` );
54+
* var array = require( `@stdlib/ndarray/array` );
55+
*
56+
* var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
57+
* var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
58+
*
59+
* var z = ns.ddot( x, y );
60+
* // returns -5.0
61+
*/
62+
ddot: typeof ddot;
63+
64+
/**
65+
* Interchanges two double-precision floating-point vectors.
66+
*
67+
* @param x - first input array
68+
* @param y - second input array
69+
* @throws first argument must be a 1-dimensional `ndarray` containing double-precision floating-point numbers
70+
* @throws second argument must be a 1-dimensional `ndarray` containing double-precision floating-point numbers
71+
* @throws input arrays must be the same length
72+
* @returns `y`
73+
*
74+
* @example
75+
* var Float64Array = require( `@stdlib/array/float64` );
76+
* var array = require( `@stdlib/ndarray/array` );
77+
*
78+
* var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
79+
* var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
80+
*
81+
* ns.dswap( x, y );
82+
*
83+
* var xbuf = x.data;
84+
* // returns <Float64Array>[ 2.0, 6.0, -1.0, -4.0, 8.0 ]
85+
*
86+
* var ybuf = y.data;
87+
* // returns <Float64Array>[ 4.0, 2.0, -3.0, 5.0, -1.0 ]
88+
*/
89+
dswap: typeof dswap;
90+
91+
/**
92+
* Standard library extended BLAS.
93+
*/
94+
ext: typeof ext;
95+
96+
/**
97+
* Computes the dot product of two vectors.
98+
*
99+
* ## Notes
100+
*
101+
* - In general, for best performance, especially for large vectors, provide 1-dimensional `ndarrays` whose underlying data type is either `float64` or `float32`.
102+
*
103+
* @param x - first input array
104+
* @param y - second input array
105+
* @throws first argument must be either an array-like object or a 1-dimensional `ndarray`
106+
* @throws second argument must be either an array-like object or a 1-dimensional `ndarray`
107+
* @throws input arrays must be the same length
108+
* @returns dot product
109+
*
110+
* @example
111+
* var x = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
112+
* var y = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
113+
*
114+
* var z = ns.gdot( x, y );
115+
* // returns -5.0
116+
*/
117+
gdot: typeof gdot;
118+
119+
/**
120+
* Interchanges two vectors.
121+
*
122+
* ## Notes
123+
*
124+
* - In general, for best performance, especially for large vectors, provide 1-dimensional `ndarrays` whose underlying data type is either `float64` or `float32`.
125+
*
126+
* @param x - first input array
127+
* @param y - second input array
128+
* @throws first argument must be either an array-like object or a 1-dimensional `ndarray`
129+
* @throws second argument must be either an array-like object or a 1-dimensional `ndarray`
130+
* @throws input arrays must be the same length
131+
* @returns `y`
132+
*
133+
* @example
134+
* var x = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
135+
* var y = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
136+
*
137+
* ns.gswap( x, y );
138+
* // x => [ 2.0, 6.0, -1.0, -4.0, 8.0 ]
139+
* // y => [ 4.0, 2.0, -3.0, 5.0, -1.0 ]
140+
*/
141+
gswap: typeof gswap;
142+
143+
/**
144+
* Computes the dot product of two single-precision floating-point vectors.
145+
*
146+
* @param x - first input array
147+
* @param y - second input array
148+
* @throws first argument must be a 1-dimensional `ndarray` containing single-precision floating-point numbers
149+
* @throws second argument must be a 1-dimensional `ndarray` containing single-precision floating-point numbers
150+
* @throws input arrays must be the same length
151+
* @returns dot product
152+
*
153+
* @example
154+
* var Float32Array = require( `@stdlib/array/float32` );
155+
* var array = require( `@stdlib/ndarray/array` );
156+
*
157+
* var x = array( new Float32Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
158+
* var y = array( new Float32Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
159+
*
160+
* var z = ns.sdot( x, y );
161+
* // returns -5.0
162+
*/
163+
sdot: typeof sdot;
164+
165+
/**
166+
* Interchanges two single-precision floating-point vectors.
167+
*
168+
* @param x - first input array
169+
* @param y - second input array
170+
* @throws first argument must be a 1-dimensional `ndarray` containing single-precision floating-point numbers
171+
* @throws second argument must be a 1-dimensional `ndarray` containing single-precision floating-point numbers
172+
* @throws input arrays must be the same length
173+
* @returns `y`
174+
*
175+
* @example
176+
* var Float32Array = require( `@stdlib/array/float32` );
177+
* var array = require( `@stdlib/ndarray/array` );
178+
*
179+
* var x = array( new Float32Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
180+
* var y = array( new Float32Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
181+
*
182+
* ns.sswap( x, y );
183+
*
184+
* var xbuf = x.data;
185+
* // returns <Float32Array>[ 2.0, 6.0, -1.0, -4.0, 8.0 ]
186+
*
187+
* var ybuf = y.data;
188+
* // returns <Float32Array>[ 4.0, 2.0, -3.0, 5.0, -1.0 ]
189+
*/
190+
sswap: typeof sswap;
191+
}
192+
193+
/**
194+
* Standard library BLAS.
195+
*/
196+
declare var ns: Namespace;
197+
198+
199+
// EXPORTS //
200+
201+
export = ns;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* tslint:disable:no-unused-expression */
20+
21+
import blas = require( './index' );
22+
23+
24+
// TESTS //
25+
26+
// The exported value is the expected interface...
27+
{
28+
blas; // $ExpectType Namespace
29+
}

lib/node_modules/@stdlib/blas/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"lib": "./lib",
2020
"test": "./test"
2121
},
22+
"types": "./docs/types",
2223
"scripts": {},
2324
"homepage": "https://github.com/stdlib-js/stdlib",
2425
"repository": {

0 commit comments

Comments
 (0)