本文整理汇总了C++中Epetra_MultiVector::Random方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_MultiVector::Random方法的具体用法?C++ Epetra_MultiVector::Random怎么用?C++ Epetra_MultiVector::Random使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_MultiVector
的用法示例。
在下文中一共展示了Epetra_MultiVector::Random方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Teuchos::RCP<Epetra_LinearProblem> build_problem_mm(Teuchos::ParameterList& test_params, Epetra_CrsMatrix* A, Epetra_MultiVector* b)
{
const Epetra_Map& rowmap = A->RowMap();
Epetra_MultiVector* x = new Epetra_MultiVector(rowmap, 1);
if (b == NULL) {
std::cout << "creating b = A*random" << std::endl;
b = new Epetra_MultiVector(rowmap, 1);
x->Random();
A->Apply(*x, *b);
}
x->PutScalar(0);
Teuchos::RCP<Epetra_LinearProblem> problem = Teuchos::rcp(new Epetra_LinearProblem(A,x,b));
return problem;
}
示例2: Amesos_TestMultiSolver
//.........这里部分代码省略.........
Epetra_MultiVector serialb(*readMap,numsolves);
Epetra_MultiVector serialxexact(*readMap,numsolves);
Epetra_MultiVector serialresid(*readMap,numsolves);
Epetra_MultiVector serialtmp(*readMap,numsolves);
bool distribute_matrix = ( matrix_type == AMESOS_Distributed ) ;
if ( distribute_matrix ) {
//
// Initialize x, b and xexact to the values read in from the file
//
A.Export(*serialA, exporter, Add);
Comm.Barrier();
assert(A.FillComplete()==0);
Comm.Barrier();
passA = &A;
passx = &x;
passb = &b;
passxexact = &xexact;
passresid = &resid;
passtmp = &tmp;
} else {
passA = serialA;
passx = &serialx;
passb = &serialb;
passxexact = &serialxexact;
passresid = &serialresid;
passtmp = &serialtmp;
}
passxexact->SetSeed(131) ;
passxexact->Random();
passx->SetSeed(11231) ;
passx->Random();
passb->PutScalar( 0.0 );
passA->Multiply( transpose, *passxexact, *passb ) ;
Epetra_MultiVector CopyB( *passb ) ;
double Anorm = passA->NormInf() ;
SparseDirectTimingVars::SS_Result.Set_Anorm(Anorm) ;
Epetra_LinearProblem Problem( (Epetra_RowMatrix *) passA,
(Epetra_MultiVector *) passx,
(Epetra_MultiVector *) passb );
double max_resid = 0.0;
for ( int j = 0 ; j < special+1 ; j++ ) {
Epetra_Time TotalTime( Comm ) ;
if ( false ) {
#ifdef TEST_UMFPACK
unused code
} else if ( SparseSolver == UMFPACK ) {
UmfpackOO umfpack( (Epetra_RowMatrix *) passA,
(Epetra_MultiVector *) passx,
(Epetra_MultiVector *) passb ) ;
umfpack.SetTrans( transpose ) ;
umfpack.Solve() ;
#endif
示例3: main
//.........这里部分代码省略.........
void GenerateCrsProblem(int numNodesX, int numNodesY, int numProcsX, int numProcsY, int numPoints,
int * xoff, int * yoff, int nrhs,
const Epetra_Comm &comm, bool verbose, bool summary,
Epetra_Map *& map,
Epetra_CrsMatrix *& A,
Epetra_MultiVector *& b,
Epetra_MultiVector *& bt,
Epetra_MultiVector *&xexact, bool StaticProfile, bool MakeLocalOnly) {
Epetra_Time timer(comm);
// Determine my global IDs
long long * myGlobalElements;
GenerateMyGlobalElements(numNodesX, numNodesY, numProcsX, numProcsY, comm.MyPID(), myGlobalElements);
int numMyEquations = numNodesX*numNodesY;
map = new Epetra_Map((long long)-1, numMyEquations, myGlobalElements, 0, comm); // Create map with 2D block partitioning.
delete [] myGlobalElements;
long long numGlobalEquations = map->NumGlobalElements64();
int profile = 0; if (StaticProfile) profile = numPoints;
#ifdef EPETRA_HAVE_STATICPROFILE
if (MakeLocalOnly)
A = new Epetra_CrsMatrix(Copy, *map, *map, profile, StaticProfile); // Construct matrix with rowmap=colmap
else
A = new Epetra_CrsMatrix(Copy, *map, profile, StaticProfile); // Construct matrix
#else
if (MakeLocalOnly)
A = new Epetra_CrsMatrix(Copy, *map, *map, profile); // Construct matrix with rowmap=colmap
else
A = new Epetra_CrsMatrix(Copy, *map, profile); // Construct matrix
#endif
long long * indices = new long long[numPoints];
double * values = new double[numPoints];
double dnumPoints = (double) numPoints;
int nx = numNodesX*numProcsX;
for (int i=0; i<numMyEquations; i++) {
long long rowID = map->GID64(i);
int numIndices = 0;
for (int j=0; j<numPoints; j++) {
long long colID = rowID + xoff[j] + nx*yoff[j]; // Compute column ID based on stencil offsets
if (colID>-1 && colID<numGlobalEquations) {
indices[numIndices] = colID;
double value = - ((double) rand())/ ((double) RAND_MAX);
if (colID==rowID)
values[numIndices++] = dnumPoints - value; // Make diagonal dominant
else
values[numIndices++] = value;
}
}
//cout << "Building row " << rowID << endl;
A->InsertGlobalValues(rowID, numIndices, values, indices);
}
delete [] indices;
delete [] values;
double insertTime = timer.ElapsedTime();
timer.ResetStartTime();
A->FillComplete(false);
double fillCompleteTime = timer.ElapsedTime();
if (verbose)
cout << "Time to insert matrix values = " << insertTime << endl
<< "Time to complete fill = " << fillCompleteTime << endl;
if (summary) {
if (comm.NumProc()==1) cout << "InsertTime" << '\t';
cout << insertTime << endl;
if (comm.NumProc()==1) cout << "FillCompleteTime" << '\t';
cout << fillCompleteTime << endl;
}
if (nrhs<=1) {
b = new Epetra_Vector(*map);
bt = new Epetra_Vector(*map);
xexact = new Epetra_Vector(*map);
}
else {
b = new Epetra_MultiVector(*map, nrhs);
bt = new Epetra_MultiVector(*map, nrhs);
xexact = new Epetra_MultiVector(*map, nrhs);
}
xexact->Random(); // Fill xexact with random values
A->Multiply(false, *xexact, *b);
A->Multiply(true, *xexact, *bt);
return;
}
示例4: main
int main(int argc, char** argv)
{
#ifdef HAVE_MPI
Teuchos::GlobalMPISession mpiSession(&argc, &argv, 0);
Epetra_MpiComm Comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
#endif
bool success = true;
string pass = "End Result: TEST PASSED";
string fail = "End Result: TEST FAILED";
int myPID = Comm.MyPID();
if(myPID == 0)
{
cout << "Starting Epetra interface test" << endl;
}
/*----------------Load a test matrix---------------*/
string matrixFileName = "wathenSmall.mtx";
Epetra_CrsMatrix *A;
Epetra_CrsMatrix *AHat;
Epetra_MultiVector *b;
Epetra_MultiVector *bHat;
Epetra_MultiVector *x;
int n = 0;
//Get Matrix
int err = EpetraExt::MatrixMarketFileToCrsMatrix(matrixFileName.c_str(), Comm, A);
if(err!=0 && myPID ==0)
{
cout << "Error reading matrix file, info = " << err << endl;
cout << fail << endl;
exit(1);
}
n = A->NumGlobalRows();
//Make b vecotor
Epetra_Map vecMap(n,0,Comm);
b = new Epetra_MultiVector(vecMap,1,false);
b->Random();
x = new Epetra_MultiVector(vecMap,1,false);
x->Random();
cout << "Epetra matrices loaded" << endl;
/*-----------------have_interface-----------------*/
/*---The have_interface checks is all the parameter list makes sense---*/
Teuchos::RCP <Teuchos::ParameterList> pLUList;
string pListFileName = "ShyLU_epetra_interface.xml";
pLUList = Teuchos::getParametersFromXmlFile(pListFileName);
/*----------------partitioning_interface--------------*/
/*-----------Will use check the epetra matrix on partition_interface------*/
//Isorropia Test - graph/Parmetis
pLUList->set("Partitioning Package","Isorropia");
Teuchos::ParameterList ptemp;
ptemp = pLUList->sublist("Isorropia Input");
Teuchos::ParameterList pptemp;
pptemp = ptemp.sublist("Zoltan");
pptemp.set("GRAPH_PACKAGE", "Parmetis");
pptemp.set("DEBUG_LEVEL", "1");
ptemp.set("partitioning method", "graph");
ptemp.set("Zoltan", pptemp);
pLUList->set("Isorropia Input", ptemp);
cout << " \n\n--------------------BIG BREAK --------------\n\n";
Teuchos::writeParameterListToXmlOStream(*pLUList, std::cout);
ShyLU::PartitionInterface<Epetra_CrsMatrix, Epetra_MultiVector> partI(A, pLUList.get());
partI.partition();
AHat = partI.reorderMatrix();
bHat = partI.reorderVector(b);
EpetraExt::RowMatrixToMatlabFile("Epetra_Isorropia_Parmetis.mat", *AHat);
cout << "Done with graph - parmetis" << endl;
/*
//Isorropia Test - Graph/PT-Scotch
pLUList->set("Partitioning Package","Isorropia");
ptemp = pLUList->sublist("Isorropia Input");
//Teuchos::ParameterList pptemp;
pptemp = ptemp.sublist("Zoltan");
pptemp.set("GRAPH_PACKAGE", "scotch");
pptemp.set("DEBUG_LEVEL", "1");
//.........这里部分代码省略.........