/* * @license Apache-2.0 * * Copyright (c) 2021 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. */ // TypeScript Version: 4.1 /* eslint-disable max-lines */ import any = require( './../../../base/any' ); import anyBy = require( './../../../base/any-by' ); import appendSingletonDimensions = require( './../../../base/append-singleton-dimensions' ); import assert = require( './../../../base/assert' ); import assign = require( './../../../base/assign' ); import assignScalar = require( './../../../base/assign-scalar' ); import atleast1d = require( './../../../base/atleast1d' ); import atleast2d = require( './../../../base/atleast2d' ); import atleast3d = require( './../../../base/atleast3d' ); import atleastnd = require( './../../../base/atleastnd' ); import binary = require( './../../../base/binary' ); import binaryInputCastingDataType = require( './../../../base/binary-input-casting-dtype' ); import binaryLoopOrder = require( './../../../base/binary-loop-interchange-order' ); import binaryOutputDataType = require( './../../../base/binary-output-dtype' ); import binaryReduceStrided1dDispatch = require( './../../../base/binary-reduce-strided1d-dispatch' ); import binaryReduceStrided1dDispatchFactory = require( './../../../base/binary-reduce-strided1d-dispatch-factory' ); import binaryBlockSize = require( './../../../base/binary-tiling-block-size' ); import bind2vind = require( './../../../base/bind2vind' ); import broadcastArray = require( './../../../base/broadcast-array' ); import broadcastArrayExceptDimensions = require( './../../../base/broadcast-array-except-dimensions' ); import broadcastArrays = require( './../../../base/broadcast-arrays' ); import broadcastScalar = require( './../../../base/broadcast-scalar' ); import broadcastScalarLike = require( './../../../base/broadcast-scalar-like' ); import broadcastShapes = require( './../../../base/broadcast-shapes' ); import buffer = require( './../../../base/buffer' ); import bufferCtors = require( './../../../base/buffer-ctors' ); import bufferDataType = require( './../../../base/buffer-dtype' ); import bufferDataTypeEnum = require( './../../../base/buffer-dtype-enum' ); import bytesPerElement = require( './../../../base/bytes-per-element' ); import char2dtype = require( './../../../base/char2dtype' ); import clampIndex = require( './../../../base/clamp-index' ); import complementShape = require( './../../../base/complement-shape' ); import consensusOrder = require( './../../../base/consensus-order' ); import copy = require( './../../../base/copy' ); import countFalsy = require( './../../../base/count-falsy' ); import countIf = require( './../../../base/count-if' ); import countTruthy = require( './../../../base/count-truthy' ); import ndarray = require( './../../../base/ctor' ); import data = require( './../../../base/data-buffer' ); import descriptor = require( './../../../base/descriptor' ); import diagonal = require( './../../../base/diagonal' ); import dtype = require( './../../../base/dtype' ); import dtypeAlignment = require( './../../../base/dtype-alignment' ); import dtypeChar = require( './../../../base/dtype-char' ); import dtypeChars = require( './../../../base/dtype-chars' ); import dtypeDesc = require( './../../../base/dtype-desc' ); import dtypeEnum2Str = require( './../../../base/dtype-enum2str' ); import dtypeEnums = require( './../../../base/dtype-enums' ); import dtypeObjects = require( './../../../base/dtype-objects' ); import dtypeResolveEnum = require( './../../../base/dtype-resolve-enum' ); import dtypeResolveStr = require( './../../../base/dtype-resolve-str' ); import dtypeStr2Enum = require( './../../../base/dtype-str2enum' ); import dtypeStrings = require( './../../../base/dtype-strings' ); import dtype2c = require( './../../../base/dtype2c' ); import dtypes2enums = require( './../../../base/dtypes2enums' ); import dtypes2signatures = require( './../../../base/dtypes2signatures' ); import dtypes2strings = require( './../../../base/dtypes2strings' ); import empty = require( './../../../base/empty' ); import emptyLike = require( './../../../base/empty-like' ); import every = require( './../../../base/every' ); import everyBy = require( './../../../base/every-by' ); import expandDimensions = require( './../../../base/expand-dimensions' ); import falses = require( './../../../base/falses' ); import falsesLike = require( './../../../base/falses-like' ); import fill = require( './../../../base/fill' ); import fillBy = require( './../../../base/fill-by' ); import fillDiagonal = require( './../../../base/fill-diagonal' ); import find = require( './../../../base/find' ); import flag = require( './../../../base/flag' ); import flags = require( './../../../base/flags' ); import flattenShape = require( './../../../base/flatten-shape' ); import flattenShapeFrom = require( './../../../base/flatten-shape-from' ); import fliplr = require( './../../../base/fliplr' ); import flipud = require( './../../../base/flipud' ); import forEach = require( './../../../base/for-each' ); import array2ndarray = require( './../../../base/from-array' ); import scalar2ndarray = require( './../../../base/from-scalar' ); import scalar2ndarrayLike = require( './../../../base/from-scalar-like' ); import full = require( './../../../base/full' ); import fullBy = require( './../../../base/full-by' ); import includes = require( './../../../base/includes' ); import ind = require( './../../../base/ind' ); import ind2sub = require( './../../../base/ind2sub' ); import iterationOrder = require( './../../../base/iteration-order' ); import loopOrder = require( './../../../base/loop-interchange-order' ); import map = require( './../../../base/map' ); import maxViewBufferIndex = require( './../../../base/max-view-buffer-index' ); import maybeBroadcastArray = require( './../../../base/maybe-broadcast-array' ); import maybeBroadcastArrayExceptDimensions = require( './../../../base/maybe-broadcast-array-except-dimensions' ); import maybeBroadcastArrays = require( './../../../base/maybe-broadcast-arrays' ); import metaDataProps = require( './../../../base/meta-data-props' ); import minSignedIntegerDataType = require( './../../../base/min-signed-integer-dtype' ); import minUnsignedIntegerDataType = require( './../../../base/min-unsigned-integer-dtype' ); import minViewBufferIndex = require( './../../../base/min-view-buffer-index' ); import minmaxViewBufferIndex = require( './../../../base/minmax-view-buffer-index' ); import nans = require( './../../../base/nans' ); import nansLike = require( './../../../base/nans-like' ); import ndarraylike2descriptor = require( './../../../base/ndarraylike2descriptor' ); import ndarraylike2ndarray = require( './../../../base/ndarraylike2ndarray' ); import ndarraylike2object = require( './../../../base/ndarraylike2object' ); import ndarraylike2scalar = require( './../../../base/ndarraylike2scalar' ); import ndims = require( './../../../base/ndims' ); import nextCartesianIndex = require( './../../../base/next-cartesian-index' ); import nonsingletonDimensions = require( './../../../base/nonsingleton-dimensions' ); import normalizeIndex = require( './../../../base/normalize-index' ); import normalizeIndices = require( './../../../base/normalize-indices' ); import nullary = require( './../../../base/nullary' ); import nullaryLoopOrder = require( './../../../base/nullary-loop-interchange-order' ); import nullaryStrided1dDispatch = require( './../../../base/nullary-strided1d-dispatch' ); import nullaryStrided1dDispatchFactory = require( './../../../base/nullary-strided1d-dispatch-factory' ); import nullaryBlockSize = require( './../../../base/nullary-tiling-block-size' ); import nulls = require( './../../../base/nulls' ); import nullsLike = require( './../../../base/nulls-like' ); import numel = require( './../../../base/numel' ); import numelDimension = require( './../../../base/numel-dimension' ); import offset = require( './../../../base/offset' ); import ones = require( './../../../base/ones' ); import onesLike = require( './../../../base/ones-like' ); import order = require( './../../../base/order' ); import outputDataType = require( './../../../base/output-dtype' ); import outputOrder = require( './../../../base/output-order' ); import outputPolicyEnum2Str = require( './../../../base/output-policy-enum2str' ); import outputPolicyResolveEnum = require( './../../../base/output-policy-resolve-enum' ); import outputPolicyResolveStr = require( './../../../base/output-policy-resolve-str' ); import outputPolicyStr2Enum = require( './../../../base/output-policy-str2enum' ); import pop = require( './../../../base/pop' ); import prependSingletonDimensions = require( './../../../base/prepend-singleton-dimensions' ); import promoteDataTypes = require( './../../../base/promote-dtypes' ); import quaternaryLoopOrder = require( './../../../base/quaternary-loop-interchange-order' ); import quaternaryBlockSize = require( './../../../base/quaternary-tiling-block-size' ); import quinaryLoopOrder = require( './../../../base/quinary-loop-interchange-order' ); import quinaryBlockSize = require( './../../../base/quinary-tiling-block-size' ); import reinterpretBoolean = require( './../../../base/reinterpret-boolean' ); import reinterpretComplex = require( './../../../base/reinterpret-complex' ); import reinterpretComplex64 = require( './../../../base/reinterpret-complex64' ); import reinterpretComplex128 = require( './../../../base/reinterpret-complex128' ); import removeSingletonDimensions = require( './../../../base/remove-singleton-dimensions' ); import reverse = require( './../../../base/reverse' ); import reverseDimension = require( './../../../base/reverse-dimension' ); import reverseDimensions = require( './../../../base/reverse-dimensions' ); import rot90 = require( './../../../base/rot90' ); import rot180 = require( './../../../base/rot180' ); import rotl90 = require( './../../../base/rotl90' ); import rotr90 = require( './../../../base/rotr90' ); import serializeMetaData = require( './../../../base/serialize-meta-data' ); import shape = require( './../../../base/shape' ); import shape2strides = require( './../../../base/shape2strides' ); import shift = require( './../../../base/shift' ); import singletonDimensions = require( './../../../base/singleton-dimensions' ); import slice = require( './../../../base/slice' ); import sliceAssign = require( './../../../base/slice-assign' ); import sliceDimension = require( './../../../base/slice-dimension' ); import sliceDimensionFrom = require( './../../../base/slice-dimension-from' ); import sliceDimensionTo = require( './../../../base/slice-dimension-to' ); import sliceFrom = require( './../../../base/slice-from' ); import sliceTo = require( './../../../base/slice-to' ); import some = require( './../../../base/some' ); import someBy = require( './../../../base/some-by' ); import spreadDimensions = require( './../../../base/spread-dimensions' ); import stride = require( './../../../base/stride' ); import strides = require( './../../../base/strides' ); import strides2offset = require( './../../../base/strides2offset' ); import strides2order = require( './../../../base/strides2order' ); import sub2ind = require( './../../../base/sub2ind' ); import ternary = require( './../../../base/ternary' ); import ternaryLoopOrder = require( './../../../base/ternary-loop-interchange-order' ); import ternaryOutputDataType = require( './../../../base/ternary-output-dtype' ); import ternaryBlockSize = require( './../../../base/ternary-tiling-block-size' ); import tile = require( './../../../base/tile' ); import blockSize = require( './../../../base/tiling-block-size' ); import ndarray2array = require( './../../../base/to-array' ); import toFlippedlr = require( './../../../base/to-flippedlr' ); import toFlippedud = require( './../../../base/to-flippedud' ); import toNormalizedIndices = require( './../../../base/to-normalized-indices' ); import toReversed = require( './../../../base/to-reversed' ); import toReversedDimension = require( './../../../base/to-reversed-dimension' ); import toReversedDimensions = require( './../../../base/to-reversed-dimensions' ); import toRot90 = require( './../../../base/to-rot90' ); import toRot180 = require( './../../../base/to-rot180' ); import toRotl90 = require( './../../../base/to-rotl90' ); import toRotr90 = require( './../../../base/to-rotr90' ); import toTransposed = require( './../../../base/to-transposed' ); import toUnflattened = require( './../../../base/to-unflattened' ); import toUniqueNormalizedIndices = require( './../../../base/to-unique-normalized-indices' ); import transpose = require( './../../../base/transpose' ); import trues = require( './../../../base/trues' ); import truesLike = require( './../../../base/trues-like' ); import unary = require( './../../../base/unary' ); import unaryAccumulate = require( './../../../base/unary-accumulate' ); import unaryAddonDispatch = require( './../../../base/unary-addon-dispatch' ); import unaryBy = require( './../../../base/unary-by' ); import unaryInputCastingDataType = require( './../../../base/unary-input-casting-dtype' ); import unaryLoopOrder = require( './../../../base/unary-loop-interchange-order' ); import unaryOutputDataType = require( './../../../base/unary-output-dtype' ); import unaryReduceStrided1dDispatch = require( './../../../base/unary-reduce-strided1d-dispatch' ); import unaryReduceStrided1dDispatchBy = require( './../../../base/unary-reduce-strided1d-dispatch-by' ); import unaryReduceStrided1dDispatchByFactory = require( './../../../base/unary-reduce-strided1d-dispatch-by-factory' ); import unaryReduceStrided1dDispatchFactory = require( './../../../base/unary-reduce-strided1d-dispatch-factory' ); import unaryReduceSubarrayBy = require( './../../../base/unary-reduce-subarray-by' ); import unaryStrided1dDispatch = require( './../../../base/unary-strided1d-dispatch' ); import unaryStrided1dDispatchFactory = require( './../../../base/unary-strided1d-dispatch-factory' ); import unaryBlockSize = require( './../../../base/unary-tiling-block-size' ); import unflatten = require( './../../../base/unflatten' ); import unflattenShape = require( './../../../base/unflatten-shape' ); import vind2bind = require( './../../../base/vind2bind' ); import wrapIndex = require( './../../../base/wrap-index' ); import zeros = require( './../../../base/zeros' ); import zerosLike = require( './../../../base/zeros-like' ); import zip2views1d = require( './../../../base/zip2views1d' ); /** * Interface describing the `base` namespace. */ interface Namespace { /** * Tests whether at least one element in an ndarray is truthy. * * @param arrays - array-like object containing an input ndarray * @returns boolean indicating whether at least one element is truthy * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../base/ctor' ); * * // Create a data buffer: * 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 ] ); * * // Define the shape of the array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Test elements: * var out = ns.any( [ x ] ); * // returns true */ any: typeof any; /** * Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @param arrays - array-like object containing an input ndarray * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns boolean indicating whether at least one element passes a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../base/ctor' ); * * function predicate( value ) { * return value > 0.0; * } * * // Create a data buffer: * 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 ] ); * * // Define the shape of the array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Test elements: * var out = ns.anyBy( [ x ], predicate ); * // returns true */ anyBy: typeof anyBy; /** * Returns an array with a specified number of appended singleton dimensions. * * @param x - input array * @param n - number of singleton dimensions to append * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.appendSingletonDimensions( x, 3, false ); * // returns [ [ [ [ [ 1 ] ] ], [ [ [ 2 ] ] ] ], [ [ [ [ 3 ] ] ], [ [ [ 4 ] ] ] ] ] */ appendSingletonDimensions: typeof appendSingletonDimensions; /** * Base ndarray assertion utilities. */ assert: typeof assert; /** * Assigns elements in an ndarray to elements in an ndarray. * * @param arrays - array-like object containing one input ndarray and one output ndarray * @throws arrays must have the same number of dimensions * @throws arrays must have the same shape * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * * // Create data buffers: * 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 ] ); * var ybuf = new Float64Array( 6 ); * * // Define the shape of the input and output arrays: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * var sy = [ 2, 2, 1 ]; * * // Define the index offsets: * var ox = 1; * var oy = 0; * * // Create the input and output ndarrays: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * var y = ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' ); * * // Copy elements: * ns.assign( [ x, y ] ); * * console.log( y.data ); * // => [ 2.0, 3.0, 6.0, 7.0, 10.0, 11.0 ] */ assign: typeof assign; /** * Assigns a scalar value to every element of an output ndarray. * * @param arrays - array-like object containing a zero-dimensional input ndarray containing the scalar value and one output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var scalar2ndarray = require( './../../../from-scalar' ); * var ndarray = require( './../../../ctor' ); * * // Create a zero-dimensional ndarray containing the scalar value: * var x = scalar2ndarray( 5.0, { * 'dtype': 'float64' * }); * * // Create a data buffer: * var ybuf = new Float64Array( 4 ); * * // Define the shape of the output array: * var shape = [ 2, 2 ]; * * // Define the array strides: * var sy = [ 2, 1 ]; * * // Define the index offset: * var oy = 0; * * // Create the output ndarray: * var y = ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' ); * * // Assign the scalar value: * ns.assignScalar( [ x, y ] ); * * console.log( y.data ); * // => [ 5.0, 5.0, 5.0, 5.0 ] */ assignScalar: typeof assignScalar; /** * Converts a list of values (scalars and/or ndarrays) to ndarrays having at least one dimension. * * @param arrays - array-like object containing a list of scalars and/or ndarrays * @returns an array of ndarrays * * @example * var array = require( './../../../array' ); * var scalar2ndarray = require( './../../../from-scalar' ); * * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] ); * // returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] * * var y = scalar2ndarray( 3.14 ); * // returns [ 3.14 ] * * var out = ns.atleast1d( [ x, y ] ); * // returns [ , ] */ atleast1d: typeof atleast1d; /** * Converts a list of values (scalars and/or ndarrays) to ndarrays having at least two dimensions. * * @param arrays - array-like object containing a list of scalars and/or ndarrays * @returns an array of ndarrays * * @example * var array = require( './../../../array' ); * var scalar2ndarray = require( './../../../from-scalar' ); * * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] ); * // returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] * * var y = scalar2ndarray( 3.14 ); * // returns [ 3.14 ] * * var out = ns.atleast2d( [ x, y ] ); * // returns [ , ] */ atleast2d: typeof atleast2d; /** * Converts a list of values (scalars and/or ndarrays) to ndarrays having at least three dimensions. * * @param arrays - array-like object containing a list of scalars and/or ndarrays * @returns an array of ndarrays * * @example * var array = require( './../../../array' ); * var scalar2ndarray = require( './../../../from-scalar' ); * * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] ); * // returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] * * var y = scalar2ndarray( 3.14 ); * // returns [ 3.14 ] * * var out = ns.atleast3d( [ x, y ] ); * // returns [ , ] */ atleast3d: typeof atleast3d; /** * Converts a list of values (scalars and/or ndarrays) to ndarrays having at least a specified number of dimensions. * * @param ndims - minimum number of dimensions * @param arrays - array-like object containing a list of scalars and/or ndarrays * @returns an array of ndarrays * * @example * var array = require( './../../../array' ); * * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] ); * // returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] * * var y = array( [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] ); * // returns [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] * * var out = ns.atleastnd( 3, [ x, y ] ); * // returns [ , ] */ atleastnd: typeof atleastnd; /** * Applies a binary callback to elements in input ndarrays and assigns results to elements in an output ndarray. * * @param arrays - array-like object containing two input ndarrays and one output ndarray * @param fcn - binary callback * @throws arrays must have the same number of dimensions * @throws arrays must have the same shape * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * var getData = require( './../../../data-buffer' ); * * function add( a, b ) { * return a + b; * } * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var ybuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var zbuf = new Float64Array( 6 ); * * // Define the shape of the input and output arrays: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 2, 2, 1 ]; * var sy = [ 2, 2, 1 ]; * var sz = [ 2, 2, 1 ]; * * // Define the index offsets: * var ox = 0; * var oy = 0; * var oz = 0; * * // Create the input and output ndarrays: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * var y = new ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' ); * var z = new ndarray( 'float64', zbuf, shape, sz, oz, 'row-major' ); * * // Apply the ns.binary function: * ns.binary( [ x, y, z ], add ); * * console.log( getData( z ) ); * // => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] */ binary: typeof binary; /** * Resolves the casting data type for an input ndarray provided to a binary function. * * @param idtype1 - input ndarray data type * @param idtype2 - additional input ndarray data type * @param odtype - output ndarray data type * @param policy - input ndarray casting data type policy * @returns input ndarray casting data type * * @example * var dt = ns.binaryInputCastingDataType( 'float64', 'float64', 'float64', 'none' ); * // returns */ binaryInputCastingDataType: typeof binaryInputCastingDataType; /** * Reorders ndarray dimensions and associated strides for loop interchange. * * ## Notes * * - The returned object has the following properties: * * - **sh**: dimensions sorted in loop order. * - **sx**: first input ndarray strides sorted in loop order. * - **sy**: second input ndarray strides sorted in loop order. * - **sz**: output ndarray strides sorted in loop order. * * - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache. * * The purpose of this function is to order ndarray dimensions according to the magnitude of array strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference. * * - Cache performance may be degraded if the layout order (i.e., row-major or column-major) differs for the input and output ndarrays. This function is intended to optimize cache performance for the most common layout order. Accordingly, if the output ndarray has a different layout order (e.g., if the input ndarrays are row-major and the output ndarray is column-major), cache misses are likely for the output ndarray. In general, to ensure best performance, input and output ndarrays should have the same layout order. * * - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting. * * @param shape - array dimensions * @param stridesX - first input array stride lengths * @param stridesY - second input array stride lengths * @param stridesZ - output array stride lengths * @returns loop interchange data * * @example * var sh = [ 2, 3, 4 ]; * * var sx = [ 12, 4, 1 ]; // row-major * var sy = [ 24, 8, 1 ]; // row-major * var sz = [ 1, -2, 6 ]; // column-major * * var o = ns.binaryLoopOrder( sh, sx, sy, sz ); * // returns {...} * * var ssh = o.sh; * // returns [ 4, 3, 2 ] * * var ssx = o.sx; * // returns [ 1, 4, 12 ] * * var ssy = o.sy; * // returns [ 1, 8, 24 ] * * var ssz = o.sz; * // returns [ 6, -2, 1 ] */ binaryLoopOrder: typeof binaryLoopOrder; /** * Resolves the output ndarray data type for a binary function. * * @param xdtype - first input ndarray data type * @param ydtype - second input ndarray data type * @param policy - output ndarray data type policy * @returns output ndarray data type * * @example * var dt = ns.binaryOutputDataType( 'float64', 'float32', 'complex_floating_point' ); * // returns */ binaryOutputDataType: typeof binaryOutputDataType; /** * Constructor for performing a reduction on two input ndarrays. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param policies - dispatch policies * @returns instance * * @example * var base = require( '@stdlib/blas/base/ndarray/gdot' ); * var dtypes = require( './../../../dtypes' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = idt; * var policies = { * 'output': 'promoted', * 'casting': 'promoted' * }; * * var table = { * 'default': base * }; * var dot = new ns.binaryReduceStrided1dDispatch( table, [ idt, idt ], odt, policies ); * * var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ]; * var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' ); * * var z = dot.apply( x, y ); * // returns [ -5.0 ] */ binaryReduceStrided1dDispatch: typeof binaryReduceStrided1dDispatch; /** * Creates a function for performing a reduction on two input ndarrays. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param policies - dispatch policies * @returns function for applying a function * * @example * var base = require( '@stdlib/blas/base/ndarray/gdot' ); * var dtypes = require( './../../../dtypes' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = idt; * var policies = { * 'output': 'promoted', * 'casting': 'promoted' * }; * * var table = { * 'default': base * }; * var dot = ns.binaryReduceStrided1dDispatchFactory( table, [ idt, idt ], odt, policies ); * * var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ]; * var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' ); * * var z = dot( x, y ); * // returns [ -5.0 ] */ binaryReduceStrided1dDispatchFactory: typeof binaryReduceStrided1dDispatchFactory; /** * Returns a loop block size for multi-dimensional array tiled loops. * * @param dtypeX - first input array data type * @param dtypeY - second input array data type * @param dtypeZ - output array data type * @returns block size (in units of elements) * * @example * var bsize = ns.binaryBlockSize( 'float64', 'float64', 'float64' ); * // returns */ binaryBlockSize: typeof binaryBlockSize; /** * Converts a linear index in an underlying data buffer to a linear index in an array view. * * @param shape - array shape * @param strides - stride array * @param offset - location of the first indexed value **based** on the stride array * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @param idx - linear index in an underlying data buffer * @param mode - specifies how to handle a linear index which exceeds array dimensions * @throws linear index must not exceed array dimensions * @returns linear index in an array view * * @example * var shape = [ 3, 3 ]; * var strides = [ -3, 1 ]; * var offset = 6; * var order = 'row-major'; * var mode = 'throw'; * * var ind = ns.bind2vind( shape, strides, offset, order, 7, mode ); * // returns 1 */ bind2vind: typeof bind2vind; /** * Broadcasts an ndarray to a specified shape. * * ## Notes * * - The function throws an error if a provided ndarray is incompatible with a provided shape. * - The returned array is a view on the input array data buffer. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned array, copy the array before performing operations which may mutate elements. * - The returned array is a "base" ndarray, and, thus, the returned array does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead. * - The function always returns a new ndarray instance even if the input ndarray shape and the desired shape are the same. * * @param arr - input array * @param shape - desired shape * @throws input array cannot have more dimensions than the desired shape * @throws input array dimension sizes must be `1` or equal to the corresponding dimension in the provided shape * @returns broadcasted array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns * * var shx = x.shape; * // returns [ 2, 2 ] * * var y = ns.broadcastArray( x, [ 3, 2, 2 ] ); * // returns * * var shy = y.shape; * // returns [ 3, 2, 2 ] * * var v = y.get( 0, 0, 0 ); * // returns 1 * * v = y.get( 0, 0, 1 ); * // returns 2 * * v = y.get( 1, 0, 0 ); * // returns 1 * * v = y.get( 1, 1, 0 ); * // returns 3 * * v = y.get( 2, 0, 0 ); * // returns 1 * * v = y.get( 2, 1, 1 ); * // returns 4 */ broadcastArray: typeof broadcastArray; /** * Broadcasts an input ndarray to a target shape while keeping a list of specified dimensions unchanged. * * ## Notes * * - The function expects that each index in the list of dimensions is negative in order to ensure that indices correspond to the same relative position in the output ndarray shape. For example, given an input ndarray shape `[2,X1,X2]` and a desired shape `[6,7,2,Y1,Y2]`, a list of negative dimensions `[-2,-1]` correctly maps the unchanged dimensions `X` in the input ndarray to ignored dimensions `Y` in the provided target shape. Nonnegative indices, however, afford no such mapping. For example, the list of dimensions `[1,2]` corresponds to `[X1,X2]` in the input ndarray shape, but to `[7,2]` in the target shape, which is not desired. By expecting negative indices, we avoid confusion and ensure that users always refer to dimensions relative to the last broadcasted dimension. * - The function throws an error if a provided ndarray is incompatible with a provided shape. * - The returned array is a view on the input array data buffer. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned array, copy the array before performing operations which may mutate elements. * - The returned array is a "base" ndarray, and, thus, the returned array does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead. * - The function always returns a new ndarray instance even if the input ndarray shape and the desired shape are the same. * * @param arr - input array * @param shape - desired shape * @param dims - list of dimensions to exclude from broadcasting * @throws input array cannot have more dimensions than the desired shape * @throws broadcasted dimensions in the input array and desired shape must be broadcast compatible * @throws dimension indices must not exceed desired shape bounds * @throws must provide unique dimension indices * @returns broadcasted array * * @example * var array = require( './../../../array' ); * var getShape = require( './../../../shape' ); * * var x = array( [ [ 1, 2, 3 ] ] ); * // returns * * var shx = getShape( x ); * // returns [ 1, 3 ] * * var y = ns.broadcastArrayExceptDimensions( x, [ 2, 2, 3 ], [ -2 ] ); * // returns * * var shy = getShape( y ); * // returns [ 2, 1, 3 ] * * var v = y.get( 0, 0, 0 ); * // returns 1 * * v = y.get( 0, 0, 1 ); * // returns 2 * * v = y.get( 0, 0, 2 ); * // returns 3 * * v = y.get( 1, 0, 0 ); * // returns 1 * * v = y.get( 1, 0, 1 ); * // returns 2 * * v = y.get( 1, 0, 2 ); * // returns 3 */ broadcastArrayExceptDimensions: typeof broadcastArrayExceptDimensions; /** * Broadcasts ndarrays to a common shape. * * ## Notes * * - The function throws an error if provided broadcast-incompatible ndarrays. * - The returned arrays are views on their respective underlying array data buffers. The views are typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to a view may affect multiple elements. If you need to write to a returned array, copy the array before performing operations which may mutate elements. * - The returned arrays are "base" ndarrays, and, thus, returned arrays do not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast ndarray-like objects within internal implementations and to do so with minimal overhead. * - The function always returns new ndarray instances even if an input ndarray shape and the broadcasted shape are the same. * * @param arrays - input arrays * @throws input arrays must be broadcast compatible * @returns list of broadcasted arrays * * @example * var array = require( './../../../array' ); * var zeros = require( './../../../zeros' ); * * var x1 = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns * * var shx = x1.shape; * // returns [ 2, 2 ] * * var y1 = zeros( [ 3, 2, 2 ] ); * // returns * * var shy = y1.shape; * // returns [ 3, 2, 2 ] * * var out = ns.broadcastArrays( [ x1, y1 ] ); * // returns [ , ] * * var x2 = out[ 0 ]; * // returns * * var y2 = out[ 1 ]; * // returns * * shx = x2.shape; * // returns [ 3, 2, 2 ] * * shy = y2.shape; * // returns [ 3, 2, 2 ] * * var v = x2.get( 0, 0, 0 ); * // returns 1 * * v = x2.get( 0, 0, 1 ); * // returns 2 * * v = x2.get( 1, 0, 0 ); * // returns 1 * * v = x2.get( 1, 1, 0 ); * // returns 3 * * v = x2.get( 2, 0, 0 ); * // returns 1 * * v = x2.get( 2, 1, 1 ); * // returns 4 * * @example * var zeros = require( './../../../zeros' ); * * var x = zeros( [ 2, 2 ] ); * // returns * * var y = zeros( [ 4, 2 ] ); * // returns * * var out = ns.broadcastArrays( [ x, y ] ); * // throws */ broadcastArrays: typeof broadcastArrays; /** * Broadcasts a scalar value to an ndarray having a specified shape. * * @param value - scalar value * @param dtype - array data type * @param shape - array shape * @param order - array order * @returns ndarray * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * * var x = ns.broadcastScalar( 1.0, 'generic', [ 2, 2 ], 'row-major' ); * // returns * * var sh = getShape( x ); * // returns [ 2, 2 ] * * var dt = String( getDType( x ) ); * // returns 'generic' * * var v = x.get( 0, 1 ); * // returns 1.0 */ broadcastScalar: typeof broadcastScalar; /** * Broadcasts a scalar value to an ndarray having the same shape and data type as a provided input ndarray. * * @param x - input array * @param value - scalar value * @returns output ndarray * * @example * var zeros = require( './../../../base/zeros' ); * var getDType = require( './../../../dtype' ); * * var x = zeros( 'float64', [ 2, 2 ], 'row-major' ); * // returns [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] * * var y = ns.broadcastScalarLike( x, 1.0 ); * // returns [ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ] * * var dt = String( getDType( y ) ); * // returns 'float64' */ broadcastScalarLike: typeof broadcastScalarLike; /** * Broadcasts array shapes to a single shape. * * ## Notes * * - Two respective dimensions in two shape arrays are compatible if * * 1. the dimensions are equal. * 2. one dimension is `1`. * * - The function returns `null` if provided incompatible shapes (i.e., shapes which cannot be broadcast with one another). * * @param shapes - array shapes * @returns broadcast shape * * @example * var shapes = [ * [ 8, 1, 6, 1 ], * [ 7, 1, 5 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 8, 7, 6, 5 ] * * @example * var shapes = [ * [ 5, 4 ], * [ 1 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 5, 4 ] * * @example * var shapes = [ * [ 5, 4 ], * [ 4 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 5, 4 ] * * @example * var shapes = [ * [ 15, 3, 5 ], * [ 15, 1, 5 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 15, 3, 5 ] * * @example * var shapes = [ * [ 15, 3, 5 ], * [ 3, 5 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 15, 3, 5 ] * * @example * var shapes = [ * [ 15, 3, 5 ], * [ 3, 1 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 15, 3, 5 ] * * @example * var shapes = [ * [ 8, 1, 1, 6, 1 ], * [ 1, 7, 1, 5 ], * [ 8, 4, 1, 6, 5 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 8, 4, 7, 6, 5 ] * * @example * var shapes = [ * [ 8, 1, 1, 6, 1 ], * [ 0 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 8, 1, 1, 6, 0 ] * * @example * var shapes = [ * [ 8, 1, 1, 6, 1 ], * [ 8, 0, 1, 6, 1 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 8, 0, 1, 6, 1 ] * * @example * var shapes = [ * [ 8, 8, 1, 6, 1 ], * [ 8, 0, 1, 6, 1 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns null * * @example * var shapes = [ * [] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [] * * @example * var shapes = [ * [], * [] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [] * * @example * var shapes = []; * * var out = ns.broadcastShapes( shapes ); * // returns [] * * @example * var shapes = [ * [ 3, 2, 1 ], * [] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 3, 2, 1 ] * * @example * var shapes = [ * [], * [ 3, 2, 1 ] * ]; * * var out = ns.broadcastShapes( shapes ); * // returns [ 3, 2, 1 ] */ broadcastShapes: typeof broadcastShapes; /** * Returns a contiguous linear ndarray data buffer. * * @param dtype - data type * @param size - buffer size * @returns data buffer * * @example * var buf = ns.buffer( 'float64', 3 ); * // returns [ 0.0, 0.0, 0.0 ] */ buffer: typeof buffer; /** * Returns an ndarray data buffer constructor. * * @param dtype - data type * @returns data buffer constructor or null * * @example * var ctor = ns.bufferCtors( 'float64' ); * // returns * * @example * var ctor = ns.bufferCtors( 'float' ); * // returns null */ bufferCtors: typeof bufferCtors; /** * Returns the data type of an ndarray data buffer. * * @param value - input value * @returns data type * * @example * var dt = ns.bufferDataType( [ 1, 2, 3 ] ); * // returns 'generic' * * var dt = ns.bufferDataType( 'beep' ); * // returns null */ bufferDataType: typeof bufferDataType; /** * Returns the data type enumeration constant for a provided ndarray data buffer. * * @param arr - strided array * @returns data type enumeration constant or null * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var x = new Float64Array( 10 ); * * var c = ns.bufferDataTypeEnum( x ); * // returns */ bufferDataTypeEnum: typeof bufferDataTypeEnum; /** * Returns the number of bytes per element for a provided underlying ndarray data type. * * @param dtype - data type * @returns number of bytes per element * * @example * var nbytes = ns.bytesPerElement( 'float64' ); * // returns 8 * * nbytes = ns.bytesPerElement( 'generic' ); * // returns null */ bytesPerElement: typeof bytesPerElement; /** * Returns an object mapping single letter character abbreviations to data type strings. * * @returns object mapping single letter character abbreviations to data type strings * * @example * var out = ns.char2dtype(); * // returns {...} */ char2dtype: typeof char2dtype; /** * Restricts an index to the interval `[0,max]`. * * @param idx - index * @param max - maximum index * @returns index * * @example * var idx = ns.clampIndex( -1, 10 ); * // returns 0 * * idx = ns.clampIndex( 15, 10 ); * // returns 10 * * idx = ns.clampIndex( 5, 10 ); * // returns 5 */ clampIndex: typeof clampIndex; /** * Returns the shape defined by the dimensions which are not included in a list of dimensions. * * @param shape - array shape * @param dims - list of dimensions * @returns output shape * * @example * var sh = ns.complementShape( [ 3, 2 ], [ -1 ] ); * // returns [ 3 ] * * sh = ns.complementShape( [ 3, 2, 1 ], [ -2 ] ); * // returns [ 3, 1 ] * * sh = ns.complementShape( [ 3 ], [ 0 ] ); * // returns [] * * sh = ns.complementShape( [ 3, 2 ], [ 0 ] ); * // returns [ 2 ] * * sh = ns.complementShape( [], [] ); * // returns [] */ complementShape: typeof complementShape; /** * Resolves the most common underlying storage layout. * * ## Notes * * - In the event of a tie or when all input array strides are "disorganized" (i.e., neither row- nor column-major), the function returns the default layout. * * @param strides - list of array strides * @returns storage layout * * @example * var strides = [ [ 2, 1 ], [ 4, 1 ] ]; * * var order = ns.consensusOrder( strides ); * // returns 'row-major' * * @example * var strides = [ [ 1, 2 ], [ 1, 4 ] ]; * * var order = ns.consensusOrder( strides ); * // returns 'column-major' * * @example * var strides = [ [ 2, 1 ], [ 1, 4 ] ]; * * var order = ns.consensusOrder( strides ); * // returns * * @example * var strides = [ [ 1, 1 ], [ 1, 1 ] ]; * * var order = ns.consensusOrder( strides ); * // returns */ consensusOrder: typeof consensusOrder; /** * Copies an input ndarray to a new ndarray having the same shape and data type. * * ## Notes * * - The function performs a full copy in which an ndarray's underlying data is copied to a new underlying data buffer. * * @param x - input array * @returns output array * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * var zeros = require( './../../../base/zeros' ); * * var x = zeros( 'float64', [ 2, 2 ], 'row-major' ); * // returns * * var sh = getShape( x ); * // returns [ 2, 2 ] * * var y = ns.copy( x ); * // returns * * sh = getShape( y ); * // returns [ 2, 2 ] */ copy: typeof copy; /** * Counts the number of falsy elements in an ndarray. * * @param arrays - array-like object containing an input ndarray * @returns number of falsy elements * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * * // Create a data buffer: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); * * // Define the shape of the input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Perform operation: * var out = ns.countFalsy( [ x ] ); * // returns 1 */ countFalsy: typeof countFalsy; /** * Counts the number of elements in an ndarray which pass a test implemented by a predicate function. * * @param arrays - array-like object containing an input ndarray * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns result * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../base/ctor' ); * * function predicate( value ) { * return value > 0.0; * } * * // Create a data buffer: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); * * // Define the shape of the array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Perform operation: * var out = ns.countIf( [ x ], predicate ); * // returns 5 */ countIf: typeof countIf; /** * Counts the number of truthy elements in an ndarray. * * @param arrays - array-like object containing an input ndarray * @returns number of truthy elements * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * * // Create a data buffer: * 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 ] ); * * // Define the shape of the input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Perform operation: * var out = ns.countTruthy( [ x ] ); * // returns 6 */ countTruthy: typeof countTruthy; /** * ndarray constructor. * * ## Notes * * - To create a zero-dimensional array, * * ```javascript * var buffer = [ 1 ]; * var shape = []; * var strides = [ 0 ]; * var offset = 0; * * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * ``` * * @param dtype - data type * @param buffer - data buffer * @param shape - array shape * @param strides - array strides * @param offset - index offset * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns ndarray instance * * @example * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var out = ns.ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); */ ndarray: typeof ndarray; /** * Returns the underlying data buffer of a provided ndarray. * * @param x - input ndarray * @returns underlying data buffer * * @example * var zeros = require( './../../../zeros' ); * * var x = zeros( [ 3, 3, 3 ], { * 'dtype': 'float64' * }); * * var out = ns.data( x ); * // returns */ data: typeof data; /** * Returns a plain object describing how to interpret a data buffer as an n-dimensional array. * * @param dtype - data type * @param buffer - data buffer * @param shape - array shape * @param strides - array strides * @param offset - index offset * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns ndarray descriptor * * @example * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var out = ns.descriptor( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns {...} */ descriptor: typeof descriptor; /** * Returns a view of the diagonal of a matrix (or stack of matrices). * * ## Notes * * - The order of the dimension indices contained in `dims` matters. The first element specifies the row-like dimension. The second element specifies the column-like dimension. * - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. * - The diagonal offset `k` is interpreted as `column - row`. Accordingly, when `k = 0`, the function returns the main diagonal; when `k > 0`, the function returns the diagonal above the main diagonal; and when `k < 0`, the function returns the diagonal below the main diagonal. * - The returned ndarray is a **view** of the input ndarray. Accordingly, writing to the original ndarray will **mutate** the returned ndarray and vice versa. * - The `writable` parameter **only** applies to ndarray constructors supporting **read-only** instances. * * @param x - input array * @param dims - dimension indices defining the plane from which to extract the diagonal * @param k - diagonal offset * @param writable - boolean indicating whether the returned ndarray should be writable * @returns ndarray view * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ], [ 7.0, 8.0, 9.0 ] ] ); * // returns [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ], [ 7.0, 8.0, 9.0 ] ] * * var y = ns.diagonal( x, [ 0, 1 ], 0, false ); * // returns [ 1.0, 5.0, 9.0 ] */ diagonal: typeof diagonal; /** * Returns the data type of a provided ndarray. * * @param x - input ndarray * @returns data type * * @example * var zeros = require( './../../../zeros' ); * * var x = zeros( [ 3, 3, 3 ], { * 'ns.dtype': 'float64' * }); * * var dt = ns.dtype( x ); * // returns 'float64' */ dtype: typeof dtype; /** * Returns an object mapping data type strings to alignments. * * @returns object mapping data type strings to alignments * * @example * var obj = ns.dtypeAlignment(); * // returns {...} */ dtypeAlignment: typeof dtypeAlignment; /** * Returns an object mapping data type strings to single letter character abbreviations. * * @returns object mapping data type strings to single letter character abbreviations * * @example * var obj = ns.dtypeChar(); * // returns {...} */ dtypeChar: typeof dtypeChar; /** * Returns a list of ndarray data type single letter character abbreviations. * * @param kind - data type kind * @returns list of ndarray data type single letter character abbreviations * * @example * var list = ns.dtypeChars(); * // returns [...] * * @example * var list = ns.dtypeChars( 'floating_point' ); * // returns [...] */ dtypeChars: typeof dtypeChars; /** * Returns an object mapping data type strings to descriptions. * * @returns object mapping data type strings to descriptions * * @example * var obj = ns.dtypeDesc(); * // returns {...} */ dtypeDesc: typeof dtypeDesc; /** * Returns the data type string associated with an ndarray data type enumeration constant. * * @param dtype - data type enumeration constant * @returns data type string * * @example * var str2enum = require( './../../../base/dtype-str2enum' ); * * var v = str2enum( 'float64' ); * // returns * * var dt = ns.dtypeEnum2Str( v ); * // returns 'float64' */ dtypeEnum2Str: typeof dtypeEnum2Str; /** * Returns an object mapping supported data type strings to enumeration constants. * * ## Notes * * - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the object should be used in an opaque manner. * - The main purpose of this function is JavaScript and C inter-operation of ndarray objects. * * @returns object mapping supported data type strings to enumeration constants * * @example * var o = ns.dtypeEnums(); * // returns {...} */ dtypeEnums: typeof dtypeEnums; /** * Returns an object mapping supported data type strings to data type objects. * * @returns object mapping supported data type strings to data type objects * * @example * var o = ns.dtypeObjects(); * // returns {...} */ dtypeObjects: typeof dtypeObjects; /** * Returns the enumeration constant associated with an ndarray data type value. * * ## Notes * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the function should be used in an opaque manner. * * @param dtype - data type value * @returns enumeration constant * * @example * var v = ns.dtypeResolveEnum( 'float64' ); * // returns */ dtypeResolveEnum: typeof dtypeResolveEnum; /** * Returns the data type string associated with an ndarray data type value. * * @param dtype - data type value * @returns data type string * * @example * var str2enum = require( './../../../base/dtype-str2enum' ); * * var v = ns.dtypeResolveStr( str2enum( 'float64' ) ); * // returns 'float64' */ dtypeResolveStr: typeof dtypeResolveStr; /** * Returns the enumeration constant associated with a ndarray data type string. * * ## Notes * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the function should be used in an opaque manner. * * @param dtype - data type string * @returns enumeration constant * * @example * var v = ns.dtypeStr2Enum( 'float64' ); * // returns */ dtypeStr2Enum: typeof dtypeStr2Enum; /** * Returns a list of ndarray data type strings. * * @param kind - data type kind * @returns list of ndarray data type strings * * @example * var list = ns.dtypeStrings(); * // returns [...] * * @example * var list = ns.dtypeStrings( 'floating_point' ); * // returns [...] */ dtypeStrings: typeof dtypeStrings; /** * Returns the C data type associated with a provided data type value. * * @param dtype - data type value * @returns C data type (or null) * * @example * var out = ns.dtype2c( 'float64' ); * // returns 'double' * * out = ns.dtype2c( 'generic' ); * // returns null */ dtype2c: typeof dtype2c; /** * Resolves a list of data type enumeration constants. * * ## Notes * * - If the function is unable to resolve an enumeration constant for a provided data type, the corresponding element in the returned array will be `null`. * * @param dtypes - list of data types * @returns results * * @example * var out = ns.dtypes2enums( [ 'float32', 'float64' ] ); * // returns [...] * * @example * var out = ns.dtypes2enums( [ 'foo', 'bar' ] ); * // returns [ null, null ] */ dtypes2enums: typeof dtypes2enums; /** * Transforms a list of array argument data types into a list of signatures. * * @param dtypes - list of array argument data types * @param nin - number of input array arguments * @param nout - number of output array arguments * @throws first argument must be an array-like object * @throws second argument must be a nonnegative integer * @throws third argument must be a nonnegative integer * @throws first argument must have at least one element * @throws first argument must be compatible with second and third arguments * @returns list of signatures * * @example * var dtypes = [ * 'float64', 'float64', * 'float32', 'float32' * ]; * * var sigs = ns.dtypes2signatures( dtypes, 1, 1 ); * // returns [ '(float64) => (float64)', '(float32) => (float32)' ] */ dtypes2signatures: typeof dtypes2signatures; /** * Resolves a list of data type strings. * * ## Notes * * - If the function is unable to resolve a data type string for a provided data type, the corresponding element in the returned array will be `null`. * * @param dtypes - list of data types * @returns results * * @example * var out = ns.dtypes2strings( [ 'float32', 'float64' ] ); * // returns [...] * * @example * var out = ns.dtypes2strings( [ 'foo', 'bar' ] ); * // returns [ null, null ] */ dtypes2strings: typeof dtypes2strings; /** * Creates an uninitialized array having a specified shape and data type. * * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns output array * * @example * var arr = ns.empty( 'float32', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; * // returns [ 2, 2 ] * * var dt = arr.dtype; * // returns 'float32' */ empty: typeof empty; /** * Creates an uninitialized array having the same shape and data type as a provided input ndarray. * * @param x - input array * @returns output array * * @example * var zeros = require( './../../../base/zeros' ); * * var x = zeros( 'generic', [ 2, 2 ], 'row-major' ); * // returns * * var sh = x.shape; * // returns [ 2, 2 ] * * var dt = x.dtype; * // returns 'generic' * * var y = ns.emptyLike( x ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * dt = y.dtype; * // returns 'generic' */ emptyLike: typeof emptyLike; /** * Tests whether every element in an ndarray is truthy. * * @param arrays - array-like object containing an input ndarray * @returns boolean indicating whether every element is truthy * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * * // Create a data buffer: * 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 ] ); * * // Define the shape of the input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Test elements: * var out = ns.every( [ x ] ); * // returns true */ every: typeof every; /** * Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @param arrays - array-like object containing an input ndarray * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../base/ctor' ); * * function predicate( value ) { * return value > 0.0; * } * * // Create a data buffer: * 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 ] ); * * // Define the shape of the array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Test elements: * var out = ns.everyBy( [ x ], predicate ); * // returns true */ everyBy: typeof everyBy; /** * Expands the shape of an array by inserting a new dimension of size one at a specified dimension index. * * ## Notes * * - A provided dimension index must reside on the interval `[-N-1, N]`, where `N` is the rank (i.e., number of dimensions) of the provided input array. If provided a negative dimension index, the position at which to insert a singleton dimension is computed as `N + dim + 1`. Hence, if provided `-1`, the resolved position is `N` (i.e., a singleton dimension is appended to the input array). * * @param x - input array * @param dim - dimension index at which to insert a singleton dimension * @param writable - boolean indicating whether the returned ndarray should be writable * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.expandDimensions( x, 1, false ); * // returns [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ] */ expandDimensions: typeof expandDimensions; /** * Creates an ndarray filled with `false` values and having a specified shape and data type. * * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns `false`-filled array * * @example * var getDType = require( './../../../dtype' ); * * var arr = ns.falses( 'generic', [ 2, 2 ], 'row-major' ); * // returns [ [ false, false ], [ false, false ] ] * * var dt = String( getDType( arr ) ); * // returns 'generic' */ falses: typeof falses; /** * Creates an ndarray filled with `false` values and having the same shape and data type as a provided input ndarray. * * @param x - input array * @returns filled ndarray * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * var empty = require( './../../../empty' ); * * var x = empty( [ 2, 2 ], { * 'dtype': 'bool' * }); * // returns * * var sh = getShape( x ); * // returns [ 2, 2 ] * * var dt = String( getDType( x ) ); * // returns 'bool' * * var y = ns.falsesLike( x ); * // returns [ [ false, false ], [ false, false ] ] * * sh = getShape( y ); * // returns [ 2, 2 ] * * dt = String( getDType( y ) ); * // returns 'bool' */ falsesLike: typeof falsesLike; /** * Fills an input ndarray with a specified value. * * ## Notes * * - A `value` must be able to safely cast to the input ndarray data type. Scalar values having floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., a scalar double-precision floating-point number can be used to fill a `'float32'` input ndarray). * * @param x - input ndarray * @param value - scalar value * @returns input ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * // Create a data buffer: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * * // Define the shape of the input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 2, 2, 1 ]; * * // Define the index offset: * var ox = 0; * * // Create the input ndarray-like object: * var x = { * 'dtype': 'float64', * 'data': xbuf, * 'shape': shape, * 'strides': sx, * 'offset': ox, * 'order': 'row-major' * }; * * var out = ns.fill( x, 10.0 ); * * console.log( x.data ); * // => [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] * * var bool = ( out === x ); * // returns true */ fill: typeof fill; /** * Fills an input ndarray according to a callback function. * * @param x - input ndarray * @param fcn - callback function * @param thisArg - callback function execution context * @returns input ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * function fcn() { * return 10.0; * } * * // Create a data buffer: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * * // Define the shape of the input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 2, 2, 1 ]; * * // Define the index offset: * var ox = 0; * * // Create the input ndarray-like object: * var x = { * 'dtype': 'float64', * 'data': xbuf, * 'shape': shape, * 'strides': sx, * 'offset': ox, * 'order': 'row-major' * }; * * var out = ns.fillBy( x, fcn ); * * console.log( x.data ); * // => [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] * * var bool = ( out === x ); * // returns true */ fillBy: typeof fillBy; /** * Fills a specified diagonal of a matrix (or stack of matrices) with a scalar value. * * ## Notes * * - The order of the dimension indices contained in `dims` matters. The first element specifies the row-like dimension. The second element specifies the column-like dimension. * - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. * - The diagonal offset `k` is interpreted as `column - row`. Accordingly, when `k = 0`, the function fills the main diagonal; when `k > 0`, the function fills the diagonal above the main diagonal; and when `k < 0`, the function fills the diagonal below the main diagonal. * - The function mutates the input ndarray in-place. * * @param x - input array * @param value - scalar value * @param dims - dimension indices defining the plane in which to fill the diagonal * @param k - diagonal offset * @returns input ndarray * * @example * var zeros = require( './../../../zeros' ); * * var x = zeros( [ 3, 3 ] ); * // returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] * * var out = ns.fillDiagonal( x, 1.0, [ 0, 1 ], 0 ); * // returns [ [ 1.0, 0.0, 0.0 ], [ 0.0, 1.0, 0.0 ], [ 0.0, 0.0, 1.0 ] ] * * var bool = ( out === x ); * // returns true */ fillDiagonal: typeof fillDiagonal; /** * Returns the first element in an ndarray which passes a test implemented by a predicate function. * * ## Notes * * - The function returns the sentinel value if no element in an input ndarray passes a test implemented by a predicate function. * * @param arrays - array-like object containing an input ndarray and a zero-dimensional ndarray containing a sentinel value * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns result * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * var scalar2ndarray = require( './../../../from-scalar' ); * * function predicate( value ) { * return value % 2.0 === 0.0; * } * * // Create data buffers: * 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 ] ); * * // Define the shape of the input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 0; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create a zero-dimensional ndarray containing a sentinel value: * var sv = scalar2ndarray( NaN, { * 'dtype': 'float64' * }); * * // Perform reduction: * var out = ns.find( [ x, sv ], predicate ); * // returns 2.0 */ find: typeof find; /** * Returns a specified flag for a provided ndarray. * * @param x - input ndarray * @param name - flag name * @returns flag value * * @example * var zeros = require( './../../../zeros' ); * * var o = ns.flag( zeros( [ 3, 3, 3 ] ), 'READONLY' ); * // returns */ flag: typeof flag; /** * Returns the flags of a provided ndarray. * * ## Notes * * - When `copy` is `false`, changes to the returned object may mutate the input ndarray flags. If there is a chance that the returned object will be mutated (either directly or by downstream consumers), set `copy` to `true` to prevent unintended side effects. * * @param x - input ndarray * @param copy - boolean indicating whether to explicitly copy the value assigned to the input ndarray's `flags` property * @returns flags * * @example * var zeros = require( './../../../zeros' ); * * var o = ns.flags( zeros( [ 3, 3, 3 ] ), false ); * // returns {...} */ flags: typeof flags; /** * Flattens a shape to a specified depth. * * @param shape - array shape * @param depth - maximum depth to flatten * @returns flattened shape * * @example * var sh = ns.flattenShape( [ 3, 2 ], 1 ); * // returns [ 6 ] * * sh = ns.flattenShape( [ 3, 2, 1 ], 1 ); * // returns [ 6, 1 ] * * sh = ns.flattenShape( [ 3 ], 0 ); * // returns [ 3 ] * * sh = ns.flattenShape( [ 3, 2 ], 0 ); * // returns [ 3, 2 ] * * sh = ns.flattenShape( [ 3 ], 1 ); * // returns [ 3 ] * * sh = ns.flattenShape( [], 1 ); * // returns [] */ flattenShape: typeof flattenShape; /** * Flattens a shape starting from a specified dimension. * * @param shape - array shape * @param dim - dimension to start flattening from * @returns flattened shape * * @example * var sh = ns.flattenShapeFrom( [ 3, 3, 2 ], 1 ); * // returns [ 3, 6 ] * * sh = ns.flattenShapeFrom( [ 3, 2, 1 ], 1 ); * // returns [ 3, 2 ] * * sh = ns.flattenShapeFrom( [ 3 ], 0 ); * // returns [ 3 ] * * sh = ns.flattenShapeFrom( [ 3, 2 ], 0 ); * // returns [ 6 ] */ flattenShapeFrom: typeof flattenShapeFrom; /** * Returns a view of an input ndarray in which the order of elements along the last dimension is reversed. * * @param x - input array * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var typedarray = require( '@stdlib/array/typed' ); * var ndarray = require( './../../../ctor' ); * var getShape = require( './../../../shape' ); * * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var sh = getShape( x ); * // returns [ 3, 2 ] * * var y = ns.fliplr( x, false ); * // returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ], [ 6.0, 5.0 ] ] * * sh = getShape( y ); * // returns [ 3, 2 ] */ fliplr: typeof fliplr; /** * Returns a view of an input ndarray in which the order of elements along the second-to-last dimension is reversed. * * @param x - input array * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var typedarray = require( '@stdlib/array/typed' ); * var ndarray = require( './../../../ctor' ); * var getShape = require( './../../../shape' ); * * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var sh = getShape( x ); * // returns [ 3, 2 ] * * var y = ns.flipud( x, false ); * // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ] * * sh = getShape( y ); * // returns [ 3, 2 ] */ flipud: typeof flipud; /** * Invokes a callback function once for each element in an ndarray. * * @param arrays - array-like object containing an input ndarray * @param fcn - callback function * @param thisArg - callback function execution context * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var naryFunction = require( '@stdlib/utils/nary-function' ); * var ndarray = require( './../../../base/ctor' ); * var log = require( '@stdlib/console/log' ); * * // Create data buffers: * var xbuf = new Float64Array( 12 ); * * // Define the shape of the array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Apply the callback function: * ns.forEach( [ x ], naryFunction( log, 1 ) ); */ forEach: typeof forEach; /** * Converts an array to a one-dimensional ndarray. * * @param buf - input array * @param order - memory layout (row-major or column-major) * @returns one-dimensional ndarray * * @example * var getDType = require( './../../../dtype' ); * * var arr = [ 1, 2, 3, 4 ]; * * var x = ns.array2ndarray( arr, 'row-major' ); * // returns * * var dt = String( getDType( x ) ); * // returns 'generic' */ array2ndarray: typeof array2ndarray; /** * Returns a zero-dimensional ndarray containing a provided scalar value. * * @param value - scalar value * @param dtype - array data type * @param order - memory layout (row-major or column-major) * @returns zero-dimensional ndarray * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * * var x = ns.scalar2ndarray( 1.0, 'generic', 'row-major' ); * // returns * * var sh = getShape( x ); * // returns [] * * var dt = String( getDType( x ) ); * // returns 'generic' * * var v = x.get(); * // returns 1.0 */ scalar2ndarray: typeof scalar2ndarray; /** * Returns a zero-dimensional ndarray containing a provided scalar value and having the same data type as a provided input ndarray. * * ## Notes * * - If provided a number, the function returns a zero-dimensional ndarray containing a complex number whose real component equals the provided scalar value and whose imaginary component is zero. * * @param x - input array * @param value - scalar value * @returns zero-dimensional ndarray * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var zeros = require( './../../../base/zeros' ); * * var x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); * // returns * * var v = new Complex128( 1.0, 2.0 ); * * var y = ns.scalar2ndarrayLike( x, v ); * // returns * * var sh = getShape( y ); * // returns [] * * var dt = String( getDType( y ) ); * // returns 'complex128' * * var v = y.get(); * // returns [ 1.0, 2.0 ] */ scalar2ndarrayLike: typeof scalar2ndarrayLike; /** * Returns an ndarray filled with a specified value and having a specified shape and data type. * * @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns output array * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * * var arr = ns.full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); * // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] * * var sh = getShape( arr ); * // returns [ 2, 2 ] * * var dt = String( getDType( arr ) ); * // returns 'float32' */ full: typeof full; /** * Returns an ndarray filled according to a callback function and having a specified shape and data type. * * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @param clbk - callback function * @param thisArg - callback function execution context * @returns output array * * @example * var getDType = require( './../../../dtype' ); * * function clbk() { * return 10.0; * } * * var arr = ns.fullBy( 'float32', [ 2, 2 ], 'row-major', clbk ); * // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] * * var dt = String( getDType( arr ) ); * // returns 'float32' */ fullBy: typeof fullBy; /** * Tests whether an ndarray contains a specified value. * * @param arrays - array-like object containing an input ndarray and a zero-dimensional search element ndarray * @returns boolean indicating whether an ndarray contains a specified value * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * var scalar2ndarray = require( './../../../from-scalar' ); * * // Create data buffers: * 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 ] ); * * // Define the shape of the input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 0; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create a zero-dimensional ndarray containing a search element: * var v = scalar2ndarray( 6.0, { * 'dtype': 'float64' * }); * * // Perform reduction: * var out = ns.includes( [ x, v ] ); * // returns true */ includes: typeof includes; /** * Returns an index given an index mode. * * @param idx - index * @param max - maximum index * @param mode - specifies how to handle an index outside the interval `[0,max]` * @returns index * * @example * var idx = ns.ind( 2, 9, 'clamp' ); * // returns 2 * * idx = ns.ind( 10, 9, 'clamp' ); * // returns 9 * * idx = ns.ind( -1, 9, 'clamp' ); * // returns 0 * * @example * var idx = ns.ind( 2, 9, 'wrap' ); * // returns 2 * * idx = ns.ind( 10, 9, 'wrap' ); * // returns 0 * * idx = ns.ind( -1, 9, 'wrap' ); * // returns 9 * * @example * var idx = ns.ind( 2, 9, 'throw' ); * // returns 2 * * idx = ns.ind( 10, 9, 'throw' ); * // throws * * idx = ns.ind( -1, 9, 'throw' ); * // throws * * @example * var idx = ns.ind( 1, 10, 'normalize' ); * // returns 1 * * idx = ns.ind( -4, 10, 'normalize' ); * // returns 7 * * idx = ns.ind( -100, 10, 'normalize' ); * // throws */ ind: typeof ind; /** * Converts a linear index to an array of subscripts. * * ## Notes * * - The function accepts the following "modes": * * - **throw**: throw an error when a linear index exceeds array dimensions. * - **normalize**: normalize negative indices and throw an error when a linear index exceeds array dimensions. * - **wrap**: wrap around a linear index exceeding array dimensions using modulo arithmetic. * - **clamp**: set a linear index exceeding array dimensions to either `0` (minimum linear index) or the maximum linear index. * * - When provided a stride array containing negative strides, if an `offset` is greater than `0`, the function interprets the linear index as an index into the underlying data buffer for the array, thus returning subscripts from the perspective of that buffer. If an `offset` is equal to `0`, the function treats the linear index as an index into an array view, thus returning subscripts from the perspective of that view. * * ```text * Dims: 2x2 * Buffer: [ 1, 2, 3, 4 ] * * View = [ a00, a01, * a10, a11 ] * * Strides: 2,1 * Offset: 0 * * View = [ 1, 2, * 3, 4 ] * * Strides: 2,-1 * Offset: 1 * * View = [ 2, 1, * 4, 3 ] * * Strides: -2,1 * Offset: 2 * * View = [ 3, 4, * 1, 2 ] * * Strides: -2,-1 * Offset: 3 * * View = [ 4, 3, * 2, 1 ] * ``` * * ```javascript * var shape = [ 2, 2 ]; * var order = 'row-major'; * var strides = [ -2, 1 ]; * var offset = 2; * var mode = 'throw'; * * // From the perspective of a view... * var s = ind2sub( shape, strides, 0, order, 0, mode ); * // returns [ 0, 0 ] * * s = ind2sub( shape, strides, 0, order, 1, mode ); * // returns [ 0, 1 ] * * s = ind2sub( shape, strides, 0, order, 2, mode ); * // returns [ 1, 0 ] * * s = ind2sub( shape, strides, 0, order, 3, mode ); * // returns [ 1, 1 ] * * // From the perspective of an underlying buffer... * s = ind2sub( shape, strides, offset, order, 0, mode ); * // returns [ 1, 0 ] * * s = ind2sub( shape, strides, offset, order, 1, mode ); * // returns [ 1, 1 ] * * s = ind2sub( shape, strides, offset, order, 2, mode ); * // returns [ 0, 0 ] * * s = ind2sub( shape, strides, offset, order, 3, mode ); * // returns [ 0, 1 ] * ``` * * In short, from the perspective of a view, view data is always ordered. * * * @param shape - array shape * @param strides - stride array * @param offset - location of the first indexed value **based** on the stride array * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @param idx - linear index * @param mode - specifies how to handle a linear index which exceeds array dimensions * @throws linear index must not exceed array dimensions * @returns subscripts * * @example * var shape = [ 3, 3, 3 ]; * var strides = [ 9, 6, 1 ]; * var offset = 0; * var order = 'row-major'; * * var s = ns.ind2sub( shape, strides, offset, order, 17, 'throw' ); * // returns [ 1, 2, 2 ] */ ind2sub: typeof ind2sub; /** * Returns array iteration order. * * ## Notes * * - Return value key: * * - `0`: unordered (i.e., strides of mixed sign; e.g., `[ 9, -3, 1 ]`) * - `1`: ordered left-to-right (i.e., all nonnegative strides) * - `-1`: ordered right-to-left (i.e., all negative strides) * * @param strides - stride array * @returns iteration order * * @example * var o = ns.iterationOrder( [ 2, 1 ] ); * // returns 1 * * o = ns.iterationOrder( [ -2, 1 ] ); * // returns 0 * * o = ns.iterationOrder( [ -2, -1 ] ); * // returns -1 */ iterationOrder: typeof iterationOrder; /** * Reorders ndarray dimensions and associated strides for loop interchange. * * ## Notes * * - The returned array has the following elements: * * ```text * [ , ... ] * ``` * * where * * - **shape**: dimensions sorted in loop order. * - **...strides**: strides for each respective ndarray sorted in loop order. * * - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache. * * The purpose of this function is to order ndarray dimensions according to the magnitude of array strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference. * * - Cache performance may be degraded if the layout order (i.e., row-major or column-major) differs for the input and output ndarrays. This function is intended to optimize cache performance for the most common layout order. Accordingly, if the output ndarray has a different layout order (e.g., if the input ndarrays are row-major and the output ndarray is column-major), cache misses are likely for the output ndarray. In general, to ensure best performance, input and output ndarrays should have the same layout order. * * - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting. * * @param shape - array dimensions * @param strides - list of stride arrays containing the stride lengths for each input and output ndarray * @returns loop interchange data * * @example * var sh = [ 2, 3, 4 ]; * * var sx = [ 12, 4, 1 ]; // row-major * var sy = [ 24, 8, 1 ]; // row-major * var sz = [ 1, -2, 6 ]; // column-major * * var o = ns.loopOrder( sh, [ sx, sy, sz ] ); * // returns [...] * * var ssh = o[ 0 ]; * // returns [ 4, 3, 2 ] * * var ssx = o[ 1 ]; * // returns [ 1, 4, 12 ] * * var ssy = o[ 2 ]; * // returns [ 1, 8, 24 ] * * var ssz = o[ 3 ]; * // returns [ 6, -2, 1 ] */ loopOrder: typeof loopOrder; /** * Applies a callback function to elements in an input ndarray and assigns results to elements in an output ndarray. * * @param arrays - array-like object containing one input ndarray and one output ndarray * @param fcn - callback function * @param thisArg - callback function execution context * @throws arrays must have the same number of dimensions * @throws arrays must have the same shape * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var getData = require( './../../../data-buffer' ); * var ndarray = require( './../../../ctor' ); * * function scale( x ) { * return x * 10.0; * } * * // Create data buffers: * 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 ] ); * var ybuf = new Float64Array( 6 ); * * // Define the shape of the input and output arrays: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * var sy = [ 2, 2, 1 ]; * * // Define the index offsets: * var ox = 1; * var oy = 0; * * // Create the input and output ndarrays: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * var y = ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' ); * * // Apply function: * ns.map( [ x, y ], scale ); * * console.log( getData( y ) ); * // => [ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ] */ map: typeof map; /** * Computes the maximum linear index in an underlying data buffer accessible to an array view. * * @param shape - array shape * @param strides - stride array * @param offset - index offset * @returns linear index * * @example * var shape = [ 10, 10 ]; * var strides = [ 10, 1 ]; * var offset = 0; * * var idx = ns.maxViewBufferIndex( shape, strides, offset ); * // returns 99 * * @example * var shape = [ 10, 10 ]; * var strides = [ -10, -1 ]; * var offset = 99; * * var idx = ns.maxViewBufferIndex( shape, strides, offset ); * // returns 99 * * @example * var shape = [ 10, 10 ]; * var strides = [ 1, 10 ]; * var offset = 0; * * var idx = ns.maxViewBufferIndex( shape, strides, offset ); * // returns 99 * * @example * var shape = [ 10, 10 ]; * var strides = [ -1, -10 ]; * var offset = 99; * * var idx = ns.maxViewBufferIndex( shape, strides, offset ); * // returns 99 */ maxViewBufferIndex: typeof maxViewBufferIndex; /** * Broadcasts an ndarray to a specified shape if and only if the specified shape differs from the provided ndarray's shape. * * ## Notes * * - The function throws an error if a provided ndarray is incompatible with a provided shape. * - If a provided ndarray has the same shape as the specified shape, the function returns the provided ndarray. * - If a provided ndarray has a different (broadcast compatible) shape than the specified shape, the function returns a new (base) ndarray view of the provided ndarray's data. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned array, copy the array before performing operations which may mutate elements. * - A returned array view is a "base" ndarray, and, thus, a returned array view does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead. * * @param arr - input array * @param shape - desired shape * @throws input array cannot have more dimensions than the desired shape * @throws input array dimension sizes must be `1` or equal to the corresponding dimension in the provided shape * @throws input array and desired shape must be broadcast compatible * @returns broadcasted array * * @example * var getShape = require( './../../../shape' ); * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var shx = getShape( x ); * // returns [ 2, 2 ] * * var y = ns.maybeBroadcastArray( x, [ 3, 2, 2 ] ); * // returns [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 1, 2 ], [ 3, 4 ] ], [ [ 1, 2 ], [ 3, 4 ] ] ] * * var shy = getShape( y ); * // returns [ 3, 2, 2 ] */ maybeBroadcastArray: typeof maybeBroadcastArray; /** * Broadcasts an ndarray to a specified shape if and only if the specified shape differs from the provided ndarray's shape. * * ## Notes * * - If a provided ndarray has the same shape as the specified shape (excluding the list of specified dimensions), the function returns the provided ndarray unchanged. * - The function expects that each index in the list of dimensions is negative in order to ensure that indices correspond to the same relative position in the output ndarray shape. For example, given an input ndarray shape `[2,X1,X2]` and a desired shape `[6,7,2,Y1,Y2]`, a list of negative dimensions `[-2,-1]` correctly maps the unchanged dimensions `X` in the input ndarray to ignored dimensions `Y` in the provided target shape. Nonnegative indices, however, afford no such mapping. For example, the list of dimensions `[1,2]` corresponds to `[X1,X2]` in the input ndarray shape, but to `[7,2]` in the target shape, which is not desired. By expecting negative indices, we avoid confusion and ensure that users always refer to dimensions relative to the last broadcasted dimension. * - The function throws an error if a provided ndarray is incompatible with a provided shape. * - If a provided ndarray does not have the same shape as the specified shape, the returned array is a view on the input array data buffer. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned array, copy the array before performing operations which may mutate elements. * - If a provided ndarray does not have the same shape as the specified shape, the returned array is a "base" ndarray, and, thus, the returned array does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead. * * @param arr - input array * @param shape - desired shape * @param dims - list of dimensions to exclude from broadcasting * @throws input array cannot have more dimensions than the desired shape * @throws broadcasted dimensions in the input array and desired shape must be broadcast compatible * @throws dimension indices must not exceed desired shape bounds * @throws must provide unique dimension indices * @returns broadcasted array * * @example * var array = require( './../../../array' ); * var getShape = require( './../../../shape' ); * * var x = array( [ [ 1, 2, 3 ] ] ); * // returns [ [ 1, 2, 3 ] ] * * var y = ns.maybeBroadcastArrayExceptDimensions( x, [ 2, 2, 3 ], [ -2 ] ); * // returns [ [ [ 1, 2, 3 ] ], [ [ 1, 2, 3 ] ] ] */ maybeBroadcastArrayExceptDimensions: typeof maybeBroadcastArrayExceptDimensions; /** * Broadcasts ndarrays to a common shape. * * ## Notes * * - The function throws an error if a provided broadcast-incompatible ndarrays. * - If a provided ndarray has a shape matching the common shape, the function returns the provided ndarray. * - If a provided ndarray has a different (broadcast compatible) shape than the common shape, the function returns a new (base) ndarray view of the provided ndarray's data. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to a view may affect multiple elements. If you need to write to a returned array, copy the array before performing operations which may mutate elements. * - A returned array view is a "base" ndarray, and, thus, a returned array view does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast ndarray-like objects within internal implementations and to do so with minimal overhead. * * @param arrays - input arrays * @throws input arrays must be broadcast compatible * @returns list of broadcasted arrays * * @example * var getShape = require( './../../../shape' ); * var array = require( './../../../array' ); * var zeros = require( './../../../zeros' ); * * var x1 = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var shx = getShape( x1 ); * // returns [ 2, 2 ] * * var y1 = zeros( [ 3, 2, 2 ] ); * // returns [ [ [ 0, 0 ], [ 0, 0 ] ], [ [ 0, 0 ], [ 0, 0 ] ], [ [ 0, 0 ], [ 0, 0 ] ] ] * * var shy = getShape( y1 ); * // returns [ 3, 2, 2 ] * * var out = ns.maybeBroadcastArrays( [ x1, y1 ] ); * // returns [ , ] * * var x2 = out[ 0 ]; * // returns [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 1, 2 ], [ 3, 4 ] ], [ [ 1, 2 ], [ 3, 4 ] ] ] * * var y2 = out[ 1 ]; * // returns [ [ [ 0, 0 ], [ 0, 0 ] ], [ [ 0, 0 ], [ 0, 0 ] ], [ [ 0, 0 ], [ 0, 0 ] ] ] * * shx = getShape( x2 ); * // returns [ 3, 2, 2 ] * * shy = getShape( y2 ); * // returns [ 3, 2, 2 ] */ maybeBroadcastArrays: typeof maybeBroadcastArrays; /** * Defines non-enumerable read-only properties which expose ndarray function meta data. * * @param meta - function meta data * @param meta.nargs - total number of arguments * @param meta.nin - total number of input arrays * @param meta.nout - total number of output arrays * @param dtypes - list of ndarray data types * @param obj - object on which to define properties * @returns object on which properties were defined * * @example * // Define ndarray function meta data: * var meta = { * 'nargs': 2, * 'nin': 1, * 'nout': 1 * }; * * // Define the list of ndarray data types: * var dtypes = [ * 'float64', 'float64', * 'float32', 'float32', * 'generic', 'generic' * ]; * * // Define an object/function on which to set the properties: * var obj = {}; * * // Set the properties: * ns.metaDataProps( meta, dtypes, obj ); */ metaDataProps: typeof metaDataProps; /** * Returns the minimum ndarray data type for storing a provided signed integer value. * * @param value - scalar value * @returns ndarray data type * * @example * var dt = ns.minSignedIntegerDataType( 1280 ); * // returns 'int16' * * @example * var dt = ns.minSignedIntegerDataType( 3 ); * // returns 'int8' */ minSignedIntegerDataType: typeof minSignedIntegerDataType; /** * Returns the minimum ndarray data type for storing a provided unsigned integer value. * * @param value - scalar value * @returns ndarray data type * * @example * var dt = ns.minUnsignedIntegerDataType( 1280 ); * // returns 'uint16' * * @example * var dt = ns.minUnsignedIntegerDataType( 3 ); * // returns 'uint8' */ minUnsignedIntegerDataType: typeof minUnsignedIntegerDataType; /** * Computes the minimum linear index in an underlying data buffer accessible to an array view. * * @param shape - array shape * @param strides - stride array * @param offset - index offset * @returns linear index * * @example * var shape = [ 10, 10 ]; * var strides = [ 10, 1 ]; * var offset = 10; * * var idx = ns.minViewBufferIndex( shape, strides, offset ); * // returns 10 * * @example * var shape = [ 10, 10 ]; * var strides = [ -10, -1 ]; * var offset = 109; * * var idx = ns.minViewBufferIndex( shape, strides, offset ); * // returns 10 * * @example * var shape = [ 10, 10 ]; * var strides = [ 1, 10 ]; * var offset = 10; * * var idx = ns.minViewBufferIndex( shape, strides, offset ); * // returns 10 * * @example * var shape = [ 10, 10 ]; * var strides = [ -1, -10 ]; * var offset = 109; * * var idx = ns.minViewBufferIndex( shape, strides, offset ); * // returns 10 */ minViewBufferIndex: typeof minViewBufferIndex; /** * Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. * * @param shape - array shape * @param strides - stride array * @param offset - index offset * @returns linear indices * * @example * var shape = [ 10, 10 ]; * var strides = [ 10, 1 ]; * var offset = 10; * * var idx = ns.minmaxViewBufferIndex( shape, strides, offset ); * // returns [ 10, 109 ] * * @example * var shape = [ 10, 10 ]; * var strides = [ -10, -1 ]; * var offset = 99; * * var idx = ns.minmaxViewBufferIndex( shape, strides, offset ); * // returns [ 0, 99 ] * * @example * var shape = [ 10, 10 ]; * var strides = [ 1, 10 ]; * var offset = 10; * * var idx = ns.minmaxViewBufferIndex( shape, strides, offset ); * // returns [ 10, 109 ] * * @example * var shape = [ 10, 10 ]; * var strides = [ -1, -10 ]; * var offset = 99; * * var idx = ns.minmaxViewBufferIndex( shape, strides, offset ); * // returns [ 0, 99 ] */ minmaxViewBufferIndex: typeof minmaxViewBufferIndex; /** * Creates a NaN-filled array having a specified shape and data type. * * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns NaN-filled array * * @example * var getDType = require( './../../../dtype' ); * * var arr = ns.nans( 'float64', [ 2, 2 ], 'row-major' ); * // returns [ [ NaN, NaN ], [ NaN, NaN ] ] * * var dt = String( getDType( arr ) ); * // returns 'float64' */ nans: typeof nans; /** * Creates a NaN-filled array having the same shape and data type as a provided input ndarray. * * @param x - input array * @returns NaN-filled array * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * var ones = require( './../../../base/ones' ); * * var x = ones( 'float64', [ 2, 2 ], 'row-major' ); * // returns [ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ] * * var sh = getShape( x ); * // returns [ 2, 2 ] * * var dt = String( getDType( x ) ); * // returns 'float64' * * var y = ns.nansLike( x ); * // returns [ [ NaN, NaN ], [ NaN, NaN ] ] * * sh = getShape( y ); * // returns [ 2, 2 ] * * dt = String( getDType( y ) ); * // returns 'float64' */ nansLike: typeof nansLike; /** * Converts an ndarray-like object to an ndarray descriptor. * * @param x - input ndarray * @returns ndarray descriptor * * @example * var zeros = require( './../../../zeros' ); * * var out = ns.ndarraylike2descriptor( zeros( [ 2, 2 ] ) ); * // returns {...} */ ndarraylike2descriptor: typeof ndarraylike2descriptor; /** * Converts an ndarray-like object to an ndarray. * * @param x - input ndarray * @returns ndarray * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); * * var out = ns.ndarraylike2ndarray( x ); * // returns */ ndarraylike2ndarray: typeof ndarraylike2ndarray; /** * Converts an ndarray-like object to an object likely to have the same "shape". * * ## Notes * * - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding ndarray meta data to ensure that internal functions operating on ndarrays are provided consistent argument "shapes". * * @param x - input ndarray * @returns object containing ndarray data * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); * * var obj = ns.ndarraylike2object( x ); * // returns {...} */ ndarraylike2object: typeof ndarraylike2object; /** * Converts an ndarray-like object to a scalar value. * * @param x - input ndarray * @returns scalar value * * @example * var scalar2ndarray = require( './../../../from-scalar' ); * * var x = scalar2ndarray( 1.0 ); * // returns * * var out = ns.ndarraylike2scalar( x ); * // returns 1.0 */ ndarraylike2scalar: typeof ndarraylike2scalar; /** * Returns the number of ndarray dimensions. * * @param x - input ndarray * @returns number of dimensions * * @example * var zeros = require( './../../../zeros' ); * * var n = ns.ndims( zeros( [ 3, 3, 3 ] ) ); * // returns 3 */ ndims: typeof ndims; /** * Returns the next Cartesian index (i.e., set of subscripts/dimension indices). * * ## Notes * * - The function does not check whether the current index is the "last" index. Instead, if the function is provided dimension indices corresponding to the last element, the function will cycle back to the "first" index. * - If provided an empty shape (i.e., a shape corresponding to a zero-dimensional ndarray) or a dimension index `dim` which is out-of-bounds, the function returns `null`. * * @param shape - array shape * @param order - iteration order * @param idx - current dimension indices * @param dim - index of the dimension from which to start incrementing (inclusive) * @returns updated dimension indices * * @example * var shape = [ 12 ]; * var idx = ns.nextCartesianIndex( shape, 'row-major', [ 2 ], 0 ); * // returns [ 3 ] * * @example * var shape = [ 2, 2, 2 ]; * * var idx = ns.nextCartesianIndex( shape, 'row-major', [ 0, 0, 1 ], -1 ); * // returns [ 0, 1, 0 ] * * idx = ns.nextCartesianIndex( shape, 'row-major', idx, -1 ); * // returns [ 0, 1, 1 ] * * idx = ns.nextCartesianIndex( shape, 'row-major', idx, -1 ); * // returns [ 1, 0, 0 ] * * idx = ns.nextCartesianIndex( shape, 'row-major', idx, -1 ); * // returns [ 1, 0, 1 ] * * idx = ns.nextCartesianIndex( shape, 'row-major', idx, -1 ); * // returns [ 1, 1, 0 ] * * idx = ns.nextCartesianIndex( shape, 'row-major', idx, -1 ); * // returns [ 1, 1, 1 ] * * @example * var shape = []; * var idx = ns.nextCartesianIndex( shape, 'row-major', [], 0 ); * // returns null * * @example * var shape = [ 12 ]; * var idx = ns.nextCartesianIndex( shape, 'row-major', [ 2 ], -10 ); * // returns null * * @example * var shape = [ 12 ]; * var idx = ns.nextCartesianIndex( shape, 'column-major', [ 2 ], 10 ); * // returns null */ nextCartesianIndex: typeof nextCartesianIndex; /** * Returns the number of non-singleton dimensions. * * ## Notes * * - A singleton dimension is a dimension whose size is equal to `1`. * * @param shape - array shape * @returns number of non-singleton dimensions * * @example * var n = ns.nonsingletonDimensions( [ 3, 3, 1, 2 ] ); * // returns 3 * * @example * var n = ns.nonsingletonDimensions( [ 1, 1 ] ); * // returns 0 */ nonsingletonDimensions: typeof nonsingletonDimensions; /** * Normalizes an index to the interval `[0,max]`. * * ## Notes * * - If provided an out-of-bounds index, the function returns `-1`. * * @param idx - index * @param max - maximum index * @returns index * * @example * var idx = ns.normalizeIndex( -2, 10 ); * // returns 9 * * idx = ns.normalizeIndex( 15, 10 ); * // returns -1 * * idx = ns.normalizeIndex( 5, 10 ); * // returns 5 */ normalizeIndex: typeof normalizeIndex; /** * Normalizes a list of indices to the interval `[0,max]`. * * ## Notes * * - If provided an out-of-bounds index, the function returns `null`. * - The function mutates the input array, even when provided an out-of-bounds index. * * @param indices - indices * @param max - maximum index * @returns normalized indices or null * * @example * var indices = ns.normalizeIndices( [ -2, 5 ], 10 ); * // returns [ 9, 5 ] * * indices = ns.normalizeIndices( [ -2, 15 ], 10 ); * // returns null */ normalizeIndices: typeof normalizeIndices; /** * Applies a nullary callback and assigns results to elements in an output ndarray. * * @param arrays - array-like object containing an output ndarray * @param fcn - nullary callback * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * * function fcn() { * return 10.0; * } * * // Create data buffers: * var xbuf = new Float64Array( 12 ); * * // Define the shape of the output array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the output ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Apply the ns.nullary function: * ns.nullary( [ x ], fcn ); * * console.log( x.data ); * // => [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] */ nullary: typeof nullary; /** * Reorders ndarray dimensions and associated strides for loop interchange. * * ## Notes * * - The returned object has the following properties: * * - **sh**: dimensions sorted in loop order. * - **sx**: ndarray strides sorted in loop order. * - **idx**: dimension indices sorted in loop order. * * - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache. * * The purpose of this function is to order ndarray dimensions according to the magnitude of array strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference. * * @param sh - array dimensions * @param sx - array stride lengths * @returns loop interchange data * * @example * var sh = [ 2, 3, 4 ]; * * var sx = [ 12, 4, 1 ]; // row-major * * var o = ns.nullaryLoopOrder( sh, sx ); * // returns {...} * * var ssh = o.sh; * // returns [ 4, 3, 2 ] * * var ssx = o.sx; * // returns [ 1, 4, 12 ] * * var idx = o.idx; * // returns [ 2, 1, 0 ] */ nullaryLoopOrder: typeof nullaryLoopOrder; /** * Constructor for applying a strided function to an ndarray. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param options - function options * @returns instance * * @example * var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); * var dtypes = require( './../../../dtypes' ); * var scalar2ndarray = require( './../../../from-scalar' ); * var ndarray2array = require( './../../../to-array' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = dtypes( 'all' ); * * var table = { * 'default': base * }; * var sorthp = new ns.nullaryStrided1dDispatch( table, [ idt ], odt ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * var order = scalar2ndarray( 1.0, { * 'dtype': 'generic' * }); * * var out = sorthp.assign( x, order ); * // returns * * var arr = ndarray2array( x ); * // returns [ -3.0, -1.0, 2.0 ] * * var bool = ( out === x ); * // returns true */ nullaryStrided1dDispatch: typeof nullaryStrided1dDispatch; /** * Creates a function for applying a strided function to an output ndarray. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param options - function options * @returns function for applying a nullary function * * @example * var base = require( '@stdlib/blas/ext/base/ndarray/gsorthp' ); * var dtypes = require( './../../../dtypes' ); * var scalar2ndarray = require( './../../../from-scalar' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = dtypes( 'all' ); * * var table = { * 'default': base * }; * var sorthp = ns.nullaryStrided1dDispatchFactory( table, [ idt ], odt ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * var order = scalar2ndarray( 1.0, { * 'dtype': 'generic' * }); * * var out = sorthp( x, order ); * // returns [ -3.0, -1.0, 2.0 ] * * var bool = ( out === x ); * // returns true */ nullaryStrided1dDispatchFactory: typeof nullaryStrided1dDispatchFactory; /** * Returns a loop block size for multi-dimensional array tiled loops. * * @param dtypeX - array data type * @returns block size (in units of elements) * * @example * var bsize = ns.nullaryBlockSize( 'float64' ); * // returns */ nullaryBlockSize: typeof nullaryBlockSize; /** * Creates a null-filled array having a specified shape and data type. * * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns null-filled array * * @example * var getDType = require( './../../../dtype' ); * * var arr = ns.nulls( 'generic', [ 2, 2 ], 'row-major' ); * // returns [ [ null, null ], [ null, null ] ] * * var dt = String( getDType( arr ) ); * // returns 'generic' */ nulls: typeof nulls; /** * Creates a null-filled array having the same shape and data type as a provided input ndarray. * * @param x - input array * @returns null-filled array * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * var empty = require( './../../../empty' ); * * var x = empty( [ 2, 2 ], { * 'dtype': 'generic' * }); * // returns * * var sh = getShape( x ); * // returns [ 2, 2 ] * * var dt = String( getDType( x ) ); * // returns 'generic' * * var y = ns.nullsLike( x ); * // returns [ [ null, null ], [ null, null ] ] * * sh = getShape( y ); * // returns [ 2, 2 ] * * dt = String( getDType( y ) ); * // returns 'generic' */ nullsLike: typeof nullsLike; /** * Returns the number of elements in an array. * * @param shape - array shape * @returns number of elements * * @example * var n = ns.numel( [ 3, 3, 3 ] ); * // returns 27 */ numel: typeof numel; /** * Returns the size (i.e., number of elements) of a specified dimension for a provided ndarray. * * @param x - input ndarray * @param dim - dimension index * @returns dimension size * * @example * var zeros = require( './../../../zeros' ); * * var d = ns.numelDimension( zeros( [ 4, 2, 3 ] ), 0 ); * // returns 4 */ numelDimension: typeof numelDimension; /** * Returns the index offset specifying the underlying buffer index of the first iterated ndarray element. * * @param x - input ndarray * @returns index offset * * @example * var zeros = require( './../../../zeros' ); * * var n = ns.offset( zeros( [ 3, 3, 3 ] ) ); * // returns 0 */ offset: typeof offset; /** * Creates a ones-filled array having a specified shape and data type. * * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns ones-filled array * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * * var arr = ns.ones( 'float64', [ 2, 2 ], 'row-major' ); * // returns [ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ] * * var sh = getShape( arr ); * // returns [ 2, 2 ] * * var dt = String( getDType( arr ) ); * // returns 'float64' */ ones: typeof ones; /** * Creates a ones-filled array having the same shape and data type as a provided input ndarray. * * @param x - input array * @returns ones-filled array * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * var ones = require( './../../../base/ones' ); * * var x = ones( 'float64', [ 2, 2 ], 'row-major' ); * // returns [ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ] * * var sh = getShape( x ); * // returns [ 2, 2 ] * * var dt = String( getDType( x ) ); * // returns 'float64' * * var y = ns.onesLike( x ); * // returns [ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ] * * sh = getShape( y ); * // returns [ 2, 2 ] * * dt = String( getDType( y ) ); * // returns 'float64' */ onesLike: typeof onesLike; /** * Returns the layout order of a provided ndarray. * * ## Notes * * - If unable to resolve a layout order, the function returns `null`. * * @param x - input ndarray * @returns layout order (or null) * * @example * var zeros = require( './../../../zeros' ); * * var x = zeros( [ 3, 3, 3 ], { * 'ns.order': 'row-major' * }); * * var o = ns.order( x ); * // returns 'row-major' */ order: typeof order; /** * Resolves the output data type from a list of input ndarray data types. * * @param dtypes - input ndarray data types * @param policy - output ndarray data type policy * @returns output ndarray data type * * @example * var dt = ns.outputDataType( [ 'float64' ], 'complex_floating_point' ); * // returns */ outputDataType: typeof outputDataType; /** * Resolves the order (i.e. memory layout) of an output ndarray according to a list of input ndarrays. * * ## Notes * * - When the layout differs among provided ndarrays, the function returns the default layout. * * @param arrays - list of input ndarrays * @returns storage layout * * @example * var zeros = require( './../../../zeros' ); * * var x = zeros( [ 2, 2 ] ); * var y = zeros( [ 2, 2 ] ); * * var order = ns.outputOrder( [ x, y ] ); * // returns */ outputOrder: typeof outputOrder; /** * Returns the policy string associated with an output ndarray data type policy enumeration constant. * * @param policy - policy enumeration constant * @returns policy string * * @example * var str2enum = require( './../../../base/output-policy-str2enum' ); * * var v = str2enum( 'same' ); * // returns * * var policy = ns.outputPolicyEnum2Str( v ); * // returns 'same' */ outputPolicyEnum2Str: typeof outputPolicyEnum2Str; /** * Returns the enumeration constant associated with an ndarray data type policy value. * * ## Notes * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `SAME == 0`). Instead, the function should be used in an opaque manner. * * @param policy - policy value * @returns enumeration constant * * @example * var v = ns.outputPolicyResolveEnum( 'same' ); * // returns */ outputPolicyResolveEnum: typeof outputPolicyResolveEnum; /** * Returns the policy string associated with an output ndarray data type policy value. * * @param policy - policy value * @returns policy string * * @example * var str2enum = require( './../../../base/output-policy-str2enum' ); * * var v = ns.outputPolicyResolveStr( str2enum( 'same' ) ); * // returns 'same' */ outputPolicyResolveStr: typeof outputPolicyResolveStr; /** * Returns the enumeration constant associated with an output ndarray data type policy string. * * ## Notes * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `SAME == 0`). Instead, the function should be used in an opaque manner. * * @param policy - policy string * @returns enumeration constant * * @example * var v = ns.outputPolicyStr2Enum( 'same' ); * // returns */ outputPolicyStr2Enum: typeof outputPolicyStr2Enum; /** * Returns an array containing a truncated view of an input ndarray and a view of the last element(s) along a specified dimension. * * ## Notes * * - The input array must have one or more dimensions. * * @param x - input array * @param dim - dimension along which to perform the operation * @param writable - boolean indicating whether returned arrays should be writable * @returns a list of ndarrays * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = new Float64Array( [ 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( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * var arr = ndarray2array( x ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.pop( x, 0, false ); * // returns [ , ] * * arr = ndarray2array( y[ 0 ] ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] * * arr = ndarray2array( y[ 1 ] ); * // returns [ [ 5.0, 6.0 ] ] */ pop: typeof pop; /** * Returns an array with a specified number of prepended singleton dimensions. * * @param x - input array * @param n - number of singleton dimensions to prepend * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.prependSingletonDimensions( x, 3, false ); * // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] */ prependSingletonDimensions: typeof prependSingletonDimensions; /** * Returns a data type that results from applying promotion rules to a provided list of data types. * * ## Notes * * - The function returns `null` if provided data types which cannot be safely cast to a promoted data type. * * @param dtypes - list of data types * @returns result * * @example * var dt = ns.promoteDataTypes( [ 'float32', 'float64' ] ); * // returns 'float64' * * @example * var dt = ns.promoteDataTypes( [ 'binary', 'complex128' ] ); * // returns null */ promoteDataTypes: typeof promoteDataTypes; /** * Reorders ndarray dimensions and associated strides for loop interchange. * * ## Notes * * - The returned object has the following properties: * * - **sh**: dimensions sorted in loop order. * - **sx**: first input ndarray strides sorted in loop order. * - **sy**: second input ndarray strides sorted in loop order. * - **sz**: third input ndarray strides sorted in loop order. * - **sw**: fourth input ndarray strides sorted in loop order. * - **su**: output ndarray strides sorted in loop order. * * - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache. * * The purpose of this function is to order ndarray dimensions according to the magnitude of array strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference. * * - Cache performance may be degraded if the layout order (i.e., row-major or column-major) differs for the input and output ndarrays. This function is intended to optimize cache performance for the most common layout order. Accordingly, if the output ndarray has a different layout order (e.g., if the input ndarrays are row-major and the output ndarray is column-major), cache misses are likely for the output ndarray. In general, to ensure best performance, input and output ndarrays should have the same layout order. * * - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting. * * @param shape - array dimensions * @param stridesX - first input array stride lengths * @param stridesY - second input array stride lengths * @param stridesZ - third input array stride lengths * @param stridesW - fourth input array stride lengths * @param stridesU - output array stride lengths * @returns loop interchange data * * @example * var sh = [ 2, 3, 4 ]; * * var sx = [ 12, 4, 1 ]; // row-major * var sy = [ 24, 8, 1 ]; // row-major * var sz = [ 1, 4, 12 ]; // column-major * var sw = [ 1, -2, 6 ]; // column-major * var su = [ 1, -2, 6 ]; // column-major * * var o = ns.quaternaryLoopOrder( sh, sx, sy, sz, sw, su ); * // returns {...} * * var ssh = o.sh; * // returns [ 2, 3, 4 ] * * var ssx = o.sx; * // returns [ 12, 4, 1 ] * * var ssy = o.sy; * // returns [ 24, 8, 1 ] * * var ssz = o.sz; * // returns [ 1, 4, 12 ] * * var ssw = o.sw; * // returns [ 1, -2, 6 ] * * var ssu = o.su; * // returns [ 1, -2, 6 ] */ quaternaryLoopOrder: typeof quaternaryLoopOrder; /** * Returns a loop block size for multi-dimensional array tiled loops. * * @param dtypeX - first input array data type * @param dtypeY - second input array data type * @param dtypeZ - third input array data type * @param dtypeW - fourth input array data type * @param dtypeU - output array data type * @returns block size (in units of elements) * * @example * var bsize = ns.quaternaryBlockSize( 'float64', 'float64', 'float64', 'float64', 'float64' ); * // returns */ quaternaryBlockSize: typeof quaternaryBlockSize; /** * Reorders ndarray dimensions and associated strides for loop interchange. * * ## Notes * * - The returned object has the following properties: * * - **sh**: dimensions sorted in loop order. * - **sx**: first input ndarray strides sorted in loop order. * - **sy**: second input ndarray strides sorted in loop order. * - **sz**: third input ndarray strides sorted in loop order. * - **sw**: fourth input ndarray strides sorted in loop order. * - **su**: fifth input ndarray strides sorted in loop order. * - **sv**: output ndarray strides sorted in loop order. * * - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache. * * The purpose of this function is to order ndarray dimensions according to the magnitude of array strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference. * * - Cache performance may be degraded if the layout order (i.e., row-major or column-major) differs for the input and output ndarrays. This function is intended to optimize cache performance for the most common layout order. Accordingly, if the output ndarray has a different layout order (e.g., if the input ndarrays are row-major and the output ndarray is column-major), cache misses are likely for the output ndarray. In general, to ensure best performance, input and output ndarrays should have the same layout order. * * - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting. * * @param shape - array dimensions * @param stridesX - first input array stride lengths * @param stridesY - second input array stride lengths * @param stridesZ - third input array stride lengths * @param stridesW - fourth input array stride lengths * @param stridesU - fifth input array stride lengths * @param stridesV - output array stride lengths * @returns loop interchange data * * @example * var sh = [ 2, 3, 4 ]; * * var sx = [ 12, 4, 1 ]; // row-major * var sy = [ 24, 8, 1 ]; // row-major * var sz = [ 12, 4, 1 ]; // row-major * var sw = [ 24, 8, 1 ]; // row-major * var su = [ 1, 4, 12 ]; // column-major * var sv = [ 1, -2, 6 ]; // column-major * * var o = ns.quinaryLoopOrder( sh, sx, sy, sz, sw, su, sv ); * // returns {...} * * var ssh = o.sh; * // returns [ 4, 3, 2 ] * * var ssx = o.sx; * // returns [ 1, 4, 12 ] * * var ssy = o.sy; * // returns [ 1, 8, 24 ] * * var ssz = o.sz; * // returns [ 1, 4, 12 ] * * var ssw = o.sw; * // returns [ 1, 8, 24 ] * * var ssu = o.su; * // returns [ 12, 4, 1 ] * * var ssv = o.sv; * // returns [ 6, -2, 1 ] */ quinaryLoopOrder: typeof quinaryLoopOrder; /** * Returns a loop block size for multi-dimensional array tiled loops. * * @param dtypeX - first input array data type * @param dtypeY - second input array data type * @param dtypeZ - third input array data type * @param dtypeW - fourth input array data type * @param dtypeU - fifth input array data type * @param dtypeV - output array data type * @returns block size (in units of elements) * * @example * var bsize = ns.quinaryBlockSize( 'float64', 'float64', 'float64', 'float64', 'float64', 'float64' ); * // returns */ quinaryBlockSize: typeof quinaryBlockSize; /** * Reinterprets a boolean ndarray as an unsigned 8-bit integer ndarray. * * ## Notes * * - The returned ndarray is a view on the input ndarray data buffer. * - The returned ndarray is a "base" ndarray, and, thus, the returned ndarray does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to reinterpret an ndarray-like object within internal implementations and to do so with minimal overhead. * * @param x - input ndarray * @returns unsigned 8-bit integer ndarray view * * @example * var zeros = require( './../../../base/zeros' ); * * var x = zeros( 'bool', [ 2, 2 ], 'row-major' ); * // returns [ [ false, false ], [ false, false ] ] * * var out = ns.reinterpretBoolean( x ); * // returns [ [ 0, 0 ], [ 0, 0 ] ] */ reinterpretBoolean: typeof reinterpretBoolean; /** * Reinterprets a single-precision complex floating-point ndarray as a real-valued single-precision floating-point ndarray containing interleaved real and imaginary components. * * ## Notes * * - The returned ndarray is a view on the input ndarray data buffer. * - The returned ndarray has an additional trailing dimension of size two whose elements correspond to the real and imaginary components, respectively, of each complex-valued element in the input ndarray. * - The returned ndarray is a "base" ndarray, and, thus, the returned ndarray does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to reinterpret an ndarray-like object within internal implementations and to do so with minimal overhead. * * @param x - input ndarray * @returns single-precision floating-point ndarray view * * @example * var zeroTo = require( '@stdlib/blas/ext/zero-to' ); * * var x = zeroTo( [ 2, 2 ], { * 'dtype': 'complex64' * }); * // returns [ [ [ 0.0, 0.0 ], [ 1.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 1.0, 0.0 ] ] ] * * var out = ns.reinterpretComplex( x ); * // returns [ [ [ 0.0, 0.0 ], [ 1.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 1.0, 0.0 ] ] ] */ reinterpretComplex: typeof reinterpretComplex; /** * Reinterprets a single-precision complex floating-point ndarray as a real-valued single-precision floating-point ndarray containing interleaved real and imaginary components. * * ## Notes * * - The returned ndarray is a view on the input ndarray data buffer. * - The returned ndarray has an additional trailing dimension of size two whose elements correspond to the real and imaginary components, respectively, of each complex-valued element in the input ndarray. * - The returned ndarray is a "base" ndarray, and, thus, the returned ndarray does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to reinterpret an ndarray-like object within internal implementations and to do so with minimal overhead. * * @param x - input ndarray * @returns single-precision floating-point ndarray view * * @example * var ones = require( './../../../base/ones' ); * * var x = ones( 'complex64', [ 2, 2 ], 'row-major' ); * // returns [ [ [ 1.0, 0.0 ], [ 1.0, 0.0 ] ], [ [ 1.0, 0.0 ], [ 1.0, 0.0 ] ] ] * * var out = ns.reinterpretComplex64( x ); * // returns [ [ [ 1.0, 0.0 ], [ 1.0, 0.0 ] ], [ [ 1.0, 0.0 ], [ 1.0, 0.0 ] ] ] */ reinterpretComplex64: typeof reinterpretComplex64; /** * Reinterprets a double-precision complex floating-point ndarray as a real-valued double-precision floating-point ndarray containing interleaved real and imaginary components. * * ## Notes * * - The returned ndarray is a view on the input ndarray data buffer. * - The returned ndarray has an additional trailing dimension of size two whose elements correspond to the real and imaginary components, respectively, of each complex-valued element in the input ndarray. * - The returned ndarray is a "base" ndarray, and, thus, the returned ndarray does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to reinterpret an ndarray-like object within internal implementations and to do so with minimal overhead. * * @param x - input ndarray * @returns double-precision floating-point ndarray view * * @example * var ones = require( './../../../base/ones' ); * * var x = ones( 'complex128', [ 2, 2 ], 'row-major' ); * // returns [ [ [ 1.0, 0.0 ], [ 1.0, 0.0 ] ], [ [ 1.0, 0.0 ], [ 1.0, 0.0 ] ] ] * * var out = ns.reinterpretComplex128( x ); * // returns [ [ [ 1.0, 0.0 ], [ 1.0, 0.0 ] ], [ [ 1.0, 0.0 ], [ 1.0, 0.0 ] ] ] */ reinterpretComplex128: typeof reinterpretComplex128; /** * Returns an ndarray without singleton dimensions. * * ## Notes * * - The function always returns a new ndarray instance even if the input ndarray does not contain any singleton dimensions. * * @param x - input array * @param writable - boolean indicating whether a returned array should be writable * @returns squeezed array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ], { * 'ndmin': 5 * }); * // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] * * var y = ns.removeSingletonDimensions( x, false ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] */ removeSingletonDimensions: typeof removeSingletonDimensions; /** * Returns a view of an input ndarray in which the order of elements along each dimension is reversed. * * @param x - input array * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var typedarray = require( '@stdlib/array/typed' ); * var getShape = require( './../../../shape' ); * var ndarray = require( './../../../ctor' ); * * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var sh = getShape( x ); * // returns [ 3, 2 ] * * var y = ns.reverse( x, false ); * // returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] * * sh = getShape( y ); * // returns [ 3, 2 ] */ reverse: typeof reverse; /** * Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed. * * @param x - input array * @param dim - index of dimension to reverse * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var typedarray = require( '@stdlib/array/typed' ); * var ndarray = require( './../../../ctor' ); * var getShape = require( './../../../shape' ); * * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var sh = getShape( x ); * // returns [ 3, 2 ] * * var y = ns.reverseDimension( x, 0, false ); * // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ] * * sh = getShape( y ); * // returns [ 3, 2 ] */ reverseDimension: typeof reverseDimension; /** * Returns a view of an input ndarray in which the order of elements along specified dimensions is reversed. * * @param x - input array * @param dims - indices of dimensions to reverse * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.reverseDimensions( x, [ 0, 1 ], false ); * // returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] */ reverseDimensions: typeof reverseDimensions; /** * Rotates an ndarray 90 degrees in a specified plane. * * ## Notes * * - If `k > 0`, the function rotates the plane from the first specified dimension toward the second specified dimension. This means that, for a two-dimensional ndarray and `dims = [0, 1]`, the function rotates the plane counterclockwise. * - If `k < 0`, the function rotates the plane from the second specified dimension toward the first specified dimension. This means that, for a two-dimensional ndarray and `dims = [0, 1]`, the function rotates the plane clockwise. * - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. * * @param x - input array * @param dims - dimension indices defining the plane of rotation * @param k - number of times to rotate by 90 degrees * @param writable - boolean indicating whether the returned ndarray should be writable * @returns ndarray view * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.rot90( x, [ 0, 1 ], 1, false ); * // returns [ [ 2, 4 ], [ 1, 3 ] ] */ rot90: typeof rot90; /** * Rotates an ndarray 180 degrees in a specified plane. * * ## Notes * * - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. * * @param x - input array * @param dims - dimension indices defining the plane of rotation * @param writable - boolean indicating whether the returned ndarray should be writable * @returns ndarray view * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.rot180( x, [ 0, 1 ], false ); * // returns [ [ 4, 3 ], [ 2, 1 ] ] */ rot180: typeof rot180; /** * Rotates a matrix (or a stack of matrices) 90 degrees counterclockwise. * * @param x - input array * @param k - number of times to rotate by 90 degrees * @param writable - boolean indicating whether the returned ndarray should be writable * @returns ndarray view * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.rotl90( x, 1, false ); * // returns [ [ 2, 4 ], [ 1, 3 ] ] */ rotl90: typeof rotl90; /** * Rotates a matrix (or a stack of matrices) 90 degrees clockwise. * * @param x - input array * @param k - number of times to rotate by 90 degrees * @param writable - boolean indicating whether the returned ndarray should be writable * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.rotr90( x, 1, false ); * // returns [ [ 3, 1 ], [ 4, 2 ] ] */ rotr90: typeof rotr90; /** * Serializes ndarray meta data. * * ## Notes * * - Serialization is performed according to host byte order (endianness). * * - Meta data format: * * ```text * | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | * ``` * * which translates to the following `ArrayBuffer` layout: * * ```text * ArrayBuffer[ * [int8], * [int16], * [int64], * [ndims*int64], * [ndims*int64], * [int64], * [int8], * [int8], * [int64], * [nsubmodes*int8] * [int32] * ] * ``` * * where `strides` and `offset` are in units of bytes. * * - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. * * - Buffer length: * * ```text * 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes * ``` * * For example, consider a three-dimensional ndarray with one subscript index mode (submode): * * ```text * 33 + (3*16) + 1 = 82 bytes * ``` * * - Views: * * - endianness: `Int8Array( buf, 0, 1 )` * - dtype: `Int16Array( buf, 1, 1 )` * - ndims: `Int64Array( buf, 3, 1 )` * - shape: `Int64Array( buf, 11, ndims )` * - strides: `Int64Array( buf, 11+(ndims*8), ndims )` * - offset: `Int64Array( buf, 11+(ndims*16), 1 )` * - order: `Int8Array( buf, 19+(ndims*16), 1 )` * - mode: `Int8Array( buf, 20+(ndims*16), 1 )` * - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` * - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` * - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1)` * * @param x - input ndarray * @returns serialized meta data * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * * var dv = ns.serializeMetaData( x ); * // returns */ serializeMetaData: typeof serializeMetaData; /** * Returns the shape of a provided ndarray. * * ## Notes * * - When `copy` is `false`, changes to the returned shape array may mutate the input ndarray shape. If there is a chance that the returned shape will be mutated (either directly or by downstream consumers), set `copy` to `true` to prevent unintended side effects. * * @param x - input ndarray * @param copy - boolean indicating whether to explicitly copy the value assigned to the input ndarray's `shape` property * @returns shape * * @example * var zeros = require( './../../../zeros' ); * * var sh = ns.shape( zeros( [ 3, 3, 3 ] ), false ); * // returns [ 3, 3, 3 ] */ shape: typeof shape; /** * Generates a stride array from an array shape. * * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns array strides * * @example * var s = ns.shape2strides( [ 3, 2 ], 'row-major' ); * // returns [ 2, 1 ] * * s = ns.shape2strides( [ 3, 2 ], 'column-major' ); * // returns [ 1, 3 ] */ shape2strides: typeof shape2strides; /** * Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. * * ## Notes * * - The input array must have one or more dimensions. * * @param x - input array * @param dim - dimension along which to perform the operation * @param writable - boolean indicating whether returned arrays should be writable * @returns a list of ndarrays * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = new Float64Array( [ 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( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * var arr = ndarray2array( x ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.shift( x, 0, false ); * // returns [ , ] * * arr = ndarray2array( y[ 0 ] ); * // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * arr = ndarray2array( y[ 1 ] ); * // returns [ [ 1.0, 2.0 ] ] */ shift: typeof shift; /** * Returns the number of singleton dimensions. * * ## Notes * * - A singleton dimension is a dimension whose size is equal to `1`. * * @param shape - array shape * @returns number of singleton dimensions * * @example * var n = ns.singletonDimensions( [ 3, 3, 1, 2 ] ); * // returns 1 * * @example * var n = ns.singletonDimensions( [ 2, 2 ] ); * // returns 0 */ singletonDimensions: typeof singletonDimensions; /** * Returns a view of an input ndarray. * * @param x - input array * @param s - multi-slice object * @param strict - boolean indicating whether to enforce strict bounds checking * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var Slice = require( '@stdlib/slice/ctor' ); * var MultiSlice = require( '@stdlib/slice/multi' ); * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var sh = x.shape; * // returns [ 3, 2 ] * * var arr = ndarray2array( x ); * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] * * var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) ); * // returns * * var y = ns.slice( x, s, false, false ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 6, 5 ], [ 2, 1 ] ] */ slice: typeof slice; /** * Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. * * ## Notes * * - The input array must be broadcast compatible with the output array view to which elements will be assigned. * - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). * * @param x - input array * @param y - output array * @param s - multi-slice object for the output array * @param strict - boolean indicating whether to enforce strict bounds checking * @returns output array * * @example * var Slice = require( '@stdlib/slice/ctor' ); * var MultiSlice = require( '@stdlib/slice/multi' ); * var ndarray = require( './../../../ctor' ); * var ndzeros = require( './../../../zeros' ); * var ndarray2array = require( './../../../to-array' ); * * // Define an input array: * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var sh = x.shape; * // returns [ 3, 2 ] * * var arr = ndarray2array( x ); * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] * * // Define an output array: * var y = ndzeros( [ 2, 3, 2 ], { * 'dtype': x.dtype * }); * * // Create a slice: * var s0 = null; * var s1 = new Slice( null, null, -1 ); * var s2 = new Slice( null, null, -1 ); * var s = new MultiSlice( s0, s1, s2 ); * // returns * * // Perform assignment: * var out = ns.sliceAssign( x, y, s, false ); * // returns * * var bool = ( out === y ); * // returns true * * arr = ndarray2array( y ); * // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ] */ sliceAssign: typeof sliceAssign; /** * Returns a view of an input ndarray when sliced along a specified dimension. * * @param x - input array * @param dim - index of dimension to slice * @param s - slice object or an integer * @param strict - boolean indicating whether to enforce strict bounds checking * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var Slice = require( '@stdlib/slice/ctor' ); * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var sh = x.shape; * // returns [ 3, 2 ] * * var arr = ndarray2array( x ); * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] * * var s = new Slice( null, null, -1 ); * // returns * * var y = ns.sliceDimension( x, 0, s, false, false ); * // returns * * sh = y.shape; * // returns [ 3, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] */ sliceDimension: typeof sliceDimension; /** * Returns a shifted view of an input ndarray along a specified dimension. * * @param x - input array * @param dim - index of dimension to slice * @param start - starting index (inclusive) * @param strict - boolean indicating whether to enforce strict bounds checking * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var sh = x.shape; * // returns [ 3, 2 ] * * var arr = ndarray2array( x ); * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] * * var y = ns.sliceDimensionFrom( x, 0, 1, false, false ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 3, 4 ], [ 5, 6 ] ] */ sliceDimensionFrom: typeof sliceDimensionFrom; /** * Returns a truncated view of an input ndarray along a specified dimension. * * @param x - input array * @param dim - index of dimension to slice * @param stop - ending index (exclusive) * @param strict - boolean indicating whether to enforce strict bounds checking * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var sh = x.shape; * // returns [ 3, 2 ] * * var arr = ndarray2array( x ); * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] * * var y = ns.sliceDimensionTo( x, 0, 2, false, false ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] */ sliceDimensionTo: typeof sliceDimensionTo; /** * Returns a shifted view of an input ndarray. * * @param x - input array * @param start - starting indices (inclusive) * @param strict - boolean indicating whether to enforce strict bounds checking * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var sh = x.shape; * // returns [ 3, 2 ] * * var arr = ndarray2array( x ); * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] * * var s = [ 1, null ]; * var y = ns.sliceFrom( x, s, false, false ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 3, 4 ], [ 5, 6 ] ] */ sliceFrom: typeof sliceFrom; /** * Returns a truncated view of an input ndarray. * * @param x - input array * @param stop - ending indices (exclusive) * @param strict - boolean indicating whether to enforce strict bounds checking * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = [ 1, 2, 3, 4, 5, 6 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var sh = x.shape; * // returns [ 3, 2 ] * * var arr = ndarray2array( x ); * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] * * var s = [ 2, null ]; * var y = ns.sliceTo( x, s, false, false ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] */ sliceTo: typeof sliceTo; /** * Tests whether at least `n` elements in an ndarray are truthy. * * @param arrays - array-like object containing an input ndarray and a zero-dimensional ndarray specifying the minimum number of elements in the input ndarray that must be truthy * @returns boolean indicating whether `n` elements pass a test * * @example * var scalar2ndarray = require( './../../../from-scalar' ); * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * * // Create a data buffer: * 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 ] ); * * // Define the shape of the array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * var n = scalar2ndarray( 3, { * 'dtype': 'generic' * }); * * // Test elements: * var out = ns.some( [ x, n ] ); * // returns true */ some: typeof some; /** * Tests whether at least `n` elements in an ndarray pass a test implemented by a predicate function. * * @param arrays - array-like object containing an input ndarray and a zero-dimensional ndarray specifying the minimum number of elements in the input ndarray that must satisfy the predicate function * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns boolean indicating whether `n` elements pass a test * * @example * var scalar2ndarray = require( './../../../from-scalar' ); * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../base/ctor' ); * * function predicate( value ) { * return value > 0.0; * } * * // Create data buffers: * 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 ] ); * * // Define the shape of the array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * var n = scalar2ndarray( 3, { * 'dtype': 'generic' * }); * * // Test elements: * var out = ns.someBy( [ x, n ], predicate ); * // returns true */ someBy: typeof someBy; /** * Expands the shape of an array to a specified dimensionality by spreading its dimensions to specified dimension indices and inserting dimensions of size one for the remaining dimensions. * * ## Notes * * - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. If provided a negative dimension index, the position at which to place a respective dimension is computed as `ndims + index`. * - Provided dimension indices must resolve to normalized dimension indices arranged in ascending order. * * @param ndims - number of dimensions in the output array * @param x - input array * @param dims - dimension indices * @param writable - boolean indicating whether a returned array should be writable * @returns output array * * @example * var getShape = require( './../../../shape' ); * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns * * var shx = getShape( x ); * // returns [ 2, 2 ] * * var y = ns.spreadDimensions( 5, x, [ 1, 3 ], false ); * // returns * * var shy = getShape( y ); * // returns [ 1, 2, 1, 2, 1 ] * * var v = y.get( 0, 0, 0, 0, 0 ); * // returns 1 * * v = y.get( 0, 0, 0, 1, 0 ); * // returns 2 * * v = y.get( 0, 1, 0, 0, 0 ); * // returns 3 * * v = y.get( 0, 1, 0, 1, 0 ); * // returns 4 */ spreadDimensions: typeof spreadDimensions; /** * Returns the stride along a specified dimension for a provided ndarray. * * ## Notes * * - A "stride" is the linear distance (i.e., number of elements) between adjacent elements along a specified dimension. * * @param x - input ndarray * @param dim - dimension index * @returns stride * * @example * var zeros = require( './../../../zeros' ); * * var st = ns.stride( zeros( [ 3, 3, 3 ] ), 0 ); * // returns 9 */ stride: typeof stride; /** * Returns the strides of a provided ndarray. * * ## Notes * * - When `copy` is `false`, changes to the returned strides array may mutate the input ndarray strides. If there is a chance that the returned strides will be mutated (either directly or by downstream consumers), set `copy` to `true` to prevent unintended side effects. * * @param x - input ndarray * @param copy - boolean indicating whether to explicitly copy the value assigned to the input ndarray's `strides` property * @returns strides * * @example * var zeros = require( './../../../zeros' ); * * var st = ns.strides( zeros( [ 3, 3, 3 ] ), false ); * // returns [ 9, 3, 1 ] */ strides: typeof strides; /** * Returns the index offset which specifies the location of the first indexed value in a multidimensional array based on a stride array. * * @param shape - array shape * @param strides - stride array * @returns offset * * @example * var shape = [ 2, 3, 10 ]; * var strides = [ 30, -10, 1 ]; * * var offset = ns.strides2offset( shape, strides ); * // returns 20 */ strides2offset: typeof strides2offset; /** * Determines the order of a multidimensional array based on a provided stride array. * * @param strides - stride array * @returns order * * @example * var order = ns.strides2order( [ 2, 1 ] ); * // returns 1 * * @example * var order = ns.strides2order( [ 1, 2 ] ); * // returns 2 * * @example * var order = ns.strides2order( [ 1, 1, 1 ] ); * // returns 3 * * @example * var order = ns.strides2order( [ 2, 3, 1 ] ); * // returns 0 */ strides2order: typeof strides2order; /** * Converts subscripts to a linear index. * * ## Notes * * - The function accepts the following "modes": * * - **throw**: throw an error when a subscript exceeds array dimensions. * - **normalize**: normalize negative subscripts and throw an error when a subscript exceeds array dimensions. * - **wrap**: wrap around subscripts exceeding array dimensions using modulo arithmetic. * - **clamp**: set subscripts exceeding array dimensions to either `0` (minimum index) or the maximum index along a particular dimension. * * - When provided fewer modes than dimensions, the function recycles modes using modulo arithmetic. * * - When provided a stride array containing negative strides, if an `offset` is greater than `0`, the function treats subscripts as mapping to a linear index in an underlying data buffer for the array, thus returning a linear index from the perspective of that buffer. If an `offset` is equal to `0`, the function treats subscripts as mapping to a linear index in an array view, thus returning a linear index from the perspective of that view. * * ```text * Dims: 2x2 * Buffer: [ 1, 2, 3, 4 ] * * View = [ a00, a01, * a10, a11 ] * * Strides: 2,1 * Offset: 0 * * View = [ 1, 2, * 3, 4 ] * * Strides: 2,-1 * Offset: 1 * * View = [ 2, 1, * 4, 3 ] * * Strides: -2,1 * Offset: 2 * * View = [ 3, 4, * 1, 2 ] * * Strides: -2,-1 * Offset: 3 * * View = [ 4, 3, * 2, 1 ] * ``` * * ```javascript * var shape = [ 2, 2 ]; * var strides = [ -2, 1 ]; * var offset = 2; * var mode = [ 'throw' ]; * * // From the perspective of a view... * var idx = sub2ind( shape, strides, 0, 0, 0, mode ); * // returns 0 * * idx = sub2ind( shape, strides, 0, 0, 1, mode ); * // returns 1 * * idx = sub2ind( shape, strides, 0, 1, 0, mode ); * // returns 2 * * idx = sub2ind( shape, strides, 0, 1, 1, mode ); * // returns 3 * * // From the perspective of an underlying buffer... * idx = sub2ind( shape, strides, offset, 0, 0, mode ); * // returns 2 * * idx = sub2ind( shape, strides, offset, 0, 1, mode ); * // returns 3 * * idx = sub2ind( shape, strides, offset, 1, 0, mode ); * // returns 0 * * idx = sub2ind( shape, strides, offset, 1, 1, mode ); * // returns 1 * ``` * * In short, from the perspective of a view, view data is always ordered. * * * @param shape - array shape * @param strides - stride array * @param offset - location of the first indexed value **based** on the stride array * @param args - subscripts followed by a `mode` specifying how to handle subscripts which exceed array dimensions * @param mode - specifies how to handle subscripts which exceed array dimensions * @throws must provide subscripts which do not exceed array dimensions * @returns linear index * * @example * var shape = [ 3, 3, 3 ]; * var strides = [ 9, 3, 1 ]; * var offset = 0; * var mode = [ 'throw' ]; * * var idx = ns.sub2ind( shape, strides, offset, 1, 2, 2, mode ); * // returns 17 */ sub2ind: typeof sub2ind; /** * Applies a ternary callback to elements in input ndarrays and assigns results to elements in an output ndarray. * * @param arrays - array-like object containing three input ndarrays and one output ndarray * @param fcn - ternary callback * @throws arrays must have the same number of dimensions * @throws arrays must have the same shape * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * var getData = require( './../../../data-buffer' ); * var add3 = require( '@stdlib/number/float64/base/add3' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var ybuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var zbuf = new Float64Array( [ 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 ] ); * var wbuf = new Float64Array( 6 ); * * // Define the shape of the input and output arrays: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 2, 2, 1 ]; * var sy = [ 2, 2, 1 ]; * var sz = [ 2, 2, 1 ]; * var sw = [ 2, 2, 1 ]; * * // Define the index offsets: * var ox = 0; * var oy = 0; * var oz = 0; * var ow = 0; * * // Create the input and output ndarrays: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * var y = new ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' ); * var z = new ndarray( 'float64', zbuf, shape, sz, oz, 'row-major' ); * var w = new ndarray( 'float64', wbuf, shape, sw, ow, 'row-major' ); * * // Apply the ns.ternary function: * ns.ternary( [ x, y, z, w ], add3 ); * * console.log( getData( w ) ); * // => [ 2.5, 4.5, 6.5, 8.5, 10.5, 12.5 ] */ ternary: typeof ternary; /** * Reorders ndarray dimensions and associated strides for loop interchange. * * ## Notes * * - The returned object has the following properties: * * - **sh**: dimensions sorted in loop order. * - **sx**: first input ndarray strides sorted in loop order. * - **sy**: second input ndarray strides sorted in loop order. * - **sz**: third input ndarray strides sorted in loop order. * - **sw**: output ndarray strides sorted in loop order. * * - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache. * * The purpose of this function is to order ndarray dimensions according to the magnitude of array strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference. * * - Cache performance may be degraded if the layout order (i.e., row-major or column-major) differs for the input and output ndarrays. This function is intended to optimize cache performance for the most common layout order. Accordingly, if the output ndarray has a different layout order (e.g., if the input ndarrays are row-major and the output ndarray is column-major), cache misses are likely for the output ndarray. In general, to ensure best performance, input and output ndarrays should have the same layout order. * * - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting. * * @param shape - array dimensions * @param stridesX - first input array stride lengths * @param stridesY - second input array stride lengths * @param stridesZ - third input array stride lengths * @param stridesW - output array stride lengths * @returns loop interchange data * * @example * var sh = [ 2, 3, 4 ]; * * var sx = [ 12, 4, 1 ]; // row-major * var sy = [ 24, 8, 1 ]; // row-major * var sz = [ 1, 4, 12 ]; // column-major * var sw = [ 1, -2, 6 ]; // column-major * * var o = ns.ternaryLoopOrder( sh, sx, sy, sz, sw ); * // returns {...} * * var ssh = o.sh; * // returns [ 2, 3, 4 ] * * var ssx = o.sx; * // returns [ 12, 4, 1 ] * * var ssy = o.sy; * // returns [ 24, 8, 1 ] * * var ssz = o.sz; * // returns [ 1, 4, 12 ] * * var ssw = o.sw; * // returns [ 1, -2, 6 ] */ ternaryLoopOrder: typeof ternaryLoopOrder; /** * Resolves the output ndarray data type for a ternary function. * * @param xdtype - first input ndarray data type * @param ydtype - second input ndarray data type * @param zdtype - third input ndarray data type * @param policy - output ndarray data type policy * @returns output ndarray data type * * @example * var dt = ns.ternaryOutputDataType( 'float64', 'float32', 'float32', 'complex_floating_point' ); * // returns */ ternaryOutputDataType: typeof ternaryOutputDataType; /** * Returns a loop block size for multi-dimensional array tiled loops. * * @param dtypeX - first input array data type * @param dtypeY - second input array data type * @param dtypeZ - third input array data type * @param dtypeW - output array data type * @returns block size (in units of elements) * * @example * var bsize = ns.ternaryBlockSize( 'float64', 'float64', 'float64', 'float64' ); * // returns */ ternaryBlockSize: typeof ternaryBlockSize; /** * Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. * * ## Notes * * - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. * - The function always copies data to a new ndarray. * * @param x - input array * @param reps - number of repetitions along each dimension * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.tile( x, [ 2, 2 ] ); * // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] */ tile: typeof tile; /** * Returns a loop block size for multi-dimensional array tiled loops. * * @param dtypes - list of input and output ndarray data types * @returns block size (in units of elements) * * @example * var bsize = ns.blockSize( [ 'float64', 'float64', 'float64', 'float64' ] ); * // returns */ blockSize: typeof blockSize; /** * Converts an ndarray buffer to a generic array (which may include nested arrays). * * @param buffer - data buffer * @param shape - array shape * @param strides - array strides * @param offset - index offset * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns array (which may include nested arrays) * * @example * var buffer = [ 1, 2, 3, 4 ]; * var shape = [ 2, 2 ]; * var order = 'row-major'; * var strides = [ 2, 1 ]; * var offset = 0; * * var out = ns.ndarray2array( buffer, shape, strides, offset, order ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] */ ndarray2array: typeof ndarray2array; /** * Returns a new ndarray where the order of elements along the last dimension of an input ndarray is reversed. * * @param x - input array * @returns output array * * @example * var typedarray = require( '@stdlib/array/typed' ); * var getShape = require( './../../../shape' ); * var ndarray = require( './../../../ctor' ); * * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var sh = getShape( x ); * // returns [ 3, 2 ] * * var y = ns.toFlippedlr( x ); * // returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ], [ 6.0, 5.0 ] ] * * sh = getShape( y ); * // returns [ 3, 2 ] */ toFlippedlr: typeof toFlippedlr; /** * Returns a new ndarray where the order of elements along the second-to-last dimension of an input ndarray is reversed. * * @param x - input array * @returns output array * * @example * var typedarray = require( '@stdlib/array/typed' ); * var getShape = require( './../../../shape' ); * var ndarray = require( './../../../ctor' ); * * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var sh = getShape( x ); * // returns [ 3, 2 ] * * var y = ns.toFlippedud( x ); * // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ] * * sh = getShape( y ); * // returns [ 3, 2 ] */ toFlippedud: typeof toFlippedud; /** * Normalizes a list of indices to the interval `[0,max]`. * * ## Notes * * - If provided an out-of-bounds index, the function normalizes the index to `-1`. * * @param indices - indices * @param max - maximum index * @returns normalized indices * * @example * var indices = ns.toNormalizedIndices( [ -2, 5 ], 10 ); * // returns [ 9, 5 ] * * indices = ns.toNormalizedIndices( [ -2, 15 ], 10 ); * // returns [ 9, -1 ] */ toNormalizedIndices: typeof toNormalizedIndices; /** * Returns a new ndarray where the order of elements of an input ndarray is reversed along each dimension. * * @param x - input array * @returns output array * * @example * var typedarray = require( '@stdlib/array/typed' ); * var getShape = require( './../../../shape' ); * var ndarray = require( './../../../ctor' ); * * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var sh = getShape( x ); * // returns [ 3, 2 ] * * var y = ns.toReversed( x ); * // returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] * * sh = getShape( y ); * // returns [ 3, 2 ] */ toReversed: typeof toReversed; /** * Returns a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed. * * @param x - input array * @param dim - index of dimension to reverse * @returns output array * * @example * var typedarray = require( '@stdlib/array/typed' ); * var ndarray = require( './../../../ctor' ); * var ndarray2array = require( './../../../to-array' ); * * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * 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 y = ns.toReversedDimension( x, 0 ); * // returns * * sh = y.shape; * // returns [ 3, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ] */ toReversedDimension: typeof toReversedDimension; /** * Returns a new ndarray where the order of elements of an input ndarray along specified dimensions is reversed. * * @param x - input array * @param dims - indices of dimensions to reverse * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.toReversedDimensions( x, [ 0, 1 ] ); * // returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] */ toReversedDimensions: typeof toReversedDimensions; /** * Returns a new ndarray where an ndarray is rotated 90 degrees in a specified plane. * * ## Notes * * - If `k > 0`, the function rotates the plane from the first specified dimension toward the second specified dimension. This means that, for a two-dimensional ndarray and `dims = [0, 1]`, the function rotates the plane counterclockwise. * - If `k < 0`, the function rotates the plane from the second specified dimension toward the first specified dimension. This means that, for a two-dimensional ndarray and `dims = [0, 1]`, the function rotates the plane clockwise. * - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. * * @param x - input array * @param dims - dimension indices defining the plane of rotation * @param k - number of times to rotate by 90 degrees * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.toRot90( x, [ 0, 1 ], 1 ); * // returns [ [ 2, 4 ], [ 1, 3 ] ] */ toRot90: typeof toRot90; /** * Returns a new ndarray where an ndarray is rotated 180 degrees in a specified plane. * * ## Notes * * - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. * * @param x - input array * @param dims - dimension indices defining the plane of rotation * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.toRot180( x, [ 0, 1 ] ); * // returns [ [ 4, 3 ], [ 2, 1 ] ] */ toRot180: typeof toRot180; /** * Returns a new ndarray where a matrix (or a stack of matrices) is rotated 90 degrees counterclockwise. * * @param x - input array * @param k - number of times to rotate by 90 degrees * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.toRotl90( x, 1 ); * // returns [ [ 2, 4 ], [ 1, 3 ] ] */ toRotl90: typeof toRotl90; /** * Returns a new ndarray where a matrix (or a stack of matrices) is rotated 90 degrees clockwise. * * @param x - input array * @param k - number of times to rotate by 90 degrees * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] * * var y = ns.toRotr90( x, 1 ); * // returns [ [ 3, 1 ], [ 4, 2 ] ] */ toRotr90: typeof toRotr90; /** * Returns a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed. * * @param x - input array * @returns output ndarray * * @example * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); * // returns [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] * * var out = ns.toTransposed( x ); * // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] */ toTransposed: typeof toTransposed; /** * Returns a new ndarray in which a specified dimension of an input ndarray is expanded over multiple dimensions. * * @param x - input array * @param dim - dimension to be unflattened * @param sizes - new shape of the unflattened dimension * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] * * var y = ns.toUnflattened( x, 0, [ 2, 3 ] ); * // returns [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ] */ toUnflattened: typeof toUnflattened; /** * Returns a list of unique indices after normalizing to the interval `[0,max]`. * * ## Notes * * - If provided an out-of-bounds index, the function returns `null`. * * @param indices - indices * @param max - maximum index * @returns normalized indices (or null) * * @example * var indices = ns.toUniqueNormalizedIndices( [ -2, 5 ], 10 ); * // returns [ 9, 5 ] * * indices = ns.toUniqueNormalizedIndices( [ -2, 15 ], 10 ); * // returns null */ toUniqueNormalizedIndices: typeof toUniqueNormalizedIndices; /** * Transposes a matrix (or a stack of matrices). * * @param x - input array * @param writable - boolean indicating whether the returned ndarray should be writable * @returns ndarray view * * @example * var getData = require( './../../../data-buffer' ); * var array = require( './../../../array' ); * * var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ], { * 'dtype': 'generic' * }); * // returns [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] * * var y = ns.transpose( x, false ); * // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * * var bool = ( getData( x ) === getData( y ) ); * // returns true */ transpose: typeof transpose; /** * Creates an ndarray filled with `true` values and having a specified shape and data type. * * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns `true`-filled array * * @example * var getDType = require( './../../../dtype' ); * * var arr = ns.trues( 'generic', [ 2, 2 ], 'row-major' ); * // returns [ [ true, true ], [ true, true ] ] * * var dt = String( getDType( arr ) ); * // returns 'generic' */ trues: typeof trues; /** * Creates an ndarray filled with `true` values and having the same shape and data type as a provided input ndarray. * * @param x - input array * @returns filled ndarray * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * var empty = require( './../../../empty' ); * * var x = empty( [ 2, 2 ], { * 'dtype': 'bool' * }); * // returns * * var sh = getShape( x ); * // returns [ 2, 2 ] * * var dt = String( getDType( x ) ); * // returns 'bool' * * var y = ns.truesLike( x ); * // returns [ [ true, true ], [ true, true ] ] * * sh = getShape( y ); * // returns [ 2, 2 ] * * dt = String( getDType( y ) ); * // returns 'bool' */ truesLike: typeof truesLike; /** * Applies a unary callback to elements in an ndarray and assigns results to elements in an ndarray. * * @param arrays - array-like object containing one input ndarray and one output ndarray * @param fcn - unary callback * @throws arrays must have the same number of dimensions * @throws arrays must have the same shape * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * * function scale( x ) { * return x * 10.0; * } * * // Create data buffers: * 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 ] ); * var ybuf = new Float64Array( 6 ); * * // Define the shape of the input and output arrays: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * var sy = [ 2, 2, 1 ]; * * // Define the index offsets: * var ox = 1; * var oy = 0; * * // Create the input and output ndarrays: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * var y = ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' ); * * // Apply the ns.unary function: * ns.unary( [ x, y ], scale ); * * console.log( y.data ); * // => [ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ] */ unary: typeof unary; /** * Performs a reduction over elements in an ndarray. * * @param arrays - array-like object containing one input ndarray * @param initial - initial value * @param clbk - callback function * @returns accumulated result * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * function add( acc, x ) { * return acc + x; * } * * // Create a data buffer: * 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 ] ); * * // Define the shape of the input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create the input ndarray-like object: * var x = { * 'dtype': 'float64', * 'data': xbuf, * 'shape': shape, * 'strides': sx, * 'offset': ox, * 'order': 'row-major' * }; * * // Compute the sum: * var v = ns.unaryAccumulate( [ x ], 0.0, add ); * // returns 39.0 */ unaryAccumulate: typeof unaryAccumulate; /** * Returns a function which dispatches to a native add-on applying a unary function to an input ndarray. * * @param addon - add-on function * @param fallback - fallback function * @returns dispatch function * * @example * var array = require( './../../../array' ); * var zeros = require( './../../../zeros' ); * * function addon( x, metaX, y, metaY ) { * // Call into native add-on... * } * * function fallback( x, y ) { * // Fallback JavaScript implementation... * } * * // Create a ns.unaryAddonDispatch function: * var f = ns.unaryAddonDispatch( addon, fallback ); * * // ... * * // Invoke the ns.unaryAddonDispatch function with ndarray arguments: * var x = array( [ [ 1, 2], [ 3, 4 ] ] ); * var y = zeros( [ 2, 2 ] ); * f( x, y ); */ unaryAddonDispatch: typeof unaryAddonDispatch; /** * Applies a unary function to elements in an ndarray and assigns results to elements in an ndarray. * * @param arrays - array-like object containing one input ndarray and one output ndarray * @param fcn - unary function to apply to callback return values * @param clbk - callback function * @param thisArg - callback execution context * @throws arrays must have the same number of dimensions * @throws arrays must have the same shape * * @example * var identity = require( '@stdlib/number/float64/base/identity' ); * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../../ctor' ); * * function scale( x ) { * return x * 10.0; * } * * // Create data buffers: * 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 ] ); * var ybuf = new Float64Array( 6 ); * * // Define the shape of the input and output arrays: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * var sy = [ 2, 2, 1 ]; * * // Define the index offsets: * var ox = 1; * var oy = 0; * * // Create the input and output ndarrays: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * var y = ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' ); * * // Apply the unary function: * ns.unaryBy( [ x, y ], scale, identity ); * * console.log( y.data ); * // => [ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ] */ unaryBy: typeof unaryBy; /** * Resolves the input ndarray casting data type for a unary function. * * @param idtype - input ndarray data type * @param odtype - output ndarray data type * @param policy - input ndarray casting data type policy * @returns input ndarray casting data type * * @example * var dt = ns.unaryInputCastingDataType( 'float64', 'float64', 'none' ); * // returns */ unaryInputCastingDataType: typeof unaryInputCastingDataType; /** * Reorders ndarray dimensions and associated strides for loop interchange. * * ## Notes * * - The returned object has the following properties: * * - **sh**: dimensions sorted in loop order. * - **sx**: input ndarray strides sorted in loop order. * - **sy**: output ndarray strides sorted in loop order. * - **idx**: dimension indices sorted in loop order. * * - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache. * * The purpose of this function is to order ndarray dimensions according to the magnitude of **input array** strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference. * * - Cache performance may be degraded if the layout order (i.e., row-major or column-major) differs for the input and output ndarrays. This function is intended to optimize cache performance for the input ndarray. If the output ndarray has a different layout order (e.g., if the input ndarray is row-major and the output ndarray is column-major), cache misses are likely for the output ndarray. In general, to ensure best performance, input and output ndarrays should have the same layout order. * * - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting. * * @param shape - array dimensions * @param stridesX - input array stride lengths * @param stridesY - output array stride lengths * @returns loop interchange data * * @example * var sh = [ 2, 3, 4 ]; * * var sx = [ 12, 4, 1 ]; // row-major * var sy = [ 1, -2, 6 ]; // column-major * * var o = ns.unaryLoopOrder( sh, sx, sy ); * // returns {...} * * var ssh = o.sh; * // returns [ 4, 3, 2 ] * * var ssx = o.sx; * // returns [ 1, 4, 12 ] * * var ssy = o.sy; * // returns [ 6, -2, 1 ] * * var idx = o.idx; * // returns [ 2, 1, 0 ] */ unaryLoopOrder: typeof unaryLoopOrder; /** * Resolves the output ndarray data type for a unary function. * * @param dtype - input ndarray data type * @param policy - output ndarray data type policy * @returns output ndarray data type * * @example * var dt = ns.unaryOutputDataType( 'float64', 'complex_floating_point' ); * // returns */ unaryOutputDataType: typeof unaryOutputDataType; /** * Constructor for performing a reduction on an input ndarray. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param policies - dispatch policies * @returns instance * * @example * var base = require( '@stdlib/stats/base/ndarray/max' ); * var dtypes = require( './../../../dtypes' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = idt; * var policies = { * 'output': 'same', * 'casting': 'none' * }; * * var table = { * 'default': base * }; * var max = new ns.unaryReduceStrided1dDispatch( table, [ idt ], odt, policies ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * var y = max.apply( x ); * // returns * * var v = y.get(); * // returns 2.0 */ unaryReduceStrided1dDispatch: typeof unaryReduceStrided1dDispatch; /** * Constructor for performing a reduction on an input ndarray according to a callback function. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param policies - dispatch policies * @returns instance * * @example * var base = require( '@stdlib/stats/base/ndarray/max-by' ); * var dtypes = require( './../../../dtypes' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = idt; * var policies = { * 'output': 'same', * 'casting': 'none' * }; * * var table = { * 'default': base * }; * var maxBy = new ns.unaryReduceStrided1dDispatchBy( table, [ idt ], odt, policies ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * function clbk( v ) { * return v * 2.0; * } * * var y = maxBy.apply( x, clbk ); * // returns * * var v = y.get(); * // returns 4.0 */ unaryReduceStrided1dDispatchBy: typeof unaryReduceStrided1dDispatchBy; /** * Creates a function for performing a reduction on a provided ndarray according to a callback function. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param policies - dispatch policies * @returns function for applying a unary function * * @example * var base = require( '@stdlib/stats/base/ndarray/max-by' ); * var dtypes = require( './../../../dtypes' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = idt; * var policies = { * 'output': 'same', * 'casting': 'none' * }; * * var table = { * 'default': base * }; * var maxBy = ns.unaryReduceStrided1dDispatchByFactory( table, [ idt ], odt, policies ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * function clbk( v ) { * return v * 2.0; * } * * var y = maxBy( x, clbk ); * // returns * * var v = y.get(); * // returns 4.0 */ unaryReduceStrided1dDispatchByFactory: typeof unaryReduceStrided1dDispatchByFactory; /** * Creates a function for performing a reduction on a provided ndarray. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param policies - dispatch policies * @returns function for applying a unary function * * @example * var base = require( '@stdlib/stats/base/ndarray/max' ); * var dtypes = require( './../../../dtypes' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = idt; * var policies = { * 'output': 'same', * 'casting': 'none' * }; * * var table = { * 'default': base * }; * var max = ns.unaryReduceStrided1dDispatchFactory( table, [ idt ], odt, policies ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * var y = max( x ); * // returns * * var v = y.get(); * // returns 2.0 */ unaryReduceStrided1dDispatchFactory: typeof unaryReduceStrided1dDispatchFactory; /** * Performs a reduction over a list of specified dimensions in an input ndarray according to a callback function and assigns results to a provided output ndarray. * * @param fcn - reduction function * @param arrays - array-like object containing ndarrays * @param dims - list of dimensions over which to perform a reduction * @param options - function options * @param clbk - callback function * @param thisArg - callback execution context * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var filled = require( '@stdlib/array/base/filled' ); * var ndarray2array = require( './../../../base/to-array' ); * var everyBy = require( './../../../base/every-by' ); * * function clbk( value ) { * return value > 0.0; * } * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); * var ybuf = filled( false, 3 ); * * // Define the array shapes: * var xsh = [ 1, 3, 2, 2 ]; * var ysh = [ 1, 3 ]; * * // Define the array strides: * var sx = [ 12, 4, 2, 1 ]; * var sy = [ 3, 1 ]; * * // Define the index offsets: * var ox = 0; * var oy = 0; * * // Create an input ndarray-like object: * var x = { * 'dtype': 'float64', * 'data': xbuf, * 'shape': xsh, * 'strides': sx, * 'offset': ox, * 'order': 'row-major' * }; * * // Create an output ndarray-like object: * var y = { * 'dtype': 'generic', * 'data': ybuf, * 'shape': ysh, * 'strides': sy, * 'offset': oy, * 'order': 'row-major' * }; * * // Perform a reduction: * ns.unaryReduceSubarrayBy( everyBy, [ x, y ], [ 2, 3 ], clbk ); * * var arr = ndarray2array( y.data, y.shape, y.strides, y.offset, y.order ); * // returns [ [ true, false, true ] ] */ unaryReduceSubarrayBy: typeof unaryReduceSubarrayBy; /** * Constructor for applying a strided function to an input ndarray. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param policies - dispatch policies * @param options - function options * @returns instance * * @example * var base = require( '@stdlib/stats/base/ndarray/cumax' ); * var dtypes = require( './../../../dtypes' ); * var ndarray2array = require( './../../../to-array' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = idt; * var policies = { * 'output': 'same', * 'casting': 'none' * }; * * var table = { * 'default': base * }; * var cumax = new ns.unaryStrided1dDispatch( table, [ idt ], odt, policies ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * var y = cumax.apply( x ); * // returns * * var arr = ndarray2array( y ); * // returns [ -1.0, 2.0, 2.0 ] */ unaryStrided1dDispatch: typeof unaryStrided1dDispatch; /** * Creates a function for applying a strided function to a provided ndarray. * * @param table - dispatch table * @param idtypes - list containing lists of supported input data types for each ndarray argument * @param odtypes - list of supported output data types * @param policies - dispatch policies * @param options - function options * @returns function for applying a unary function * * @example * var base = require( '@stdlib/stats/base/ndarray/cumax' ); * var dtypes = require( './../../../dtypes' ); * var ndarray2array = require( './../../../to-array' ); * var ndarray = require( './../../../base/ctor' ); * * var idt = dtypes( 'real_and_generic' ); * var odt = idt; * var policies = { * 'output': 'same', * 'casting': 'none' * }; * * var table = { * 'default': base * }; * var cumax = ns.unaryStrided1dDispatchFactory( table, [ idt ], odt, policies ); * * var xbuf = [ -1.0, 2.0, -3.0 ]; * var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); * * var y = cumax( x ); * // returns * * var arr = ndarray2array( y ); * // returns [ -1.0, 2.0, 2.0 ] */ unaryStrided1dDispatchFactory: typeof unaryStrided1dDispatchFactory; /** * Returns a loop block size for multi-dimensional array tiled loops. * * @param dtypeX - input array data type * @param dtypeY - output array data type * @returns block size (in units of elements) * * @example * var bsize = ns.unaryBlockSize( 'float64', 'float64' ); * // returns */ unaryBlockSize: typeof unaryBlockSize; /** * Returns a view of an input ndarray in which a specified dimension is expanded over multiple dimensions. * * @param x - input array * @param dim - dimension to be unflattened * @param sizes - new shape of the unflattened dimension * @param writable - boolean indicating whether the returned ndarray should be writable * @returns output array * * @example * var array = require( './../../../array' ); * * var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] * * var out = ns.unflatten( x, 0, [ 2, 3 ], false ); * // returns [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ] */ unflatten: typeof unflatten; /** * Expands a dimension over multiple dimensions. * * @param shape - array shape * @param dim - dimension to be unflattened * @param sizes - new shape of the unflattened dimension * @returns unflattened shape * * @example * var sh = ns.unflattenShape( [ 6, 2, 1 ], 0, [ 3, 2 ] ); * // returns [ 3, 2, 2, 1 ] * * @example * var o = [ 0, 0, 0, 0 ]; * * var out = ns.unflattenShape.assign( [ 6, 2, 1 ], 0, [ 3, 2 ], o ); * // returns [ 3, 2, 2, 1 ] * * var bool = ( out === o ); * // returns true */ unflattenShape: typeof unflattenShape; /** * Converts a linear index in an array view to a linear index in an underlying data buffer. * * @param shape - array shape * @param strides - stride array * @param offset - location of the first indexed value **based** on the stride array * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @param idx - linear index in an array view * @param mode - specifies how to handle a linear index which exceeds array dimensions * @throws linear index must not exceed array dimensions * @returns linear index in an underlying data buffer * * @example * var shape = [ 3, 3 ]; * var strides = [ -3, 1 ]; * var offset = 6; * var order = 'row-major'; * var mode = 'throw'; * * var ind = ns.vind2bind( shape, strides, offset, order, 1, mode ); * // returns 7 */ vind2bind: typeof vind2bind; /** * Wraps an index on the interval `[0,max]`. * * @param idx - index * @param max - maximum index * @returns index * * @example * var idx = ns.wrapIndex( -1, 10 ); * // returns 10 * * idx = ns.wrapIndex( 13, 10 ); * // returns 2 * * idx = ns.wrapIndex( 6, 10 ); * // returns 6 */ wrapIndex: typeof wrapIndex; /** * Creates a zero-filled array having a specified shape and data type. * * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) * @returns zero-filled array * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * * var arr = ns.zeros( 'float64', [ 2, 2 ], 'row-major' ); * // returns [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] * * var sh = getShape( arr ); * // returns [ 2, 2 ] * * var dt = String( getDType( arr ) ); * // returns 'float64' */ zeros: typeof zeros; /** * Creates a zero-filled array having the same shape and data type as a provided input ndarray. * * @param x - input array * @returns zero-filled array * * @example * var getShape = require( './../../../shape' ); * var getDType = require( './../../../dtype' ); * var zeros = require( './../../../base/zeros' ); * * var x = zeros( 'float64', [ 2, 2 ], 'row-major' ); * // returns [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] * * var sh = getShape( x ); * // returns [ 2, 2 ] * * var dt = String( getDType( x ) ); * // returns 'float64' * * var y = ns.zerosLike( x ); * // returns [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] * * sh = getShape( y ); * // returns [ 2, 2 ] * * dt = String( getDType( y ) ); * // returns 'float64' */ zerosLike: typeof zerosLike; /** * Zips one or more one-dimensional ndarrays to an array of composite views. * * ## Notes * * - The function assumes that the list of ndarrays to be zipped all have the same length. * - The list of provided labels should equal the number of ndarrays to be zipped. * - Each view in the returned array shares the same memory as the corresponding elements in the input ndarrays. Accordingly, mutation of either an input ndarray or a view will mutate the other. * * @param arrays - list of ndarrays to be zipped * @param labels - list of labels * @returns output array * * @example * var array2ndarray = require( './../../../base/from-array' ); * * var x = array2ndarray( [ 1, 2, 3 ], 'row-major' ); * var y = array2ndarray( [ 'a', 'b', 'c' ], 'row-major' ); * * var labels = [ 'x', 'y' ]; * * var z = ns.zip2views1d( [ x, y ], labels ); * // returns [ , , ] * * var v0 = z[ 0 ].toJSON(); * // returns { 'x': 1, 'y': 'a' } * * var v1 = z[ 1 ].toJSON(); * // returns { 'x': 2, 'y': 'b' } * * var v2 = z[ 2 ].toJSON(); * // returns { 'x': 3, 'y': 'c' } * * // Mutate one of the input arrays: * x.set( 0, 5 ); * * v0 = z[ 0 ].toJSON(); * // returns { 'x': 5, 'y': 'a' } * * // Set a view property: * z[ 1 ].y = 'beep'; * * v1 = z[ 1 ].toJSON(); * // returns { 'x': 2, 'y': 'beep' } * * var v = y.get( 1 ); * // returns 'beep' */ zip2views1d: typeof zip2views1d; } /** * Base ndarray. */ declare var ns: Namespace; // EXPORTS // export = ns;