// These functions seek the iterator to the exit that matches a specific // starting or ending point void portal::SeekStartRoom( entityid p_room ) { BeginPath(); while( IsValidPath() ) { // exit out when you find a match if( CurrentStart() == p_room ) return; NextPath(); } }
//========================================================================= Epetra_CrsMatrix* EpetraExt::RowMatrix_Transpose::CreateTransposeLocal(OriginalTypeRef orig) { #ifdef ENABLE_TRANSPOSE_TIMINGS Teuchos::Time myTime("global"); Teuchos::TimeMonitor MM(myTime); Teuchos::RCP<Teuchos::Time> mtime; mtime=MM.getNewTimer("Transpose: CreateTransposeLocal 1"); mtime->start(); #endif int i,j,err; const Epetra_CrsMatrix * OrigCrsMatrix = dynamic_cast<const Epetra_CrsMatrix*>(&orig); if(OrigCrsMatrix) OrigMatrixIsCrsMatrix_ = true; else OrigMatrixIsCrsMatrix_ = false; const Epetra_Map & TransMap = orig.RowMatrixColMap(); int TransNnz = orig.NumMyNonzeros(); int NumIndices; Epetra_CrsMatrix *TempTransA1 = new Epetra_CrsMatrix(Copy, TransMap,orig.RowMatrixRowMap(),0); Epetra_IntSerialDenseVector & TransRowptr = TempTransA1->ExpertExtractIndexOffset(); Epetra_IntSerialDenseVector & TransColind = TempTransA1->ExpertExtractIndices(); double *& TransVals = TempTransA1->ExpertExtractValues(); NumMyRows_ = orig.NumMyRows(); NumMyCols_ = orig.NumMyCols(); TransRowptr.Resize(NumMyCols_+1); TransColind.Resize(TransNnz); resize_doubles(0,TransNnz,TransVals); std::vector<int> CurrentStart(NumMyCols_,0); // Count up nnz using the Rowptr to count the number of non-nonzeros. if (OrigMatrixIsCrsMatrix_) { const Epetra_CrsGraph & OrigGraph = OrigCrsMatrix->Graph(); // Get matrix graph for (i=0; i<NumMyRows_; i++) { err = OrigGraph.ExtractMyRowView(i, NumIndices, Indices_); // Get view of ith row if (err != 0) throw OrigGraph.ReportError("ExtractMyRowView failed",err); for (j=0; j<NumIndices; j++) ++CurrentStart[Indices_[j]]; } } else // Original is not a CrsMatrix { MaxNumEntries_ = 0; MaxNumEntries_ = orig.MaxNumEntries(); delete [] Indices_; delete [] Values_; Indices_ = new int[MaxNumEntries_]; Values_ = new double[MaxNumEntries_]; for (i=0; i<NumMyRows_; i++) { err = orig.ExtractMyRowCopy(i, MaxNumEntries_, NumIndices, Values_, Indices_); if (err != 0) { std::cerr << "ExtractMyRowCopy failed."<<std::endl; throw err; } for (j=0; j<NumIndices; j++) ++CurrentStart[Indices_[j]]; } } // Scansum the rowptr; reset currentstart TransRowptr[0] = 0; for (i=1;i<NumMyCols_+1; i++) TransRowptr[i] = CurrentStart[i-1] + TransRowptr[i-1]; for (i=0;i<NumMyCols_; i++) CurrentStart[i] = TransRowptr[i]; // Now copy values and global indices into newly create transpose storage for (i=0; i<NumMyRows_; i++) { if (OrigMatrixIsCrsMatrix_) err = OrigCrsMatrix->ExtractMyRowView(i, NumIndices, Values_, Indices_); else err = orig.ExtractMyRowCopy(i, MaxNumEntries_, NumIndices, Values_, Indices_); if (err != 0) { std::cerr << "ExtractMyRowCopy failed."<<std::endl; throw err; } for (j=0; j<NumIndices; j++) { int idx = CurrentStart[Indices_[j]]; TransColind[idx] = i; TransVals[idx] = Values_[j]; ++CurrentStart[Indices_[j]];// increment the counter into the local row } } #ifdef ENABLE_TRANSPOSE_TIMINGS mtime->stop(); mtime=MM.getNewTimer("Transpose: CreateTransposeLocal 2"); mtime->start(); #endif // Prebuild the importers and exporters the no-communication way, flipping the importers // and exporters around. Epetra_Import * myimport = 0; Epetra_Export * myexport = 0; if(OrigMatrixIsCrsMatrix_ && OrigCrsMatrix->Importer()) myexport = new Epetra_Export(*OrigCrsMatrix->Importer()); if(OrigMatrixIsCrsMatrix_ && OrigCrsMatrix->Exporter()) myimport = new Epetra_Import(*OrigCrsMatrix->Exporter()); #ifdef ENABLE_TRANSPOSE_TIMINGS mtime->stop(); mtime=MM.getNewTimer("Transpose: CreateTransposeLocal 3"); mtime->start(); #endif // Call ExpertStaticFillComplete err = TempTransA1->ExpertStaticFillComplete(orig.OperatorRangeMap(),orig.OperatorDomainMap(),myimport,myexport); if (err != 0) { throw TempTransA1->ReportError("ExpertStaticFillComplete failed.",err); } #ifdef ENABLE_TRANSPOSE_TIMINGS mtime->stop(); #endif return TempTransA1; }