本文整理汇总了C++中nox::abstract::MultiVector::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiVector::clone方法的具体用法?C++ MultiVector::clone怎么用?C++ MultiVector::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nox::abstract::MultiVector
的用法示例。
在下文中一共展示了MultiVector::clone方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
示例2:
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);
}
示例3:
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));
}
示例4:
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);
}
}
*/
}
示例5:
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);
}
示例6: alpha
// Solves turning point equations via classic Salinger bordering
// The first m columns of input_x and input_null store the RHS while
// the last column stores df/dp, d(Jn)/dp respectively. Note however
// input_param has only m columns (not m+1). result_x, result_null,
// are result_param have the same dimensions as their input counterparts
NOX::Abstract::Group::ReturnType
LOCA::TurningPoint::MooreSpence::PhippsBordering::solveTransposeContiguous(
Teuchos::ParameterList& params,
const NOX::Abstract::MultiVector& input_x,
const NOX::Abstract::MultiVector& input_null,
const NOX::Abstract::MultiVector::DenseMatrix& input_param,
NOX::Abstract::MultiVector& result_x,
NOX::Abstract::MultiVector& result_null,
NOX::Abstract::MultiVector::DenseMatrix& result_param) const
{
std::string callingFunction =
"LOCA::TurningPoint::MooreSpence::PhippsBordering::solveTransposeContiguous()";
NOX::Abstract::Group::ReturnType finalStatus = NOX::Abstract::Group::Ok;
NOX::Abstract::Group::ReturnType status;
int m = input_x.numVectors()-2;
std::vector<int> index_input(m);
std::vector<int> index_input_dp(m+1);
std::vector<int> index_null(1);
std::vector<int> index_dp(1);
for (int i=0; i<m; i++) {
index_input[i] = i;
index_input_dp[i] = i;
}
index_input_dp[m] = m;
index_dp[0] = m;
index_null[0] = m+1;
NOX::Abstract::MultiVector::DenseMatrix tmp_mat_1(1, m+1);
NOX::Abstract::MultiVector::DenseMatrix tmp_mat_2(1, m+2);
// Create view of first m+1 columns of input_null, result_null
Teuchos::RCP<NOX::Abstract::MultiVector> input_null_view =
input_null.subView(index_input_dp);
Teuchos::RCP<NOX::Abstract::MultiVector> result_null_view =
result_null.subView(index_input_dp);
// verify underlying Jacobian is valid
if (!group->isJacobian()) {
status = group->computeJacobian();
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
// Solve |J^T v||A B| = |G -phi|
// |u^T 0||a b| |0 0 |
status =
transposeBorderedSolver->applyInverseTranspose(params,
input_null_view.get(),
NULL,
*result_null_view,
tmp_mat_1);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status, finalStatus,
callingFunction);
Teuchos::RCP<NOX::Abstract::MultiVector> A =
result_null.subView(index_input);
Teuchos::RCP<NOX::Abstract::MultiVector> B =
result_null.subView(index_dp);
double b = tmp_mat_1(0,m);
// compute (Jv)_x^T[A B u]
result_null[m+1] = *uVector;
Teuchos::RCP<NOX::Abstract::MultiVector> tmp =
result_null.clone(NOX::ShapeCopy);
status = group->computeDwtJnDxMulti(result_null, *nullVector, *tmp);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
// compute [F 0 0] - (Jv)_x^T[A B u]
tmp->update(1.0, input_x, -1.0);
// verify underlying Jacobian is valid
if (!group->isJacobian()) {
status = group->computeJacobian();
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
// Solve |J^T v||C D E| = |F - (Jv)_x^T A -(Jv)_x^T B -(Jv)_x^T u|
// |u^T 0||c d e| | 0 0 0 |
status =
transposeBorderedSolver->applyInverseTranspose(params,
tmp.get(),
NULL,
result_x,
tmp_mat_2);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status, finalStatus,
//.........这里部分代码省略.........
示例7: ltC
// Solves Hopf equations via classic Salinger bordering
// The first m columns of input_x, input_y, input_z store the RHS, the
// next column stores df/dp, (Jy-wBz)_p and (Jz+wBy)_p respectively, the
// last column of input_y and input_z store Bz and -By respectively. Note
// input_x has m+1 columns, input_y and input_z have m+2, and input_w and
// input_p have m columns. result_x, result_y, result_z, result_w and
// result_param have the same dimensions as their input counterparts
NOX::Abstract::Group::ReturnType
LOCA::Hopf::MooreSpence::SalingerBordering::solveContiguous(
Teuchos::ParameterList& params,
const NOX::Abstract::MultiVector& input_x,
const NOX::Abstract::MultiVector& input_y,
const NOX::Abstract::MultiVector& input_z,
const NOX::Abstract::MultiVector::DenseMatrix& input_w,
const NOX::Abstract::MultiVector::DenseMatrix& input_p,
NOX::Abstract::MultiVector& result_x,
NOX::Abstract::MultiVector& result_y,
NOX::Abstract::MultiVector& result_z,
NOX::Abstract::MultiVector::DenseMatrix& result_w,
NOX::Abstract::MultiVector::DenseMatrix& result_p) const
{
std::string callingFunction =
"LOCA::Hopf::MooreSpence::SalingerBordering::solveContiguous()";
NOX::Abstract::Group::ReturnType finalStatus = NOX::Abstract::Group::Ok;
NOX::Abstract::Group::ReturnType status;
int m = input_x.numVectors()-1;
std::vector<int> index_input(m);
std::vector<int> index_dp(1);
std::vector<int> index_B(1);
std::vector<int> index_ip(m+1);
for (int i=0; i<m; i++) {
index_input[i] = i;
index_ip[i] = i;
}
index_ip[m] = m;
index_dp[0] = m;
index_B[0] = m+1;
// verify underlying Jacobian is valid
if (!group->isJacobian()) {
status = group->computeJacobian();
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
// compute [A b] = J^-1 [F df/dp]
status = group->applyJacobianInverseMultiVector(params, input_x, result_x);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status, finalStatus,
callingFunction);
Teuchos::RCP<NOX::Abstract::MultiVector> A =
result_x.subView(index_input);
Teuchos::RCP<NOX::Abstract::MultiVector> b =
result_x.subView(index_dp);
// verify underlying complex matrix is valid
if (!group->isComplex()) {
status = group->computeComplex(w);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
// compute (J+iwB)(y+iz)_x [A b]
Teuchos::RCP<NOX::Abstract::MultiVector> tmp_real =
result_y.clone(NOX::ShapeCopy);
Teuchos::RCP<NOX::Abstract::MultiVector> tmp_real_sub =
tmp_real->subView(index_ip);
Teuchos::RCP<NOX::Abstract::MultiVector> tmp_imag =
result_y.clone(NOX::ShapeCopy);
Teuchos::RCP<NOX::Abstract::MultiVector> tmp_imag_sub =
tmp_imag->subView(index_ip);
tmp_real->init(0.0);
tmp_imag->init(0.0);
status = group->computeDCeDxa(*yVector, *zVector, w, result_x,
*CeRealVector, *CeImagVector, *tmp_real_sub,
*tmp_imag_sub);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status, finalStatus,
callingFunction);
// compute [G+iH d(J+iwB)(y+iz)/dp iB(y+iz)] - [(J+iwB)_x[A b] 0+i0]
tmp_real->update(1.0, input_y, -1.0);
tmp_imag->update(1.0, input_z, -1.0);
// verify underlying complex matrix is valid
if (!group->isComplex()) {
status = group->computeComplex(w);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
// compute [C+iD e+if g+ih] = (J+iwB)^-1 (tmp_real + i tmp_imag)
status = group->applyComplexInverseMultiVector(params, *tmp_real, *tmp_imag,
//.........这里部分代码省略.........
示例8: R
void
LOCA::BorderedSolver::HouseholderQR::computeQR(
const NOX::Abstract::MultiVector::DenseMatrix& C,
const NOX::Abstract::MultiVector& B,
bool use_c_transpose,
NOX::Abstract::MultiVector::DenseMatrix& Y1,
NOX::Abstract::MultiVector& Y2,
NOX::Abstract::MultiVector::DenseMatrix& T,
NOX::Abstract::MultiVector::DenseMatrix& R)
{
double beta;
int m = B.numVectors();
// Initialize
Y1.putScalar(0.0);
T.putScalar(0.0);
Y2 = B;
if (use_c_transpose) {
for (int i=0; i<m; i++)
for (int j=0; j<m; j++)
R(i,j) = C(j,i); // Copy transpose of C into R
}
else
R.assign(C);
// A temporary vector
Teuchos::RCP<NOX::Abstract::MultiVector> v2 = Y2.clone(1);
Teuchos::RCP<NOX::Abstract::MultiVector::DenseMatrix> v1;
Teuchos::RCP<NOX::Abstract::MultiVector> h2;
Teuchos::RCP<NOX::Abstract::MultiVector::DenseMatrix> h1;
Teuchos::RCP<NOX::Abstract::MultiVector> y2;
Teuchos::RCP<NOX::Abstract::MultiVector::DenseMatrix> y1;
Teuchos::RCP<NOX::Abstract::MultiVector::DenseMatrix> z;
std::vector<int> h_idx;
std::vector<int> y_idx;
y_idx.reserve(m);
for (int i=0; i<m; i++) {
// Create view of column i of Y1 starting at row i
v1 =
Teuchos::rcp(new NOX::Abstract::MultiVector::DenseMatrix(Teuchos::View,
Y1,
m-i,
1, i, i));
// Create view of columns i through m-1 of Y2
h_idx.resize(m-i);
for (unsigned int j=0; j<h_idx.size(); j++)
h_idx[j] = i+j;
h2 = Y2.subView(h_idx);
// Create view of columns i thru m-1 of R, starting at row i
h1 =
Teuchos::rcp(new NOX::Abstract::MultiVector::DenseMatrix(Teuchos::View,
R,
m-i,
m-i,
i, i));
if (i > 0) {
// Create view of columns 0 through i-1 of Y2
y_idx.push_back(i-1);
y2 = Y2.subView(y_idx);
// Create view of columns 0 through i-1 of Y1, starting at row i
y1 =
Teuchos::rcp(new NOX::Abstract::MultiVector::DenseMatrix(Teuchos::View,
Y1,
m-i,
i, i, 0));
// Create view of column i, row 0 through i-1 of T
z =
Teuchos::rcp(new NOX::Abstract::MultiVector::DenseMatrix(Teuchos::View,
T,
i,
1,
0, i));
}
// Compute Householder Vector
computeHouseholderVector(i, R, Y2, *v1, *v2, beta);
// Apply Householder reflection
applyHouseholderVector(*v1, *v2, beta, *h1, *h2);
// Copy v2 into Y2
Y2[i] = (*v2)[0];
T(i,i) = -beta;
if (i > 0) {
// Compute z = y2^T * v2
v2->multiply(1.0, *y2, *z);
// Compute z = -beta * (z + y1^T * v1)
//.........这里部分代码省略.........