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 Dec 2, 2023
1 parent 01b8a99 commit 6054672
Show file tree
Hide file tree
Showing 33 changed files with 1,903 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/index.js.map

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions is-complex128matrix-like/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<!--
@license Apache-2.0
Copyright (c) 2023 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# isComplex128MatrixLike

> Test if a value is a 2-dimensional [ndarray][@stdlib/ndarray/ctor]-like object containing double-precision complex floating-point numbers.
<section class="usage">

## Usage

```javascript
var isComplex128MatrixLike = require( '@stdlib/assert/is-complex128matrix-like' );
```

#### isComplex128MatrixLike( value )

Tests if a value is a 2-dimensional [ndarray][@stdlib/ndarray/ctor]-like object whose underlying data type is `complex128`.

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var ndarray = require( '@stdlib/ndarray/ctor' );

var arr = ndarray( 'complex128', new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );

var bool = isComplex128MatrixLike( arr );
// returns true
```

</section>

<!-- /.usage -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var ndarray = require( '@stdlib/ndarray/ctor' );
var Complex128Array = require( '@stdlib/array/complex128' );
var isComplex128MatrixLike = require( '@stdlib/assert/is-complex128matrix-like' );

var buffer = new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] );
var arr = ndarray( 'complex128', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );

var out = isComplex128MatrixLike( arr );
// returns true

out = isComplex128MatrixLike( [ 1, 2, 3, 4 ] );
// returns false

out = isComplex128MatrixLike( {} );
// returns false

out = isComplex128MatrixLike( null );
// returns false
```

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor

</section>

<!-- /.links -->
97 changes: 97 additions & 0 deletions is-complex128matrix-like/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isBoolean = require( './../../is-boolean' ).isPrimitive;
var ndarray = require( '@stdlib/ndarray/ctor' );
var Complex128Array = require( '@stdlib/array/complex128' );
var pkg = require( './../package.json' ).name;
var isComplex128MatrixLike = require( './../lib' );


// MAIN //

bench( pkg+'::true', function benchmark( b ) {
var strides;
var offset;
var buffer;
var values;
var shape;
var order;
var bool;
var arr;
var i;

buffer = new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] );
shape = [ 2, 2 ];
strides = [ 2, 1 ];
offset = 0;
order = 'row-major';

arr = ndarray( 'complex128', buffer, shape, strides, offset, order );

values = [
arr,
arr
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isComplex128MatrixLike( values[ i%values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+'::false', function benchmark( b ) {
var values;
var bool;
var i;

values = [
[ 1, 2, 3 ],
null,
5,
'beep'
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isComplex128MatrixLike( values[ i%values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();
});
42 changes: 42 additions & 0 deletions is-complex128matrix-like/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

{{alias}}( value )
Tests if a value is a 2-dimensional ndarray-like object containing double-
precision complex floating-point numbers.

Parameters
----------
value: any
Value to test.

Returns
-------
bool: boolean
Boolean indicating whether a value is a 2-dimensional ndarray-like
object containing double-precision complex floating-point numbers.

Examples
--------
> var M = {};
> M.data = new {{alias:@stdlib/array/complex128}}( [ 0, 0, 0, 0, 0, 0, 0, 0 ] );
> M.ndims = 2;
> M.shape = [ 2, 2 ];
> M.strides = [ 2, 1 ];
> M.offset = 0;
> M.order = 'row-major';
> M.dtype = 'complex128';
> M.length = 4;
> M.flags = {};
> M.get = function get( i, j ) {};
> M.set = function set( i, j ) {};
> var bool = {{alias}}( M )
true
> bool = {{alias}}( [ 1, 2, 3, 4 ] )
false
> bool = {{alias}}( 3.14 )
false
> bool = {{alias}}( {} )
false

See Also
--------

44 changes: 44 additions & 0 deletions is-complex128matrix-like/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 4.1

/**
* Tests if a value is a 2-dimensional ndarray-like object whose underlying data type is `complex128`.
*
* @param v - value to test
* @returns boolean indicating if a value is a 2-dimensional ndarray-like object whose underlying data type is `complex128`
*
* @example
* var Complex128Array = require( `@stdlib/array/complex128` );
* var ndarray = require( `@stdlib/ndarray/ctor` );
*
* var arr = ndarray( 'complex128', new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
*
* var bool = isComplex128MatrixLike( arr );
* // returns true
*
* bool = isComplex128MatrixLike( [] );
* // returns false
*/
declare function isComplex128MatrixLike( v: any ): boolean;


// EXPORTS //

export = isComplex128MatrixLike;
33 changes: 33 additions & 0 deletions is-complex128matrix-like/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import isComplex128MatrixLike = require( './index' );


// TESTS //

// The function returns a boolean...
{
isComplex128MatrixLike( [] ); // $ExpectType boolean
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
isComplex128MatrixLike(); // $ExpectError
isComplex128MatrixLike( 'abc', 123 ); // $ExpectError
}
38 changes: 38 additions & 0 deletions is-complex128matrix-like/examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var ndarray = require( '@stdlib/ndarray/ctor' );
var Complex128Array = require( '@stdlib/array/complex128' );
var isComplex128MatrixLike = require( './../lib' );

var buffer = new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] );
var arr = ndarray( 'complex128', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );

console.log( isComplex128MatrixLike( arr ) );
// => true

console.log( isComplex128MatrixLike( [ 1, 2, 3, 4 ] ) );
// => false

console.log( isComplex128MatrixLike( {} ) );
// => false

console.log( isComplex128MatrixLike( null ) );
// => false
Loading

0 comments on commit 6054672

Please sign in to comment.