本文整理汇总了C++中nox::abstract::MultiVector类的典型用法代码示例。如果您正苦于以下问题:C++ MultiVector类的具体用法?C++ MultiVector怎么用?C++ MultiVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MultiVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
示例2:
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));
}
示例3:
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);
}
}
*/
}
示例4:
void
LOCA::MultiContinuation::ConstrainedGroup::fillB(
NOX::Abstract::MultiVector& B) const
{
std::string callingFunction =
"LOCA::MultiContinuation::ConstrainedGroup::fillB";
bool isZeroB = constraintsPtr->isDXZero();
Teuchos::RCP<const NOX::Abstract::MultiVector> my_B;
if (!isZeroB) {
Teuchos::RCP<const LOCA::MultiContinuation::ConstraintInterfaceMVDX> constraints_mvdx = Teuchos::rcp_dynamic_cast<const LOCA::MultiContinuation::ConstraintInterfaceMVDX>(constraintsPtr);
if (constraints_mvdx == Teuchos::null)
globalData->locaErrorCheck->throwError(
callingFunction,
std::string("Constraints object must be of type") +
std::string("ConstraintInterfaceMVDX"));
my_B = Teuchos::rcp(constraints_mvdx->getDX(),false);
}
// If the underlying system isn't bordered, we're done
if (!isBordered) {
if (isZeroB)
B.init(0.0);
else
B = *my_B;
return;
}
// Create views for underlying group
int w = bordered_grp->getBorderedWidth();
std::vector<int> idx1(w);
for (int i=0; i<w; i++)
idx1[i] = i;
Teuchos::RCP<NOX::Abstract::MultiVector> underlyingB =
B.subView(idx1);
// Combine blocks in underlying group
bordered_grp->fillB(*underlyingB);
// Create views for my blocks
std::vector<int> idx2(numParams);
for (int i=0; i<numParams; i++)
idx2[i] = w+i;
Teuchos::RCP<NOX::Abstract::MultiVector> my_B_x =
B.subView(idx2);
// Extract solution component from my_B and store in B
if (isZeroB)
my_B_x->init(0.0);
else
bordered_grp->extractSolutionComponent(*my_B, *my_B_x);
}
示例5: 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
}
示例6:
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);
}
示例7: B
NOX::Abstract::Group::ReturnType
LOCA::LAPACK::Group::applyShiftedMatrixInverseMultiVector(
Teuchos::ParameterList& params,
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);
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);
}
bool res = shiftedSolver.solve(false, nVecs, &B(0,0));
if (!res)
return NOX::Abstract::Group::Failed;
// 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) = B(i,j);
}
return NOX::Abstract::Group::Ok;
}
示例8:
void
LOCA::TurningPoint::MooreSpence::ExtendedGroup::lTransNorm(
const NOX::Abstract::MultiVector& n,
NOX::Abstract::MultiVector::DenseMatrix& result) const
{
n.multiply(1.0 / lengthVec->length(), *lengthMultiVec, result);
}
示例9: getDX
NOX::Abstract::Group::ReturnType
LOCA::MultiContinuation::ConstraintInterfaceMVDX::addDX(
Teuchos::ETransp transb,
double alpha,
const NOX::Abstract::MultiVector::DenseMatrix& b,
double beta,
NOX::Abstract::MultiVector& result_x) const
{
if (!isDXZero()) {
const NOX::Abstract::MultiVector* dgdx = getDX();
result_x.update(transb, alpha, *dgdx, b, beta);
}
else
result_x.scale(beta);
return NOX::Abstract::Group::Ok;
}
示例10: 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
}
示例11:
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);
}
示例12: 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;
}
示例13:
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;
}
示例14:
// =============================================================================
// 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;
}
示例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);
}