本文整理汇总了C++中Epetra_Vector::Norm1方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_Vector::Norm1方法的具体用法?C++ Epetra_Vector::Norm1怎么用?C++ Epetra_Vector::Norm1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_Vector
的用法示例。
在下文中一共展示了Epetra_Vector::Norm1方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeNorm
double AztecOO_StatusTestResNorm::ComputeNorm(const Epetra_Vector & vec, NormType typeofnorm) {
double result = 0.0;
if (typeofnorm==TwoNorm) vec.Norm2(&result);
else if (typeofnorm==OneNorm) vec.Norm1(&result);
else vec.NormInf(&result);
return(result);
}
示例2: printSolution
//
// Calculate and print the 1-norm of the solution vector x along with the parameter value.
// Used to generate the solution graph
//
void HeqProblem::printSolution(const Epetra_Vector &x, const double conParam)
{
double n1; // temporary variable to hold the value of the norm
x.Norm1(&n1); // calculate the 1-norm of x
if (outputFilePtr) { // print out the values of c and ||x||_1
if (Comm->MyPID()==0) {
(*outputFilePtr) << conParam << " " << n1 << endl;
}
}
else
cout << "No output file!" << endl;
}
示例3: compute_balance
/******************************************************************
Compute weight balance
******************************************************************/
int compute_balance(const Epetra_Vector &wgts, double myGoalWeight,
double &min, double &max, double &avg)
{
if ((myGoalWeight < 0) || (myGoalWeight > 1.0)){
std::cerr << "compute_balance: Goal weight should be in the range [0, 1]" << std::endl;
return -1;
}
double weightTotal;
wgts.Norm1(&weightTotal);
double weightLocal = 0.0;
for (int i=0; i < wgts.MyLength(); i++){
weightLocal += wgts[i];
}
/* My degree of imbalance.
* If myGoalWeight is zero, I'm in perfect balance since I got what I wanted.
*/
double goalWeight = myGoalWeight * weightTotal;
double imbalance = 1.0;
if (myGoalWeight > 0.0){
if (weightLocal >= goalWeight)
imbalance += (weightLocal - goalWeight) / goalWeight;
else
imbalance += (goalWeight - weightLocal) / goalWeight;
}
const Epetra_Comm &comm = wgts.Comm();
comm.MaxAll(&imbalance, &max, 1);
comm.MinAll(&imbalance, &min, 1);
comm.SumAll(&imbalance, &avg, 1);
avg /= comm.NumProc();
return 0;
}
示例4: TestOneMatrix
//.........这里部分代码省略.........
// Call routine to read in symmetric Triplet matrix
EPETRA_CHK_ERR( Trilinos_Util_ReadTriples2Epetra64( &TRIname[0], true, Comm,
readMap, TriplesA, Triplesx,
Triplesb, Triplesxexact, false, false ) );
delete readMap;
} else {
assert( false ) ;
}
}
}
EPETRA_CHK_ERR( Trilinos_Util_ReadMatrixMarket2Epetra64( &MMname[0], Comm, readMap,
MatrixMarketA, MatrixMarketx,
MatrixMarketb, MatrixMarketxexact) );
delete readMap;
// Call routine to read in HB problem
Trilinos_Util_ReadHb2Epetra64( &HBname[0], Comm, readMap, HbA, Hbx,
Hbb, Hbxexact) ;
#if 0
std::cout << " HbA " ;
HbA->Print( std::cout ) ;
std::cout << std::endl ;
std::cout << " MatrixMarketA " ;
MatrixMarketA->Print( std::cout ) ;
std::cout << std::endl ;
std::cout << " TriplesA " ;
TriplesA->Print( std::cout ) ;
std::cout << std::endl ;
#endif
int TripleErr = 0 ;
int MMerr = 0 ;
for ( int i = 0 ; i < 10 ; i++ )
{
double resid_Hb_Triples;
double resid_Hb_Matrix_Market;
double norm_A ;
Hbx->Random();
//
// Set the output vectors to different values:
//
Triplesb->PutScalar(1.1);
Hbb->PutScalar(1.2);
MatrixMarketb->PutScalar(1.3);
HbA->Multiply( false, *Hbx, *Hbb );
norm_A = HbA->NormOne( ) ;
TriplesA->Multiply( false, *Hbx, *Triplesb );
Triplesb->Update( 1.0, *Hbb, -1.0 ) ;
MatrixMarketA->Multiply( false, *Hbx, *MatrixMarketb );
MatrixMarketb->Update( 1.0, *Hbb, -1.0 ) ;
Triplesb->Norm1( &resid_Hb_Triples ) ;
MatrixMarketb->Norm1( &resid_Hb_Matrix_Market ) ;
TripleErr += ( resid_Hb_Triples > 1e-11 * norm_A ) ;
MMerr += ( resid_Hb_Matrix_Market > 1e-11 * norm_A ) ;
if ( verbose && resid_Hb_Triples > 1e-11 * norm_A )
std::cout << " resid_Hb_Triples = " << resid_Hb_Triples
<< " norm_A = " << norm_A << std::endl ;
if ( verbose && resid_Hb_Matrix_Market > 1e-11 * norm_A )
std::cout << " resid_Hb_Matrix_Market = " << resid_Hb_Matrix_Market
<< " norm_A = " << norm_A << std::endl ;
}
if ( verbose ) {
if ( TripleErr ) std::cout << " Error in reading " << HBname << " or " << TRIname << std::endl ;
if ( MMerr ) std::cout << " Error in reading " << HBname << " or " << MMname << std::endl ;
}
delete HbA;
delete Hbx;
delete Hbb;
delete Hbxexact;
delete TriplesA;
delete Triplesx;
delete Triplesb;
delete Triplesxexact;
delete MatrixMarketA;
delete MatrixMarketx;
delete MatrixMarketb;
delete MatrixMarketxexact;
delete readMap;
return TripleErr+MMerr ;
}
示例5: if
//.........这里部分代码省略.........
else if (level_ != nlevel_-1) // set the smoother from the input
Set_Smoother(ml,ag,level_,nlevel,thislevel_ml_,thislevel_ag_,smoothertype,nsmooth);
else // set the coarse solver from the input
Set_Smoother(ml,ag,level_,nlevel,thislevel_ml_,thislevel_ag_,coarsesolvetype,nsmooth_coarse);
// create this level's preconditioner class
ML_Epetra::MultiLevelOperator* ml_tmp = new ML_Epetra::MultiLevelOperator(
thislevel_ml_,comm_,
Mat->OperatorDomainMap(),
Mat->OperatorRangeMap());
thislevel_prec_ = new ML_NOX::ML_Nox_ConstrainedMultiLevelOperator(ml_tmp,*coarseinterface_);
if (!thislevel_prec_)
{
cout << "**ERR**: ML_NOX::ML_Nox_NonlinearLevel::ML_Nox_NonlinearLevel:\n"
<< "**ERR**: thislevel_prec_==NULL on level " << level_ << "\n"
<< "**ERR**: file/line: " << __FILE__ << "/" << __LINE__ << "\n"; throw -1;
}
// intensive test of this level's ML-smoother
#if 0
{
cout << "Test of smoother on level " << level_ << endl;
Epetra_Vector *out = new Epetra_Vector(Copy,*xthis_,0);
out->PutScalar(0.0);
cout << "Input\n";
xthis_->PutScalar(1.0);
Mat->Multiply(false,*xthis_,*out);
xthis_->PutScalar(3.0);
cout << "rhs\n";
cout << *out;
double norm = 0.0;
out->Norm1(&norm);
cout << "Norm of rhs = " << norm << endl;
thislevel_prec_->ApplyInverse(*out,*xthis_);
cout << "result after smoother\n";
cout << *xthis_;
delete out; out = 0;
}
if (level_==2) exit(0);
#endif
// ------------------------------------------------------------------------
// generate this level's coarse prepostoperator
if (level_==0)
coarseprepost_ = new ML_NOX::Ml_Nox_CoarsePrePostOperator(*coarseinterface_,
fineinterface_);
// ------------------------------------------------------------------------
// set up NOX on this level
// ------------------------------------------------------------------------
nlParams_ = new Teuchos::ParameterList();
Teuchos::ParameterList& printParams = nlParams_->sublist("Printing");
printParams.setParameter("MyPID", comm_.MyPID());
printParams.setParameter("Output Precision", 9);
printParams.setParameter("Output Processor", 0);
if (ml_printlevel_>9)
printParams.setParameter("Output Information",
NOX::Utils::OuterIteration +
//NOX::Utils::OuterIterationStatusTest +
//NOX::Utils::InnerIteration +
//NOX::Utils::Parameters +
//NOX::Utils::Details +
NOX::Utils::Warning);
else if (ml_printlevel_>8)