function convert( x, dtype ) {
	var isc64;
	var ctor;
	var xbuf;
	var obuf;
	var get;
	var out;
	var len;
	var t;
	var i;

	if ( !isCollection( x ) ) {
		throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );
	}
	// If the output data type is "generic", our task is relatively straightforward...
	if ( dtype === 'generic' ) {
		return copy( x );
	}
	ctor = ctors( dtype );
	if ( ctor === null ) {
		throw new TypeError( format( 'invalid argument. Second argument must be a recognized array data type. Value: `%s`.', dtype ) );
	}
	// Cache the input array length:
	len = x.length;

	// Get the input array data type:
	t = getType( x );
	isc64 = isComplex64( t );

	// Create the output array:
	out = new ctor( len );

	// As the output data type is not "generic", we need to explicitly handle complex number input arrays...
	if ( isc64 || isComplex128( t ) ) {
		if ( isc64 ) {
			xbuf = reinterpret64( x, 0 );
		} else {
			xbuf = reinterpret128( x, 0 );
		}
		// Check whether the output data type is a complex number data type...
		if ( isComplex64( dtype ) ) { // cmplx => cmplx
			obuf = reinterpret64( out, 0 );
			gcopy( len*2, xbuf, 1, obuf, 1 );
			return out;
		}
		if ( isComplex128( dtype ) ) { // cmplx => cmplx
			obuf = reinterpret128( out, 0 );
			gcopy( len*2, xbuf, 1, obuf, 1 );
			return out;
		}
		// Check whether the output data type is a boolean data type...
		if ( isBool( dtype ) ) { // cmplx => bool
			obuf = reinterpretBoolean( out, 0 );
			for ( i = 0; i < len; i++ ) {
				// A complex number is only falsy when both the real and imaginary components are zero...
				if ( xbuf[ 2*i ] || xbuf[ (2*i)+1 ] ) {
					obuf[ i ] = 1;
				} else {
					obuf[ i ] = 0;
				}
			}
			return out;
		}
		// We assume that the output data type is a real number data type, given that we're looking to convert a provided complex number array; in which case, we'll only extract the real components from the complex number input array...
		gcopy( len, xbuf, 2, out, 1 ); // cmplx => real
		return out;
	}
	// Check whether the input array is a boolean array...
	if ( isBool( t ) ) {
		xbuf = reinterpretBoolean( x, 0 );

		// Check whether the output data type is a boolean data type...
		if ( isBool( dtype ) ) { // bool => bool
			obuf = reinterpretBoolean( out, 0 );
			gcopy( len, xbuf, 1, obuf, 1 );
			return out;
		}
		// Check whether the output data type is a complex number data type...
		if ( isComplex64( dtype ) ) { // bool => cmplx
			obuf = reinterpret64( out, 0 );
			gcopy( len, xbuf, 1, obuf, 2 );
			return out;
		}
		if ( isComplex128( dtype ) ) { // bool => cmplx
			obuf = reinterpret128( out, 0 );
			gcopy( len, xbuf, 1, obuf, 2 );
			return out;
		}
		gcopy( len, xbuf, 1, out, 1 ); // bool => real
		return out;
	}
	// Check whether we need to explicitly handle complex number output arrays...
	isc64 = isComplex64( dtype );
	if ( isc64 || isComplex128( dtype ) ) {
		if ( isc64 ) {
			obuf = reinterpret64( out, 0 );
		} else {
			obuf = reinterpret128( out, 0 );
		}
		// We assume that the input data type is a real number data type, given that we're looking to convert to a complex number array; in which case, we'll only set the real components... (WARNING: we're assuming that the output array has been zero-initialized! The imaginary components should be zero!)
		gcopy( len, x, 1, obuf, 2 ); // real => cmplx
		return out;
	}
	// Check whether the output data type is a boolean data type...
	if ( isBool( dtype ) ) {
		obuf = reinterpretBoolean( out, 0 );
		get = resolveGetter( x );
		for ( i = 0; i < len; i++ ) {
			if ( get( x, i ) ) {
				obuf[ i ] = 1;
			} else {
				obuf[ i ] = 0;
			}
		}
		return out;
	}
	// At this point, we're no longer handling complex number or boolean arrays, so we'll just assume that we can perform a straightforward copy...
	gcopy( len, x, 1, out, 1 ); // note: `gcopy` is assumed to support arrays using accessors
	return out;
}
Converts an array to an array of a different data type.

@param {Collection} x - array to convert
@param {string} dtype - output data type
@throws {TypeError} first argument must be an array-like object
@throws {TypeError} second argument must be a recognized array data type
@returns {(Array|TypedArray|ComplexArray)} output array

@example
var arr = [ 1.0, 2.0, 3.0, 4.0 ];

var out = convert( arr, 'float64' );
// returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]