text: 'use strict';
  
  // FUNCTIONS //
  
  var mset1 = require( './mset1.js' ),
  	mset2 = require( './mset2.js' ),
  	mset3 = require( './mset3.js' ),
  	mset4 = require( './mset4.js' ),
  	mset5 = require( './mset5.js' ),
  	mset6 = require( './mset6.js' );
  
  /**
  * FUNCTION: getIndices( idx, len )
  *	Returns an array of indices.
  *
  * @private
  * @param {Number[]|Null} idx - indices
  * @param {Number} len - max index
  * @returns {Number[]} indices
  */
  function getIndices( idx, len ) {
  	var out,
  		i;
  	if ( idx === null ) {
  		out = new Array( len );
  		for ( i = 0; i < len; i++ ) {
  			out[ i ] = i;
  		}
  	} else {
  		out = idx;
  	}
  	return out;
  } // end FUNCTION getIndices()
  
  
  // MSET //
  
  /**
  * FUNCTION: mset( i[, j], value[, thisArg] )
  *	Sets multiple matrix elements. If provided a single array, `i` is treated as an array of linear indices.
  *
  * @param {Number[]|Null} i - linear/row indices
  * @param {Number[]|Null} [j] - column indices
  * @param {Number|Matrix|Function} value - either a single numeric value, a matrix containing the values to set, or a function which returns a numeric value
  * @returns {Matrix} Matrix instance
  */
  function mset() {
  	/*jshint validthis:true */
  	var nargs = arguments.length,
  		args,
  		rows,
  		cols,
  		i;
  
  	args = new Array( nargs );
  	for ( i = 0; i < nargs; i++ ) {
  		args[ i ] = arguments[ i ];
  	}
  
  	// 2 input arguments...
  	if ( nargs < 3 ) {
  		// indices, clbk
  		if ( typeof args[ 1 ] === 'function' ) {
  			mset2( this, args[ 0 ], args[ 1 ] );
  		}
  		// indices, number
  		else if ( typeof args[ 1 ] === 'number' ) {
  			mset1( this, args[ 0 ], args[ 1 ] );
  		}
  		// indices, matrix
  		else {
  			mset3( this, args[ 0 ], args[ 1 ] );
  		}
  	}
  	// 3 input arguments...
  	else if ( nargs === 3 ) {
  		// indices, clbk, context
  		if ( typeof args[ 1 ] === 'function' ) {
  			mset2( this, args[ 0 ], args[ 1 ], args[ 2 ] );
  		}
  		// rows, cols, function
  		else if ( typeof args[ 2 ] === 'function' ) {
  			rows = getIndices( args[ 0 ], this.shape[ 0 ] );
  			cols = getIndices( args[ 1 ], this.shape[ 1 ] );
  			mset4( this, rows, cols, args[ 2 ], this );
  		}
  		// rows, cols, number
  		else if ( typeof args[ 2 ] === 'number' ) {
  			rows = getIndices( args[ 0 ], this.shape[ 0 ] );
  			cols = getIndices( args[ 1 ], this.shape[ 1 ] );
  			mset5( this, rows, cols, args[ 2 ] );
  		}
  		// rows, cols, matrix
  		else {
  			rows = getIndices( args[ 0 ], this.shape[ 0 ] );
  			cols = getIndices( args[ 1 ], this.shape[ 1 ] );
  			mset6( this, rows, cols, args[ 2 ] );
  		}
  	}
  	// 4 input arguments...
  	else {
  		rows = getIndices( args[ 0 ], this.shape[ 0 ] );
  		cols = getIndices( args[ 1 ], this.shape[ 1 ] );
  		mset4( this, rows, cols, args[ 2 ], args[ 3 ] );
  	}
  	return this;
  } // end FUNCTION mset()
  
  
  // EXPORTS //
  
  module.exports = mset;
  