本文整理汇总了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);
}
示例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;
}