本文整理汇总了C++中DoubleMatrix::numCols方法的典型用法代码示例。如果您正苦于以下问题:C++ DoubleMatrix::numCols方法的具体用法?C++ DoubleMatrix::numCols怎么用?C++ DoubleMatrix::numCols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix::numCols方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mult
DoubleMatrix mult(DoubleMatrix& m2, ComplexMatrix& m1)
{
// Check dimensions
unsigned int m1_nRows = m1.numRows();
unsigned int m2_nRows = m2.numRows();
unsigned int m1_nColumns = m1.numCols();
unsigned int m2_nColumns = m2.numCols();
if (m1.size() == 0)
{
return real(m1);
}
if (m2.size() == 0)
{
return m2;
}
DoubleMatrix result(m1_nRows, m2_nColumns);
if (m1_nColumns == m2_nRows)
{
for (unsigned int row = 0; row < result.numRows(); row++)
{
for (unsigned int col = 0; col < m2_nColumns; col++)
{
double sum = 0.0;
for (unsigned int k = 0; k < m1_nColumns; k++)
{
sum = sum + (real(m1[row][k]) * m2[k][col]);
}
result[row][col] = sum;
}
}
return result;
}
if (m1_nRows == m2_nColumns)
{
return mult(m2, m1);
}
throw ("Incompatible matrix operands to multiply");
}
示例2: run_ensemble
void run_ensemble(const char* fname, unsigned long seed)
{
try {
RoadRunner r(fname);
DoubleMatrix result = ensemble(r, 5, seed, 0, 10, 150);
cout.precision(6);
for(int row = 0; row < result.numRows(); ++row) {
for(int col = 0; col < result.numCols(); ++col) {
cout << result(row, col) << ", ";
}
cout << endl;
}
} catch (std::exception& e) {
cout << "Error running ensemble: " << e.what() << endl;
}
}