// Print a two-dimensional array (typically, one time level)
void printMatrixInExcel(const NumericMatrix<double, long>& matrix,
				 const Vector<double, long>& xarr, const Vector<double, long>& yarr, 
				 const std::string& SheetName)
{

	// PREC: Type II, III
	if (xarr.Size() != matrix.Rows() || yarr.Size() != matrix.Columns())
	{
		string tmp = "Vectors X, Y, matrix M: " + getString(xarr.Size()) + comma + getString(yarr.Size())
			+ bracketL + getString(matrix.Rows()) + comma + getString(matrix.Columns()) + bracketR;

		throw DatasimException(string("Size mismatch of vector(s) and matrix"), string("PrintMatrixInExcel"),
			tmp);
	}

	ExcelDriver& excel = ExcelDriver::Instance();
	excel.MakeVisible(true);
	// Print a matrix showing the x and y positions

	// We need to convert the double arrays to lists of strings
	cout << "Starting Excel";

	list<std::string> rowlabels = convertToString(xarr);
	list<std::string> columnlabels = convertToString(yarr);

	cout << "Starting Excel";
	
	excel.AddMatrix(SheetName, matrix, rowlabels, columnlabels);

}
NumericMatrix<V, I, S> NumericMatrix<V, I, S>::operator * (const NumericMatrix<V, I, S>& m) const
{ // Multiply the matrix.
  // This function can be optimized by calculating the inner product ourselfs instead of 
  // using the InnerProduct function of Vector. This saves a couple of row and column copies.


	// Create new matrix with same row size of first matrix and column size of second matrix and same starting index as first matrix
	NumericMatrix<V, I, S> result(Rows(), m.Columns(), MinRowIndex(), MinColumnIndex());
	I r1, c2, rr, cr;

	// Element of resulting array is dot/inner product of corresponding row m1 and corresponding column m2
	for (I rr=result.MinRowIndex(); rr<=result.MaxRowIndex(); ++rr)
	{
		
		for (I cr = result.MinColumnIndex(); cr <= result.MaxColumnIndex(); ++cr) 
		{
			result(rr, cr) = 0.0;
			for (I k = result.MinColumnIndex(); k <= result.MaxColumnIndex(); ++k)
			{

					result(rr, cr) += (*this)(rr, k) * m(k,cr);
			}
			cout << "*" << rr << "," << cr << "," << result(rr, cr)<< endl;
		}
			
	}

	// Return the result
	return result;
}