Skip to content

Commit afcc970

Browse files
committed
feat(WIP): create main.js and index.js
1 parent 8af00b1 commit afcc970

2 files changed

Lines changed: 595 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
/**
22+
* Apply a condition to elements in two input ndarrays and assign results to elements in an output ndarray.
23+
*
24+
* @module @stdlib/ndarray/base/where
25+
*
26+
* @example
27+
* var Float64Array = require( '@stdlib/array/float64' );
28+
* var Uint8Array = require( '@stdlib/array/uint8' );
29+
* var where = require( '@stdlib/ndarray/base/where' );
30+
*
31+
* // Create data buffers:
32+
* var cbuf = new Uint8Array( [ 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1 ] );
33+
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
34+
* var ybuf = new Float64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0, -10.0, -11.0, -12.0 ] );
35+
* var obuf = new Float64Array( 6 );
36+
*
37+
* // Define the shape of the input and output arrays:
38+
* var shape = [ 3, 1, 2 ];
39+
*
40+
* // Define the array strides:
41+
* var sc = [ 4, 4, 1 ];
42+
* var sx = [ 4, 4, 1 ];
43+
* var sy = [ 4, 4, 1 ];
44+
* var so = [ 2, 2, 1 ];
45+
*
46+
* // Define the index offsets:
47+
* var oc = 1;
48+
* var ox = 1;
49+
* var oy = 1;
50+
* var oo = 0;
51+
*
52+
* // Create the input and output ndarray-like objects:
53+
* var condition = {
54+
* 'dtype': 'uint8',
55+
* 'data': cbuf,
56+
* 'shape': shape,
57+
* 'strides': sc,
58+
* 'offset': oc,
59+
* 'order': 'row-major'
60+
* };
61+
* var x = {
62+
* 'dtype': 'float64',
63+
* 'data': xbuf,
64+
* 'shape': shape,
65+
* 'strides': sx,
66+
* 'offset': ox,
67+
* 'order': 'row-major'
68+
* };
69+
* var y = {
70+
* 'dtype': 'float64',
71+
* 'data': ybuf,
72+
* 'shape': shape,
73+
* 'strides': sy,
74+
* 'offset': oy,
75+
* 'order': 'row-major'
76+
* };
77+
* var out = {
78+
* 'dtype': 'float64',
79+
* 'data': obuf,
80+
* 'shape': shape,
81+
* 'strides': so,
82+
* 'offset': oo,
83+
* 'order': 'row-major'
84+
* };
85+
*
86+
* // Apply the condition:
87+
* where( [ condition, x, y, out ] );
88+
*
89+
* console.log( out.data );
90+
* // => <Float64Array>[ -2.0, -3.0, 6.0, 7.0, -10.0, -11.0 ]
91+
*/
92+
93+
// MODULES //
94+
95+
var main = require( './main.js' );
96+
97+
98+
// EXPORTS //
99+
100+
module.exports = main;

0 commit comments

Comments
 (0)