-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c4a708
commit b60ffb5
Showing
3 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<!-- | ||
@license Apache-2.0 | ||
Copyright (c) 2021 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. | ||
--> | ||
|
||
# Complex128Array | ||
|
||
> 128-bit complex number array. | ||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> | ||
|
||
<section class="intro"> | ||
|
||
</section> | ||
|
||
<!-- /.intro --> | ||
|
||
<!-- Package usage documentation. --> | ||
|
||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var Complex128Array = require( '@stdlib/array/complex128' ); | ||
``` | ||
|
||
<a name="constructor"></a> | ||
|
||
#### Complex128Array() | ||
|
||
Creates a 128-bit complex number array. | ||
|
||
```javascript | ||
var arr = new Complex128Array(); | ||
// returns <Complex128Array> | ||
``` | ||
|
||
<!-- /.usage --> | ||
|
||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="notes"> | ||
|
||
<!-- /.notes --> | ||
|
||
<!-- Package usage examples. --> | ||
|
||
<section class="examples"> | ||
|
||
* * * | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var Complex128 = require( '@stdlib/complex/float64' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var Complex128Array = require( '@stdlib/array/complex128' ); | ||
|
||
var arr; | ||
var out; | ||
|
||
// Create a complex array by specifying a length: | ||
out = new Complex128Array( 3 ); | ||
console.log( out ); | ||
|
||
// Create a complex array from an array of complex numbers: | ||
arr = [ | ||
new Complex128( 1.0, -1.0 ), | ||
new Complex128( -3.14, 3.14 ), | ||
new Complex128( 0.5, 0.5 ) | ||
]; | ||
out = new Complex128Array( arr ); | ||
console.log( out ); | ||
|
||
// Create a complex array from an interleaved typed array: | ||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); | ||
out = new Complex128Array( arr ); | ||
console.log( out ); | ||
|
||
// Create a complex array from an array buffer: | ||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); | ||
out = new Complex128Array( arr.buffer ); | ||
console.log( out ); | ||
|
||
// Create a complex array from an array buffer view: | ||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); | ||
out = new Complex128Array( arr.buffer, 16, 2 ); | ||
console.log( out ); | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="references"> | ||
|
||
</section> | ||
|
||
<!-- /.references --> | ||
|
||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="links"> | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2018 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 Complex128 = require( '@stdlib/complex/float64' ); | ||
var Float64Array = require( './../../float64' ); | ||
var Complex128Array = require( './../lib' ); | ||
|
||
var arr; | ||
var out; | ||
|
||
// Create a complex array by specifying a length: | ||
out = new Complex128Array( 3 ); | ||
console.log( out ); | ||
|
||
// Create a complex array from an array of complex numbers: | ||
arr = [ | ||
new Complex128( 1.0, -1.0 ), | ||
new Complex128( -3.14, 3.14 ), | ||
new Complex128( 0.5, 0.5 ) | ||
]; | ||
out = new Complex128Array( arr ); | ||
console.log( out ); | ||
|
||
// Create a complex array from an interleaved typed array: | ||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); | ||
out = new Complex128Array( arr ); | ||
console.log( out ); | ||
|
||
// Create a complex array from an array buffer: | ||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); | ||
out = new Complex128Array( arr.buffer ); | ||
console.log( out ); | ||
|
||
// Create a complex array from an array buffer view: | ||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); | ||
out = new Complex128Array( arr.buffer, 16, 2 ); | ||
console.log( out ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2021 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 tape = require( 'tape' ); | ||
var Complex128Array = require( './../lib' ); | ||
|
||
|
||
// TESTS // | ||
|
||
tape( 'main export is a function', function test( t ) { | ||
t.ok( true, __filename ); | ||
t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); | ||
t.end(); | ||
}); | ||
|
||
tape( 'the function is a constructor', function test( t ) { | ||
var arr = new Complex128Array( 0 ); | ||
t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); | ||
t.end(); | ||
}); | ||
|
||
tape( 'the constructor does not require the `new` keyword', function test( t ) { | ||
var ctor; | ||
var arr; | ||
|
||
ctor = Complex128Array; | ||
|
||
arr = ctor( 0 ); | ||
t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); | ||
|
||
t.end(); | ||
}); | ||
|
||
// TODO: Add tests |