本文整理汇总了C++中MultiVector::GetMyLength方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiVector::GetMyLength方法的具体用法?C++ MultiVector::GetMyLength怎么用?C++ MultiVector::GetMyLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiVector
的用法示例。
在下文中一共展示了MultiVector::GetMyLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Eig
// ======================================================================
void Eig(const Operator& Op, MultiVector& ER, MultiVector& EI)
{
int ierr;
if (Op.GetDomainSpace() != Op.GetRangeSpace())
ML_THROW("Matrix is not square", -1);
ER.Reshape(Op.GetDomainSpace());
EI.Reshape(Op.GetDomainSpace());
Epetra_LinearProblem Problem;
Problem.SetOperator(const_cast<Epetra_RowMatrix*>(Op.GetRowMatrix()));
Amesos_Lapack Lapack(Problem);
Epetra_Vector ER_Epetra(Op.GetRowMatrix()->RowMatrixRowMap());
Epetra_Vector EI_Epetra(Op.GetRowMatrix()->RowMatrixRowMap());
ierr = Lapack.GEEV(ER_Epetra, EI_Epetra);
if (ierr)
ML_THROW("GEEV returned error code = " + GetString(ierr), -1);
for (int i = 0 ; i < ER.GetMyLength() ; ++i) {
ER(i) = ER_Epetra[i];
EI(i) = EI_Epetra[i];
}
}
示例2: Redistribute
// ======================================================================
MultiVector Redistribute(const MultiVector& y, const int NumEquations)
{
StackPush();
if (y.GetMyLength() % NumEquations)
ML_THROW("NumEquations does not divide MyLength()", -1);
if (y.GetNumVectors() != 1)
ML_THROW("Redistribute() works with single vectors only", -1);
Space NewSpace(y.GetMyLength() / NumEquations);
MultiVector y2(NewSpace, NumEquations);
for (int i = 0 ; i < y2.GetMyLength() ; ++i)
for (int j = 0 ; j < NumEquations ; ++j)
y2(i, j) = y(j + NumEquations * i);
StackPop();
return(y2);
}
示例3: GetPtent1D
// ======================================================================
Operator GetPtent1D(const MultiVector& D, const int offset = 0)
{
if (D.GetNumVectors() != 1)
ML_THROW("D.GetNumVectors() != 1", -1);
int size = D.GetMyLength();
if (size == 0)
ML_THROW("empty diagonal vector in input", -1);
double* diag = new double[size];
for (int i = 0 ; i < size ; ++i)
diag[i] = D(i);
// creates the ML operator and store the diag pointer,
// as well as the function pointers
ML_Operator* MLDiag = ML_Operator_Create(GetML_Comm());
int invec_leng = size / 3 + size % 3;
int outvec_leng = size;
MLDiag->invec_leng = invec_leng;
MLDiag->outvec_leng = outvec_leng;
MLDiag->data = (void*)diag;
MLDiag->data_destroy = Ptent1D_destroy;
MLDiag->matvec->func_ptr = Ptent1D_matvec;
MLDiag->matvec->ML_id = ML_NONEMPTY;
MLDiag->matvec->Nrows = outvec_leng;
MLDiag->from_an_ml_operator = 0;
MLDiag->getrow->func_ptr = Ptent1D_getrows;
MLDiag->getrow->ML_id = ML_NONEMPTY;
MLDiag->getrow->Nrows = outvec_leng;
// creates the domain space
vector<int> MyGlobalElements(invec_leng);
for (int i = 0 ; i < invec_leng ; ++i)
MyGlobalElements[i] = D.GetVectorSpace()(i * 3) / 3;
Space DomainSpace(invec_leng, -1, &MyGlobalElements[0]);
Space RangeSpace = D.GetVectorSpace();
// creates the MLAPI wrapper
Operator Diag(DomainSpace,RangeSpace,MLDiag,true);
return(Diag);
}
示例4: GetDiagonal
// ======================================================================
Operator GetDiagonal(const MultiVector& D)
{
if (D.GetNumVectors() != 1)
ML_THROW("D.GetNumVectors() != 1", -1);
int size = D.GetMyLength();
if (size == 0)
ML_THROW("empty diagonal vector in input", -1);
double* diag = new double[size];
for (int i = 0 ; i < size ; ++i)
diag[i] = D(i);
// creates the ML operator and store the diag pointer,
// as well as the function pointers
ML_Operator* MLDiag = ML_Operator_Create(GetML_Comm());
MLDiag->invec_leng = size;
MLDiag->outvec_leng = size;
MLDiag->data = (void*)diag;
MLDiag->matvec->func_ptr = diag_matvec;
MLDiag->matvec->ML_id = ML_NONEMPTY;
MLDiag->matvec->Nrows = size;
MLDiag->from_an_ml_operator = 0;
MLDiag->data_destroy = diag_destroy;
MLDiag->getrow->func_ptr = diag_getrows;
MLDiag->getrow->ML_id = ML_NONEMPTY;
MLDiag->getrow->Nrows = size;
// creates the MLAPI wrapper
Operator Diag(D.GetVectorSpace(),D.GetVectorSpace(),MLDiag,true);
return(Diag);
}
示例5: GetPtent
// ======================================================================
void GetPtent(const Operator& A, Teuchos::ParameterList& List,
const MultiVector& ThisNS,
Operator& Ptent, MultiVector& NextNS)
{
std::string CoarsenType = List.get("aggregation: type", "Uncoupled");
/* old version
int NodesPerAggr = List.get("aggregation: per aggregate", 64);
*/
double Threshold = List.get("aggregation: threshold", 0.0);
int NumPDEEquations = List.get("PDE equations", 1);
ML_Aggregate* agg_object;
ML_Aggregate_Create(&agg_object);
ML_Aggregate_Set_MaxLevels(agg_object,2);
ML_Aggregate_Set_StartLevel(agg_object,0);
ML_Aggregate_Set_Threshold(agg_object,Threshold);
//agg_object->curr_threshold = 0.0;
ML_Operator* ML_Ptent = 0;
ML_Ptent = ML_Operator_Create(GetML_Comm());
if (ThisNS.GetNumVectors() == 0)
ML_THROW("zero-dimension null space", -1);
int size = ThisNS.GetMyLength();
double* null_vect = 0;
ML_memory_alloc((void **)(&null_vect), sizeof(double) * size * ThisNS.GetNumVectors(), "ns");
int incr = 1;
for (int v = 0 ; v < ThisNS.GetNumVectors() ; ++v)
DCOPY_F77(&size, (double*)ThisNS.GetValues(v), &incr,
null_vect + v * ThisNS.GetMyLength(), &incr);
ML_Aggregate_Set_NullSpace(agg_object, NumPDEEquations,
ThisNS.GetNumVectors(), null_vect,
ThisNS.GetMyLength());
if (CoarsenType == "Uncoupled")
agg_object->coarsen_scheme = ML_AGGR_UNCOUPLED;
else if (CoarsenType == "Uncoupled-MIS")
agg_object->coarsen_scheme = ML_AGGR_HYBRIDUM;
else if (CoarsenType == "MIS") {
/* needed for MIS, otherwise it sets the number of equations to
* the null space dimension */
agg_object->max_levels = -7;
agg_object->coarsen_scheme = ML_AGGR_MIS;
}
else if (CoarsenType == "METIS")
agg_object->coarsen_scheme = ML_AGGR_METIS;
else {
ML_THROW("Requested aggregation scheme (" + CoarsenType +
") not recognized", -1);
}
int NextSize = ML_Aggregate_Coarsen(agg_object, A.GetML_Operator(),
&ML_Ptent, GetML_Comm());
/* This is the old version
int NextSize;
if (CoarsenType == "Uncoupled") {
NextSize = ML_Aggregate_CoarsenUncoupled(agg_object, A.GetML_Operator(),
}
else if (CoarsenType == "MIS") {
NextSize = ML_Aggregate_CoarsenMIS(agg_object, A.GetML_Operator(),
&ML_Ptent, GetML_Comm());
}
else if (CoarsenType == "METIS") {
ML ml_object;
ml_object.ML_num_levels = 1; // crap for line below
ML_Aggregate_Set_NodesPerAggr(&ml_object,agg_object,0,NodesPerAggr);
NextSize = ML_Aggregate_CoarsenMETIS(agg_object, A.GetML_Operator(),
&ML_Ptent, GetML_Comm());
}
else {
ML_THROW("Requested aggregation scheme (" + CoarsenType +
") not recognized", -1);
}
*/
ML_Operator_ChangeToSinglePrecision(ML_Ptent);
int NumMyElements = NextSize;
Space CoarseSpace(-1,NumMyElements);
Ptent.Reshape(CoarseSpace,A.GetRangeSpace(),ML_Ptent,true);
assert (NextSize * ThisNS.GetNumVectors() != 0);
NextNS.Reshape(CoarseSpace, ThisNS.GetNumVectors());
size = NextNS.GetMyLength();
for (int v = 0 ; v < NextNS.GetNumVectors() ; ++v)
DCOPY_F77(&size, agg_object->nullspace_vect + v * size, &incr,
NextNS.GetValues(v), &incr);
ML_Aggregate_Destroy(&agg_object);
ML_memory_free((void**)(&null_vect));
//.........这里部分代码省略.........
示例6: space
//.........这里部分代码省略.........
Operator ImBWTfine = GetIdentity(space,space) - mlapiBWT;
Operator ImBWTcoarse;
Operator Ptent;
Operator P;
Operator Pmod;
Operator Rtent;
Operator R;
Operator Rmod;
Operator IminusA;
Operator C;
InverseOperator S;
mlapiAtildesplit_.resize(maxlevels);
mlapiAhat_.resize(maxlevels);
mlapiImBWT_.resize(maxlevels);
mlapiImWBT_.resize(maxlevels);
mlapiRmod_.resize(maxlevels);
mlapiPmod_.resize(maxlevels);
mlapiS_.resize(maxlevels);
mlapiAtildesplit_[0] = mlapiAtildesplit;
mlapiAhat_[0] = mlapiAhat;
mlapiImBWT_[0] = ImBWTfine;
mlapiImWBT_[0] = GetTranspose(ImBWTfine);
// build nullspace
MultiVector NS;
MultiVector NextNS;
NS.Reshape(mlapiAsplit.GetRangeSpace(),nsdim);
if (nullspace)
{
for (int i=0; i<nsdim; ++i)
for (int j=0; j<NS.GetMyLength(); ++j)
NS(j,i) = nullspace[i*NS.GetMyLength()+j];
}
else
{
if (numpde==1) NS = 1.0;
else
{
NS = 0.0;
for (int i=0; i<NS.GetMyLength(); ++i)
for (int j=0; j<numpde; ++j)
if ( i % numpde == j)
NS(i,j) = 1.0;
}
}
double lambdamax;
// construct the hierarchy
int level=0;
for (level=0; level<maxlevels-1; ++level)
{
// this level's smoothing operator
mlapiAtildesplit = mlapiAtildesplit_[level];
// build smoother
if (Comm().MyPID()==0)
{
ML_print_line("-", 78);
std::cout << "MOERTEL/ML : creating smoother level " << level << std::endl;
fflush(stdout);
}
S.Reshape(mlapiAtildesplit,smoothertype,mlparams_);