diff --git a/lib/node_modules/@stdlib/complex/float64/reim/README.md b/lib/node_modules/@stdlib/complex/float64/reim/README.md new file mode 100644 index 00000000000..7aa06b8727c --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/README.md @@ -0,0 +1,245 @@ + + +# reim + +> Return the real and imaginary components of a double-precision complex floating-point number. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var reim = require( '@stdlib/complex/float64/reim' ); +``` + +#### reim( z ) + +Returns the **real** and **imaginary** components of a double-precision complex floating-point number. + +```javascript +var Complex128 = require( '@stdlib/complex/float64/ctor' ); + +var z = new Complex128( 5.0, 3.0 ); +var out = reim( z ); +// returns [ 5.0, 3.0 ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + + + +```javascript +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var reim = require( '@stdlib/complex/float64/reim' ); + +function random() { + return new Complex128( discreteUniform( -10, 10 ), discreteUniform( -10, 10 ) ); +} + +// Generate an array of random complex numbers: +var x = filledarrayBy( 100, 'complex128', random ); +// returns + +// Return the real and imaginary components of each complex number... +var out; +var z; +var i; +for ( i = 0; i < x.length; i++ ) { + z = x.get( i ); + out = reim( z ); + console.log( '%s => %d, %d', z.toString(), out[ 0 ], out[ 1 ] ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/complex/float64/reim.h" +``` + +#### stdlib_complex128_reim( z, \*re, \*im ) + +Returns the real and imaginary components of a double-precision complex floating-point number. + +```c +#include "stdlib/complex/float64/ctor.h" + +stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); + +// ... + +double re; +double im; + +stdlib_complex128_reim( z, &re, &im ); +``` + +The function accepts the following arguments: + +- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. +- **re**: `[out] double*` destination for real component. +- **im**: `[out] double*` destination for imaginary component. + +```c +void stdlib_complex128_reim( const stdlib_complex128_t z, double *re, double *im ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/complex/float64/reim.h" +#include "stdlib/complex/float64/ctor.h" +#include + +int main( void ) { + const stdlib_complex128_t x[] = { + stdlib_complex128( 5.0, 2.0 ), + stdlib_complex128( -2.0, 1.0 ), + stdlib_complex128( 0.0, -0.0 ), + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) + }; + + double re; + double im; + int i; + for ( i = 0; i < 4; i++ ) { + stdlib_complex128_reim( x[ i ], &re, &im ); + printf( "reim(v) = %lf, %lf\n", re, im ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/complex/float64/reim/benchmark/benchmark.js b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/benchmark.js new file mode 100644 index 00000000000..01413b04fea --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/benchmark.js @@ -0,0 +1,57 @@ +/** +* @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'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var randu = require( '@stdlib/random/base/randu' ); +var isArrayLike = require( '@stdlib/assert/is-array-like' ); +var pkg = require( './../package.json' ).name; +var reim = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var arr; + var i; + + values = [ + new Complex128( randu(), randu() ), + new Complex128( randu(), randu() ), + new Complex128( randu(), randu() ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = reim( values[ i%values.length ] ); + if ( arr.length === 0 ) { + b.fail( 'should not be empty' ); + } + } + b.toc(); + if ( !isArrayLike( arr ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/reim/benchmark/c/Makefile b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/c/Makefile new file mode 100644 index 00000000000..7f6bbc4c205 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/complex/float64/reim/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/c/benchmark.c new file mode 100644 index 00000000000..9815450ded0 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/c/benchmark.c @@ -0,0 +1,138 @@ +/** +* @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. +*/ + +#include "stdlib/complex/float64/reim.h" +#include "stdlib/complex/float64/ctor.h" +#include +#include +#include +#include +#include +#include + +#define NAME "complex128_reim" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +void print_version() { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +double tic() { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1]. +* +* @return random number +*/ +double rand_double() { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +double benchmark() { + stdlib_complex128_t z; + double elapsed; + double re; + double im; + double t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + re = rand_double(); + im = rand_double(); + z = stdlib_complex128( re, im ); + stdlib_complex128_reim( z, &re, &im ); + if ( re != re ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( im != im ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::native::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/complex/float64/reim/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/julia/REQUIRE new file mode 100644 index 00000000000..98645e192e4 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/complex/float64/reim/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/julia/benchmark.jl new file mode 100755 index 00000000000..671c19a085c --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/benchmark/julia/benchmark.jl @@ -0,0 +1,144 @@ +#!/usr/bin/env julia +# +# @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. + +import BenchmarkTools +using Printf + +# Benchmark variables: +name = "reim"; +repeats = 3; + +""" + print_version() + +Prints the TAP version. + +# Examples + +``` julia +julia> print_version() +``` +""" +function print_version() + @printf( "TAP version 13\n" ); +end + +""" + print_summary( total, passing ) + +Print the benchmark summary. + +# Arguments + +* `total`: total number of tests +* `passing`: number of passing tests + +# Examples + +``` julia +julia> print_summary( 3, 3 ) +``` +""" +function print_summary( total, passing ) + @printf( "#\n" ); + @printf( "1..%d\n", total ); # TAP plan + @printf( "# total %d\n", total ); + @printf( "# pass %d\n", passing ); + @printf( "#\n" ); + @printf( "# ok\n" ); +end + +""" + print_results( iterations, elapsed ) + +Print benchmark results. + +# Arguments + +* `iterations`: number of iterations +* `elapsed`: elapsed time (in seconds) + +# Examples + +``` julia +julia> print_results( 1000000, 0.131009101868 ) +``` +""" +function print_results( iterations, elapsed ) + rate = iterations / elapsed + + @printf( " ---\n" ); + @printf( " iterations: %d\n", iterations ); + @printf( " elapsed: %0.9f\n", elapsed ); + @printf( " rate: %0.9f\n", rate ); + @printf( " ...\n" ); +end + +""" + benchmark() + +Run a benchmark. + +# Notes + +* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. +* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. +* The elapsed time is in seconds. + +# Examples + +``` julia +julia> out = benchmark(); +``` +""" +function benchmark() + t = BenchmarkTools.@benchmark reim( ComplexF64( rand(), rand() ) ) samples=1e6 + + # Compute the total "elapsed" time and convert from nanoseconds to seconds: + s = sum( t.times ) / 1.0e9; + + # Determine the number of "iterations": + iter = length( t.times ); + + # Return the results: + [ iter, s ]; +end + +""" + main() + +Run benchmarks. + +# Examples + +``` julia +julia> main(); +``` +""" +function main() + print_version(); + for i in 1:repeats + @printf( "# julia::%s\n", name ); + results = benchmark(); + print_results( results[ 1 ], results[ 2 ] ); + @printf( "ok %d benchmark finished\n", i ); + end + print_summary( repeats, repeats ); +end + +main(); diff --git a/lib/node_modules/@stdlib/complex/float64/reim/docs/repl.txt b/lib/node_modules/@stdlib/complex/float64/reim/docs/repl.txt new file mode 100644 index 00000000000..b1cb3841bb7 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/docs/repl.txt @@ -0,0 +1,24 @@ + +{{alias}}( z ) + Returns the real and imaginary components of a double-precision complex + floating-point number. + + Parameters + ---------- + z: Complex128 + Complex number. + + Returns + ------- + out: Float64Array + Array containing the real and imaginary components, respectively. + + Examples + -------- + > var z = new {{alias:@stdlib/complex/float64/ctor}}( 5.0, 3.0 ); + > var out = {{alias}}( z ) + [ 5.0, 3.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/complex/float64/reim/docs/types/index.d.ts b/lib/node_modules/@stdlib/complex/float64/reim/docs/types/index.d.ts new file mode 100644 index 00000000000..f791e242ced --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/docs/types/index.d.ts @@ -0,0 +1,44 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex128 } from '@stdlib/types/complex'; + +/** +* Returns the real and imaginary components of a double-precision complex floating-point number. +* +* @param z - complex number +* @returns real and imaginary components +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var z = new Complex128( 5.0, 3.0 ); +* +* var out = reim( z ); +* // returns [ 5.0, 3.0 ] +*/ +declare function reim( z: Complex128 ): Float64Array; + + +// EXPORTS // + +export = reim; diff --git a/lib/node_modules/@stdlib/complex/float64/reim/docs/types/test.ts b/lib/node_modules/@stdlib/complex/float64/reim/docs/types/test.ts new file mode 100644 index 00000000000..2eb39fa78be --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/docs/types/test.ts @@ -0,0 +1,45 @@ +/* +* @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. +*/ + +import Complex128 = require( '@stdlib/complex/float64/ctor' ); +import reim = require( './index' ); + + +// TESTS // + +// The function returns a floating-point typed array... +{ + reim( new Complex128( 5.0, 3.0 ) ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided an argument that is not a complex number... +{ + reim( 'abc' ); // $ExpectError + reim( 123 ); // $ExpectError + reim( true ); // $ExpectError + reim( false ); // $ExpectError + reim( [] ); // $ExpectError + reim( {} ); // $ExpectError + reim( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + reim(); // $ExpectError + reim( new Complex128( 5.0, 3.0 ), 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/complex/float64/reim/examples/c/Makefile b/lib/node_modules/@stdlib/complex/float64/reim/examples/c/Makefile new file mode 100644 index 00000000000..70c91f4e131 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/complex/float64/reim/examples/c/example.c b/lib/node_modules/@stdlib/complex/float64/reim/examples/c/example.c new file mode 100644 index 00000000000..1305d66b5e2 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/examples/c/example.c @@ -0,0 +1,38 @@ +/** +* @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. +*/ + +#include "stdlib/complex/float64/reim.h" +#include "stdlib/complex/float64/ctor.h" +#include + +int main( void ) { + const stdlib_complex128_t x[] = { + stdlib_complex128( 5.0, 2.0 ), + stdlib_complex128( -2.0, 1.0 ), + stdlib_complex128( 0.0, -0.0 ), + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) + }; + + double re; + double im; + int i; + for ( i = 0; i < 4; i++ ) { + stdlib_complex128_reim( x[ i ], &re, &im ); + printf( "reim(v) = %lf, %lf\n", re, im ); + } +} diff --git a/lib/node_modules/@stdlib/complex/float64/reim/examples/index.js b/lib/node_modules/@stdlib/complex/float64/reim/examples/index.js new file mode 100644 index 00000000000..7e149a4c159 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/examples/index.js @@ -0,0 +1,42 @@ +/** +* @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/ctor' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var reim = require( './../lib' ); + +function random() { + return new Complex128( discreteUniform( -10, 10 ), discreteUniform( -10, 10 ) ); // eslint-disable-line max-len +} + +// Generate an array of random complex numbers: +var x = filledarrayBy( 100, 'complex128', random ); +// returns + +// Return the real and imaginary components of each complex number... +var out; +var z; +var i; +for ( i = 0; i < x.length; i++ ) { + z = x.get( i ); + out = reim( z ); + console.log( '%s => %d, %d', z.toString(), out[ 0 ], out[ 1 ] ); +} diff --git a/lib/node_modules/@stdlib/complex/float64/reim/include/stdlib/complex/float64/reim.h b/lib/node_modules/@stdlib/complex/float64/reim/include/stdlib/complex/float64/reim.h new file mode 100644 index 00000000000..642b61b9981 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/include/stdlib/complex/float64/reim.h @@ -0,0 +1,40 @@ +/** +* @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. +*/ + +#ifndef STDLIB_COMPLEX_FLOAT64_REIM_H +#define STDLIB_COMPLEX_FLOAT64_REIM_H + +#include "stdlib/complex/float64/ctor.h" + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Returns the real and imaginary components of a double-precision complex floating-point number. +*/ +void stdlib_complex128_reim( const stdlib_complex128_t z, double *re, double *im ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_COMPLEX_FLOAT64_REIM_H diff --git a/lib/node_modules/@stdlib/complex/float64/reim/lib/index.js b/lib/node_modules/@stdlib/complex/float64/reim/lib/index.js new file mode 100644 index 00000000000..bf44e74e34c --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/lib/index.js @@ -0,0 +1,43 @@ +/** +* @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'; + +/** +* Return the real and imaginary components of a double-precision complex floating-point number. +* +* @module @stdlib/complex/float64/reim +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var reim = require( '@stdlib/complex/float64/reim' ); +* +* var z = new Complex128( 5.0, 3.0 ); +* +* var out = reim( z ); +* // returns [ 5.0, 3.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/complex/float64/reim/lib/main.js b/lib/node_modules/@stdlib/complex/float64/reim/lib/main.js new file mode 100644 index 00000000000..f3973e03b5c --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/lib/main.js @@ -0,0 +1,52 @@ +/** +* @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'; + +// MODULES // + +var Float64Array = require( '@stdlib/array/float64' ); + + +// MAIN // + +/** +* Returns the real and imaginary components of a double-precision complex floating-point number. +* +* @param {Complex128} z - complex number +* @returns {Float64Array} real and imaginary components +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var z = new Complex128( 5.0, 3.0 ); +* +* var out = reim( z ); +* // returns [ 5.0, 3.0 ] +*/ +function reim( z ) { + var out = new Float64Array( 2 ); + out[ 0 ] = z.re; + out[ 1 ] = z.im; + return out; +} + + +// EXPORTS // + +module.exports = reim; diff --git a/lib/node_modules/@stdlib/complex/float64/reim/manifest.json b/lib/node_modules/@stdlib/complex/float64/reim/manifest.json new file mode 100644 index 00000000000..5bd876d7417 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/manifest.json @@ -0,0 +1,40 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float64/ctor" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/complex/float64/reim/package.json b/lib/node_modules/@stdlib/complex/float64/reim/package.json new file mode 100644 index 00000000000..e0c82f41dd7 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/complex/float64/reim", + "version": "0.0.0", + "description": "Return the real and imaginary components of a double-precision complex floating-point number.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "mathematics", + "math", + "complex", + "cmplx", + "real", + "re", + "imaginary", + "imag", + "im", + "number" + ] +} diff --git a/lib/node_modules/@stdlib/complex/float64/reim/src/main.c b/lib/node_modules/@stdlib/complex/float64/reim/src/main.c new file mode 100644 index 00000000000..5eb3fbe0cb5 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/src/main.c @@ -0,0 +1,46 @@ +/** +* @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. +*/ + +#include "stdlib/complex/float64/reim.h" +#include "stdlib/complex/float64/ctor.h" + +/** +* Returns the real and imaginary components of a double-precision complex floating-point number. +* +* @param z double-precision complex floating-point number +* @param re destination for real component +* @param im destination for imaginary component +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* +* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); +* +* // ... +* +* double re; +* double im; +* +* stdlib_complex128_reim( z, &re, &im ); +*/ +void stdlib_complex128_reim( const stdlib_complex128_t z, double *re, double *im ) { + stdlib_complex128_parts_t v; + v.value = z; // cppcheck-suppress unreadVariable + *re = v.parts[ 0 ]; + *im = v.parts[ 1 ]; +} diff --git a/lib/node_modules/@stdlib/complex/float64/reim/test/test.js b/lib/node_modules/@stdlib/complex/float64/reim/test/test.js new file mode 100644 index 00000000000..802c2176367 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/reim/test/test.js @@ -0,0 +1,49 @@ +/** +* @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'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Float64Array = require( '@stdlib/array/float64' ); +var reim = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof reim, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the real and imaginary components of a complex number', function test( t ) { + var expected; + var out; + var z; + + z = new Complex128( 3.14, -3.14 ); + out = reim( z ); + expected = new Float64Array( [ 3.14, -3.14 ] ); + t.strictEqual( out[ 0 ], expected[ 0 ], 'returns expected value' ); + t.strictEqual( out[ 1 ], expected[ 1 ], 'returns expected value' ); + + t.end(); +});