/* * @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( './../../any' ); import anyBy = require( './../../any-by' ); import array = require( './../../array' ); import at = require( './../../at' ); import base = require( './../../base' ); import broadcastArray = require( './../../broadcast-array' ); import broadcastArrays = require( './../../broadcast-arrays' ); import broadcastScalar = require( './../../broadcast-scalar' ); import castingModes = require( './../../casting-modes' ); import concat = require( './../../concat' ); import concat1d = require( './../../concat1d' ); import copy = require( './../../copy' ); import countFalsy = require( './../../count-falsy' ); import countIf = require( './../../count-if' ); import countTruthy = require( './../../count-truthy' ); import ndarray = require( './../../ctor' ); import dataBuffer = require( './../../data-buffer' ); import defaults = require( './../../defaults' ); import dispatch = require( './../../dispatch' ); import dtype = require( './../../dtype' ); import DataType = require( './../../dtype-ctor' ); import dtypes = require( './../../dtypes' ); import empty = require( './../../empty' ); import emptyLike = require( './../../empty-like' ); import every = require( './../../every' ); import everyBy = require( './../../every-by' ); import FancyArray = require( './../../fancy' ); import fill = require( './../../fill' ); import fillBy = require( './../../fill-by' ); import fillSlice = require( './../../fill-slice' ); import filter = require( './../../filter' ); import filterMap = require( './../../filter-map' ); import find = require( './../../find' ); import findLast = require( './../../find-last' ); import flag = require( './../../flag' ); import flags = require( './../../flags' ); import flatten = require( './../../flatten' ); import flattenBy = require( './../../flatten-by' ); import flattenFrom = require( './../../flatten-from' ); import flattenFromBy = require( './../../flatten-from-by' ); import fliplr = require( './../../fliplr' ); import flipud = require( './../../flipud' ); import forEach = require( './../../for-each' ); import scalar2ndarray = require( './../../from-scalar' ); import scalar2ndarrayLike = require( './../../from-scalar-like' ); import includes = require( './../../includes' ); import ind2sub = require( './../../ind2sub' ); import ndindex = require( './../../index' ); import indexModes = require( './../../index-modes' ); import inputCastingPolicies = require( './../../input-casting-policies' ); import iter = require( './../../iter' ); import map = require( './../../map' ); import maybeBroadcastArray = require( './../../maybe-broadcast-array' ); import maybeBroadcastArrays = require( './../../maybe-broadcast-arrays' ); import minDataType = require( './../../min-dtype' ); import mostlySafeCasts = require( './../../mostly-safe-casts' ); import ndarraylike2ndarray = require( './../../ndarraylike2ndarray' ); import ndims = require( './../../ndims' ); import nextDataType = require( './../../next-dtype' ); import numel = require( './../../numel' ); import numelDimension = require( './../../numel-dimension' ); import offset = require( './../../offset' ); import ones = require( './../../ones' ); import order = require( './../../order' ); import orders = require( './../../orders' ); import outputDataTypePolicies = require( './../../output-dtype-policies' ); import pop = require( './../../pop' ); import prependSingletonDimensions = require( './../../prepend-singleton-dimensions' ); import promotionRules = require( './../../promotion-rules' ); import push = require( './../../push' ); import reject = require( './../../reject' ); import reverse = require( './../../reverse' ); import reverseDimension = require( './../../reverse-dimension' ); import safeCasts = require( './../../safe-casts' ); import sameKindCasts = require( './../../same-kind-casts' ); import shape = require( './../../shape' ); import shift = require( './../../shift' ); import slice = require( './../../slice' ); import sliceAssign = require( './../../slice-assign' ); import sliceDimension = require( './../../slice-dimension' ); import sliceDimensionFrom = require( './../../slice-dimension-from' ); import sliceDimensionTo = require( './../../slice-dimension-to' ); import sliceFrom = require( './../../slice-from' ); import sliceTo = require( './../../slice-to' ); import some = require( './../../some' ); import someBy = require( './../../some-by' ); import spreadDimensions = require( './../../spread-dimensions' ); import stride = require( './../../stride' ); import strides = require( './../../strides' ); import sub2ind = require( './../../sub2ind' ); import ndarray2array = require( './../../to-array' ); import toFlippedlr = require( './../../to-flippedlr' ); import toFlippedud = require( './../../to-flippedud' ); import ndarray2json = require( './../../to-json' ); import ndarray2localeString = require( './../../to-locale-string' ); import toReversed = require( './../../to-reversed' ); import toReversedDimension = require( './../../to-reversed-dimension' ); import unshift = require( './../../unshift' ); import vector = require( './../../vector' ); import ndarrayWith = require( './../../with' ); import zeros = require( './../../zeros' ); import zerosLike = require( './../../zeros-like' ); /** * Interface describing the `ndarray` namespace. */ interface Namespace { /** * Tests whether at least one element along one or more ndarray dimensions is truthy. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @returns output ndarray * * @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 sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.any( x ); * // returns [ true ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * // 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 an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'bool' * }); * * // Perform reduction: * var out = ns.any.assign( x, y ); * // returns [ true ] */ any: typeof any; /** * Tests whether at least one element along one or more ndarray dimensions passes a test implemented by a predicate function. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @param predicate - predicate function * @param thisArg - predicate execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * function isPositive( 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 input array: * var sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.anyBy( x, isPositive ); * // returns [ true ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * function isPositive( 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 input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'bool' * }); * * // Perform reduction: * var out = ns.anyBy.assign( x, y, isPositive ); * // returns [ true ] */ anyBy: typeof anyBy; /** * Returns a multidimensional array. * * @param buffer - data source * @param options - function options * @param options.buffer - data source * @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) (default: 'float64') * @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') * @param options.shape - array shape * @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']) * @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) * @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) * @param options.ndmin - minimum number of dimensions (default: 0) * @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') * @param options.readonly - boolean indicating whether an array should be read-only * @throws must provide valid options * @throws must provide either an array shape, data source, or both * @throws invalid cast * @throws data source must be compatible with specified meta data * @returns ndarray instance * * @example * var arr = ns.array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns * * var v = arr.get( 0, 0 ); * // returns 1 * * @example * var opts = { * 'dtype': 'generic', * 'flatten': false * }; * * var arr = ns.array( [ [ 1, 2 ], [ 3, 4 ] ], opts ); * // returns * * var v = arr.get( 0 ); * // returns [ 1, 2 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var opts = { * 'shape': [ 2, 2 ] * }; * * var arr = ns.array( new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), opts ); * // returns * * var v = arr.get( 0, 0 ); * // returns 1.0 */ array: typeof array; /** * Returns an ndarray element. * * ## Notes * * - The number of index arguments must equal the number of ndarray dimensions. * - Negative indices are resolved relative to the last element along the respective dimension, with the last element corresponding to `-1`. * - If provided out-of-bounds indices, the function always returns `undefined`. * * @param x - input ndarray * @param indices - index arguments * @returns ndarray element * * @example * var zeros = require( './../../zeros' ); * * var x = zeros( [ 3, 3 ], { * 'dtype': 'generic' * }); * // returns * * var v = ns.at( x, 0, 0 ); * // returns 0 * * v = ns.at( x, 5, 5 ); * // returns undefined */ at: typeof at; /** * Base ndarray. */ base: typeof base; /** * 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 **read-only** 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 input array may affect multiple elements. If you need to write to the input array, copy the input array before broadcasting. * - The function always returns a new ndarray instance even if the input ndarray shape and the desired shape are the same. * * @param x - 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 ndarrays to a common shape. * * ## Notes * * - The function throws an error if provided broadcast-incompatible ndarrays. * - The returned arrays are **read-only** 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 an input array, copy the array before broadcasting. * - 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 of a specified shape. * * ## Notes * * - If a `dtype` option is not provided and `value` * * - is a number, the default data type is the default real-valued floating-point data type. * - is a boolean, the default data type is the default boolean data type. * - is a complex number object of a known complex data type, the data type is the same as the provided value. * - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type. * - is any other value type, the default data type is `'generic'`. * * @param value - scalar value * @param shape - shape of output ndarray * @param options - options * @returns ndarray * * @example * var getDType = require( './../../dtype' ); * * var x = ns.broadcastScalar( 1.0, [ 2, 2 ], { * 'dtype': 'generic' * }); * // returns [ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ] * * var dt = String( getDType( x ) ); * // returns 'generic' */ broadcastScalar: typeof broadcastScalar; /** * Returns a list of ndarray casting modes. * * ## Notes * * - The output array contains the following modes: * * - 'none': only allow casting between identical types * - 'equiv': allow casting between identical and byte swapped types * - 'safe': only allow "safe" casts * - 'mostly-safe': allow "safe" casts and, for floating-point data types, downcasts * - 'same-kind': allow "safe" casts and casts within the same kind (e.g., * between signed integers or between floats) * - 'unsafe': allow casting between all types (including between integers and * floats) * * @returns list of ndarray casting modes * * @example * var list = ns.castingModes(); * // returns [ 'none', 'equiv', 'safe', 'mostly-safe', 'same-kind', 'unsafe' ] */ castingModes: typeof castingModes; /** * Concatenates a list of ndarrays along a specified ndarray dimension. * * @param arrays - array-like object containing input ndarrays * @param options - function options * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); * var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); * * var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); * var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); * * var out = ns.concat( [ x, y ], { * 'dim': -1 * }); * // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); * var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); * * var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); * var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); * * var z = new ndarray( 'float64', new Float64Array( 10 ), [ 2, 5 ], [ 5, 1 ], 0, 'row-major' ); * * var out = ns.concat.assign( [ x, y ], z, { * 'dim': -1 * }); * // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] * * var bool = ( out === z ); * // returns true */ concat: typeof concat; /** * Returns a one-dimensional ndarray formed by concatenating provided input arguments. * * @param arrays - input arguments * @returns output ndarray * * @example * var array = require( './../../array' ); * var ndarray2array = require( './../../to-array' ); * * var x = array( [ -1.0, 2.0, 3.0, 4.0 ] ); * var y = array( [ -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] ); * * var out = ns.concat1d( x, y ); * // returns [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] * * @example * var array = require( './../../array' ); * var empty = require( './../../empty' ); * var ndarray2array = require( './../../to-array' ); * * var x = array( [ -1.0, 2.0, 3.0, 4.0 ] ); * var y = array( [ -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] ); * var z = empty( [ 10 ] ); * * var out = ns.concat1d.assign( [ x, y ], z ); * // returns [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] * * var bool = ( out === z ); * // returns true */ concat1d: typeof concat1d; /** * 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 * @param options - options * @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) * @param options.mode - specifies how to handle a linear index which exceeds array dimensions * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis * @returns output array * * @example * var getShape = require( './../../shape' ); * var zeros = require( './../../zeros' ); * * var x = zeros( [ 2, 2 ] ); * // 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 along one or more ndarray dimensions. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @returns output ndarray * * @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 sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.countFalsy( x ); * // returns [ 1 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * // 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 an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'int32' * }); * * // Perform reduction: * var out = ns.countFalsy.assign( x, y ); * // returns [ 1 ] */ countFalsy: typeof countFalsy; /** * Counts the number of elements along one or more ndarray dimensions which pass a test implemented by a predicate function. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../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 input array: * var sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.countIf( x, predicate ); * // returns [ 5 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * 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 input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'int32' * }); * * // Perform reduction: * var out = ns.countIf.assign( x, y, predicate ); * // returns [ 5 ] */ countIf: typeof countIf; /** * Counts the number of truthy elements along one or more ndarray dimensions. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @returns output ndarray * * @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 sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.countTruthy( x ); * // returns [ 5 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * // 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 an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'int32' * }); * * // Perform reduction: * var out = ns.countTruthy.assign( x, y ); * // returns [ 5 ] */ countTruthy: typeof countTruthy; /** * ndarray constructor. * * @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) * @param options - function options * @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']) * @param options.readonly - specifies whether an array should be read-only (default: false) * @throws `buffer` argument `get` and `set` properties must be functions * @throws `shape` argument must be an array-like object containing nonnegative integers * @throws `shape` argument length must equal the number of dimensions * @throws `strides` argument must be an array-like object containing integers * @throws `strides` argument length must equal the number of dimensions (except for zero-dimensional arrays; in which case, the `strides` argument length must be equal to `1`) * @throws for zero-dimensional ndarrays, the `strides` argument must contain a single element equal to `0` * @throws `offset` argument must be a nonnegative integer * @throws `buffer` argument must be compatible with specified meta data * @throws must provide valid options * @throws too many dimensions * @returns ndarray instance * * @example * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var 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.dataBuffer( x ); * // returns */ dataBuffer: typeof dataBuffer; /** * Returns default ndarray settings. * * @returns default settings * * @example * var o = ns.defaults(); * // returns {...} * * @example * var v = ns.defaults.get( 'order' ); * // returns */ defaults: typeof defaults; /** * Returns an ndarray function interface which performs multiple dispatch. * * @param fcns - list of ndarray functions * @param types - one-dimensional list of ndarray argument data types * @param data - ndarray function data (e.g., callbacks) * @param nargs - total number of ndarray function interface arguments * @param nin - number of input ndarrays * @param nout - number of output ndarrays * @throws first argument must be either a function or an array of functions * @throws second argument must be an array-like object * @throws third argument must be an array-like object or `null` * @throws third and first arguments must have the same number of elements * @throws fourth argument must be a positive integer * @throws fifth argument must be a nonnegative integer * @throws sixth argument must be a nonnegative integer * @throws fourth argument must equal the specified number of input and output arrays * @throws number of types must match the number of functions times the total number of array arguments for each function * @throws interface must accept at least one input and/or output ndarray * @returns ndarray function interface * * @example * var unary = require( './../../base/unary' ); * var abs = require( '@stdlib/math/base/special/abs' ); * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * var types = [ * 'float64', 'float64' * ]; * * var data = [ * abs * ]; * * var fcn = ns.dispatch( unary, types, data, 2, 1, 1 ); * * // ... * * var xbuf = new Float64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0 ] ); * var ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * * var x = ndarray( 'float64', xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); * var y = ndarray( 'float64', ybuf, [ 5 ], [ 1 ], 0, 'row-major' ); * * fcn( x, y ); * // ybuf => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] */ dispatch: typeof dispatch; /** * 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; /** * Data type. */ DataType: typeof DataType; /** * Returns a list of ndarray data type strings. * * @param kind - data type kind * @returns list of ndarray data type strings * * @example * var list = ns.dtypes(); * // returns [...] * * @example * var list = ns.dtypes( 'floating_point' ); * // returns [...] */ dtypes: typeof dtypes; /** * Creates an uninitialized array having a specified shape and data type. * * @param shape - array shape * @param options - options * @param options.dtype - underlying data type (default: 'float64') * @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') * @param options.mode - specifies how to handle a linear index which exceeds array dimensions * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis * @returns output array * * @example * var getShape = require( './../../shape' ); * var getDType = require( './../../dtype' ); * * var arr = ns.empty( [ 2, 2 ] ); * // returns * * var sh = getShape( arr ); * // returns [ 2, 2 ] * * var dt = String( getDType( arr ) ); * // returns 'float64' */ empty: typeof empty; /** * Creates an uninitialized array having the same shape and data type as a provided input ndarray. * * @param x - input array * @param options - options * @param options.dtype - output array data type * @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) * @param options.shape - output array shape * @param options.mode - specifies how to handle a linear index which exceeds array dimensions * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis * @returns output array * * @example * var getShape = require( './../../shape' ); * var getDType = require( './../../dtype' ); * var zeros = require( './../../zeros' ); * * var x = zeros( [ 2, 2 ], { * 'dtype': 'float64' * }); * // 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.emptyLike( x ); * // returns * * sh = getShape( y ); * // returns [ 2, 2 ] * * dt = String( getDType( y ) ); * // returns 'float64' */ emptyLike: typeof emptyLike; /** * Tests whether every element along one or more ndarray dimensions is truthy. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @returns output ndarray * * @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 sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.every( x ); * // returns * * var v = out.get(); * // returns true * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * // 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 an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'bool' * }); * * // Perform reduction: * var out = ns.every.assign( x, y ); * // returns * * var v = out.get(); * // returns true */ every: typeof every; /** * Tests whether all elements along one or more ndarray dimensions pass a test implemented by a predicate function. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @param predicate - predicate function * @param thisArg - predicate execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * function isPositive( 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 input array: * var sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.everyBy( x, isPositive ); * // returns [ true ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * function isPositive( 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 input array: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'bool' * }); * * // Perform reduction: * var out = ns.everyBy.assign( x, y, isPositive ); * // returns [ true ] * * var bool = ( out === y ); * // returns true */ everyBy: typeof everyBy; /** * Fancy array constructor. * * @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) * @param options - function options * @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']) * @param options.readonly - specifies whether an array should be read-only (default: false) * @throws `buffer` argument `get` and `set` properties must be functions * @throws `shape` argument must be an array-like object containing nonnegative integers * @throws `shape` argument length must equal the number of dimensions * @throws `strides` argument must be an array-like object containing integers * @throws `strides` argument length must equal the number of dimensions (except for zero-dimensional arrays; in which case, the `strides` argument length must be equal to `1`) * @throws for zero-dimensional ndarrays, the `strides` argument must contain a single element equal to `0` * @throws `offset` argument must be a nonnegative integer * @throws `buffer` argument must be compatible with specified meta data * @throws must provide valid options * @throws too many dimensions * @returns an ndarray * * @example * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var out = new ns.FancyArray( 'generic', buffer, shape, strides, offset, 'row-major' ); */ FancyArray: typeof FancyArray; /** * 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 zeros = require( './../../zeros' ); * var getData = require( './../../data-buffer' ); * * var x = zeros( [ 3, 1, 2 ], { * 'dtype': 'float64' * }); * * ns.fill( x, 10.0 ); * * console.log( getData( x ) ); * // => [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] */ 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 zeros = require( './../../zeros' ); * var getData = require( './../../data-buffer' ); * * function fcn() { * return 10.0; * } * * var x = zeros( [ 3, 1, 2 ], { * 'dtype': 'float64' * }); * * ns.fillBy( x, fcn ); * * console.log( getData( x ) ); * // => [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] */ fillBy: typeof fillBy; /** * Fills an input ndarray view with a specified value. * * @param x - input ndarray * @param value - fill value * @param args - slice and option arguments * @returns input ndarray * * @example * var zeros = require( './../../zeros' ); * var MultiSlice = require( '@stdlib/slice/multi' ); * var Slice = require( '@stdlib/slice/ctor' ); * var ndarray2array = require( './../../to-array' ); * * var x = zeros( [ 3, 4 ], { * 'dtype': 'generic' * }); * * // Specify the fill region: * var s0 = new Slice( 1, 3 ); * var s1 = new Slice( 2, 4 ); * * // Fill the slice: * var y = ns.fillSlice( x, 5.0, s0, s1 ); * // returns * * var bool = ( y === x ); * // returns true * * var arr = ndarray2array( x ); * // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] */ fillSlice: typeof fillSlice; /** * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function. * * @param x - input ndarray * @param options - options * @param options.dtype - output ndarray data type * @param options.order - iteration order * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output ndarray * * @example * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * var buffer = 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 shape = [ 2, 3 ]; * var strides = [ 6, 1 ]; * var offset = 1; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * var opts = { * 'dtype': 'generic' * }; * var y = ns.filter( x, opts, isEven ); * // returns [ 2.0, 4.0, 8.0, 10.0 ] */ filter: typeof filter; /** * Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. * * @param x - input ndarray * @param options - options * @param options.dtype - output ndarray data type * @param options.order - iteration order * @param fcn - callback function * @param thisArg - callback function execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * function scale( z ) { * if ( z > 5.0 ) { * return z * 10.0; * } * } * * var buffer = 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 shape = [ 2, 3 ]; * var strides = [ 6, 1 ]; * var offset = 1; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * var opts = { * 'dtype': 'generic' * }; * var y = ns.filterMap( x, opts, scale ); * // returns [ 80.0, 90.0, 100.0 ] */ filterMap: typeof filterMap; /** * Returns a new ndarray containing the first elements which pass a test implemented by a predicate function along one or more ndarray dimensions. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @param options.sentinel - sentinel value * @param predicate - predicate function * @param thisArg - predicate execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * var ndarray = require( './../../ctor' ); * * // 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 sh = [ 3, 2 ]; * * // Define the array strides: * var sx = [ 2, 1 ]; * * // Define the index offset: * var ox = 0; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform the operation: * var out = ns.find( x, isEven ); * // returns * * var v = out.get(); * // returns 2.0 * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * var empty = require( './../../empty' ); * * // 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, 2 ]; * * // Define the array strides: * var sx = [ 2, 1 ]; * * // Define the index offset: * var ox = 0; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'float64' * }); * * // Perform the operation: * var out = ns.find.assign( x, y, isEven ); * // returns * * var v = out.get(); * // returns 2.0 */ find: typeof find; /** * Returns a new ndarray containing the last elements which pass a test implemented by a predicate function along one or more ndarray dimensions. * * @param x - input ndarray * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @param options.sentinel - sentinel value * @param predicate - predicate function * @param thisArg - predicate execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * var ndarray = require( './../../ctor' ); * * // 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 sh = [ 3, 2 ]; * * // Define the array strides: * var sx = [ 2, 1 ]; * * // Define the index offset: * var ox = 0; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform the operation: * var out = ns.findLast( x, isEven ); * // returns [ 6.0 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * var empty = require( './../../empty' ); * * // 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, 2 ]; * * // Define the array strides: * var sx = [ 2, 1 ]; * * // Define the index offset: * var ox = 0; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'float64' * }); * * // Perform the operation: * var out = ns.findLast.assign( x, y, isEven ); * // returns [ 6.0 ] */ findLast: typeof findLast; /** * 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. * * @param x - input ndarray * @returns flags * * @example * var zeros = require( './../../zeros' ); * * var o = ns.flags( zeros( [ 3, 3, 3 ] ) ); * // returns {...} */ flags: typeof flags; /** * Returns a flattened copy of an input ndarray. * * ## Notes * * - The function **always** returns a copy of input ndarray data, even when an input ndarray already has the desired number of dimensions. * * @param x - input ndarray * @param options - function options * @param options.depth - maximum number of dimensions to flatten * @param options.order - order in which input ndarray elements should be flattened * @param options.dtype - output ndarray data type * @returns output ndarray * * @example * var array = require( './../../array' ); * * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] ); * // returns * * var y = ns.flatten( x ); * // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] */ flatten: typeof flatten; /** * Flattens an ndarray according to a callback function. * * @param x - input ndarray * @param options - function options * @param options.depth - maximum number of dimensions to flatten * @param options.order - order in which input ndarray elements should be flattened * @param options.dtype - output ndarray data type * @param fcn - callback function * @param thisArg - callback execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * function scale( value ) { * return value * 2.0; * } * * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var shape = [ 3, 1, 2 ]; * var strides = [ 2, 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * var opts = { * 'depth': 2 * }; * * var y = ns.flattenBy( x, opts, scale ); * // returns [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] */ flattenBy: typeof flattenBy; /** * Returns a copy of an input ndarray where all dimensions of the input ndarray are flattened starting from a specified dimension. * * ## Notes * * - The function **always** returns a copy of input ndarray data, even when an input ndarray already has the desired number of dimensions. * * @param x - input ndarray * @param dim - dimension to start flattening from * @param options - function options * @param options.order - order in which input ndarray elements should be flattened * @param options.dtype - output ndarray data type * @returns output ndarray * * @example * var array = require( './../../array' ); * var shape = require( './../../shape' ); * * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] ); * // returns * * var shx = shape( x ); * // returns [ 3, 1, 2 ] * * var y = ns.flattenFrom( x, 1 ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var shy = shape( y ); * // returns [ 3, 2 ] */ flattenFrom: typeof flattenFrom; /** * Flattens an ndarray according to a callback function starting from a specified dimension. * * @param x - input ndarray * @param dim - dimension to start flattening from * @param options - function options * @param options.order - order in which input ndarray elements should be flattened * @param options.dtype - output ndarray data type * @param fcn - callback function * @param thisArg - callback execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * function scale( value ) { * return value * 2.0; * } * * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var shape = [ 3, 1, 2 ]; * var strides = [ 2, 2, 1 ]; * var offset = 0; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * var opts = { * 'dtype': 'float32' * }; * * var y = ns.flattenFromBy( x, 1, opts, scale ); * // returns [ [ 2.0, 4.0 ], [ 6.0, 8.0 ], [ 10.0, 12.0 ] ] */ flattenFromBy: typeof flattenFromBy; /** * Returns a read-only view of an input ndarray in which the order of elements along the last dimension is reversed. * * @param x - input array * @returns output array * * @example * var ndarray = require( './../../ctor' ); * * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.fliplr( x ); * // returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ], [ 6.0, 5.0 ] ] */ fliplr: typeof fliplr; /** * Returns a read-only view of an input ndarray in which the order of elements along the second-to-last dimension is reversed. * * @param x - input array * @returns output array * * @example * var ndarray = require( './../../ctor' ); * * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.flipud( x ); * // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ] */ flipud: typeof flipud; /** * Invokes a callback function once for each ndarray element. * * @param x - input ndarray * @param fcn - callback function * @param thisArg - callback function execution context * * @example * var ndarray = require( './../../ctor' ); * var naryFunction = require( '@stdlib/utils/nary-function' ); * var log = require( '@stdlib/console/log' ); * * var buffer = [ 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 shape = [ 2, 3 ]; * var strides = [ 3, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * // Apply the callback function: * ns.forEach( x, naryFunction( log, 1 ) ); */ forEach: typeof forEach; /** * Returns a zero-dimensional ndarray containing a provided scalar value. * * ## Notes * * - If a `dtype` option is not provided and `value` * * - is a number, the default data type is the default real-valued floating-point data type. * - is a boolean, the default data type is the default boolean data type. * - is a complex number object of a known complex data type, the data type is the same as the provided value. * - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type. * - is any other value type, the default data type is `'generic'`. * * @param value - scalar value * @param options - options * @returns zero-dimensional ndarray * * @example * var x = ns.scalar2ndarray( 1.0, { * 'dtype': 'generic' * }); * // returns * * var sh = x.shape; * // returns [] * * var dt = x.dtype; * // returns 'generic' * * var v = x.get(); * // returns 1.0 */ scalar2ndarray: typeof scalar2ndarray; /** * Converts a scalar value to a zero-dimensional ndarray having the same data type as a provided ndarray. * * @param x - input ndarray * @param value - scalar value * @param options - function options * @returns zero-dimensional ndarray * * @example * var getShape = require( './../../shape' ); * var getDType = require( './../../dtype' ); * var empty = require( './../../empty' ); * * var x = empty( [ 2 ] ); * // returns * * var out = ns.scalar2ndarrayLike( x, 1.0, { * 'dtype': 'generic' * }); * // returns [ 1.0 ] * * var sh = getShape( out ); * // returns [] * * var dt = String( getDType( out ) ); * // returns 'generic' */ scalar2ndarrayLike: typeof scalar2ndarrayLike; /** * Tests whether an ndarray contains a specified value along one or more dimensions. * * @param x - input ndarray * @param searchElement - search element * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @returns output ndarray * * @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 sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.includes( x, 6.0 ); * // returns * * var v = out.get(); * // returns true * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * // 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 an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'bool' * }); * * // Perform reduction: * var out = ns.includes.assign( x, 6.0, y ); * // returns * * var v = out.get(); * // returns true */ includes: typeof includes; /** * 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 linear 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. * * @param shape - array shape * @param idx - linear index * @param options - function options * @param options.mode - specifies how to handle a linear index which exceeds array dimensions (default: 'throw') * @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') * @throws shape argument must be an array-like object containing nonnegative integers * @throws must provide valid options * @throws must provide a linear index which does not exceed array dimensions * @returns subscripts * * @example * var s = ns.ind2sub( [ 3, 3, 3 ], 17 ); * // returns [ 1, 2, 2 ] * * @example * var shape = [ 3, 3, 3 ]; * var out = [ 0, 0, 0 ]; * * var s = ns.ind2sub.assign( shape, 17, out ); * // returns [ 1, 2, 2 ] * * var bool = ( s === out ); * // returns true */ ind2sub: typeof ind2sub; /** * ndarray index constructor. * * @param x - input ndarray * @param options - function options * @param options.persist - boolean indicating whether to continue persisting an index object after first usage * @param options.kind - specifies whether a provided ndarray is a specialized kind of integer input ndarray * @returns ndindex instance * * @example * var Uint8Array = require( '@stdlib/array/uint8' ); * var array = require( './../../array' ); * * var x = array( new Uint8Array( [ 1, 0, 1, 0 ] ) ); * * var idx = new ns.ndindex( x ); * // returns * * @example * var Int32Array = require( '@stdlib/array/int32' ); * var array = require( './../../array' ); * * var x = array( new Int32Array( [ 1, 0, 1, 0 ] ) ); * * var idx = ns.ndindex.cartesianIndex( x ); * // returns * * @example * var Int32Array = require( '@stdlib/array/int32' ); * var array = require( './../../array' ); * * var x = array( new Int32Array( [ 1, 0, 1, 0 ] ) ); * * var idx = ns.ndindex.linearIndex( x ); * // returns */ ndindex: typeof ndindex; /** * Returns a list of ndarray index modes. * * ## Notes * * - The output array contains the following modes: * * - **throw**: specifies that a function should throw an error when an index is * outside a restricted interval. * - **normalize**: specifies that a function should normalize negative indices and throw an error when an index is outside a restricted interval. * - **wrap**: specifies that a function should wrap around an index using modulo * arithmetic. * - **clamp**: specifies that a function should set an index less than zero to * zero (minimum index) and set an index greater than a maximum index value to * the maximum possible index. * * @returns list of ndarray index modes * * @example * var list = ns.indexModes(); * // returns [ 'throw', 'normalize', 'clamp', 'wrap' ] */ indexModes: typeof indexModes; /** * Returns a list of input ndarray casting policies. * * ## Notes * * - The output array contains the following policies: * * - `none`: no guidance on specific casting behavior. An input ndarray may or may not be cast depending on the needs of an implementation. * - `promoted`: cast an input ndarray to a promoted data type. * - `accumulation`: cast an input ndarray to a data type amenable to accumulation. * - `output`: cast an input ndarray to the data type of the output ndarray. * * @returns list of policies * * @example * var list = ns.inputCastingPolicies(); * // returns [...] */ inputCastingPolicies: typeof inputCastingPolicies; /** * Multidimensional array iterators. */ iter: typeof iter; /** * Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray. * * @param x - input ndarray * @param options - options * @param options.dtype - output ndarray data type * @param fcn - callback function * @param thisArg - callback function execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * * function scale( z ) { * return z * 10.0; * } * * var buffer = 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 shape = [ 2, 3 ]; * var strides = [ 6, 1 ]; * var offset = 1; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * var opts = { * 'dtype': 'generic' * }; * var y = ns.map( x, opts, scale ); * // returns [ [ 20, 30, 40 ], [ 80, 90, 100 ] ] */ map: typeof map; /** * 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 **read-only** 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 input array may affect multiple elements. If you need to write to the input array, copy the array before broadcasting. * * @param x - 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 array = require( './../../array' ); * * var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns * * var shx = x.shape; * // returns [ 2, 2 ] * * var y = ns.maybeBroadcastArray( 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 */ maybeBroadcastArray: typeof maybeBroadcastArray; /** * 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 **read-only** 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 an input array, copy the array before broadcasting. * * @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 x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * // returns * * var shx = x.shape; * // returns [ 2, 2 ] * * var y1 = zeros( [ 3, 2, 2 ] ); * // returns * * var shy = y1.shape; * // returns [ 3, 2, 2 ] * * var out = ns.maybeBroadcastArrays( x, 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 */ maybeBroadcastArrays: typeof maybeBroadcastArrays; /** * Returns the minimum ndarray data type of the closest "kind" necessary for storing a provided scalar value. * * @param value - scalar value * @returns ndarray data type * * @example * var dt = ns.minDataType( 3.141592653589793 ); * // returns 'float32' * * @example * var dt = ns.minDataType( 3 ); * // returns 'uint8' */ minDataType: typeof minDataType; /** * Returns a list of ndarray data types to which a provided ndarray data type can be safely cast and, for floating-point data types, can be downcast. * * ## Notes * * - If not provided an ndarray data type, the function returns a casting table. * - If provided an unrecognized ndarray data type, the function returns `null`. * * @param dtype - ndarray data type value * @returns list of ndarray data types or null * * @example * var list = ns.mostlySafeCasts( 'float32' ); * // returns [...] */ mostlySafeCasts: typeof mostlySafeCasts; /** * Converts an ndarray-like object to an ndarray. * * ## Notes * * - If provided a read-only ndarray, the function returns a read-only ndarray. * * @param x - input ndarray * @param options - function options * @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']) * @param options.readonly - specifies whether an array should be read-only * @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; /** * 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 larger ndarray data type of the same kind. * * ## Notes * * - If not provided a data type, the function returns a table. * - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. * - If provided an unrecognized data type, the function returns `null`. * * @param dtype - ndarray data type value * @returns next larger data type(s) or null * * @example * var dt = ns.nextDataType( 'float32' ); * // returns 'float64' */ nextDataType: typeof nextDataType; /** * Returns the number of elements in an ndarray. * * @param x - input ndarray * @returns number of elements * * @example * var zeros = require( './../../zeros' ); * * var n = ns.numel( zeros( [ 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 shape - array shape * @param options - options * @param options.dtype - underlying data type (default: 'float64') * @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') * @param options.mode - specifies how to handle a linear index which exceeds array dimensions * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis * @param options.readonly - boolean indicating whether an array should be read-only * @returns ones-filled array * * @example * var getShape = require( './../../shape' ); * var getDType = require( './../../dtype' ); * * var arr = ns.ones( [ 2, 2 ] ); * // 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; /** * 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; /** * Returns a list of ndarray orders. * * ## Notes * * - The output array contains the following orders: * * - row-major: row-major (C-style) order. * - column-major: column-major (Fortran-style) order. * * @returns list of ndarray orders * * @example * var list = ns.orders(); * // e.g., returns [ 'row-major', 'column-major' ] */ orders: typeof orders; /** * Returns a list of output ndarray data type policies. * * ## Notes * * - The output array contains the following data type policies: * * - `same`: return the same data type. * - `promoted`: return a promoted data type. * - `accumulation`: return a data type amenable to accumulation. * - `boolean`: return a boolean data type. * - `boolean_and_generic`: return a boolean or "generic" data type. * - `signed_integer`: return a signed integer data type. * - `signed_integer_and_generic`: return a signed integer or "generic" data type. * - `unsigned_integer`: return an unsigned integer data type. * - `unsigned_integer_and_generic`: return an unsigned integer or "generic" data type. * - `integer`: return an integer data type (i.e., either signed or unsigned). * - `integer_and_generic`: return an integer (i.e., either signed or unsigned) or "generic" data type. * - `floating_point`: return a floating-point data type (i.e., either real-valued or complex-valued). * - `floating_point_and_generic`: return a floating-point (i.e., either real-valued or complex-valued) or "generic" data type. * - `real_floating_point`: return a real-valued floating-point data type. * - `real_floating_point_and_generic`: return a real-valued or "generic" floating-point data type. * - `complex_floating_point`: return a complex-valued floating-point data type. * - `complex_floating_point_and_generic`: return a complex-valued or "generic" floating-point data type. * - `real`: return a real-valued data type. * - `real_and_generic`: return a real-valued or "generic" data type. * - `numeric`: return a numeric data type. * - `numeric_and_generic`: return a numeric or "generic" data type. * - `integer_index`: return an integer index data type. * - `integer_index_and_generic`: return an integer index or "generic" data type. * - `boolean_index`: return a boolean index data type. * - `boolean_index_and_generic`: return a boolean index or "generic" data type. * - `mask_index`: return a mask index data type. * - `mask_index_and_generic`: return a mask index or "generic" data type. * - `default`: return the default data type. * - `default_index`: return the default index data type. * * @returns list of data type policies * * @example * var list = ns.outputDataTypePolicies(); * // returns [...] */ outputDataTypePolicies: typeof outputDataTypePolicies; /** * Returns an array containing a read-only truncated view of an input ndarray and a read-only 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 options - function options * @param options.dim - dimension along which to perform the operation * @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 ); * // returns [ , ] * * arr = ndarray2array( y[ 0 ] ); * // returns [ [ 1.0 ], [ 3.0 ], [ 5.0 ] ] * * arr = ndarray2array( y[ 1 ] ); * // returns [ [ 2.0 ], [ 4.0 ], [ 6.0 ] ] */ pop: typeof pop; /** * Returns a read-only view of an input ndarray with a specified number of prepended singleton dimensions. * * @param x - input array * @param n - number of singleton dimensions to prepend * @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 ); * // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] */ prependSingletonDimensions: typeof prependSingletonDimensions; /** * Returns a type promotion table displaying the ndarray data types with the smallest size and closest "kind" to which ndarray data types can be safely cast. * * @returns promotion rule table * * @example * var table = ns.promotionRules(); * // returns {...} */ promotionRules: typeof promotionRules; /** * Returns an ndarray formed by appending provided scalar values to a one-dimensional input ndarray. * * @param x - input ndarray * @param values - scalar values * @returns output ndarray * * @example * var array = require( './../../array' ); * * var x = array( [ 1.0, 2.0, 3.0, 4.0 ] ); * * var out = ns.push( x, 5.0, 6.0, 7.0 ); * // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] * * @example * var array = require( './../../array' ); * var empty = require( './../../empty' ); * * var x = array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = empty( [ 7 ] ); * * var out = ns.push.assign( x, 5.0, 6.0, 7.0, y ); * // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] * * var bool = ( out === y ); * // returns true */ push: typeof push; /** * Returns a shallow copy of an ndarray containing only those elements which fail a test implemented by a predicate function. * * @param x - input ndarray * @param options - options * @param options.dtype - output ndarray data type * @param options.order - iteration order * @param predicate - predicate function * @param thisArg - predicate function execution context * @returns output ndarray * * @example * var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; * 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, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); * var shape = [ 2, 3 ]; * var strides = [ 6, 1 ]; * var offset = 1; * * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); * // returns * * var opts = { * 'dtype': 'generic' * }; * var y = ns.reject( x, opts, isOdd ); * // returns * * var arr = ndarray2array( y ); * // returns [ 2.0, 4.0, 8.0, 10.0 ] */ reject: typeof reject; /** * Returns a read-only view of an input ndarray in which the order of elements along each dimension is reversed. * * @param x - input array * @returns output array * * @example * var ndarray = require( './../../ctor' ); * var ndarray2array = require( './../../to-array' ); * * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var arr = ndarray2array( x ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.reverse( x ); * // returns * * arr = ndarray2array( y ); * // returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] */ reverse: typeof reverse; /** * Returns a read-only 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 * @returns output array * * @example * var ndarray = require( './../../ctor' ); * var ndarray2array = require( './../../to-array' ); * * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var arr = ndarray2array( x ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.reverseDimension( x, 0 ); * // returns * * arr = ndarray2array( y ); * // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ] */ reverseDimension: typeof reverseDimension; /** * Returns a list of ndarray data types to which a provided ndarray data type can be safely cast. * * ## Notes * * - If not provided an ndarray data type, the function returns a casting table. * - If provided an unrecognized ndarray data type, the function returns `null`. * * @param dtype - ndarray data type value * @returns list of ndarray data types or null * * @example * var list = ns.safeCasts( 'float32' ); * // returns [...] */ safeCasts: typeof safeCasts; /** * Returns a list of ndarray data types to which a provided ndarray data type can be safely cast or cast within the same "kind". * * ## Notes * * - If not provided an ndarray data type, the function returns a casting table. * - If provided an unrecognized ndarray data type, the function returns `null`. * * @param dtype - ndarray data type value * @returns list of ndarray data types or null * * @example * var list = ns.sameKindCasts( 'float32' ); * // returns [...] */ sameKindCasts: typeof sameKindCasts; /** * Returns the shape of a provided ndarray. * * @param x - input ndarray * @returns shape * * @example * var zeros = require( './../../zeros' ); * * var sh = ns.shape( zeros( [ 3, 3, 3 ] ) ); * // returns [ 3, 3, 3 ] */ shape: typeof shape; /** * Returns an array containing a read-only truncated view of an input ndarray and a read-only 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 options - function options * @param options.dim - dimension along which to perform the operation * @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 ); * // returns [ , ] * * arr = ndarray2array( y[ 0 ] ); * // returns [ [ 2.0 ], [ 4.0 ], [ 6.0 ] ] * * arr = ndarray2array( y[ 1 ] ); * // returns [ [ 1.0 ], [ 3.0 ], [ 5.0 ] ] */ shift: typeof shift; /** * Returns a read-only view of an input ndarray. * * @param x - input array * @param slices - slice arguments * @param options - function options * @param options.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 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 s0 = new Slice( null, null, -2 ); * var s1 = new Slice( null, null, -1 ); * * var y = ns.slice( x, s0, s1 ); * // 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 args - slice and option arguments * @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 ); * * // Perform assignment: * var out = ns.sliceAssign( x, y, s0, s1, s2 ); * // 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 read-only 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 options - function options * @param options.strict - boolean indicating whether to enforce strict bounds checking * @returns output array * * @example * var Slice = require( '@stdlib/slice/ctor' ); * var ndarray = require( './../../ctor' ); * var typedarray = require( '@stdlib/array/typed' ); * 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 s = new Slice( null, null, -1 ); * // returns * * var y = ns.sliceDimension( x, 0, s ); * // returns * * sh = y.shape; * // returns [ 3, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ] */ sliceDimension: typeof sliceDimension; /** * Returns a read-only 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 options - function options * @param options.strict - boolean indicating whether to enforce strict bounds checking * @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 ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 3, 4 ], [ 5, 6 ] ] */ sliceDimensionFrom: typeof sliceDimensionFrom; /** * Returns a read-only 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 options - function options * @param options.strict - boolean indicating whether to enforce strict bounds checking * @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 ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] */ sliceDimensionTo: typeof sliceDimensionTo; /** * Returns a read-only shifted view of an input ndarray. * * @param x - input array * @param start - starting indices (inclusive) * @param options - function options * @param options.strict - boolean indicating whether to enforce strict bounds checking * @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.sliceFrom( x, 1, null ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 3, 4 ], [ 5, 6 ] ] */ sliceFrom: typeof sliceFrom; /** * Returns a read-only truncated view of an input ndarray. * * @param x - input array * @param stop - ending indices (exclusive) * @param options - function options * @param options.strict - boolean indicating whether to enforce strict bounds checking * @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.sliceTo( x, 2, null ); * // returns * * sh = y.shape; * // returns [ 2, 2 ] * * arr = ndarray2array( y ); * // returns [ [ 1, 2 ], [ 3, 4 ] ] */ sliceTo: typeof sliceTo; /** * Tests whether at least `n` elements along one or more ndarray dimensions are truthy. * * @param x - input ndarray * @param n - number of elements which must be truthy * @param options - function options * @returns output ndarray * * @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 sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.some( x, 3 ); * // returns [ true ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var empty = require( './../../empty' ); * * // 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 an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'bool' * }); * * // Perform reduction: * var out = ns.some.assign( x, 3, y ); * // returns [ true ] */ some: typeof some; /** * Tests whether at least `n` elements along one or more ndarray dimensions pass a test implemented by a predicate function. * * @param x - input ndarray * @param n - number of elements which must pass a test * @param options - function options * @param options.dims - list of dimensions over which to perform a reduction * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) * @param predicate - predicate function * @param thisArg - predicate execution context * @returns output ndarray * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * 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 sh = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; * * // Define the index offset: * var ox = 1; * * // Create an input ndarray: * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); * * // Perform reduction: * var out = ns.someBy( x, 3, isEven ); * // returns [ true ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( './../../ctor' ); * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * var empty = require( './../../empty' ); * * // 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 an input ndarray: * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * * // Create an output ndarray: * var y = empty( [], { * 'dtype': 'bool' * }); * * // Perform reduction: * var out = ns.someBy.assign( x, 3, y, isEven ); * // returns [ true ] */ someBy: typeof someBy; /** * Returns a read-only view of an input ndarray where the dimensions of the input ndarray are expanded to a specified dimensionality by spreading dimensions to specified dimension indices and inserting dimensions of size one for the remaining dimensions. * * @param ndims - number of dimensions in the output array * @param x - input ndarray * @param dims - dimension indices * @returns output array * * @example * var ndarray = require( './../../ctor' ); * var ndarray2array = require( './../../to-array' ); * * var buffer = [ 1.0, 2.0, 3.0, 4.0 ]; * var shape = [ 2, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] * * var y = ns.spreadDimensions( 5, x, [ 1, 3 ] ); * // returns [ [ [ [ [ 1.0 ], [ 2.0 ] ] ], [ [ [ 3.0 ], [ 4.0 ] ] ] ] ] */ 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. * * @param x - input ndarray * @returns strides * * @example * var zeros = require( './../../zeros' ); * * var sh = ns.strides( zeros( [ 3, 3, 3 ] ) ); * // returns [ 9, 3, 1 ] */ strides: typeof strides; /** * 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. * * - If provided fewer modes than dimensions, the function recycles modes using modulo arithmetic. * * @param shape - array shape * @param args - subscripts followed by an optional options object * @throws first argument must be an array-like object containing nonnegative integers * @throws subscripts must be integer valued * @throws must provide valid options * @throws must provide subscripts which do not exceed array dimensions * @throws number of subscripts much match the number of dimensions * @returns linear index * * @example * var i = ns.sub2ind( [ 3, 3, 3 ], 1, 2, 2 ); * // returns 17 */ sub2ind: typeof sub2ind; /** * Converts an ndarray to a generic array (which may include nested arrays). * * @param x - input ndarray * @returns array (which may include nested arrays) * * @example * var array = require( './../../array' ); * * var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); * var out = ns.ndarray2array( arr ); * // 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 ndarray * * @example * var ndarray = require( './../../ctor' ); * * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.toFlippedlr( x ); * // returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ], [ 6.0, 5.0 ] ] */ 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 ndarray * * @example * var ndarray = require( './../../ctor' ); * * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.toFlippedud( x ); * // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ] */ toFlippedud: typeof toFlippedud; /** * Serializes an ndarray as a JSON object. * * ## Notes * * - The function does **not** serialize data outside of the buffer region defined by the ndarray view. * * @param x - input ndarray * @returns JSON object * * @example * var array = require( './../../array' ); * * var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); * // returns * * var o = ns.ndarray2json( x ); * // returns {...} */ ndarray2json: typeof ndarray2json; /** * Serializes an ndarray as a locale-aware string. * * ## Notes * * - The function does **not** serialize data outside of the buffer region defined by the ndarray view. * * @param x - input ndarray * @param locales - locale identifier(s) * @param options - configuration options * @returns string representation * * @example * var array = require( './../../array' ); * * var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); * // returns * * var str = ns.ndarray2localeString( x ); * // returns */ ndarray2localeString: typeof ndarray2localeString; /** * Returns a new ndarray where the order of elements of an input ndarray is reversed along each dimension. * * @param x - input array * @returns output ndarray * * @example * var ndarray = require( './../../ctor' ); * var ndarray2array = require( './../../to-array' ); * * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * var shape = [ 3, 2 ]; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); * // returns * * var arr = ndarray2array( x ); * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] * * var y = ns.toReversed( x ); * // returns * * arr = ndarray2array( y ); * // returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] */ 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 options - function options * @param options.dim - index of dimension to reverse * @returns output array * * @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 = ns.toReversedDimension( x ); * // returns [ [ 2.0, 1.0 ], [ 4.0, 3.0 ] ] */ toReversedDimension: typeof toReversedDimension; /** * Returns a one-dimensional ndarray formed by prepending provided scalar values to a one-dimensional input ndarray. * * @param x - input ndarray * @param values - scalar values * @returns output ndarray * * @example * var array = require( './../../array' ); * * var x = array( [ 1.0, 2.0, 3.0, 4.0 ] ); * * var out = ns.unshift( x, -2.0, -1.0, 0.0 ); * // returns [ -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] * * @example * var array = require( './../../array' ); * var empty = require( './../../empty' ); * * var x = array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = empty( [ 7 ] ); * * var out = ns.unshift.assign( x, -2.0, -1.0, 0.0, y ); * // returns [ -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] * * var bool = ( out === y ); * // returns true */ unshift: typeof unshift; /** * Vector constructors and associated utilities. */ vector: typeof vector; /** * Returns a new ndarray with the element at a specified index replaced by a provided value. * * @param x - input ndarray * @param indices - indices of the element to replace * @param value - value to set * @returns output ndarray * * @example * var ndarray = require( './../../ctor' ); * * var buffer = [ 1, 2, 3, 4 ]; * var shape = [ 2, 2 ]; * var order = 'row-major'; * var strides = [ 2, 1 ]; * var offset = 0; * * var x = ndarray( 'generic', buffer, shape, strides, offset, order ); * * var out = ns.ndarrayWith( x, [ 0, 0 ], 5 ); * // returns * * var v = out.get( 0, 0 ); * // returns 5 */ ndarrayWith: typeof ndarrayWith; /** * Creates a zero-filled array having a specified shape and data type. * * @param shape - array shape * @param options - options * @param options.dtype - underlying data type (default: 'float64') * @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') * @param options.mode - specifies how to handle a linear index which exceeds array dimensions * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis * @param options.readonly - boolean indicating whether an array should be read-only * @returns zero-filled array * * @example * var getShape = require( './../../shape' ); * var getDType = require( './../../dtype' ); * * var arr = ns.zeros( [ 2, 2 ] ); * // 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 * @param options - options * @param options.dtype - output array data type * @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) * @param options.shape - output array shape * @param options.mode - specifies how to handle a linear index which exceeds array dimensions * @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis * @param options.readonly - boolean indicating whether an array should be read-only * @returns zero-filled array * * @example * var getShape = require( './../../shape' ); * var getDType = require( './../../dtype' ); * var zeros = require( './../../zeros' ); * * var x = zeros( [ 2, 2 ], { * 'dtype': 'float64' * }); * // 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; } /** * Multidimensional arrays. */ declare var ns: Namespace; // EXPORTS // export = ns;