16
16
* limitations under the License.
17
17
*/
18
18
19
- /// <reference types="@stdlib/types"/>
20
-
21
- import { ndarray } from '@stdlib/types/ndarray' ;
19
+ import zeros = require( '@stdlib/ndarray/zeros' ) ;
22
20
import ddot = require( './index' ) ;
23
21
24
- /**
25
- * Returns an ndarray object.
26
- *
27
- * @returns ndarray object
28
- */
29
- function createArray ( ) : ndarray {
30
- const arr : ndarray = {
31
- 'byteLength' : null ,
32
- 'BYTES_PER_ELEMENT' : null ,
33
- 'data' : new Float64Array ( [ 1 , 2 , 3 ] ) ,
34
- 'dtype' : 'float64' ,
35
- 'flags' : {
36
- 'ROW_MAJOR_CONTIGUOUS' : true ,
37
- 'COLUMN_MAJOR_CONTIGUOUS' : false
38
- } ,
39
- 'length' : 3 ,
40
- 'ndims' : 1 ,
41
- 'offset' : 0 ,
42
- 'order' : 'row-major' ,
43
- 'shape' : [ 3 ] ,
44
- 'strides' : [ 1 ] ,
45
- 'get' : ( i : number ) : any => {
46
- return arr . data [ i ] ;
47
- } ,
48
- 'set' : ( i : number , v : any ) : ndarray => {
49
- arr . data [ i ] = v ;
50
- return arr ;
51
- }
52
- } ;
53
- return arr ;
54
- }
55
-
56
22
57
23
// TESTS //
58
24
59
25
// The function returns a number...
60
26
{
61
- ddot ( createArray ( ) , createArray ( ) ) ; // $ExpectType number
27
+ ddot ( zeros ( [ 10 ] ) , zeros ( [ 10 ] ) ) ; // $ExpectType number
62
28
}
63
29
64
30
// The compiler throws an error if the function is provided a first argument which is not an ndarray...
65
31
{
66
- const y : ndarray = createArray ( ) ;
32
+ const y = zeros ( [ 10 ] ) ;
67
33
68
34
ddot ( 10 , y ) ; // $ExpectError
69
35
ddot ( '10' , y ) ; // $ExpectError
@@ -78,7 +44,7 @@ function createArray(): ndarray {
78
44
79
45
// The compiler throws an error if the function is provided a second argument which is not an ndarray...
80
46
{
81
- const x : ndarray = createArray ( ) ;
47
+ const x = zeros ( [ 10 ] ) ;
82
48
83
49
ddot ( x , 10 ) ; // $ExpectError
84
50
ddot ( x , '10' ) ; // $ExpectError
@@ -93,8 +59,8 @@ function createArray(): ndarray {
93
59
94
60
// The compiler throws an error if the function is provided an unsupported number of arguments...
95
61
{
96
- const x : ndarray = createArray ( ) ;
97
- const y : ndarray = createArray ( ) ;
62
+ const x = zeros ( [ 10 ] ) ;
63
+ const y = zeros ( [ 10 ] ) ;
98
64
99
65
ddot ( ) ; // $ExpectError
100
66
ddot ( x ) ; // $ExpectError
0 commit comments