/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var isVectorLike = require( '@stdlib/assert/is-vector-like' );
var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' );
var isFloat64Array = require( '@stdlib/assert/is-float64array' );
var array = require( '@stdlib/ndarray/array' );
var dot = require( '@stdlib/blas/base/ddot' ).ndarray;


// MAIN //

/**
* Computes the dot product of `x` and `y`.
*
* ## Notes
*
* -   Casting is **not** safe in order to accommodate generic arrays and array-like objects.
* -   For best performance, provide 1-dimensional `ndarrays` whose underlying data type is `float64`.
*
* @param {(ArrayLike|VectorLike)} x - first input array
* @param {(ArrayLike|VectorLike)} y - second input array
* @throws {TypeError} first argument must be either an array-like object or a 1-dimensional ndarray
* @throws {TypeError} second argument must be either an array-like object or a 1-dimensional ndarray
* @throws {TypeError} first argument must be either an array-like object or ndarray which can be cast to a 1-dimensional ndarray
* @throws {TypeError} second argument must be either an array-like object or ndarray which can be cast to a 1-dimensional ndarray
* @throws {RangeError} input arrays must be the same length
* @returns {number} dot product of `x` and `y`
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
* var array = require( '@stdlib/ndarray/array' );
*
* var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
* var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
*
* var z = ddot( x, y );
* // returns -5.0
*
* @example
* var x = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
* var y = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
*
* var z = ddot( x, y );
* // returns -5.0
*/
function ddot( x, y ) {
	var opts;
	var bool;

	bool = (
		isVectorLike( x ) &&
		isVectorLike( y ) &&
		isFloat64Array( x.data ) &&
		isFloat64Array( y.data )
	);
	if ( bool === false ) {
		if ( !isArrayLikeObject( x ) ) {
			throw new TypeError( 'invalid argument. First argument must be either an array-like object or a 1-dimensional ndarray. Value: `' + x + '`.' );
		}
		if ( !isArrayLikeObject( y ) ) {
			throw new TypeError( 'invalid argument. Second argument must be either an array-like object or a 1-dimensional ndarray. Value: `' + y + '`.' );
		}
		opts = {
			'dtype': 'float64',
			'casting': 'unsafe'
		};
		x = array( x, opts );
		y = array( y, opts );
		if ( x.ndims !== 1 ) {
			throw new TypeError( 'invalid argument. First argument must be either an array-like object or ndarray which can be cast to a 1-dimensional ndarray. Value: `' + x + '`.' );
		}
		if ( y.ndims !== 1 ) {
			throw new TypeError( 'invalid argument. Second argument must be either an array-like object or ndarray which can be cast to a 1-dimensional ndarray. Value: `' + y + '`.' );
		}
	}
	if ( x.length !== y.length ) {
		throw new RangeError( 'invalid argument. Arrays must be the same length. First argument length: ' + x.length + '. Second argument length: ' + y.length + '.' );
	}
	return dot( x.length, x.data, x.strides[ 0 ], x.offset, y.data, y.strides[ 0 ], y.offset ); // eslint-disable-line max-len
}


// EXPORTS //

module.exports = ddot;

@@ -3027,21 +3027,28 @@
 %09if ( x.
-ndims
+shape.length
  !== 1 )
@@ -3242,13 +3242,20 @@
 ( y.
-ndims
+shape.length
  !==

Use more widespread field for testing for dimensionality