本文整理汇总了C++中MatrixView::setZero方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixView::setZero方法的具体用法?C++ MatrixView::setZero怎么用?C++ MatrixView::setZero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixView
的用法示例。
在下文中一共展示了MatrixView::setZero方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LU_Inverse
void LU_Inverse(
const GenBandMatrix<T1>& LUx, const ptrdiff_t* p, MatrixView<T> minv)
{
TMVAssert(LUx.isSquare());
TMVAssert(minv.isSquare());
TMVAssert(minv.colsize() == LUx.colsize());
#ifdef XDEBUG
LowerTriMatrix<T,UnitDiag> L0(LUx.colsize());
LU_PackedPL_Unpack(LUx,p,L0.view());
UpperTriMatrix<T> U0 = BandMatrixViewOf(LUx,0,LUx.nhi());
Matrix<T> PLU = L0 * U0;
if (LUx.nlo() > 0) PLU.reversePermuteRows(p);
Matrix<T> minv2 = PLU.inverse();
#endif
if (minv.colsize() > 0) {
if ( !(minv.iscm() || minv.isrm())) {
Matrix<T,ColMajor> temp(minv.colsize(),minv.colsize());
LU_Inverse(LUx,p,temp.view());
minv = temp;
} else {
minv.setZero();
UpperTriMatrixView<T> U = minv.upperTri();
U = BandMatrixViewOf(LUx,0,LUx.nhi());
TriInverse(U,LUx.nhi());
LU_PackedPL_RDivEq(LUx,p,minv);
}
}
#ifdef XDEBUG
TMV_RealType(T) normdiff = Norm(PLU*minv - T(1));
TMV_RealType(T) kappa = Norm(PLU)*Norm(minv);
if (normdiff > 0.001*kappa*minv.colsize()) {
cerr<<"LUInverse:\n";
cerr<<"LUx = "<<LUx<<endl;
cerr<<"p = ";
for(ptrdiff_t i=0;i<LUx.colsize();i++) cerr<<p[i]<<" ";
cerr<<endl;
cerr<<"PLU = "<<PLU<<endl;
cerr<<"minv = "<<minv<<endl;
cerr<<"minv2 = "<<minv2<<endl;
cerr<<"m*minv = "<<PLU*minv<<endl;
cerr<<"minv*m = "<<minv*PLU<<endl;
cerr<<"Norm(m*minv - 1) = "<<normdiff<<endl;
cerr<<"kappa = "<<kappa<<endl;
abort();
}
#endif
}
示例2: switch
void seissol::model::getTransposedElasticCoefficientMatrix( seissol::model::ElasticMaterial const& i_material,
unsigned i_dim,
MatrixView<9, 9> o_M )
{
o_M.setZero();
real lambda2mu = i_material.lambda + 2.0 * i_material.mu;
real rhoInv = 1.0 / i_material.rho;
switch (i_dim)
{
case 0:
o_M(6,0) = -lambda2mu;
o_M(6,1) = -i_material.lambda;
o_M(6,2) = -i_material.lambda;
o_M(7,3) = -i_material.mu;
o_M(8,5) = -i_material.mu;
o_M(0,6) = -rhoInv;
o_M(3,7) = -rhoInv;
o_M(5,8) = -rhoInv;
break;
case 1:
o_M(7,0) = -i_material.lambda;
o_M(7,1) = -lambda2mu;
o_M(7,2) = -i_material.lambda;
o_M(6,3) = -i_material.mu;
o_M(8,4) = -i_material.mu;
o_M(3,6) = -rhoInv;
o_M(1,7) = -rhoInv;
o_M(4,8) = -rhoInv;
break;
case 2:
o_M(8,0) = -i_material.lambda;
o_M(8,1) = -i_material.lambda;
o_M(8,2) = -lambda2mu;
o_M(7,4) = -i_material.mu;
o_M(6,5) = -i_material.mu;
o_M(5,6) = -rhoInv;
o_M(4,7) = -rhoInv;
o_M(2,8) = -rhoInv;
break;
default:
break;
}
}
示例3: sqrt
void seissol::model::getTransposedElasticGodunovState( seissol::model::ElasticMaterial const& local,
seissol::model::ElasticMaterial const& neighbor,
MatrixView<9, 9> QgodLocal,
MatrixView<9, 9> QgodNeighbor )
{
QgodNeighbor.setZero();
real cpL = sqrt((local.lambda + 2.0 * local.mu) / local.rho);
real cpN = sqrt((neighbor.lambda + 2.0 * neighbor.mu) / neighbor.rho);
real csL = sqrt(local.mu / local.rho);
real csN = sqrt(neighbor.mu / neighbor.rho);
real constP = cpN * (local.lambda + 2.0 * local.mu) + cpL * (neighbor.lambda + 2.0 * neighbor.mu);
real constS = csN * local.mu + csL * neighbor.mu;
QgodNeighbor(0,0) = cpN * (local.lambda + 2.0 * local.mu) / constP;
QgodNeighbor(6,0) = (local.lambda + 2.0 * local.mu) * (neighbor.lambda + 2.0 * neighbor.mu) / constP;
QgodNeighbor(0,1) = cpN * local.lambda / constP;
QgodNeighbor(6,1) = local.lambda * (neighbor.lambda + 2.0 * neighbor.mu) / constP;
QgodNeighbor(0,2) = QgodNeighbor(0,1);
QgodNeighbor(6,2) = QgodNeighbor(6,1);
QgodNeighbor(3,3) = csN * local.mu / constS;
QgodNeighbor(7,3) = local.mu * neighbor.mu / constS;
QgodNeighbor(5,5) = QgodNeighbor(3,3);
QgodNeighbor(8,5) = QgodNeighbor(7,3);
QgodNeighbor(0,6) = cpL * cpN / constP;
QgodNeighbor(6,6) = cpL * (neighbor.lambda + 2.0 * neighbor.mu) / constP;
QgodNeighbor(3,7) = csL * csN / constS;
QgodNeighbor(7,7) = csL * neighbor.mu / constS;
QgodNeighbor(5,8) = QgodNeighbor(3,7);
QgodNeighbor(8,8) = QgodNeighbor(7,7);
// QgodLocal = I - QgodNeighbor
for (unsigned idx = 0; idx < QgodLocal.rows() * QgodLocal.cols(); ++idx) {
QgodLocal.data[idx] = -QgodNeighbor.data[idx];
}
for (unsigned idx = 0; idx < QgodLocal.rows() && idx < QgodLocal.cols(); ++idx) {
QgodLocal(idx, idx) += 1.0;
}
}