Skip to content

Commit 4a35300

Browse files
author
aayush0325
committed
feat: add docs
1 parent 2cd18bf commit 4a35300

File tree

4 files changed

+151
-0
lines changed

4 files changed

+151
-0
lines changed
Lines changed: 35 additions & 0 deletions
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
{{alias}}( z )
3+
Computes the absolute value of a single-precision complex floating-point
4+
number.
5+
6+
The absolute value of a complex number is its distance from zero.
7+
8+
Parameters
9+
----------
10+
z: Complex64
11+
Complex number.
12+
13+
Returns
14+
-------
15+
y: number
16+
Absolute value.
17+
18+
Examples
19+
--------
20+
> var y = {{alias}}( new {{alias:@stdlib/complex/float32/ctor}}( 5.0, 3.0 ) )
21+
~5.831
22+
23+
See Also
24+
--------
25+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { Complex64 } from '@stdlib/types/complex';
24+
25+
/**
26+
* Computes the absolute value of a single-precision complex floating-point number.
27+
*
28+
* ## Notes
29+
*
30+
* - The absolute value of a complex number is its distance from zero.
31+
*
32+
* @param z - complex number
33+
* @returns absolute value
34+
*
35+
* @example
36+
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
37+
*
38+
* var v = cabsf( new Complex64( 5.0, 3.0 ) );
39+
* // returns ~5.83
40+
*/
41+
declare function cabsf( z: Complex64 ): number;
42+
43+
44+
// EXPORTS //
45+
46+
export = cabsf;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 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+
import Complex64 = require( '@stdlib/complex/float32/ctor' );
20+
import cabsf = require( './index' );
21+
22+
23+
// TESTS //
24+
25+
// The function returns a number...
26+
{
27+
cabsf( new Complex64( 5, 3 ) ); // $ExpectType number
28+
}
29+
30+
// The compiler throws an error if the function is not provided a complex number...
31+
{
32+
cabsf( true ); // $ExpectError
33+
cabsf( false ); // $ExpectError
34+
cabsf( null ); // $ExpectError
35+
cabsf( undefined ); // $ExpectError
36+
cabsf( '5' ); // $ExpectError
37+
cabsf( [] ); // $ExpectError
38+
cabsf( {} ); // $ExpectError
39+
cabsf( ( x: number ): number => x ); // $ExpectError
40+
}
41+
42+
// The compiler throws an error if the function is provided insufficient arguments...
43+
{
44+
cabsf(); // $ExpectError
45+
}

0 commit comments

Comments
 (0)