<!--

@license Apache-2.0

Copyright (c) 2026 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.

-->

# reinterpretComplex

> Reinterpret a complex-valued floating-point [ndarray][@stdlib/ndarray/base/ctor] as a real-valued floating-point [ndarray][@stdlib/ndarray/base/ctor] having the same precision.

<section class="intro">

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var reinterpretComplex = require( '@stdlib/ndarray/base/reinterpret-complex' );
```

#### reinterpretComplex( x )

Reinterprets a complex-valued floating-point [ndarray][@stdlib/ndarray/base/ctor] as a real-valued floating-point [ndarray][@stdlib/ndarray/base/ctor] having the same precision.

```javascript
var zeroTo = require( '@stdlib/blas/ext/zero-to' );

var x = zeroTo( [ 2, 2 ], {
    'dtype': 'complex128'
});
// returns <ndarray>[ [ <Complex128>[ 0.0, 0.0 ], <Complex128>[ 1.0, 0.0 ] ], [ <Complex128>[ 0.0, 0.0 ], <Complex128>[ 1.0, 0.0 ] ] ]

var out = reinterpretComplex( x );
// returns <ndarray>[ [ [ 0.0, 0.0 ], [ 1.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 1.0, 0.0 ] ] ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

-   The returned [ndarray][@stdlib/ndarray/base/ctor] is a view on the input [ndarray][@stdlib/ndarray/base/ctor] data buffer.
-   The returned [ndarray][@stdlib/ndarray/base/ctor] has an additional trailing dimension of size two whose elements correspond to the real and imaginary components, respectively, of each complex-valued element in the input [ndarray][@stdlib/ndarray/base/ctor].
-   The returned [ndarray][@stdlib/ndarray/base/ctor] is a "base" [ndarray][@stdlib/ndarray/base/ctor], and, thus, the returned [ndarray][@stdlib/ndarray/base/ctor] does not perform bounds checking or afford any of the guarantees of the non-base [ndarray][@stdlib/ndarray/ctor] constructor. The primary intent of this function is to reinterpret an ndarray-like object within internal implementations and to do so with minimal overhead.

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var zeroTo = require( '@stdlib/blas/ext/zero-to' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var reinterpretComplex = require( '@stdlib/ndarray/base/reinterpret-complex' );

// Create a double-precision complex floating-point ndarray:
var x = zeroTo( [ 2, 2 ], {
    'dtype': 'complex128'
});

// Reinterpret as a double-precision floating-point ndarray:
var out = reinterpretComplex( x );
console.log( ndarray2array( out ) );
```

</section>

<!-- /.examples -->

<section class="references">

</section>

<!-- /.references -->

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

<section class="related">

</section>

<!-- /.related -->

<section class="links">

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

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

</section>

<!-- /.links -->
