本文整理汇总了C++中Matrix::DataNotConst方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::DataNotConst方法的具体用法?C++ Matrix::DataNotConst怎么用?C++ Matrix::DataNotConst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::DataNotConst方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeNanWhenLesOrEqualZero
void SegmentorOTSU::MakeNanWhenLesOrEqualZero (Matrix& m)
{
kkint32 r, c;
double** data = m.DataNotConst ();
for (r = 0; r < m.NumOfRows (); ++r)
{
double* dataRow = data[r];
for (c = 0; c < m.NumOfCols (); ++c)
{
if (dataRow[c] <= 0.0)
dataRow[c] = NaN;
}
}
} /* MakeNanWhenLesOrEqualZero */
示例2: ZeroOutNaN
void SegmentorOTSU::ZeroOutNaN (Matrix& m)
{
double** data = m.DataNotConst ();
kkuint32 numOfRows = m.NumOfRows ();
kkuint32 numOfCols = m.NumOfCols ();
kkuint32 r, c;
for (r = 0; r < numOfRows; ++r)
{
double* dataRow = data[r];
for (c = 0; c < numOfCols; ++c)
{
if (IsNaN (dataRow[c]))
dataRow[c] = 0.0;
}
}
} /* ZeroOutNaN */
示例3: DotDiv
Matrix SegmentorOTSU::DotDiv (const Matrix& left,
const Matrix& right
)
{
kkint32 maxNumOfRows = Max (left.NumOfRows (), right.NumOfRows ());
kkint32 maxNumOfCols = Max (left.NumOfCols (), right.NumOfCols ());
kkint32 minNumOfRows = Min (left.NumOfRows (), right.NumOfRows ());
kkint32 minNumOfCols = Min (left.NumOfCols (), right.NumOfCols ());
Matrix result (maxNumOfRows, maxNumOfCols);
double const * const * leftData = left.Data ();
double const * const * rightData = right.Data ();
double** resultData = result.DataNotConst ();
kkint32 r, c;
for (r = 0; r < minNumOfRows; ++r)
{
double const * leftDataRow = leftData[r];
double const * rightDataRow = rightData[r];
double* resultDataRow = resultData[r];
for (c = 0; c < minNumOfCols; ++c)
resultDataRow[c] = leftDataRow[c] / rightDataRow[c];
}
for (r = minNumOfRows; r < maxNumOfRows; ++r)
{
double* resultDataRow = resultData[r];
for (c = minNumOfCols; c < maxNumOfCols; ++c)
{
if ((r >= right.NumOfRows ()) || (c >= right.NumOfCols ()))
resultDataRow[c] = NaN;
else if (rightData[r][c] == 0.0)
resultDataRow[c] = NaN;
else
resultDataRow[c] = 0.0;
}
}
return result;
} /* DotDiv */
示例4: Power
Matrix SegmentorOTSU::Power (const Matrix& left,
double right
)
{
kkuint32 numOfRows = left.NumOfRows ();
kkuint32 numOfCols = left.NumOfCols ();
Matrix result (numOfRows, numOfCols);
double const * const * leftData = left.Data ();
double** resultData = result.DataNotConst ();
kkuint32 r, c;
for (r = 0; r < numOfRows; ++r)
{
double const * leftDataRow = leftData[r];
double* resultDataRow = resultData[r];
for (c = 0; c < numOfCols; ++c)
resultDataRow[c] = pow (leftDataRow[c], right);
}
return result;
} /* Power */