//================================================ void DynamicalGraph::Run(uint32_t t_init, uint32_t t_measure) { std::ofstream fout("timeseries.dat"); for( ; m_currentTime<t_init; m_currentTime++) { Update(); if( m_currentTime%1024 == 0 ) { std::cerr << "t : " << m_currentTime << std::endl; fout << m_currentTime << ' ' << Diversity() << ' ' << LinkDensity() << ' ' << CC() << std::endl; } } ClearHisto(); for( ; m_currentTime<t_init+t_measure; m_currentTime++) { Update(); m_densitySum += LinkDensity(); m_densityCount++; if( m_currentTime % 128 == 0 ) { m_CCsum += CC(); m_CCcount++; } if( m_currentTime%1024 == 0 ) { std::cerr << "t : " << m_currentTime << std::endl; fout << m_currentTime << ' ' << Diversity() << ' ' << LinkDensity() << ' ' << CC() << std::endl; } } fout.close(); }
void cesar_cipher2(list *p_l,int *key,int *pos) { list node = *p_l; // liste temporaire int i; for(i=0;i<*pos;i++) node = node->next; if(CONTENT >= 'A' && CONTENT <= 'Z') // si le char est une majuscule CONTENT = CC(CONTENT,*key,'A'); // on chiffre la phrase else if(CONTENT >= 'a' && CONTENT <= 'z') // si le char est une minuscule CONTENT = CC(CONTENT,*key,'a'); // on chiffre la phrase }
void mpz_matrix_manager::tensor_product(mpz_matrix const & A, mpz_matrix const & B, mpz_matrix & C) { scoped_mpz_matrix CC(*this); mk(A.m * B.m, A.n * B.n, CC); for (unsigned i = 0; i < CC.m(); i++) for (unsigned j = 0; j < CC.n(); j++) nm().mul(A(i / B.m, j / B.n), B(i % B.m, j % B.n), CC(i, j)); C.swap(CC); }
void cesar_cipher(list *p_l,int *key) { list node = *p_l; // liste temporaire while(node) { if(CONTENT >= 'A' && CONTENT <= 'Z') // si le char est une majuscule CONTENT = CC(CONTENT,*key,'A'); // on chiffre la phrase else if(CONTENT >= 'a' && CONTENT <= 'z') // si le char est une minuscule CONTENT = CC(CONTENT,*key,'a'); // on chiffre la phrase node = node->next; // on avance dans la liste } }
void CMyAI::newGame() { memcpy(originalBoard, p_ai->GetBoard(), sizeof(int)*BOARD_SIZE); history.clear(); firstMoveIsOver = true; cout << "===================start a new game=====================" << endl; if (we == PLAYER_1) { cout << "\t\twe are player 1" << endl; } else { cout << "\t\twe are player 2" << endl; } if (next == we) { cout << "\tYeah! We go first!!!" << endl; first = next; } else { cout << "\tOh shit! We do not go first!" << endl; first = next; } int count7x7 = 0; for (int x = 2; x <= 8; x++){ for (int y = 2; y <= 8; y++){ if (originalBoard[CC(x, y)] == BLOCK_OBSTACLE) count7x7++; } } int count3x3 = 0; for (int x = 4; x <= 6; x++){ for (int y = 4; y <= 6; y++){ if (originalBoard[CC(x, y)] == BLOCK_OBSTACLE) count3x3++; } } if (count7x7 >= 8 || (count3x3 >= 2 && count7x7 >= 6)){ searcher.heuristic.rateBoard = &CHeuristicBase::simpleRateBoard; } else { searcher.heuristic.rateBoard = &CHeuristicBase::voronoiRateBoard; } }
BEmailMessage * BEmailMessage::ForwardMessage(bool accountFromMail, bool includeAttachments) { BString header = "------ Forwarded Message: ------\n"; header << "To: " << To() << '\n'; header << "From: " << From() << '\n'; if (CC() != NULL) { // Can use CC rather than "Cc" since display only. header << "CC: " << CC() << '\n'; } header << "Subject: " << Subject() << '\n'; header << "Date: " << Date() << "\n\n"; if (_text_body != NULL) header << _text_body->Text() << '\n'; BEmailMessage *message = new BEmailMessage(); message->SetBodyTextTo(header.String()); // set the subject BString subject = Subject(); if (subject.IFindFirst("fwd") == B_ERROR && subject.IFindFirst("forward") == B_ERROR && subject.FindFirst("FW") == B_ERROR) subject << " (fwd)"; message->SetSubject(subject.String()); if (includeAttachments) { for (int32 i = 0; i < CountComponents(); i++) { BMailComponent *cmpt = GetComponent(i); if (cmpt == _text_body || cmpt == NULL) continue; //---I am ashamed to have the written the code between here and the next comment // ... and you still managed to get it wrong ;-)), axeld. // we should really move this stuff into copy constructors // or something like that BMallocIO io; cmpt->RenderToRFC822(&io); BMailComponent *clone = cmpt->WhatIsThis(); io.Seek(0, SEEK_SET); clone->SetToRFC822(&io, io.BufferLength(), true); message->AddComponent(clone); } } if (accountFromMail) message->SendViaAccountFrom(this); return message; }
//--------------------------------------------------------------------------------------- // Initialize, use a Config object bool CCudaProjector3D::initialize(const Config& _cfg) { assert(_cfg.self); ConfigStackCheck<CProjector3D> CC("CudaProjector3D", this, _cfg); // if already initialized, clear first if (m_bIsInitialized) { clear(); } // initialization of parent class if (!CProjector3D::initialize(_cfg)) { return false; } XMLNode node = _cfg.self.getSingleNode("ProjectionKernel"); m_projectionKernel = ker3d_default; if (node) { std::string sProjKernel = node.getContent(); if (sProjKernel == "default") { } else if (sProjKernel == "sum_square_weights") { m_projectionKernel = ker3d_sum_square_weights; } else { return false; } } CC.markNodeParsed("ProjectionKernel"); m_bIsInitialized = _check(); return m_bIsInitialized; }
//--------------------------------------------------------------------------------------- // Initialize - Config bool CSirtAlgorithm::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CAlgorithm> CC("SirtAlgorithm", this, _cfg); // if already initialized, clear first if (m_bIsInitialized) { clear(); } // initialization of parent class if (!CSartAlgorithm::initialize(_cfg)) { return false; } //// init data objects and data projectors //_init(); //// Alpha //m_fAlpha = _cfg.self.getOptionNumerical("Alpha", m_fAlpha); //CC.markOptionParsed("Alpha"); // success m_bIsInitialized = _check(); return m_bIsInitialized; }
KOKKOS_INLINE_FUNCTION int Gemm<Trans::ConjTranspose,Trans::NoTranspose, AlgoGemm::SparseSparseSuperNodes,Variant::One> ::invoke(PolicyType &policy, MemberType &member, const ScalarType alpha, CrsExecViewTypeA &A, CrsExecViewTypeB &B, const ScalarType beta, CrsExecViewTypeC &C) { if (member.team_rank() == 0) { DenseMatrixView<typename CrsExecViewTypeA::flat_mat_base_type> AA(A.Flat()); DenseMatrixView<typename CrsExecViewTypeA::flat_mat_base_type> BB(B.Flat()); DenseMatrixView<typename CrsExecViewTypeA::flat_mat_base_type> CC(C.Flat()); Gemm<Trans::ConjTranspose,Trans::NoTranspose, AlgoGemm::ExternalBlas,Variant::One> ::invoke(policy, member, alpha, AA, BB, beta, CC); } return 0; }
void computeConsensus() { ::libmaus::consensus::ConsensusComputation::unique_ptr_type CC(new ::libmaus::consensus::ConsensusComputation); typedef ::libmaus::fastx::SocketFastAReader reader_type; typedef reader_type::pattern_type pattern_type; ::libmaus::network::SocketBase sockbase(STDIN_FILENO); reader_type sockreader(&sockbase); std::vector<std::string> V; pattern_type pattern; while ( sockreader.getNextPatternUnlocked(pattern) ) { V.push_back(pattern.spattern); std::cerr << V.back() << std::endl; } try { std::string const consensus = CC->computeConsensus(V,7,&(std::cerr)); std::cout << "consensus: " << consensus << std::endl; } catch(std::exception const & ex) { std::cerr << ex.what() << std::endl; } CC.reset(); }
void statisticsNetwork::closenessCentrality ( string filename ) // funktioniert nur für komplett verbundene Netzwerke korrekt { nodeIterator vi; network::nodeList vl; verticesMatching(vl, _dynNode_); unsigned int i; double distSum; vector <double> CC (vl.size()); vector<baseType> distance; distance.resize(vl.size()); for( vi=vl.begin() ; vi!=vl.end() ; vi++ ) { dijkstra( distance, vl, *vi ); distSum=0; for ( i=0 ; i<vl.size() ; i++ ) distSum = distSum + distance[i]; CC[ *vi -*vl.begin() ] = (vl.size()-1) / distSum ; } ofstream out(filename.c_str()); for( i=0 ; i<vl.size() ; i++) out << CC[i] << endl ; }
void mark_cells_on_cells(CellIt seed, CellSeq& cell_seq, EltMarker& visited, int level, CellPred inside) { typedef typename CellIt::grid_type grid_type; typedef GT gt; typedef typename gt::Cell Cell; typedef typename gt::CellOnCellIterator CellOnCellIterator; enumerated_cell_range<grid_type> new_cells(cell_seq.TheGrid()); while(! seed.IsDone()) { Cell C = *seed; for(CellOnCellIterator cc(C); ! cc.IsDone(); ++cc) if(inside(*cc)) { Cell CC(*cc); if(visited(CC) == 0) { visited[CC] = level; //cell_seq.append(CC); new_cells.append(CC); } } ++seed; } cell_seq.append(new_cells.FirstCell(), new_cells.EndCell()); }
inline void igl::PlanarizerShapeUp<DerivedV, DerivedF>::assembleP() { P.setZero(3*ni*numF); for (int fi = 0; fi< numF; fi++) { // todo: this can be made faster by omitting the selector matrix Eigen::SparseMatrix<typename DerivedV::Scalar > Sfi; assembleSelector(fi, Sfi); Eigen::SparseMatrix<typename DerivedV::Scalar > NSi = Ni*Sfi; Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> Vi = NSi*Vv; Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, Eigen::Dynamic> CC(3,ni); for (int i = 0; i <ni; ++i) CC.col(i) = Vi.segment(3*i, 3); Eigen::Matrix<typename DerivedV::Scalar, 3, 3> C = CC*CC.transpose(); // Alec: Doesn't compile Eigen::EigenSolver<Eigen::Matrix<typename DerivedV::Scalar, 3, 3>> es(C); // the real() is for compilation purposes Eigen::Matrix<typename DerivedV::Scalar, 3, 1> lambda = es.eigenvalues().real(); Eigen::Matrix<typename DerivedV::Scalar, 3, 3> U = es.eigenvectors().real(); int min_i; lambda.cwiseAbs().minCoeff(&min_i); U.col(min_i).setZero(); Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, Eigen::Dynamic> PP = U*U.transpose()*CC; for (int i = 0; i <ni; ++i) P.segment(3*ni*fi+3*i, 3) = weightsSqrt[fi]*PP.col(i); } }
void CC_HASH(unsigned int hashlen, void (*CC)(const void *data, uint32_t len, unsigned char *md), C_BLOB &Param1, C_LONGINT &Param2, C_TEXT &returnValue) { uint8_t *buf = (uint8_t *)calloc(hashlen, sizeof(uint8_t)); CC((unsigned char *)Param1.getBytesPtr(), Param1.getBytesLength(), buf); C_BLOB temp; temp.setBytes((const uint8_t *)buf, hashlen); switch (Param2.getIntValue()) { case 1: temp.toB64Text(&returnValue); break; case 2: temp.toB64Text(&returnValue, true); break; default: temp.toHexText(&returnValue); break; } free(buf); }
//--------------------------------------------------------------------------------------- // Initialize, use a Config object bool CCudaProjector2D::initialize(const Config& _cfg) { assert(_cfg.self); ConfigStackCheck<CProjector2D> CC("CudaProjector2D", this, _cfg); // if already initialized, clear first if (m_bIsInitialized) { clear(); } // initialization of parent class if (!CProjector2D::initialize(_cfg)) { return false; } // TODO: Check the projection geometry is a supported type XMLNode node = _cfg.self.getSingleNode("ProjectionKernel"); m_projectionKernel = ker2d_default; if (node) { std::string sProjKernel = node.getContent(); if (sProjKernel == "default") { } else { return false; } } CC.markNodeParsed("ProjectionKernel"); m_bIsInitialized = _check(); return m_bIsInitialized; }
KOKKOS_INLINE_FUNCTION int Herk<Uplo::Upper,Trans::ConjTranspose, AlgoHerk::SparseSparseSuperNodesByBlocks,Variant::One> ::invoke(PolicyType &policy, MemberType &member, const ScalarType alpha, CrsExecViewTypeA &A, const ScalarType beta, CrsExecViewTypeC &C) { if (member.team_rank() == 0) { DenseMatrixView<typename CrsExecViewTypeA::hier_mat_base_type> AA(A.Hier()); DenseMatrixView<typename CrsExecViewTypeA::hier_mat_base_type> CC(C.Hier()); Herk<Uplo::Upper,Trans::ConjTranspose, AlgoHerk::DenseByBlocks,Variant::One> ::invoke(policy, member, alpha, AA, beta, CC); } return 0; }
Expected<const CodeRegions &> AsmCodeRegionGenerator::parseCodeRegions() { MCTargetOptions Opts; Opts.PreserveAsmComments = false; MCStreamerWrapper Str(Ctx, Regions); // Create a MCAsmParser and setup the lexer to recognize llvm-mca ASM // comments. std::unique_ptr<MCAsmParser> Parser( createMCAsmParser(Regions.getSourceMgr(), Ctx, Str, MAI)); MCAsmLexer &Lexer = Parser->getLexer(); MCACommentConsumer CC(Regions); Lexer.setCommentConsumer(&CC); // Create a target-specific parser and perform the parse. std::unique_ptr<MCTargetAsmParser> TAP( TheTarget.createMCAsmParser(STI, *Parser, MCII, Opts)); if (!TAP) return make_error<StringError>( "This target does not support assembly parsing.", inconvertibleErrorCode()); Parser->setTargetParser(*TAP); Parser->Run(false); // Get the assembler dialect from the input. llvm-mca will use this as the // default dialect when printing reports. AssemblerDialect = Parser->getAssemblerDialect(); return Regions; }
bool CFanFlatVecProjectionGeometry2D::initializeAngles(const Config& _cfg) { ConfigStackCheck<CProjectionGeometry2D> CC("FanFlatVecProjectionGeometry2D", this, _cfg); // Required: Vectors XMLNode node = _cfg.self.getSingleNode("Vectors"); ASTRA_CONFIG_CHECK(node, "FanFlatVecProjectionGeometry2D", "No Vectors tag specified."); vector<float32> data; try { data = node.getContentNumericalArray(); } catch (const StringUtil::bad_cast &e) { ASTRA_CONFIG_CHECK(false, "FanFlatVecProjectionGeometry2D", "Vectors must be a numerical matrix."); } CC.markNodeParsed("Vectors"); ASTRA_CONFIG_CHECK(data.size() % 6 == 0, "FanFlatVecProjectionGeometry2D", "Vectors doesn't consist of 6-tuples."); m_iProjectionAngleCount = data.size() / 6; m_pProjectionAngles = new SFanProjection[m_iProjectionAngleCount]; for (int i = 0; i < m_iProjectionAngleCount; ++i) { SFanProjection& p = m_pProjectionAngles[i]; p.fSrcX = data[6*i + 0]; p.fSrcY = data[6*i + 1]; p.fDetUX = data[6*i + 4]; p.fDetUY = data[6*i + 5]; // The backend code currently expects the corner of the detector, while // the matlab interface supplies the center p.fDetSX = data[6*i + 2] - 0.5f * m_iDetectorCount * p.fDetUX; p.fDetSY = data[6*i + 3] - 0.5f * m_iDetectorCount * p.fDetUY; } return true; }
//--------------------------------------------------------------------------------------- // Initialize - Config bool CCudaFDKAlgorithm3D::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CAlgorithm> CC("CudaFDKAlgorithm3D", this, _cfg); // if already initialized, clear first if (m_bIsInitialized) { clear(); } // initialization of parent class if (!CReconstructionAlgorithm3D::initialize(_cfg)) { return false; } initializeFromProjector(); // Deprecated options m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling); m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", m_iGPUIndex); m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("VoxelSuperSampling"); CC.markOptionParsed("GPUIndex"); if (!_cfg.self.hasOption("GPUIndex")) CC.markOptionParsed("GPUindex"); m_bShortScan = _cfg.self.getOptionBool("ShortScan", false); CC.markOptionParsed("ShortScan"); // success m_bIsInitialized = _check(); return m_bIsInitialized; }
float * delayed_lsqfit( int veclen , float * data , int nref , float *ref[] , double * cc ) { int ii , jj ; float *alpha = NULL ; double *rr = NULL ; register double sum ; if( nref < 1 || veclen < nref || data == NULL || ref == NULL || cc == NULL ) return NULL ; /*** form RHS vector into rr ***/ rr = DBLEVEC(nref) ; if( rr == NULL ) return NULL ; for( ii=0 ; ii < nref ; ii++ ){ sum = 0.0 ; for( jj=0 ; jj < veclen ; jj++ ) sum += ref[ii][jj] * data[jj] ; rr[ii] = sum ; } /*** forward solve ***/ for( ii=0 ; ii < nref ; ii++ ){ sum = rr[ii] ; for( jj=0 ; jj < ii ; jj++ ) sum -= CC(ii,jj) * rr[jj] ; rr[ii] = sum / CC(ii,ii) ; } /*** backward solve ***/ for( ii=nref-1 ; ii >= 0 ; ii-- ){ sum = rr[ii] ; for( jj=ii+1 ; jj < nref ; jj++ ) sum -= CC(jj,ii) * rr[jj] ; rr[ii] = sum / CC(ii,ii) ; } /*** put result into alpha ***/ alpha = (float *) malloc( sizeof(float) * nref ) ; if( alpha == NULL ) return NULL ; for( ii=0 ; ii < nref ; ii++ ) alpha[ii] = rr[ii] ; /*** cleanup and exit ***/ free(rr) ; return alpha ; }
//--------------------------------------------------------------------------------------- // Initialize - Config bool CConeVecProjectionGeometry3D::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CProjectionGeometry3D> CC("ConeVecProjectionGeometry3D", this, _cfg); XMLNode* node; // TODO: Fix up class hierarchy... this class doesn't fit very well. // initialization of parent class //CProjectionGeometry3D::initialize(_cfg); // Required: DetectorRowCount node = _cfg.self->getSingleNode("DetectorRowCount"); ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No DetectorRowCount tag specified."); m_iDetectorRowCount = boost::lexical_cast<int>(node->getContent()); ASTRA_DELETE(node); CC.markNodeParsed("DetectorRowCount"); // Required: DetectorColCount node = _cfg.self->getSingleNode("DetectorColCount"); ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No DetectorColCount tag specified."); m_iDetectorColCount = boost::lexical_cast<int>(node->getContent()); m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount; ASTRA_DELETE(node); CC.markNodeParsed("DetectorColCount"); // Required: Vectors node = _cfg.self->getSingleNode("Vectors"); ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No Vectors tag specified."); vector<double> data = node->getContentNumericalArrayDouble(); CC.markNodeParsed("Vectors"); ASTRA_DELETE(node); ASTRA_CONFIG_CHECK(data.size() % 12 == 0, "ConeVecProjectionGeometry3D", "Vectors doesn't consist of 12-tuples."); m_iProjectionAngleCount = data.size() / 12; m_pProjectionAngles = new SConeProjection[m_iProjectionAngleCount]; for (int i = 0; i < m_iProjectionAngleCount; ++i) { SConeProjection& p = m_pProjectionAngles[i]; p.fSrcX = data[12*i + 0]; p.fSrcY = data[12*i + 1]; p.fSrcZ = data[12*i + 2]; p.fDetUX = data[12*i + 6]; p.fDetUY = data[12*i + 7]; p.fDetUZ = data[12*i + 8]; p.fDetVX = data[12*i + 9]; p.fDetVY = data[12*i + 10]; p.fDetVZ = data[12*i + 11]; // The backend code currently expects the corner of the detector, while // the matlab interface supplies the center p.fDetSX = data[12*i + 3] - 0.5f * m_iDetectorRowCount * p.fDetVX - 0.5f * m_iDetectorColCount * p.fDetUX; p.fDetSY = data[12*i + 4] - 0.5f * m_iDetectorRowCount * p.fDetVY - 0.5f * m_iDetectorColCount * p.fDetUY; p.fDetSZ = data[12*i + 5] - 0.5f * m_iDetectorRowCount * p.fDetVZ - 0.5f * m_iDetectorColCount * p.fDetUZ; } // success m_bInitialized = _check(); return m_bInitialized; }
//---------------------------------------------------------------------------------------- // Initialization with a Config object bool CProjectionGeometry2D::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CProjectionGeometry2D> CC("ProjectionGeometry2D", this, _cfg); // uninitialize if the object was initialized before if (m_bInitialized) { clear(); } // Required: DetectorWidth XMLNode* node = _cfg.self->getSingleNode("DetectorWidth"); ASTRA_CONFIG_CHECK(node, "ProjectionGeometry2D", "No DetectorWidth tag specified."); m_fDetectorWidth = boost::lexical_cast<float32>(node->getContent()); ASTRA_DELETE(node); CC.markNodeParsed("DetectorWidth"); // Required: DetectorCount node = _cfg.self->getSingleNode("DetectorCount"); ASTRA_CONFIG_CHECK(node, "ProjectionGeometry2D", "No DetectorCount tag specified."); m_iDetectorCount = boost::lexical_cast<int>(node->getContent()); ASTRA_DELETE(node); CC.markNodeParsed("DetectorCount"); // Required: ProjectionAngles node = _cfg.self->getSingleNode("ProjectionAngles"); ASTRA_CONFIG_CHECK(node, "ProjectionGeometry2D", "No ProjectionAngles tag specified."); vector<float32> angles = node->getContentNumericalArray(); delete node; m_iProjectionAngleCount = angles.size(); ASTRA_CONFIG_CHECK(m_iProjectionAngleCount > 0, "ProjectionGeometry2D", "Not enough ProjectionAngles specified."); m_pfProjectionAngles = new float32[m_iProjectionAngleCount]; for (int i = 0; i < m_iProjectionAngleCount; i++) { m_pfProjectionAngles[i] = angles[i]; } CC.markNodeParsed("ProjectionAngles"); vector<float32> offset = _cfg.self->getOptionNumericalArray("ExtraDetectorOffset"); m_pfExtraDetectorOffset = new float32[m_iProjectionAngleCount]; if (offset.size() == (size_t)m_iProjectionAngleCount) { for (int i = 0; i < m_iProjectionAngleCount; i++) { m_pfExtraDetectorOffset[i] = offset[i]; } } else { for (int i = 0; i < m_iProjectionAngleCount; i++) { m_pfExtraDetectorOffset[i] = 0.0f; } } CC.markOptionParsed("ExtraDetectorOffset"); // some checks ASTRA_CONFIG_CHECK(m_iDetectorCount > 0, "ProjectionGeometry2D", "DetectorCount should be positive."); ASTRA_CONFIG_CHECK(m_fDetectorWidth > 0.0f, "ProjectionGeometry2D", "DetectorWidth should be positive."); ASTRA_CONFIG_CHECK(m_pfProjectionAngles != NULL, "ProjectionGeometry2D", "ProjectionAngles not initialized"); // Interface class, so don't return true return false; }
//--------------------------------------------------------------------------------------- // Initialize - Config bool CCudaFDKAlgorithm3D::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CAlgorithm> CC("CudaFDKAlgorithm3D", this, _cfg); // if already initialized, clear first if (m_bIsInitialized) { clear(); } // initialization of parent class if (!CReconstructionAlgorithm3D::initialize(_cfg)) { return false; } initializeFromProjector(); // Deprecated options m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling); m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", m_iGPUIndex); m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("VoxelSuperSampling"); CC.markOptionParsed("GPUIndex"); if (!_cfg.self.hasOption("GPUIndex")) CC.markOptionParsed("GPUindex"); // filter if (_cfg.self.hasOption("FilterSinogramId")){ m_iFilterDataId = (int)_cfg.self.getOptionInt("FilterSinogramId"); const CFloat32ProjectionData2D * pFilterData = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(m_iFilterDataId)); if (!pFilterData){ ASTRA_ERROR("Incorrect FilterSinogramId"); return false; } const CProjectionGeometry3D* projgeom = m_pSinogram->getGeometry(); const CProjectionGeometry2D* filtgeom = pFilterData->getGeometry(); int iPaddedDetCount = calcNextPowerOfTwo(2 * projgeom->getDetectorColCount()); int iHalfFFTSize = calcFFTFourierSize(iPaddedDetCount); if(filtgeom->getDetectorCount()!=iHalfFFTSize || filtgeom->getProjectionAngleCount()!=projgeom->getProjectionCount()){ ASTRA_ERROR("Filter size does not match required size (%i angles, %i detectors)",projgeom->getProjectionCount(),iHalfFFTSize); return false; } }else { m_iFilterDataId = -1; } CC.markOptionParsed("FilterSinogramId"); m_bShortScan = _cfg.self.getOptionBool("ShortScan", false); CC.markOptionParsed("ShortScan"); // success m_bIsInitialized = _check(); return m_bIsInitialized; }
static int dis_bpcc(uint32_t *pc, uint32_t inst) { char *bpcc[0x10] = { "bpn", "bpe", "bple", "bpl", "bpleu", "bpcs", "bpneg", "bpvs" "bpa", "bpne", "bpg", "bpge", "bpgu", "bpcc", "bppos", "bpvc" }; if ((CC(inst) != 0) && (CC(inst) != 2)) { ILLEGAL; } (void)printf("%p:\t%s%s%s\t%s,0x%lx\n", (void *)pc, bpcc[COND(inst)], A(inst) ? ",a" : "", PT(inst) ? ",pt" : ",pn", CC(inst) ? "%xcc" : "%icc", DISP19(inst) + (int64_t)pc); return DELAY; }
//--------------------------------------------------------------------------------------- // Initialize - Config bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CAlgorithm> CC("CudaForwardProjectionAlgorithm", this, _cfg); // Projector XMLNode node = _cfg.self.getSingleNode("ProjectorId"); CCudaProjector2D* pCudaProjector = 0; if (node) { int id = boost::lexical_cast<int>(node.getContent()); CProjector2D *projector = CProjector2DManager::getSingleton().get(id); pCudaProjector = dynamic_cast<CCudaProjector2D*>(projector); if (!pCudaProjector) { ASTRA_WARN("non-CUDA Projector2D passed to FP_CUDA"); } } CC.markNodeParsed("ProjectorId"); // sinogram data node = _cfg.self.getSingleNode("ProjectionDataId"); ASTRA_CONFIG_CHECK(node, "FP_CUDA", "No ProjectionDataId tag specified."); int id = boost::lexical_cast<int>(node.getContent()); m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id)); CC.markNodeParsed("ProjectionDataId"); // volume data node = _cfg.self.getSingleNode("VolumeDataId"); ASTRA_CONFIG_CHECK(node, "FP_CUDA", "No VolumeDataId tag specified."); id = boost::lexical_cast<int>(node.getContent()); m_pVolume = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id)); CC.markNodeParsed("VolumeDataId"); // GPU number m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1); m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex); CC.markOptionParsed("GPUindex"); if (!_cfg.self.hasOption("GPUindex")) CC.markOptionParsed("GPUIndex"); // Detector supersampling factor m_iDetectorSuperSampling = 1; if (pCudaProjector) { // New interface m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling(); } // Deprecated option m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling); CC.markOptionParsed("DetectorSuperSampling"); // return success return check(); }
//--------------------------------------------------------------------------------------- // Initialize - Config bool CParallelProjectionGeometry2D::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CProjectionGeometry2D> CC("ParallelProjectionGeometry2D", this, _cfg); // initialization of parent class CProjectionGeometry2D::initialize(_cfg); // success m_bInitialized = _check(); return m_bInitialized; }
static PetscErrorCode KSPGMRESUpdateHessenberg(KSP ksp,PetscInt it,PetscBool hapend,PetscReal *res) { PetscScalar *hh,*cc,*ss,tt; PetscInt j; KSP_GMRES *gmres = (KSP_GMRES*)(ksp->data); PetscFunctionBegin; hh = HH(0,it); cc = CC(0); ss = SS(0); /* Apply all the previously computed plane rotations to the new column of the Hessenberg matrix */ for (j=1; j<=it; j++) { tt = *hh; *hh = PetscConj(*cc) * tt + *ss * *(hh+1); hh++; *hh = *cc++ * *hh - (*ss++ * tt); } /* compute the new plane rotation, and apply it to: 1) the right-hand-side of the Hessenberg system 2) the new column of the Hessenberg matrix thus obtaining the updated value of the residual */ if (!hapend) { tt = PetscSqrtScalar(PetscConj(*hh) * *hh + PetscConj(*(hh+1)) * *(hh+1)); if (tt == 0.0) { ksp->reason = KSP_DIVERGED_NULL; PetscFunctionReturn(0); } *cc = *hh / tt; *ss = *(hh+1) / tt; *GRS(it+1) = -(*ss * *GRS(it)); *GRS(it) = PetscConj(*cc) * *GRS(it); *hh = PetscConj(*cc) * *hh + *ss * *(hh+1); *res = PetscAbsScalar(*GRS(it+1)); } else { /* happy breakdown: HH(it+1, it) = 0, therfore we don't need to apply another rotation matrix (so RH doesn't change). The new residual is always the new sine term times the residual from last time (GRS(it)), but now the new sine rotation would be zero...so the residual should be zero...so we will multiply "zero" by the last residual. This might not be exactly what we want to do here -could just return "zero". */ *res = 0.0; } PetscFunctionReturn(0); }
void Tests::ProcessArgument(std::vector<std::string> &args) { #define CC(a, n) if (args.size() != n + 1) { std::cout<<"Error: "<<a<<" expects "<<n<<" params"<<std::endl; return; } std::string arg = args[0]; if (arg == "help") { CC("help", 0) PrintHelp(); } else if (arg == "i") { CC("i", 1) inputFilename = args[1]; } else if (arg == "ct") { CC("ct", 1) complexType = static_cast<ComplexType>(atoi(args[1].c_str())); } else if (arg == "rt") { CC("rt", 1) reductionType = static_cast<ReductionType>(atoi(args[1].c_str())); } else if (arg == "h") { CC("h", 1) hapProgramFilename = args[1]; } else { std::cout<<"Unknown argument: "<<arg<<std::endl; } #undef CC }
//--------------------------------------------------------------------------------------- // Initialize - Config bool CArtAlgorithm::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CAlgorithm> CC("ArtAlgorithm", this, _cfg); // if already initialized, clear first if (m_bIsInitialized) { clear(); } // initialization of parent class if (!CReconstructionAlgorithm2D::initialize(_cfg)) { return false; } // ray order string projOrder = _cfg.self.getOption("RayOrder", "sequential"); CC.markOptionParsed("RayOrder"); m_iCurrentRay = 0; m_iRayCount = m_pProjector->getProjectionGeometry()->getProjectionAngleCount() * m_pProjector->getProjectionGeometry()->getDetectorCount(); if (projOrder == "sequential") { m_piProjectionOrder = new int[m_iRayCount]; m_piDetectorOrder = new int[m_iRayCount]; for (int i = 0; i < m_iRayCount; i++) { m_piProjectionOrder[i] = (int)floor((float)i / m_pProjector->getProjectionGeometry()->getDetectorCount()); m_piDetectorOrder[i] = i % m_pProjector->getProjectionGeometry()->getDetectorCount(); } } else if (projOrder == "custom") { vector<float32> rayOrderList = _cfg.self.getOptionNumericalArray("RayOrderList"); m_iRayCount = rayOrderList.size() / 2; m_piProjectionOrder = new int[m_iRayCount]; m_piDetectorOrder = new int[m_iRayCount]; for (int i = 0; i < m_iRayCount; i++) { m_piProjectionOrder[i] = static_cast<int>(rayOrderList[2*i]); m_piDetectorOrder[i] = static_cast<int>(rayOrderList[2*i+1]); } CC.markOptionParsed("RayOrderList"); } else { return false; } m_fLambda = _cfg.self.getOptionNumerical("Lambda", 1.0f); CC.markOptionParsed("Lambda"); // success m_bIsInitialized = _check(); return m_bIsInitialized; }
//--------------------------------------------------------------------------------------- // Initialize - Config bool CCudaBackProjectionAlgorithm::initialize(const Config& _cfg) { ASTRA_ASSERT(_cfg.self); ConfigStackCheck<CAlgorithm> CC("CudaBackProjectionAlgorithm", this, _cfg); m_bIsInitialized = CCudaReconstructionAlgorithm2D::initialize(_cfg); if (!m_bIsInitialized) return false; m_pAlgo = new BPalgo(); m_bAlgoInit = false; return true; }