diff --git a/ndarray/base/coverage.ndjson b/ndarray/base/coverage.ndjson new file mode 100644 index 000000000..901a0ac5e --- /dev/null +++ b/ndarray/base/coverage.ndjson @@ -0,0 +1 @@ +[631,631,100,1,1,100,0,0,100,631,631,100,"fcbe4c18fd4ebfad0466b56b4c19abda6cdb4c2b","2023-09-26 14:05:25 -0700"] diff --git a/ndarray/base/index.html b/ndarray/base/index.html new file mode 100644 index 000000000..01cd1743d --- /dev/null +++ b/ndarray/base/index.html @@ -0,0 +1,116 @@ + + + + +
++ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
index.js | +
+
+ |
+ 100% | +631/631 | +100% | +1/1 | +100% | +0/0 | +100% | +631/631 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2018 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. +*/ + +'use strict'; + +/* +* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. +*/ + +/* +* The following modules are intentionally not exported: function-object, napi, unary +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); + + +// MAIN // + +/** +* Top-level namespace. +* +* @namespace ns +*/ +var ns = {}; + +/** +* @name assert +* @memberof ns +* @readonly +* @type {Namespace} +* @see {@link module:@stdlib/ndarray/base/assert} +*/ +setReadOnly( ns, 'assert', require( '@stdlib/ndarray/base/assert' ) ); + +/** +* @name binaryLoopOrder +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/binary-loop-interchange-order} +*/ +setReadOnly( ns, 'binaryLoopOrder', require( '@stdlib/ndarray/base/binary-loop-interchange-order' ) ); + +/** +* @name binaryBlockSize +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/binary-tiling-block-size} +*/ +setReadOnly( ns, 'binaryBlockSize', require( '@stdlib/ndarray/base/binary-tiling-block-size' ) ); + +/** +* @name bind2vind +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/bind2vind} +*/ +setReadOnly( ns, 'bind2vind', require( '@stdlib/ndarray/base/bind2vind' ) ); + +/** +* @name broadcastArray +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/broadcast-array} +*/ +setReadOnly( ns, 'broadcastArray', require( '@stdlib/ndarray/base/broadcast-array' ) ); + +/** +* @name broadcastScalar +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/broadcast-scalar} +*/ +setReadOnly( ns, 'broadcastScalar', require( '@stdlib/ndarray/base/broadcast-scalar' ) ); + +/** +* @name broadcastShapes +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/broadcast-shapes} +*/ +setReadOnly( ns, 'broadcastShapes', require( '@stdlib/ndarray/base/broadcast-shapes' ) ); + +/** +* @name buffer +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/buffer} +*/ +setReadOnly( ns, 'buffer', require( '@stdlib/ndarray/base/buffer' ) ); + +/** +* @name bufferCtors +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/buffer-ctors} +*/ +setReadOnly( ns, 'bufferCtors', require( '@stdlib/ndarray/base/buffer-ctors' ) ); + +/** +* @name bufferDataType +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/buffer-dtype} +*/ +setReadOnly( ns, 'bufferDataType', require( '@stdlib/ndarray/base/buffer-dtype' ) ); + +/** +* @name bufferDataTypeEnum +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/buffer-dtype-enum} +*/ +setReadOnly( ns, 'bufferDataTypeEnum', require( '@stdlib/ndarray/base/buffer-dtype-enum' ) ); + +/** +* @name bytesPerElement +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/bytes-per-element} +*/ +setReadOnly( ns, 'bytesPerElement', require( '@stdlib/ndarray/base/bytes-per-element' ) ); + +/** +* @name char2dtype +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/char2dtype} +*/ +setReadOnly( ns, 'char2dtype', require( '@stdlib/ndarray/base/char2dtype' ) ); + +/** +* @name clampIndex +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/clamp-index} +*/ +setReadOnly( ns, 'clampIndex', require( '@stdlib/ndarray/base/clamp-index' ) ); + +/** +* @name ndarray +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/ctor} +*/ +setReadOnly( ns, 'ndarray', require( '@stdlib/ndarray/base/ctor' ) ); + +/** +* @name dtypeChar +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/dtype-char} +*/ +setReadOnly( ns, 'dtypeChar', require( '@stdlib/ndarray/base/dtype-char' ) ); + +/** +* @name dtypeDesc +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/dtype-desc} +*/ +setReadOnly( ns, 'dtypeDesc', require( '@stdlib/ndarray/base/dtype-desc' ) ); + +/** +* @name dtypeEnum2Str +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/dtype-enum2str} +*/ +setReadOnly( ns, 'dtypeEnum2Str', require( '@stdlib/ndarray/base/dtype-enum2str' ) ); + +/** +* @name dtypeResolveEnum +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/dtype-resolve-enum} +*/ +setReadOnly( ns, 'dtypeResolveEnum', require( '@stdlib/ndarray/base/dtype-resolve-enum' ) ); + +/** +* @name dtypeResolveStr +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/dtype-resolve-str} +*/ +setReadOnly( ns, 'dtypeResolveStr', require( '@stdlib/ndarray/base/dtype-resolve-str' ) ); + +/** +* @name dtypeStr2Enum +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/dtype-str2enum} +*/ +setReadOnly( ns, 'dtypeStr2Enum', require( '@stdlib/ndarray/base/dtype-str2enum' ) ); + +/** +* @name dtype2c +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/dtype2c} +*/ +setReadOnly( ns, 'dtype2c', require( '@stdlib/ndarray/base/dtype2c' ) ); + +/** +* @name dtypes2signatures +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/dtypes2signatures} +*/ +setReadOnly( ns, 'dtypes2signatures', require( '@stdlib/ndarray/base/dtypes2signatures' ) ); + +/** +* @name empty +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/empty} +*/ +setReadOnly( ns, 'empty', require( '@stdlib/ndarray/base/empty' ) ); + +/** +* @name emptyLike +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/empty-like} +*/ +setReadOnly( ns, 'emptyLike', require( '@stdlib/ndarray/base/empty-like' ) ); + +/** +* @name expandDimensions +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/expand-dimensions} +*/ +setReadOnly( ns, 'expandDimensions', require( '@stdlib/ndarray/base/expand-dimensions' ) ); + +/** +* @name scalar2ndarray +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/from-scalar} +*/ +setReadOnly( ns, 'scalar2ndarray', require( '@stdlib/ndarray/base/from-scalar' ) ); + +/** +* @name ind +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/ind} +*/ +setReadOnly( ns, 'ind', require( '@stdlib/ndarray/base/ind' ) ); + +/** +* @name ind2sub +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/ind2sub} +*/ +setReadOnly( ns, 'ind2sub', require( '@stdlib/ndarray/base/ind2sub' ) ); + +/** +* @name iterationOrder +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/iteration-order} +*/ +setReadOnly( ns, 'iterationOrder', require( '@stdlib/ndarray/base/iteration-order' ) ); + +/** +* @name maxViewBufferIndex +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/max-view-buffer-index} +*/ +setReadOnly( ns, 'maxViewBufferIndex', require( '@stdlib/ndarray/base/max-view-buffer-index' ) ); + +/** +* @name maybeBroadcastArray +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/maybe-broadcast-array} +*/ +setReadOnly( ns, 'maybeBroadcastArray', require( '@stdlib/ndarray/base/maybe-broadcast-array' ) ); + +/** +* @name metaDataProps +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/meta-data-props} +*/ +setReadOnly( ns, 'metaDataProps', require( '@stdlib/ndarray/base/meta-data-props' ) ); + +/** +* @name minViewBufferIndex +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/min-view-buffer-index} +*/ +setReadOnly( ns, 'minViewBufferIndex', require( '@stdlib/ndarray/base/min-view-buffer-index' ) ); + +/** +* @name minmaxViewBufferIndex +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/minmax-view-buffer-index} +*/ +setReadOnly( ns, 'minmaxViewBufferIndex', require( '@stdlib/ndarray/base/minmax-view-buffer-index' ) ); + +/** +* @name ndarraylike2object +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/ndarraylike2object} +*/ +setReadOnly( ns, 'ndarraylike2object', require( '@stdlib/ndarray/base/ndarraylike2object' ) ); + +/** +* @name nonsingletonDimensions +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/nonsingleton-dimensions} +*/ +setReadOnly( ns, 'nonsingletonDimensions', require( '@stdlib/ndarray/base/nonsingleton-dimensions' ) ); + +/** +* @name nullary +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/nullary} +*/ +setReadOnly( ns, 'nullary', require( '@stdlib/ndarray/base/nullary' ) ); + +/** +* @name nullaryLoopOrder +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/nullary-loop-interchange-order} +*/ +setReadOnly( ns, 'nullaryLoopOrder', require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ) ); + +/** +* @name nullaryBlockSize +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/nullary-tiling-block-size} +*/ +setReadOnly( ns, 'nullaryBlockSize', require( '@stdlib/ndarray/base/nullary-tiling-block-size' ) ); + +/** +* @name numel +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/numel} +*/ +setReadOnly( ns, 'numel', require( '@stdlib/ndarray/base/numel' ) ); + +/** +* @name outputPolicyEnum2Str +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/output-policy-enum2str} +*/ +setReadOnly( ns, 'outputPolicyEnum2Str', require( '@stdlib/ndarray/base/output-policy-enum2str' ) ); + +/** +* @name outputPolicyResolveEnum +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/output-policy-resolve-enum} +*/ +setReadOnly( ns, 'outputPolicyResolveEnum', require( '@stdlib/ndarray/base/output-policy-resolve-enum' ) ); + +/** +* @name outputPolicyResolveStr +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/output-policy-resolve-str} +*/ +setReadOnly( ns, 'outputPolicyResolveStr', require( '@stdlib/ndarray/base/output-policy-resolve-str' ) ); + +/** +* @name outputPolicyStr2Enum +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/output-policy-str2enum} +*/ +setReadOnly( ns, 'outputPolicyStr2Enum', require( '@stdlib/ndarray/base/output-policy-str2enum' ) ); + +/** +* @name prependSingletonDimensions +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/prepend-singleton-dimensions} +*/ +setReadOnly( ns, 'prependSingletonDimensions', require( '@stdlib/ndarray/base/prepend-singleton-dimensions' ) ); + +/** +* @name removeSingletonDimensions +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/remove-singleton-dimensions} +*/ +setReadOnly( ns, 'removeSingletonDimensions', require( '@stdlib/ndarray/base/remove-singleton-dimensions' ) ); + +/** +* @name serializeMetaData +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/serialize-meta-data} +*/ +setReadOnly( ns, 'serializeMetaData', require( '@stdlib/ndarray/base/serialize-meta-data' ) ); + +/** +* @name shape2strides +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/shape2strides} +*/ +setReadOnly( ns, 'shape2strides', require( '@stdlib/ndarray/base/shape2strides' ) ); + +/** +* @name singletonDimensions +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/singleton-dimensions} +*/ +setReadOnly( ns, 'singletonDimensions', require( '@stdlib/ndarray/base/singleton-dimensions' ) ); + +/** +* @name slice +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/slice} +*/ +setReadOnly( ns, 'slice', require( '@stdlib/ndarray/base/slice' ) ); + +/** +* @name strides2offset +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/strides2offset} +*/ +setReadOnly( ns, 'strides2offset', require( '@stdlib/ndarray/base/strides2offset' ) ); + +/** +* @name strides2order +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/strides2order} +*/ +setReadOnly( ns, 'strides2order', require( '@stdlib/ndarray/base/strides2order' ) ); + +/** +* @name sub2ind +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/sub2ind} +*/ +setReadOnly( ns, 'sub2ind', require( '@stdlib/ndarray/base/sub2ind' ) ); + +/** +* @name ndarray2array +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/to-array} +*/ +setReadOnly( ns, 'ndarray2array', require( '@stdlib/ndarray/base/to-array' ) ); + +/** +* @name transpose +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/transpose} +*/ +setReadOnly( ns, 'transpose', require( '@stdlib/ndarray/base/transpose' ) ); + +/** +* @name unary +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/unary} +*/ +setReadOnly( ns, 'unary', require( '@stdlib/ndarray/base/unary' ) ); + +/** +* @name unaryBy +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/unary-by} +*/ +setReadOnly( ns, 'unaryBy', require( '@stdlib/ndarray/base/unary-by' ) ); + +/** +* @name unaryLoopOrder +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/unary-loop-interchange-order} +*/ +setReadOnly( ns, 'unaryLoopOrder', require( '@stdlib/ndarray/base/unary-loop-interchange-order' ) ); + +/** +* @name unaryOutputDataType +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/unary-output-dtype} +*/ +setReadOnly( ns, 'unaryOutputDataType', require( '@stdlib/ndarray/base/unary-output-dtype' ) ); + +/** +* @name unaryBlockSize +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/unary-tiling-block-size} +*/ +setReadOnly( ns, 'unaryBlockSize', require( '@stdlib/ndarray/base/unary-tiling-block-size' ) ); + +/** +* @name vind2bind +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/vind2bind} +*/ +setReadOnly( ns, 'vind2bind', require( '@stdlib/ndarray/base/vind2bind' ) ); + +/** +* @name wrapIndex +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/wrap-index} +*/ +setReadOnly( ns, 'wrapIndex', require( '@stdlib/ndarray/base/wrap-index' ) ); + +/** +* @name zeros +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/zeros} +*/ +setReadOnly( ns, 'zeros', require( '@stdlib/ndarray/base/zeros' ) ); + +/** +* @name zerosLike +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/zeros-like} +*/ +setReadOnly( ns, 'zerosLike', require( '@stdlib/ndarray/base/zeros-like' ) ); + + +// EXPORTS // + +module.exports = ns; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + + + + + + + + + + + + +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +'use strict'; + +// MODULES // + +var buffer = require( '@stdlib/ndarray/base/buffer' ); +var zeros = require( '@stdlib/array/base/zeros' ); +var options = require( './options.js' ); + + +// MAIN // + +/** +* Returns an empty n-dimensional ndarray. +* +* @private +* @param {Function} ctor - ndarray constructor +* @param {string} dtype - array data type +* @param {NonNegativeIntegerArray} shape - array shape +* @param {string} order - layout order +* @returns {ndarray} empty ndarray +*/ +function empty( ctor, dtype, shape, order ) { + var strides; + var ndims; + + ndims = shape.length; + if ( ndims === 0 ) { + strides = [ 0 ]; + } else { + strides = zeros( ndims ); + } + return new ctor( dtype, buffer( dtype, 0 ), shape, strides, 0, order, options() ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = empty; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
empty.js | +
+
+ |
+ 78.57% | +44/56 | +100% | +1/1 | +0% | +0/1 | +78.57% | +44/56 | +
index.js | +
+
+ |
+ 100% | +67/67 | +100% | +1/1 | +100% | +0/0 | +100% | +67/67 | +
main.js | +
+
+ |
+ 52.79% | +85/161 | +100% | +1/1 | +0% | +0/1 | +52.79% | +85/161 | +
options.js | +
+
+ |
+ 84.61% | +33/39 | +100% | +1/1 | +0% | +0/1 | +84.61% | +33/39 | +
slice_start.js | +
+
+ |
+ 77.96% | +46/59 | +100% | +1/1 | +0% | +0/1 | +77.96% | +46/59 | +
slice_strides.js | +
+
+ |
+ 76.66% | +46/60 | +100% | +1/1 | +0% | +0/1 | +76.66% | +46/60 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +'use strict'; + +/** +* Return a read-only view of an input ndarray. +* +* @module @stdlib/ndarray/base/slice +* +* @example +* var Slice = require( '@stdlib/slice/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var slice = require( '@stdlib/ndarray/base/slice' ); +* +* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* var shape = [ 3, 2 ]; +* var strides = [ 2, 1 ]; +* var offset = 0; +* +* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); +* // returns <ndarray> +* +* var sh = x.shape; +* // returns [ 3, 2 ] +* +* var arr = ndarray2array( x ); +* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) ); +* // returns <MultiSlice> +* +* var y = slice( x, s, false ); +* // returns <ndarray> +* +* sh = y.shape; +* // returns [ 2, 2 ] +* +* arr = ndarray2array( y ); +* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +'use strict'; + +// MODULES // + +var normalizeMultiSlice = require( '@stdlib/slice/base/normalize-multi-slice' ); +var nonreducedDimensions = require( '@stdlib/slice/base/nonreduced-dimensions' ); +var sliceShape = require( '@stdlib/slice/base/shape' ); +var take = require( '@stdlib/array/base/take' ); +var zeros = require( '@stdlib/array/base/zeros' ); +var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var format = require( '@stdlib/string/format' ); +var sliceStart = require( './slice_start.js' ); +var slice2strides = require( './slice_strides.js' ); +var options = require( './options.js' ); +var empty = require( './empty.js' ); + + +// MAIN // + +/** +* Returns a read-only view of an input ndarray. +* +* @param {ndarray} x - input array +* @param {MultiSlice} s - multi-slice object +* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking +* @throws {RangeError} number of slice dimensions must match the number of array dimensions +* @throws {RangeError} slice exceeds array bounds +* @returns {ndarray} ndarray view +* +* @example +* var Slice = require( '@stdlib/slice/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* var shape = [ 3, 2 ]; +* var strides = [ 2, 1 ]; +* var offset = 0; +* +* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); +* // returns <ndarray> +* +* var sh = x.shape; +* // returns [ 3, 2 ] +* +* var arr = ndarray2array( x ); +* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) ); +* // returns <MultiSlice> +* +* var y = slice( x, s, false ); +* // returns <ndarray> +* +* sh = y.shape; +* // returns [ 2, 2 ] +* +* arr = ndarray2array( y ); +* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ] +*/ +function slice( x, s, strict ) { + var strides; + var offset; + var dtype; + var shape; + var order; + var sdims; + var ndims; + var ctor; + var sh; + var ns; + + // Retrieve array meta data: + dtype = x.dtype; + shape = x.shape; + strides = x.strides; + offset = x.offset; + order = x.order; + ndims = shape.length; + + // Ensure that the number of array dimensions matches the number of slices: + if ( s.ndims !== ndims ) { + throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', shape.join( ',' ), s.ndims ) ); + } + // Resolve the output array constructor: + ctor = x.constructor; + + // If provided a zero-dimensional input array, return a zero-dimensional array view... + if ( ndims === 0 ) { + return new ctor( dtype, x.data, shape, strides, offset, order, options() ); // eslint-disable-line max-len + } + // Resolve the indices of the non-reduced dimensions: + sdims = nonreducedDimensions( s ); + + // Normalize the slice object based on the array shape: + ns = normalizeMultiSlice( s, shape, true ); + + // Check whether the slice exceeds array bounds... + if ( ns.code ) { + if ( strict ) { + throw new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array shape: (%s).', shape.join( ',' ) ) ); + } + // Normalize again, this time allowing for out-of-bounds indices: + ns = normalizeMultiSlice( s, shape, false ); + + // Compute the slice shape: + sh = sliceShape( ns ); + + // If the non-reduced dimensions contain elements, this means that at least one reduced dimension exceeded array bounds; in which case, we generate a shape containing zeros: + if ( numel( take( sh, sdims ) ) > 0 ) { + sh = zeros( sh.length ); + } + } else { + // Compute the slice shape: + sh = sliceShape( ns ); + } + // If the slice does not contain any elements, return an empty array... + if ( numel( sh ) === 0 ) { + return empty( ctor, dtype, take( sh, sdims ), order ); + } + // Resolve the index offset of the first element indexed by the slice: + offset = vind2bind( shape, strides, offset, order, sliceStart( ns, shape, strides, 0 ), 'throw' ); // TODO: @stdlib/ndarray/base/sind2bind + + // Remove reduced dimensions from the slice shape: + sh = take( sh, sdims ); + + // If all dimensions were reduced, return a zero-dimensional array... + if ( sh.length === 0 ) { + return new ctor( dtype, x.data, [], [ 0 ], offset, order, options() ); + } + // Update strides according to slice steps: + strides = slice2strides( ns, strides, sdims ); // TODO: @stdlib/ndarray/base/slice2strides??? + + // Return a slice view: + return new ctor( dtype, x.data, sh, strides, offset, order, options() ); +} + + +// EXPORTS // + +module.exports = slice; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + + + + + + +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns array creation options. +* +* @private +* @returns {Object} options +*/ +function options() { + return { + // Default to always returning read-only arrays: + 'readonly': true + }; +} + + +// EXPORTS // + +module.exports = options; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + + + + + + + + + + + + + +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +'use strict'; + +// MODULES // + +var sub2ind = require( '@stdlib/ndarray/base/sub2ind' ); + + +// MAIN // + +/** +* Resolves the linear index of the first element indexed by a normalized multi-slice. +* +* ## Notes +* +* - If `strides` contains negative strides, if an `offset` is greater than `0`, the function returns a linear index with respect to the underlying data buffer. If an `offset` is equal to `0`, the function returns a linear index with respect to the array view. For more information, see `@stdlib/ndarray/base/sub2ind`. +* +* @private +* @param {MultiSlice} slice - normalized multi-slice object +* @param {NonNegativeIntegerArray} shape - array shape +* @param {IntegerArray} strides - array strides +* @param {NonNegativeInteger} offset - index offset +* @returns {NonNegativeInteger} linear index of the first element +*/ +function sliceStart( slice, shape, strides, offset ) { + var data; + var args; + var i; + + data = slice.data; + args = [ shape, strides, offset ]; + for ( i = 0; i < data.length; i++ ) { + args.push( data[ i ].start ); + } + args.push( 'throw' ); + return sub2ind.apply( null, args ); +} + + +// EXPORTS // + +module.exports = sliceStart; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + + + + + + + + + + + + + + +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +'use strict'; + +// MAIN // + +/** +* Resolves slice strides for a provided normalized multi-slice object. +* +* @private +* @param {MultiSlice} slice - normalized multi-slice object +* @param {IntegerArray} strides - array strides +* @param {NonNegativeIntegerArray} rdims - indices of non-reduced dimensions +* @returns {IntegerArray} slice strides +* +* @example +* var Slice = require( '@stdlib/slice/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* +* var s = new MultiSlice( new Slice( 2, 3, 1 ), new Slice( 10, null, -2 ) ); +* // returns <MultiSlice> +* +* var strides = slice2strides( s, [ 8, 2 ], [ 1 ] ); +* // returns [ -4 ] +*/ +function slice2strides( slice, strides, rdims ) { + var data; + var out; + var i; + var j; + + data = slice.data; + out = []; + for ( i = 0; i < rdims.length; i++ ) { + j = rdims[ i ]; + out.push( strides[j] * data[j].step ); + } + return out; +} + + +// EXPORTS // + +module.exports = slice2strides; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 | 2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + + + + + + + + + + +2x +2x +2x +2x +2x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +'use strict'; + +// MODULES // + +var isRangeError = require( '@stdlib/assert/is-range-error' ); +var isTypeError = require( '@stdlib/assert/is-type-error' ); +var isSyntaxError = require( '@stdlib/assert/is-syntax-error' ); + + +// MAIN // + +/** +* Returns the error constructor for a provided error object. +* +* @private +* @param {Error} err - error object +* @returns {Function} error constructor +*/ +function errConstructor( err ) { + if ( isRangeError( err ) ) { + return RangeError; + } + if ( isTypeError( err ) ) { + return TypeError; + } + if ( isSyntaxError( err ) ) { + return SyntaxError; + } + return Error; +} + + +// EXPORTS // + +module.exports = errConstructor; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 | 2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + +2x +2x +2x +2x +2x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +'use strict'; + +// MODULES // + +var replace = require( '@stdlib/string/base/replace' ); + + +// MAIN // + +/** +* Returns an updated error message for trapped errors. +* +* @private +* @param {string} msg - error message +* @returns {string} updated message +*/ +function errMessage( msg ) { + return replace( msg, /^invalid argument/, 'invalid operation' ); +} + + +// EXPORTS // + +module.exports = errMessage; + |