本文整理汇总了C++中nox::abstract::MultiVector::numVectors方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiVector::numVectors方法的具体用法?C++ MultiVector::numVectors怎么用?C++ MultiVector::numVectors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nox::abstract::MultiVector
的用法示例。
在下文中一共展示了MultiVector::numVectors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
LOCA::Epetra::AnasaziOperator::Floquet::apply(const NOX::Abstract::MultiVector& input,
NOX::Abstract::MultiVector& output) const
{
// Apply first part of monodromy operator on input vector
Teuchos::RCP<NOX::Abstract::MultiVector> tmpVec = input.clone();
for (int i=0; i < input.numVectors(); i++) {
NOX::Abstract::Vector& nAV = tmpVec->operator[](i);
NOX::Epetra::Vector& nEV = dynamic_cast<NOX::Epetra::Vector&>(nAV);
Epetra_Vector& eV = nEV.getEpetraVector();
xyztInterface->beginFloquetOperatorApplication(eV);
}
// Now apply the main part of the monodromy matrix
NOX::Abstract::Group::ReturnType status =
grp->applyJacobianInverseMultiVector(*solverParams, *(tmpVec.get()), output);
globalData->locaErrorCheck->checkReturnType(status,
"LOCA::Epetra::AnasaziOperator::Floquet::apply()");
for (int i=0; i < input.numVectors(); i++) {
NOX::Abstract::Vector& nAV = output.operator[](i);
NOX::Epetra::Vector& nEV = dynamic_cast<NOX::Epetra::Vector&>(nAV);
Epetra_Vector& eV = nEV.getEpetraVector();
xyztInterface->finishFloquetOperatorApplication(eV);
}
// Was this needed?
// TESTING: Doubling the call to this routine resulted in the
// squaring of the Floquet multipliers, as they should.
// Replacing the apply function so the operator is diagonal
// with entries 1/(i+2) led to the Floquet multipliers.
/*
std::cout << " Fixing apply so Floquets at 1/2 1/3 1/4 ... " << std::endl;
Teuchos::RCP<NOX::Abstract::MultiVector> tmpVec = input.clone();
for (int i=0; i < input.numVectors(); i++) {
NOX::Abstract::Vector& nAV = output.operator[](i);
NOX::Epetra::Vector& nEV = dynamic_cast<NOX::Epetra::Vector&>(nAV);
Epetra_Vector& oV = nEV.getEpetraVector();
NOX::Abstract::Vector& nAV2 = tmpVec->operator[](i);
NOX::Epetra::Vector& nEV2 = dynamic_cast<NOX::Epetra::Vector&>(nAV2);
Epetra_Vector& iV = nEV2.getEpetraVector();
for (int j=0; j < iV.MyLength(); j++) {
oV[j] = iV[j] / (j + 2.0);
}
}
*/
}
示例2: if
void
LOCA::BorderedSolver::HouseholderQR::applyCompactWY(
const NOX::Abstract::MultiVector::DenseMatrix& Y1,
const NOX::Abstract::MultiVector& Y2,
const NOX::Abstract::MultiVector::DenseMatrix& T,
NOX::Abstract::MultiVector::DenseMatrix& X1,
NOX::Abstract::MultiVector& X2,
bool isZeroX1, bool isZeroX2,
bool useTranspose) const
{
if (isZeroX1 && isZeroX2) {
X1.putScalar(0.0);
X2.init(0.0);
return;
}
int m = Y2.numVectors();
Teuchos::ETransp T_flag;
if (useTranspose)
T_flag = Teuchos::TRANS;
else
T_flag = Teuchos::NO_TRANS;
NOX::Abstract::MultiVector::DenseMatrix tmp(m, X2.numVectors());
// Compute Y1^T*X1 + Y2^T*X2
if (!isZeroX2)
X2.multiply(1.0, Y2, tmp);
// Opportunity for optimization here since Y1 is a lower-triangular
// matrix with unit diagonal
if (!isZeroX2 && !isZeroX1)
tmp.multiply(Teuchos::TRANS, Teuchos::NO_TRANS, 1.0, Y1, X1, 1.0);
else if (!isZeroX1)
tmp.multiply(Teuchos::TRANS, Teuchos::NO_TRANS, 1.0, Y1, X1, 0.0);
// Compute op(T)*(Y1^T*X1 + Y2^T*X2)
dblas.TRMM(Teuchos::LEFT_SIDE, Teuchos::UPPER_TRI, T_flag,
Teuchos::NON_UNIT_DIAG, tmp.numRows(), tmp.numCols(), 1.0,
T.values(), T.numRows(), tmp.values(), tmp.numRows());
// Compute X1 = X1 + Y1*op(T)*(Y1^T*X1 + Y2^T*X2)
// Opportunity for optimization here since Y1 is a lower-triangular
// matrix with unit diagonal
if (isZeroX1)
X1.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, Y1, tmp, 0.0);
else
X1.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, Y1, tmp, 1.0);
// Compute X2 = X2 + Y1*op(T)*(Y1^T*X1 + Y2^T*X2)
if (isZeroX2)
X2.update(Teuchos::NO_TRANS, 1.0, Y2, tmp, 0.0);
else
X2.update(Teuchos::NO_TRANS, 1.0, Y2, tmp, 1.0);
}
示例3: complex_input
NOX::Abstract::Group::ReturnType
LOCA::Epetra::Group::applyComplexMultiVector(
const NOX::Abstract::MultiVector& input_real,
const NOX::Abstract::MultiVector& input_imag,
NOX::Abstract::MultiVector& result_real,
NOX::Abstract::MultiVector& result_imag) const
{
std::string callingFunction =
"LOCA::Epetra::Group::applyComplexMultiVector()";
// We must have the time-dependent interface
if (userInterfaceTime == Teuchos::null)
return NOX::Abstract::Group::BadDependency;
#ifdef HAVE_NOX_EPETRAEXT
const NOX::Epetra::MultiVector& epetra_input_real =
dynamic_cast<const NOX::Epetra::MultiVector&>(input_real);
const NOX::Epetra::MultiVector& epetra_input_imag =
dynamic_cast<const NOX::Epetra::MultiVector&>(input_imag);
NOX::Epetra::MultiVector& epetra_result_real =
dynamic_cast<NOX::Epetra::MultiVector&>(result_real);
NOX::Epetra::MultiVector& epetra_result_imag =
dynamic_cast<NOX::Epetra::MultiVector&>(result_imag);
// Get Jacobian matrix for row map
Teuchos::RCP<Epetra_RowMatrix> jac = Teuchos::rcp_dynamic_cast<Epetra_RowMatrix>(sharedLinearSystem.getObject(this)->getJacobianOperator());
EpetraExt::BlockMultiVector complex_input(jac->RowMatrixRowMap(),
complexMatrix->RowMap(),
input_real.numVectors());
complex_input.LoadBlockValues(epetra_input_real.getEpetraMultiVector(), 0);
complex_input.LoadBlockValues(epetra_input_imag.getEpetraMultiVector(), 1);
EpetraExt::BlockMultiVector complex_result(jac->RowMatrixRowMap(),
complexMatrix->RowMap(),
input_real.numVectors());
complex_result.PutScalar(0.0);
complexMatrix->Apply(complex_input, complex_result);
complex_result.ExtractBlockValues(epetra_result_real.getEpetraMultiVector(),
0);
complex_result.ExtractBlockValues(epetra_result_imag.getEpetraMultiVector(),
1);
return NOX::Abstract::Group::Ok;
#else
globalData->locaErrorCheck->throwError(callingFunction,
"Must have EpetraExt support for Hopf tracking. Configure trilinos with --enable-epetraext");
return NOX::Abstract::Group::BadDependency;
#endif
}
示例4: B
NOX::Abstract::Group::ReturnType
LOCA::LAPACK::Group::applyShiftedMatrixMultiVector(
const NOX::Abstract::MultiVector& input,
NOX::Abstract::MultiVector& result) const
{
// Number of RHS
int nVecs = input.numVectors();
int m = shiftedSolver.getMatrix().numRows();
// Copy all input vectors into one matrix
NOX::LAPACK::Matrix<double> B(m,nVecs);
NOX::LAPACK::Matrix<double> C(m,nVecs);
const NOX::LAPACK::Vector* constVecPtr;
for (int j=0; j<nVecs; j++) {
constVecPtr = dynamic_cast<const NOX::LAPACK::Vector*>(&(input[j]));
for (int i=0; i<m; i++)
B(i,j) = (*constVecPtr)(i);
}
// Apply shifted matrix
shiftedSolver.apply(false, nVecs, &B(0,0), &C(0,0));
// Copy result from matrix
NOX::LAPACK::Vector* vecPtr;
for (int j=0; j<nVecs; j++) {
vecPtr = dynamic_cast<NOX::LAPACK::Vector*>(&(result[j]));
for (int i=0; i<m; i++)
(*vecPtr)(i) = C(i,j);
}
return NOX::Abstract::Group::Ok;
}
示例5:
void
LOCA::AnasaziOperator::Cayley2Matrix::apply(const NOX::Abstract::MultiVector& input,
NOX::Abstract::MultiVector& output) const
{
std::string callingFunction =
"LOCA::AnasaziOperator::Cayley2Matrix::apply()";
NOX::Abstract::Group::ReturnType finalStatus = NOX::Abstract::Group::Ok;
NOX::Abstract::Group::ReturnType status;
// Allocate temporary vector
if (tmp_r == Teuchos::null || tmp_r->numVectors() != input.numVectors())
tmp_r = input.clone(NOX::ShapeCopy);
// Compute J-mu*M -- moved to preProcessSeedVector
// Compute (J-mu*M)*input
status = grp->applySecondShiftedMatrixMultiVector(input, *tmp_r);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
// Compute J-sigma*M -- moved to preProcessSeedVector
// Solve (J-sigma*M)*output = (J-mu*M)*input
status = grp->applyShiftedMatrixInverseMultiVector(*solverParams, *tmp_r,
output);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
示例6:
LOCA::MultiContinuation::ExtendedMultiVector::ExtendedMultiVector(
const Teuchos::RCP<LOCA::GlobalData>& global_data,
const NOX::Abstract::MultiVector& xVec,
int nScalarRows) :
LOCA::Extended::MultiVector(global_data, xVec.numVectors(), 1, nScalarRows)
{
LOCA::Extended::MultiVector::setMultiVectorPtr(0, xVec.clone(NOX::DeepCopy));
}
示例7: input
NOX::Abstract::Group::ReturnType
LOCA::LAPACK::Group::applyComplexTransposeInverseMultiVector(
Teuchos::ParameterList& params,
const NOX::Abstract::MultiVector& input_real,
const NOX::Abstract::MultiVector& input_imag,
NOX::Abstract::MultiVector& result_real,
NOX::Abstract::MultiVector& result_imag) const
{
#ifdef HAVE_TEUCHOS_COMPLEX
// Check validity of the Jacobian
if (!isComplex())
return NOX::Abstract::Group::BadDependency;
int n = complexSolver.getMatrix().numRows();
int p = input_real.numVectors();
// Copy inputs into a complex vector
std::vector< std::complex<double> > input(n*p);
const NOX::LAPACK::Vector* lapack_input_real;
const NOX::LAPACK::Vector* lapack_input_imag;
for (int j=0; j<p; j++) {
lapack_input_real =
dynamic_cast<const NOX::LAPACK::Vector*>(&(input_real[j]));
lapack_input_imag =
dynamic_cast<const NOX::LAPACK::Vector*>(&(input_imag[j]));
for (int i=0; i<n; i++)
input[i+n*j] = std::complex<double>((*lapack_input_real)(i),
(*lapack_input_imag)(i));
}
// Solve complex matrix
bool res = complexSolver.solve(true, p, &input[0]);
// Copy result into NOX vectors
NOX::LAPACK::Vector* lapack_result_real;
NOX::LAPACK::Vector* lapack_result_imag;
for (int j=0; j<p; j++) {
lapack_result_real =
dynamic_cast<NOX::LAPACK::Vector*>(&(result_real[j]));
lapack_result_imag =
dynamic_cast<NOX::LAPACK::Vector*>(&(result_imag[j]));
for (int i=0; i<n; i++) {
(*lapack_result_real)(i) = input[i+n*j].real();
(*lapack_result_imag)(i) = input[i+n*j].imag();
}
}
if (res)
return NOX::Abstract::Group::Ok;
else
return NOX::Abstract::Group::Failed;
#else
globalData->locaErrorCheck->throwError(
"LOCA::LAPACK::Group::applyComplexTransposeInverseMultiVector()",
"TEUCHOS_COMPLEX must be enabled for complex support! Reconfigure with -D Teuchos_ENABLE_COMPLEX");
return NOX::Abstract::Group::BadDependency;
#endif
}
示例8: if
NOX::Abstract::Group::ReturnType
LOCA::Epetra::Group::applyShiftedMatrixInverseMultiVector(
Teuchos::ParameterList& lsParams,
const NOX::Abstract::MultiVector& input,
NOX::Abstract::MultiVector& result) const
{
if (shiftedSharedLinearSystem != Teuchos::null) {
NOX::Epetra::LinearSystem::PreconditionerReusePolicyType precPolicy =
sharedLinearSystem.getObject(this)->getPreconditionerPolicy();
if (!isValidShiftedPrec) {
if (precPolicy == NOX::Epetra::LinearSystem::PRPT_REBUILD) {
shiftedSharedLinearSystem->getObject(this)->destroyPreconditioner();
shiftedSharedLinearSystem->getObject(this)->
createPreconditioner(xVector, lsParams, false);
isValidShiftedPrec = true;
}
else if (precPolicy == NOX::Epetra::LinearSystem::PRPT_RECOMPUTE) {
sharedLinearSystem.getObject(this)->recomputePreconditioner(xVector,
lsParams);
}
else if (precPolicy == NOX::Epetra::LinearSystem::PRPT_REUSE) {
// Do Nothing!!!
}
}
const NOX::Epetra::Vector* epetra_input;
NOX::Epetra::Vector* epetra_result;
bool status;
bool finalStatus = true;
for (int i=0; i<input.numVectors(); i++) {
epetra_input = dynamic_cast<const NOX::Epetra::Vector*>(&input[i]);
epetra_result = dynamic_cast<NOX::Epetra::Vector*>(&result[i]);
status =
shiftedSharedLinearSystem->getObject(this)->applyJacobianInverse(
lsParams,
*epetra_input,
*epetra_result);
finalStatus = finalStatus && status;
}
if (finalStatus)
return NOX::Abstract::Group::Ok;
else
return NOX::Abstract::Group::NotConverged;
}
else
return NOX::Abstract::Group::BadDependency;
}
示例9:
NOX::Abstract::Group::ReturnType
LOCA::Epetra::Group::applyJacobianTransposeInverseMultiVector(
Teuchos::ParameterList& params,
const NOX::Abstract::MultiVector& input,
NOX::Abstract::MultiVector& result) const
{
std::string callingFunction =
"LOCA::Epetra::Group::applyJacobianTransposeInverseMultiVector()";
NOX::Abstract::Group::ReturnType status;
NOX::Abstract::Group::ReturnType finalStatus = NOX::Abstract::Group::Ok;
// Get non-const linsys
Teuchos::RCP<NOX::Epetra::LinearSystem> linSys =
sharedLinearSystem.getObject(this);
// Get Jacobian operator
Teuchos::RCP<Epetra_Operator> jac =
linSys->getJacobianOperator();
// Instantiate transpose solver
LOCA::Epetra::TransposeLinearSystem::Factory tls_factory(globalData);
if (tls_strategy == Teuchos::null)
tls_strategy = tls_factory.create(Teuchos::rcp(¶ms, false), linSys);
// Compute Jacobian transpose J^T
tls_strategy->createJacobianTranspose();
// Now compute preconditioner for J^T
tls_strategy->createTransposePreconditioner(xVector, params);
// Solve for each RHS
int m = input.numVectors();
for (int i=0; i<m; i++) {
bool stat =
tls_strategy->applyJacobianTransposeInverse(
params,
dynamic_cast<const NOX::Epetra::Vector&>(input[i]),
dynamic_cast<NOX::Epetra::Vector&>(result[i]));
if (stat == true)
status = NOX::Abstract::Group::Ok;
else
status = NOX::Abstract::Group::NotConverged;
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
// Set original operators in linear system
jac->SetUseTranspose(false);
linSys->setJacobianOperatorForSolve(jac);
linSys->destroyPreconditioner();
return finalStatus;
}
示例10:
// =============================================================================
// Compute result_p = alpha * dg/dx * input_x.
NOX::Abstract::Group::ReturnType
Ginla::FDM::Constraint::MinDist::
multiplyDX ( double alpha,
const NOX::Abstract::MultiVector & input_x,
NOX::Abstract::MultiVector::DenseMatrix & result_p
) const
{
TEUCHOS_ASSERT( komplex_.is_valid_ptr() && !komplex_.is_null() );
TEUCHOS_ASSERT_EQUALITY( result_p.numCols(), input_x.numVectors() );
for ( int k=0; k<input_x.numVectors(); k++ )
{
const Epetra_Vector & xE =
Teuchos::dyn_cast<const NOX::Epetra::Vector>( input_x[0] ).getEpetraVector();
Teuchos::RCP<ComplexVector> xPsi = komplex_->real2complex( xE );
result_p(0,k) = alpha * std::imag( psiRef_->dot(*xPsi) );
}
return NOX::Abstract::Group::Ok;
}
示例11:
LOCA::Hopf::MooreSpence::ExtendedMultiVector::ExtendedMultiVector(
const Teuchos::RCP<LOCA::GlobalData>& global_data,
const NOX::Abstract::MultiVector& xVec,
const NOX::Abstract::MultiVector& realEigenVec,
const NOX::Abstract::MultiVector& imagEigenVec,
const NOX::Abstract::MultiVector::DenseMatrix& freqs,
const NOX::Abstract::MultiVector::DenseMatrix& bifParams) :
LOCA::Extended::MultiVector(global_data, xVec.numVectors(), 3, 2)
{
LOCA::Extended::MultiVector::setMultiVectorPtr(0, xVec.clone(NOX::DeepCopy));
LOCA::Extended::MultiVector::setMultiVectorPtr(1, realEigenVec.clone(NOX::DeepCopy));
LOCA::Extended::MultiVector::setMultiVectorPtr(2, imagEigenVec.clone(NOX::DeepCopy));
LOCA::Extended::MultiVector::getScalarRows(1,0)->assign(freqs);
LOCA::Extended::MultiVector::getScalarRows(1,1)->assign(bifParams);
}
示例12:
void
LOCA::AnasaziOperator::ShiftInvert::apply(
const NOX::Abstract::MultiVector& input,
NOX::Abstract::MultiVector& output) const
{
std::string callingFunction =
"LOCA::AnasaziOperator::ShiftInvert::apply()";
NOX::Abstract::Group::ReturnType finalStatus = NOX::Abstract::Group::Ok;
NOX::Abstract::Group::ReturnType status;
// Allocate temporary vector
if (tmp_r == Teuchos::null || tmp_r->numVectors() != input.numVectors())
tmp_r = input.clone(NOX::ShapeCopy);
// Compute M
status = grp->computeShiftedMatrix(0.0, 1.0);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
// Compute M*input
status = grp->applyShiftedMatrixMultiVector(input, *tmp_r);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
// Compute J-omega*M
status = grp->computeShiftedMatrix(1.0, -shift);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
// Solve (J-omega*M)*output = M*input
status = grp->applyShiftedMatrixInverseMultiVector(*solverParams, *tmp_r,
output);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
示例13: computeVectorNorm
int
NOX::TestCompare::testMultiVector(
const NOX::Abstract::MultiVector& mvec,
const NOX::Abstract::MultiVector& mvec_expected,
double rtol, double atol,
const std::string& name)
{
bool passed;
double inf_norm;
double inf_norm_max = 0.0;
for (int i=0; i<mvec_expected.numVectors(); i++) {
inf_norm = computeVectorNorm(mvec[i], mvec_expected[i], rtol, atol);
if (inf_norm > inf_norm_max)
inf_norm_max = inf_norm;
}
if (inf_norm_max < 1)
passed = true;
else
passed = false;
if (utils.isPrintType(NOX::Utils::TestDetails)) {
os << std::endl
<< "\tChecking " << name << ": ";
if (passed)
os << "Passed." << std::endl;
else
os << "Failed." << std::endl;
os << "\t\tComputed norm: " << utils.sciformat(inf_norm_max)
<< std::endl
<< "\t\tRelative Tolerance: " << utils.sciformat(rtol)
<< std::endl
<< "\t\tAbsolute Tolerance: " << utils.sciformat(rtol)
<< std::endl;
}
if (passed)
return 0;
else
return 1;
}
示例14: applySecondShiftedMatrix
NOX::Abstract::Group::ReturnType
LOCA::Epetra::Group::applySecondShiftedMatrixMultiVector(
const NOX::Abstract::MultiVector& input,
NOX::Abstract::MultiVector& result) const
{
std::string callingFunction =
"LOCA::Epetra::Group::applySecondShiftedMatrixMultiVector()";
NOX::Abstract::Group::ReturnType finalStatus = NOX::Abstract::Group::Ok;
NOX::Abstract::Group::ReturnType status;
for (int i=0; i<input.numVectors(); i++) {
status = applySecondShiftedMatrix(input[i], result[i]);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
return finalStatus;
}
示例15: u
void
LOCA::BorderedSolver::HouseholderQR::applyHouseholderVector(
const NOX::Abstract::MultiVector::DenseMatrix& V1,
const NOX::Abstract::MultiVector& V2,
double beta,
NOX::Abstract::MultiVector::DenseMatrix& A1,
NOX::Abstract::MultiVector& A2)
{
int nColsA = A2.numVectors();
// Compute u = V2^T * A2
NOX::Abstract::MultiVector::DenseMatrix u(1, nColsA);
A2.multiply(1.0, V2, u);
// Compute u = u + V1^T * A_P
u.multiply(Teuchos::TRANS, Teuchos::NO_TRANS, 1.0, V1, A1, 1.0);
// Compute A1 = A1 - b*V1*u
A1.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, -beta, V1, u, 1.0);
// Compute A2 = A2 - b*V2*u
A2.update(Teuchos::NO_TRANS, -beta, V2, u, 1.0);
}