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 46d8c63 commit 01b8a99
Show file tree
Hide file tree
Showing 40 changed files with 1,913 additions and 18 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

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-complex64matrix-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.
-->

# isComplex64MatrixLike

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

## Usage

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

#### isComplex64MatrixLike( value )

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

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var ndarray = require( '@stdlib/ndarray/ctor' );

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

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

</section>

<!-- /.usage -->

<section class="examples">

## Examples

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

```javascript
var ndarray = require( '@stdlib/ndarray/ctor' );
var Complex64Array = require( '@stdlib/array/complex64' );
var isComplex64MatrixLike = require( '@stdlib/assert/is-complex64matrix-like' );

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

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

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

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

out = isComplex64MatrixLike( 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-complex64matrix-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 Complex64Array = require( '@stdlib/array/complex64' );
var pkg = require( './../package.json' ).name;
var isComplex64MatrixLike = 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 Complex64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] );
shape = [ 2, 2 ];
strides = [ 2, 1 ];
offset = 0;
order = 'row-major';

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

values = [
arr,
arr
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isComplex64MatrixLike( 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 = isComplex64MatrixLike( 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-complex64matrix-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 single-
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 single-precision complex floating-point numbers.

Examples
--------
> var M = {};
> M.data = new {{alias:@stdlib/array/complex64}}( [ 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 = 'complex64';
> 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-complex64matrix-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 `complex64`.
*
* @param v - value to test
* @returns boolean indicating if a value is a 2-dimensional ndarray-like object whose underlying data type is `complex64`
*
* @example
* var Complex64Array = require( `@stdlib/array/complex64` );
* var ndarray = require( `@stdlib/ndarray/ctor` );
*
* var arr = ndarray( 'complex64', new Complex64Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
*
* var bool = isComplex64MatrixLike( arr );
* // returns true
*
* bool = isComplex64MatrixLike( [] );
* // returns false
*/
declare function isComplex64MatrixLike( v: any ): boolean;


// EXPORTS //

export = isComplex64MatrixLike;
33 changes: 33 additions & 0 deletions is-complex64matrix-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 isComplex64MatrixLike = require( './index' );


// TESTS //

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

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
isComplex64MatrixLike(); // $ExpectError
isComplex64MatrixLike( 'abc', 123 ); // $ExpectError
}
38 changes: 38 additions & 0 deletions is-complex64matrix-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 Complex64Array = require( '@stdlib/array/complex64' );
var isComplex64MatrixLike = require( './../lib' );

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

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

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

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

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

0 comments on commit 01b8a99

Please sign in to comment.