Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 331 additions & 0 deletions lib/node_modules/@stdlib/blas/ext/base/dcartesian-power/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
<!--

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

-->

# dcartesianPower

> Compute the Cartesian power for a double-precision floating-point strided array.

<section class="intro">

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var dcartesianPower = require( '@stdlib/blas/ext/base/dcartesian-power' );
```

#### dcartesianPower( N, k, x, strideX, out, LDO )

Computes the Cartesian power for a double-precision floating-point strided array.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var x = new Float64Array( [ 1.0, 2.0 ] );
var out = new Float64Array( 8 );

dcartesianPower( x.length, 2, x, 1, out, 2 );
// out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
```

The function has the following parameters:

- **N**: number of indexed elements.
- **k**: power.
- **x**: input [`Float64Array`][@stdlib/array/float64].
- **strideX**: stride length for `x`.
- **out**: output [`Float64Array`][@stdlib/array/float64].
- **LDO**: stride length for the leading dimension of `out`.

The `N`, `k`, and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the Cartesian power of every other element:

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] );
var out = new Float64Array( 8 );

dcartesianPower( 2, 2, x, 2, out, 2 );
// out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

<!-- eslint-disable stdlib/capitalized-comments -->

```javascript
var Float64Array = require( '@stdlib/array/float64' );

// Initial arrays...
var x0 = new Float64Array( [ 0.0, 1.0, 2.0 ] );
var out0 = new Float64Array( 8 );

// Create offset views...
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

dcartesianPower( 2, 2, x1, 1, out0, 2 );
// out0 => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
```

<!--lint disable maximum-heading-length-->

#### dcartesianPower.ndarray( N, k, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut )

<!--lint enable maximum-heading-length-->

Computes the Cartesian power for a double-precision floating-point strided array using alternative indexing semantics.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var x = new Float64Array( [ 1.0, 2.0 ] );
var out = new Float64Array( 8 );

dcartesianPower.ndarray( x.length, 2, x, 1, 0, out, 2, 1, 0 );
// out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
```

The function has the following additional parameters:

- **offsetX**: starting index for `x`.
- **strideOut1**: stride length for the first dimension of `out`.
- **strideOut2**: stride length for the second dimension of `out`.
- **offsetOut**: starting index for `out`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to compute the Cartesian power of every other value in the strided input array starting from the second value:

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var x = new Float64Array( [ 0.0, 1.0, 2.0 ] );
var out = new Float64Array( 8 );

dcartesianPower.ndarray( 2, 2, x, 1, 1, out, 2, 1, 0 );
// out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- If `N <= 0` or `k <= 0`, both functions return `out` unchanged.
- The output array must contain at least `N^k * k` elements.

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var dcartesianPower = require( '@stdlib/blas/ext/base/dcartesian-power' );

var x = new Float64Array( [ 1.0, 2.0 ] );
console.log( x );

var out = new Float64Array( 24 );

dcartesianPower( x.length, 3, x, 1, out, 3 );
console.log( out );
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- 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 -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/blas/ext/base/dcartesianpower.h"
```

<!--lint disable maximum-heading-length-->

#### stdlib_strided_dcartesian_power( N, k, \*X, strideX, \*Out, LDO )

<!--lint enable maximum-heading-length-->

Computes the Cartesian power for a double-precision floating-point strided array.

```c
const double X[] = { 1.0, 2.0 };
double Out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

stdlib_strided_dcartesian_power( 2, 2, X, 1, Out, 2 );
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **k**: `[in] CBLAS_INT` power.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **Out**: `[out] double*` output array.
- **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `Out`.

```c
void stdlib_strided_dcartesian_power( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO );
```

<!--lint disable maximum-heading-length-->

#### stdlib_strided_dcartesian_power_ndarray( N, k, \*X, strideX, offsetX, \*Out, strideOut1, strideOut2, offsetOut )

<!--lint enable maximum-heading-length-->

Computes the Cartesian power for a double-precision floating-point strided array using alternative indexing semantics.

```c
const double X[] = { 1.0, 2.0 };
double Out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

stdlib_strided_dcartesian_power_ndarray( 2, 2, X, 1, 0, Out, 2, 1, 0 );
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **k**: `[in] CBLAS_INT` power.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
- **Out**: `[out] double*` output array.
- **strideOut1**: `[in] CBLAS_INT` stride length for the first dimension of `Out`.
- **strideOut2**: `[in] CBLAS_INT` stride length for the second dimension of `Out`.
- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.

```c
void stdlib_strided_dcartesian_power_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
#include "stdlib/blas/ext/base/dcartesianpower.h"
#include <stdio.h>

int main( void ) {
// Create a strided input array:
const double X[] = { 1.0, 2.0 };

// Specify the number of indexed elements and power:
const int N = 2;
const int k = 2;

// Create an output array:
double out[ 8 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

// Specify strides:
const int strideX = 1;
const int LDO = 2;

// Compute the Cartesian power:
stdlib_strided_dcartesian_power( N, k, X, strideX, out, LDO );

// Print the result:
for ( int i = 0; i < N*N; i++ ) {
printf( "out[ %i ] = ( %lf, %lf )\n", i, out[ i*2 ], out[ i*2+1 ] );
}
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<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 for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[@stdlib/array/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float64

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

</section>

<!-- /.links -->
Loading