本文整理汇总了C++中Matrix::Data方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::Data方法的具体用法?C++ Matrix::Data怎么用?C++ Matrix::Data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::Data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Avx2Mat4x4TestF64
void Avx2Mat4x4TestF64(const Matrix<double>& m1, const Matrix<double>& m2)
{
if (!Matrix<double>::IsConforming(m1, m2))
throw runtime_error("Non-conforming operands - Avx2Mat4x4TestF64");
const size_t nrows = m1.GetNumRows();
const size_t ncols = m1.GetNumCols();
if (nrows != 4 || ncols != 4)
throw runtime_error("Invalid size - Avx2Mat4x4TestF64");
Matrix<double> m3_a(nrows, ncols);
Matrix<double> m3_b(nrows, ncols);
Matrix<double>::Mul(m3_a, m1, m2);
Avx2Mat4x4MulF64_(m3_b.Data(), m1.Data(), m2.Data());
cout << "\nResults for Avx2Mat4x4TestF64\n";
cout << "\nMatrix m3_a\n";
cout << m3_a << endl;
cout << "\nMatrix m3_b\n";
cout << m3_b << endl;
double tr_a = m1.Trace();
double tr_b = Avx2Mat4x4TraceF64_(m1.Data());
cout << "tr_a = " << tr_a << '\n';
cout << "tr_b = " << tr_b << '\n';
}
示例2: 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 */
示例3: renderFrame
void renderFrame(void)
{
//glViewport(0, 0, 600, 800);
// Get parameters from Effect
Effect* effect = sprite.GetEffect();
GLint u_MVPMatrix_handle = glGetUniformLocation(effect->GetProgramHandle(),"u_MVPMatrix");
GLint a_Position_handle = glGetAttribLocation(effect->GetProgramHandle(), "a_Position");
GLint a_TexCoordinate = glGetAttribLocation(effect->GetProgramHandle(), "a_TexCoordinate");
GLint mTextureUniformHandle = glGetUniformLocation(effect->GetProgramHandle(), "u_Texture");
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
glUseProgram(sprite.GetEffect()->GetProgramHandle());
glActiveTexture(GL_TEXTURE0);
// Bind the texture to this unit.
Texture* texture = (Texture*)sprite.GetTexture();
const GLuint thandle = texture->GetTextureHandle();
glBindTexture(GL_TEXTURE_2D, thandle); //sprite.GetTexture()->GetTextureHandle());
// Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0.
glUniform1i(mTextureUniformHandle, 0);
// Set position attribute and MVP matrix uniform
glVertexAttribPointer(a_Position_handle, 3, GL_FLOAT, false, 0, Sprite::GetVertexPosStatic());
glEnableVertexAttribArray(a_Position_handle);
glVertexAttribPointer(a_TexCoordinate, 2, GL_FLOAT, false, 0, Sprite::GetVertexTexStatic());
glEnableVertexAttribArray(a_TexCoordinate);
const Matrix *proj;
proj = camera.GetProjection();
std::string s;
Matrix projworld;
Matrix world;
world = Matrix::Translation(0,0,zoom);
Matrix::Multiply(*proj,world, projworld);
glUniformMatrix4fv(u_MVPMatrix_handle, 1, false, projworld.Data());
std::cout << std::flush;
glDrawArrays(GL_TRIANGLES, 0, 6);
//glFlush();
}
示例4: assert
void MatrixQuantizerCPU<ElemType>::QuantizeAsync(const Matrix<ElemType>& inMatrix, const Matrix<ElemType>& inResidual, QuantizedMatrix<ElemType>& outQMatrix, Matrix<ElemType>& outResidual, bool zeroThresholdFor1Bit)
{
// The outQMatrix should be on the CPU
// TODO: Support transferring the quantization output to a quantized matrix on the GPU
assert(outQMatrix.GetDeviceId() == CPUDEVICE);
size_t nBits = outQMatrix.GetNumBits();
size_t nRow = inMatrix.GetNumRows();
size_t nCol = inMatrix.GetNumCols();
// Verify that the different matrix parameters have matching dimensions
assert((outQMatrix.GetNumRows() == nRow) && (outQMatrix.GetNumCols() == nCol));
assert((inResidual.GetNumRows() == nRow) && (inResidual.GetNumCols() == nCol));
assert((outResidual.GetNumRows() == nRow) && (outResidual.GetNumCols() == nCol));
const size_t ldNbits = ValueQuantizer<ElemType>::ld(nBits);
#ifdef QUANTUSEPPL
Concurrency::parallel_for((size_t) 0, us.cols(), [&](size_t j)
#else
for (size_t j = 0; j < nCol; j++)
#endif
{
auto& qcol = *(outQMatrix.GetQuantizedColumn(j));
if (zeroThresholdFor1Bit)
{
// Explicit use of 'template' keyword is needed to compile with GCC
ColumnQuantizer<ElemType>::template ComputeRangeStatColj<true>(inMatrix.Data(), inResidual.Data(), (long) nRow, j, nBits, qcol.lower, qcol.upper);
}
else
{
// Explicit use of 'template' keyword is needed to compile with GCC
ColumnQuantizer<ElemType>::template ComputeRangeStatColj<false>(inMatrix.Data(), inResidual.Data(), (long) nRow, j, nBits, qcol.lower, qcol.upper);
}
ColumnQuantizer<ElemType> q(ldNbits, qcol.lower, qcol.upper);
if (zeroThresholdFor1Bit)
{
// Explicit use of 'template' keyword is needed to compile with GCC
q.template Quantize<true>(inMatrix.Data(), inResidual.Data(), (long) nRow, j, qcol.bits, outResidual.Data());
}
else
{
// Explicit use of 'template' keyword is needed to compile with GCC
q.template Quantize<false>(inMatrix.Data(), inResidual.Data(), (long) nRow, j, qcol.bits, outResidual.Data());
}
}
#ifdef QUANTUSEPPL
);
示例5: 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 */
示例6: AvxMat4x4TransposeF32
void AvxMat4x4TransposeF32(Matrix<float>& m_src)
{
const size_t nr = 4;
const size_t nc = 4;
Matrix<float> m_des1(nr ,nc);
Matrix<float> m_des2(nr ,nc);
Matrix<float>::Transpose(m_des1, m_src);
AvxMat4x4TransposeF32_(m_des2.Data(), m_src.Data());
cout << fixed << setprecision(1);
m_src.SetOstream(12, " ");
m_des1.SetOstream(12, " ");
m_des2.SetOstream(12, " ");
cout << "Results for AvxMat4x4TransposeF32\n";
cout << "Matrix m_src \n" << m_src << '\n';
cout << "Matrix m_des1\n" << m_des1 << '\n';
cout << "Matrix m_des2\n" << m_des2 << '\n';
if (m_des1 != m_des2)
cout << "\nMatrix compare failed - AvxMat4x4TransposeF32\n";
}