Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Oct 8, 2023
1 parent 1e78923 commit 77db1f8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
14 changes: 10 additions & 4 deletions base/broadcast-array/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@

// MODULES //

var copy = require( '@stdlib/array/base/copy-indexed' );
var ndarray = require( './../../../base/ctor' );
var getShape = require( './../../../base/shape' );
var getStrides = require('./../../../base/strides' );
var getOffset = require( './../../../base/offset' );
var getOrder = require( './../../../base/order' );
var getDType = require( './../../../base/dtype' );
var getData = require( './../../../base/data-buffer' );
var format = require( '@stdlib/string/format' );
var copy = require( '@stdlib/array/base/copy-indexed' );


// MAIN //
Expand Down Expand Up @@ -95,7 +101,7 @@ function broadcastArray( arr, shape ) {
var j;

N = shape.length;
sh = arr.shape;
sh = getShape( arr, false );
M = sh.length;
if ( N < M ) {
throw new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' );
Expand All @@ -106,7 +112,7 @@ function broadcastArray( arr, shape ) {
strides.push( 0 );
}
// Determine the output array strides...
st = arr.strides;
st = getStrides( arr, false );
for ( i = N-1; i >= 0; i-- ) {
j = M - N + i;
if ( j < 0 ) {
Expand All @@ -128,7 +134,7 @@ function broadcastArray( arr, shape ) {
throw new Error( format( 'invalid argument. Input array and the specified shape are broadcast incompatible. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( sh ).join( ', ' ), copy( shape ).join( ', ' ), i ) );
}
}
return ndarray( arr.dtype, arr.data, copy( shape ), strides, arr.offset, arr.order ); // eslint-disable-line max-len
return ndarray( getDType( arr ), getData( arr ), copy( shape ), strides, getOffset( arr ), getOrder( arr ) ); // eslint-disable-line max-len
}


Expand Down
9 changes: 6 additions & 3 deletions base/empty-like/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
var shape2strides = require( './../../../base/shape2strides' );
var strides2offset = require( './../../../base/strides2offset' );
var numel = require( './../../../base/numel' );
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var getOrder = require( './../../../base/order' );
var emptyArray = require( '@stdlib/array/empty' );
var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' );

Expand Down Expand Up @@ -60,9 +63,9 @@ function emptyLike( x ) {
var st;
var dt;

dt = x.dtype;
sh = x.shape;
ord = x.order;
dt = getDType( x );
sh = getShape( x );
ord = getOrder( x );

ndims = sh.length;
if ( ndims > 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 77db1f8

Please sign in to comment.