当前位置: 首页>>代码示例>>C++>>正文


C++ NumericMatrix::Columns方法代码示例

本文整理汇总了C++中NumericMatrix::Columns方法的典型用法代码示例。如果您正苦于以下问题:C++ NumericMatrix::Columns方法的具体用法?C++ NumericMatrix::Columns怎么用?C++ NumericMatrix::Columns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NumericMatrix的用法示例。


在下文中一共展示了NumericMatrix::Columns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printMatrixInExcel

// 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);

}
开发者ID:mistletoe999,项目名称:cpp-samples,代码行数:31,代码来源:ExcelMechanisms.cpp

示例2: result

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;
}
开发者ID:cablegui,项目名称:Prototype_pattern_exercise,代码行数:30,代码来源:NumericMatrix.cpp


注:本文中的NumericMatrix::Columns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。