|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 The Stdlib Authors. |
| 6 | +
|
| 7 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +you may not use this file except in compliance with the License. |
| 9 | +You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | +Unless required by applicable law or agreed to in writing, software |
| 14 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +See the License for the specific language governing permissions and |
| 17 | +limitations under the License. |
| 18 | +
|
| 19 | +--> |
| 20 | + |
| 21 | +# complementShape |
| 22 | + |
| 23 | +> Return the shape defined by the dimensions which are not included in a list of dimensions. |
| 24 | +
|
| 25 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 26 | + |
| 27 | +<section class="intro"> |
| 28 | + |
| 29 | +</section> |
| 30 | + |
| 31 | +<!-- /.intro --> |
| 32 | + |
| 33 | +<!-- Package usage documentation. --> |
| 34 | + |
| 35 | +<section class="usage"> |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```javascript |
| 40 | +var complementShape = require( '@stdlib/ndarray/base/complement-shape' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### complementShape( shape, dims ) |
| 44 | + |
| 45 | +Returns the shape defined by the dimensions which are not included in a list of dimensions. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var sh = complementShape( [ 3, 2 ], [ -1 ] ); |
| 49 | +// returns [ 3 ] |
| 50 | +``` |
| 51 | + |
| 52 | +The function accepts the following parameters: |
| 53 | + |
| 54 | +- **shape**: array shape. |
| 55 | +- **dims**: list of dimensions. |
| 56 | + |
| 57 | +</section> |
| 58 | + |
| 59 | +<!-- /.usage --> |
| 60 | + |
| 61 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 62 | + |
| 63 | +<section class="notes"> |
| 64 | + |
| 65 | +</section> |
| 66 | + |
| 67 | +<!-- /.notes --> |
| 68 | + |
| 69 | +<!-- Package usage examples. --> |
| 70 | + |
| 71 | +<section class="examples"> |
| 72 | + |
| 73 | +## Examples |
| 74 | + |
| 75 | +<!-- eslint no-undef: "error" --> |
| 76 | + |
| 77 | +```javascript |
| 78 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 79 | +var zip = require( '@stdlib/array/base/zip' ); |
| 80 | +var filled = require( '@stdlib/array/base/filled' ); |
| 81 | +var logEachMap = require( '@stdlib/console/log-each-map' ); |
| 82 | +var complementShape = require( '@stdlib/ndarray/base/complement-shape' ); |
| 83 | + |
| 84 | +var opts = { |
| 85 | + 'dtype': 'int32' |
| 86 | +}; |
| 87 | +var d1 = discreteUniform( 100, 1, 10, opts ); |
| 88 | +var d2 = discreteUniform( d1.length, 1, 10, opts ); |
| 89 | +var d3 = discreteUniform( d1.length, 1, 10, opts ); |
| 90 | +var d4 = discreteUniform( d1.length, 1, 10, opts ); |
| 91 | + |
| 92 | +var dims = discreteUniform( 2, -4, 3, opts ); |
| 93 | +var shapes = zip( [ d1, d2, d3, d4 ] ); |
| 94 | + |
| 95 | +logEachMap( 'shape: (%s). dims: (%s). complement: (%s).', shapes, filled( dims, d1.length ), complementShape ); |
| 96 | +``` |
| 97 | + |
| 98 | +</section> |
| 99 | + |
| 100 | +<!-- /.examples --> |
| 101 | + |
| 102 | +<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 103 | + |
| 104 | +<section class="references"> |
| 105 | + |
| 106 | +</section> |
| 107 | + |
| 108 | +<!-- /.references --> |
| 109 | + |
| 110 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 111 | + |
| 112 | +<section class="related"> |
| 113 | + |
| 114 | +</section> |
| 115 | + |
| 116 | +<!-- /.related --> |
| 117 | + |
| 118 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 119 | + |
| 120 | +<section class="links"> |
| 121 | + |
| 122 | +</section> |
| 123 | + |
| 124 | +<!-- /.links --> |
0 commit comments