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
326 changes: 326 additions & 0 deletions lib/node_modules/@stdlib/blas/ext/base/dcross/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
<!--

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

-->

# dcross

> Compute the cross product of two double-precision floating-point input strided arrays and assign the results to an output strided array.

<section class="intro">

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var dcross = require( '@stdlib/blas/ext/base/dcross' );
```

#### dcross( x, strideX, y, strideY, z, strideZ )

Computes the cross product of two double-precision floating-point input strided arrays and assigns the results to an output strided array.

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

var x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
var y = new Float64Array( [ 4.0, 5.0, 6.0 ] );
var z = new Float64Array( [ 0.0, 0.0, 0.0 ] );

dcross( x, 1, y, 1, z, 1 );
// z => <Float64Array>[ -3.0, 6.0, -3.0 ]
```

The function has the following parameters:

- **x**: first input [`Float64Array`][@stdlib/array/float64]. Must contain `3` indexed elements.
- **strideX**: stride length for `x`.
- **y**: second input [`Float64Array`][@stdlib/array/float64]. Must contain `3` indexed elements.
- **strideY**: stride length for `y`.
- **z**: output [`Float64Array`][@stdlib/array/float64]. Must contain `3` indexed elements.
- **strideZ**: stride length for `z`.

The stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cross product using every other element:

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

var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] );
var y = new Float64Array( [ 4.0, 0.0, 5.0, 0.0, 6.0, 0.0 ] );
var z = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );

dcross( x, 2, y, 2, z, 2 );
// z => <Float64Array>[ -3.0, 0.0, 6.0, 0.0, -3.0, 0.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, 3.0 ] );
var y0 = new Float64Array( [ 0.0, 4.0, 5.0, 6.0 ] );
var z0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] );

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

dcross( x1, 1, y1, 1, z1, 1 );
// z0 => <Float64Array>[ 0.0, -3.0, 6.0, -3.0 ]
```

#### dcross.ndarray( x, strideX, offsetX, y, strideY, offsetY, z, strideZ, offsetZ )

Computes the cross product of two double-precision floating-point input strided arrays and assigns the results to an output strided array using alternative indexing semantics.

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

var x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
var y = new Float64Array( [ 4.0, 5.0, 6.0 ] );
var z = new Float64Array( [ 0.0, 0.0, 0.0 ] );

dcross.ndarray( x, 1, 0, y, 1, 0, z, 1, 0 );
// z => <Float64Array>[ -3.0, 6.0, -3.0 ]
```

The function has the following additional parameters:

- **offsetX**: starting index for `x`.
- **offsetY**: starting index for `y`.
- **offsetZ**: starting index for `z`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example:

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

var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );
var y = new Float64Array( [ 0.0, 4.0, 5.0, 6.0 ] );
var z = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] );

dcross.ndarray( x, 1, 1, y, 1, 1, z, 1, 1 );
// z => <Float64Array>[ 0.0, -3.0, 6.0, -3.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var Float64Array = require( '@stdlib/array/float64' );
var dcross = require( '@stdlib/blas/ext/base/dcross' );

var x = discreteUniform( 3, -100, 100, {
'dtype': 'float64'
});
console.log( x );

var y = discreteUniform( 3, -100, 100, {
'dtype': 'float64'
});
console.log( y );

var z = new Float64Array( 3 );

dcross( x, 1, y, 1, z, 1 );
console.log( z );
```

</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/dcross.h"
```

#### stdlib_strided_dcross( \*X, strideX, \*Y, strideY, \*Z, strideZ )

Computes the cross product of two double-precision floating-point input strided arrays and assigns the results to an output strided array.

```c
const double x[] = { 1.0, 2.0, 3.0 };
const double y[] = { 4.0, 5.0, 6.0 };
double z[] = { 0.0, 0.0, 0.0 };

stdlib_strided_dcross( x, 1, y, 1, z, 1 );
```

The function accepts the following arguments:

- **X**: `[in] double*` first input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **Y**: `[in] double*` second input array.
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
- **Z**: `[out] double*` output array.
- **strideZ**: `[in] CBLAS_INT` stride length for `Z`.

```c
void stdlib_strided_dcross( const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *Z, const CBLAS_INT strideZ );
```

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

#### stdlib_strided_dcross_ndarray( \*X, strideX, offsetX, \*Y, strideY, offsetY, \*Z, strideZ, offsetZ )

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

Computes the cross product of two double-precision floating-point input strided arrays and assigns the results to an output strided array using alternative indexing semantics.

```c
const double x[] = { 1.0, 2.0, 3.0 };
const double y[] = { 4.0, 5.0, 6.0 };
double z[] = { 0.0, 0.0, 0.0 };

stdlib_strided_dcross_ndarray( x, 1, 0, y, 1, 0, z, 1, 0 );
```

The function accepts the following arguments:

- **X**: `[in] double*` first input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
- **Y**: `[in] double*` second input array.
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
- **Z**: `[out] double*` output array.
- **strideZ**: `[in] CBLAS_INT` stride length for `Z`.
- **offsetZ**: `[in] CBLAS_INT` starting index for `Z`.

```c
void stdlib_strided_dcross_ndarray( const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *Z, const CBLAS_INT strideZ, const CBLAS_INT offsetZ );
```

</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/dcross.h"
#include <stdio.h>

int main( void ) {
// Create strided input arrays:
const double x[] = { 1.0, 2.0, 3.0 };
const double y[] = { 4.0, 5.0, 6.0 };

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

// Specify strides:
const int strideX = 1;
const int strideY = 1;
const int strideZ = 1;

// Compute the cross product:
stdlib_strided_dcross( x, strideX, y, strideY, z, strideZ );

// Print the result:
for ( int i = 0; i < 3; i++ ) {
printf( "z[ %i ] = %lf\n", i, z[ i ] );
}
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

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