Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jan 7, 2024
1 parent 9e784ae commit 5c1ad14
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 43 deletions.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright (c) 2016-2023 The Stdlib Authors.
Copyright (c) 2016-2024 The Stdlib Authors.
4 changes: 2 additions & 2 deletions ddot/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

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

import { ndarray } from '@stdlib/types/ndarray';
import { float64ndarray } from '@stdlib/types/ndarray';

/**
* Computes the dot product of two double-precision floating-point vectors.
Expand All @@ -42,7 +42,7 @@ import { ndarray } from '@stdlib/types/ndarray';
* var z = ddot( x, y );
* // returns -5.0
*/
declare function ddot( x: ndarray, y: ndarray ): number;
declare function ddot( x: float64ndarray, y: float64ndarray ): number;


// EXPORTS //
Expand Down
46 changes: 6 additions & 40 deletions ddot/docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,20 @@
* limitations under the License.
*/

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

import { ndarray } from '@stdlib/types/ndarray';
import zeros = require( '@stdlib/ndarray/zeros' );
import ddot = require( './index' );

/**
* Returns an ndarray object.
*
* @returns ndarray object
*/
function createArray(): ndarray {
const arr: ndarray = {
'byteLength': null,
'BYTES_PER_ELEMENT': null,
'data': new Float64Array( [ 1, 2, 3 ] ),
'dtype': 'float64',
'flags': {
'ROW_MAJOR_CONTIGUOUS': true,
'COLUMN_MAJOR_CONTIGUOUS': false
},
'length': 3,
'ndims': 1,
'offset': 0,
'order': 'row-major',
'shape': [ 3 ],
'strides': [ 1 ],
'get': ( i: number ): any => {
return arr.data[ i ];
},
'set': ( i: number, v: any ): ndarray => {
arr.data[ i ] = v;
return arr;
}
};
return arr;
}


// TESTS //

// The function returns a number...
{
ddot( createArray(), createArray() ); // $ExpectType number
ddot( zeros( [ 10 ] ), zeros( [ 10 ] ) ); // $ExpectType number
}

// The compiler throws an error if the function is provided a first argument which is not an ndarray...
{
const y: ndarray = createArray();
const y = zeros( [ 10 ] );

ddot( 10, y ); // $ExpectError
ddot( '10', y ); // $ExpectError
Expand All @@ -78,7 +44,7 @@ function createArray(): ndarray {

// The compiler throws an error if the function is provided a second argument which is not an ndarray...
{
const x: ndarray = createArray();
const x = zeros( [ 10 ] );

ddot( x, 10 ); // $ExpectError
ddot( x, '10' ); // $ExpectError
Expand All @@ -93,8 +59,8 @@ function createArray(): ndarray {

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
const x: ndarray = createArray();
const y: ndarray = createArray();
const x = zeros( [ 10 ] );
const y = zeros( [ 10 ] );

ddot(); // $ExpectError
ddot( x ); // $ExpectError
Expand Down

0 comments on commit 5c1ad14

Please sign in to comment.