TEST(BinarySerializationCompatibility, ParentBlockSerializer) { CryptoNote::ParentBlock pb; fillParentBlock(pb); uint64_t timestamp = 1408106672; uint32_t nonce = 1234567; checkCompatibility(pb, timestamp, nonce, false, false); checkCompatibility(pb, timestamp, nonce, true, false); checkCompatibility(pb, timestamp, nonce, false, true); }
TEST(BinarySerializationCompatibility, TransactionInputGenerate) { cryptonote::TransactionInputGenerate s; s.height = 0x8000000000000001; checkCompatibility(s); s.height = 0x7FFFFFFFFFFFFFFF; checkCompatibility(s); s.height = 0; checkCompatibility(s); };
TEST(BinarySerializationCompatibility, tx_extra_merge_mining_tag) { CryptoNote::tx_extra_merge_mining_tag tag; tag.depth = 0xdeadbeef; fillHash(tag.merkle_root); checkCompatibility(tag); }
bool fillRegularVolumeInfo( VolumeInformation& info ) { const Vector3ui& blockSize = info.maximumBlockSize - info.overlap * 2; if( !checkCompatibility( info.voxels, blockSize )) return false; const float maxDim = float( info.voxels.find_max( )); info.maximumBlockSize = blockSize + info.overlap * 2; info.dataType = DT_UINT8; info.compCount = 1; info.isBigEndian = false; info.worldSpacePerVoxel = 1.0f / maxDim; info.worldSize = Vector3f( info.voxels[0], info.voxels[1], info.voxels[2] ) / maxDim; // Find the depth of hierarchy const Vector3ui numBlocks = info.voxels / blockSize; Vector3ui blocksSize = numBlocks; const uint32_t xDepth = std::log2( blocksSize[0] ); const uint32_t yDepth = std::log2( blocksSize[1] ); const uint32_t zDepth = std::log2( blocksSize[2] ); const uint32_t depth = std::min( xDepth, std::min( yDepth, zDepth )); blocksSize = blocksSize / ( 1u << depth ); info.rootNode = RootNode( depth + 1, blocksSize ); return true; }
/*!It adds a pin between two objects. * \param[in] objSend Pointer to BaseManipulation sender object. * \param[in] objRec Pointer to BaseManipulation receiver object. * \param[in] portS Port ID of the output port of sender object. * \param[in] portR Port ID of the input port of receiver object. * \param[in] forced If true it forces to build the connection without checking the compatibility between ports. * \return True if the pin is added. */ bool addPin(BaseManipulation* objSend, BaseManipulation* objRec, PortID portS, PortID portR, bool forced) { bool done = false; if (!objSend->arePortsBuilt()) { objSend->buildPorts(); if (!objSend->arePortsBuilt()) { std::cout << "MiMMO : error " << objSend->m_name << " cannot build ports -> exit! " << std::endl; exit(11); } } if (!objRec->arePortsBuilt()) { objRec->buildPorts(); if (!objRec->arePortsBuilt()) { std::cout << "MiMMO : error " << objRec->m_name << " cannot build ports -> exit! " << std::endl; exit(11); } } if (!(objSend->getConnectionType() == ConnectionType::BACKWARD) && !(objRec->getConnectionType() == ConnectionType::FORWARD) ) { if (objSend->m_portOut.count(portS) != 0 && objRec->m_portIn.count(portR) != 0) { if (forced || checkCompatibility(objSend, objRec, portS, portR)) { objSend->addPinOut(objRec, portS, portR); objRec->addPinIn(objSend, portR); objSend->addChild(objRec); objRec->addParent(objSend); done = true; } } } return done; }
TEST(BinarySerializationCompatibility, Transaction) { cryptonote::Transaction tx; fillTransaction(tx); checkCompatibility(tx); }
TEST(BinarySerializationCompatibility, TransactionOutputMultisignature) { cryptonote::TransactionOutputMultisignature s; fillTransactionOutputMultisignature(s); checkCompatibility(s); }
TEST(BinarySerializationCompatibility, TransactionInputMultisignature) { cryptonote::TransactionInputMultisignature s; s.amount = 0xfff000ffff778822; s.signatures = 0x7f259200; s.outputIndex = 0; checkCompatibility(s); }
TEST(BinarySerializationCompatibility, account_public_address) { cryptonote::AccountPublicAddress addr; fillPublicKey(addr.m_spendPublicKey, 0x50); fillPublicKey(addr.m_viewPublicKey, 0xAA); checkCompatibility(addr); }
LongstaffSchwartzExerciseStrategy::LongstaffSchwartzExerciseStrategy( const Clone<MarketModelBasisSystem>& basisSystem, const std::vector<std::vector<Real> >& basisCoefficients, const EvolutionDescription& evolution, const std::vector<Size>& numeraires, const Clone<MarketModelExerciseValue>& exercise, const Clone<MarketModelExerciseValue>& control) : basisSystem_(basisSystem), basisCoefficients_(basisCoefficients), exercise_(exercise), control_(control), numeraires_(numeraires) { checkCompatibility(evolution, numeraires); relevantTimes_ = evolution.evolutionTimes(); isBasisTime_.resize(relevantTimes_.size()); isBasisTime_ = isInSubset(relevantTimes_, basisSystem_->evolution().evolutionTimes()); isRebateTime_.resize(relevantTimes_.size()); isRebateTime_ = isInSubset(relevantTimes_, exercise_->evolution().evolutionTimes()); isControlTime_.resize(relevantTimes_.size()); isControlTime_ = isInSubset(relevantTimes_, control_->evolution().evolutionTimes()); exerciseIndex_ = std::vector<Size>(relevantTimes_.size()); isExerciseTime_.resize(relevantTimes_.size(), false); std::valarray<bool> v = exercise_->isExerciseTime(); Size exercises = 0, idx = 0; Size i; for (i=0; i<relevantTimes_.size(); ++i) { exerciseIndex_[i] = exercises; if (isRebateTime_[i]) { isExerciseTime_[i] = v[idx++]; if (isExerciseTime_[i]) { exerciseTimes_.push_back(relevantTimes_[i]); ++exercises; } } } std::vector<Time> rateTimes = evolution.rateTimes(); std::vector<Time> rebateTimes = exercise_->possibleCashFlowTimes(); rebateDiscounters_.reserve(rebateTimes.size()); for (i=0; i<rebateTimes.size(); ++i) rebateDiscounters_.push_back( MarketModelDiscounter(rebateTimes[i], rateTimes)); std::vector<Time> controlTimes = control_->possibleCashFlowTimes(); controlDiscounters_.reserve(controlTimes.size()); for (i=0; i<controlTimes.size(); ++i) controlDiscounters_.push_back( MarketModelDiscounter(controlTimes[i], rateTimes)); std::vector<Size> basisSizes = basisSystem_->numberOfFunctions(); basisValues_.resize(basisSystem_->numberOfExercises()); for (i=0; i<basisValues_.size(); ++i) basisValues_[i].resize(basisSizes[i]); }
TEST(BinarySerializationCompatibility, TransactionInputToKey) { cryptonote::TransactionInputToKey s; s.amount = 123456987032; s.keyOffsets = {12,3323,0x7f00000000000000, std::numeric_limits<uint64_t>::max(), 0}; fillKeyImage(s.keyImage); checkCompatibility(s); }
TEST(BinarySerializationCompatibility, TransactionOutput_TransactionOutputToKey) { cryptonote::TransactionOutput s; s.amount = 0xfff000ffff778822; cryptonote::TransactionOutputToKey out; fillPublicKey(out.key); s.target = out; checkCompatibility(s); }
TEST(BinarySerializationCompatibility, TransactionOutput_TransactionOutputMultisignature) { cryptonote::TransactionOutput s; s.amount = 0xfff000ffff778822; cryptonote::TransactionOutputMultisignature out; fillTransactionOutputMultisignature(out); s.target = out; checkCompatibility(s); }
TEST(BinarySerializationCompatibility, Block) { cryptonote::Block block; fillBlockHeader(block); fillTransaction(block.minerTx); for (size_t i = 0; i < 7; ++i) { crypto::hash hash; fillHash(hash, 0x7F + i); block.txHashes.push_back(hash); } checkCompatibility(block); }
TEST(BinarySerializationCompatibility, BlockVersion2) { CryptoNote::Block block; fillBlockHeaderVersion2(block); fillParentBlock(block.parentBlock); fillTransaction(block.minerTx); for (size_t i = 0; i < 7; ++i) { crypto::hash hash; fillHash(hash, static_cast<char>(0x7F + i)); block.txHashes.push_back(hash); } checkCompatibility(block); }
LogNormalFwdRateIpc::LogNormalFwdRateIpc( const boost::shared_ptr<MarketModel>& marketModel, const BrownianGeneratorFactory& factory, const std::vector<Size>& numeraires, Size initialStep) : marketModel_(marketModel), numeraires_(numeraires), initialStep_(initialStep), numberOfRates_(marketModel->numberOfRates()), numberOfFactors_(marketModel->numberOfFactors()), curveState_(marketModel->evolution().rateTimes()), forwards_(marketModel->initialRates()), displacements_(marketModel->displacements()), logForwards_(numberOfRates_), initialLogForwards_(numberOfRates_), drifts1_(numberOfRates_), initialDrifts_(numberOfRates_), g_(numberOfRates_), brownians_(numberOfFactors_), correlatedBrownians_(numberOfRates_), rateTaus_(marketModel->evolution().rateTaus()), alive_(marketModel->evolution().firstAliveRate()) { checkCompatibility(marketModel->evolution(), numeraires); QL_REQUIRE(isInTerminalMeasure(marketModel->evolution(), numeraires), "terminal measure required for ipc "); Size steps = marketModel->evolution().numberOfSteps(); generator_ = factory.create(numberOfFactors_, steps-initialStep_); currentStep_ = initialStep_; calculators_.reserve(steps); fixedDrifts_.reserve(steps); for (Size j=0; j<steps; ++j) { const Matrix& A = marketModel->pseudoRoot(j); calculators_.push_back(LMMDriftCalculator(A, displacements_, marketModel->evolution().rateTaus(), numeraires[j], alive_[j])); const Matrix& C = marketModel->covariance(j); std::vector<Real> fixed(numberOfRates_); for (Size k=0; k<numberOfRates_; ++k) { Real variance = C[k][k]; fixed[k] = -0.5*variance; } fixedDrifts_.push_back(fixed); } setForwards(marketModel_->initialRates()); }
TGen::OpenGL::Renderer::Renderer() : colorFromVertex(true) , lastShader(NULL) #ifdef _GFX_KEEP_DEPRECATED , lastVb(NULL) , lastIb(NULL) #endif , lastVb2(NULL) , lastIb2(NULL) , lastVb1(-1) , lastIb1(-1) , ibReadOffset(0) , vbReadOffset(0) , indexBufferFormatSize(0) , lastFBO(-1) , lastBoundFBO(NULL) , hasCoordElements(NULL) , hasNormalElements(NULL) , hasColorElements(NULL) , hasEdgeElements(NULL) , textureCoordGenU(TGen::TextureCoordGenBase) , textureCoordGenV(TGen::TextureCoordGenBase) , currentWinding(TGen::FaceWindingCCW) { TGen::OpenGL::BindFunctions(); // will be needed if we're running on a sucky platform with old OpenGL (Windows, I'm looking at you...) parseExtensions(); readCaps(); checkCompatibility(); textureUnitTargets = new GLenum[caps.maxTextureUnits]; textureUnitTextures = new TGen::Texture*[caps.maxTextureUnits]; for (int i = 0; i < caps.maxTextureUnits; ++i) { textureUnitTargets[i] = GL_NONE; textureUnitTextures[i] = NULL; if (i < 8) hasTexCoordUnitElements[i] = false; } glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); }
void EventManager::addDelegate(EventDelegate *target, uint16_t flags, fzInt priority, fzEventHandlerMode mode) { FZ_ASSERT(target != NULL, "Target argument must be non-NULL."); fzEventHandler *handler = getHandlerForTarget(target); if(handler) { handler->mode = mode; if(priority != handler->priority) { updateHandlerFlags(handler, 0); handler = NULL; }else if(flags != handler->flags) updateHandlerFlags(handler, flags); } if(handler == NULL && flags != 0) { fzEventHandler newHandle; newHandle.flags = flags; newHandle.mode = mode; newHandle.priority = priority; newHandle.delegate = target; m_handlers.insert(indexForPriority(priority), newHandle); } #if defined (FORZE_DEBUG) && FORZE_DEBUG > 0 uint16_t compatibility = checkCompatibility(flags); if((flags & kFZEventType_Tap) != kFZEventType_Tap) { if(compatibility & kFZEventType_Touch) FZLOGERROR("EventManager: Touch events are not available in this device."); if(compatibility & kFZEventType_Mouse) FZLOGERROR("EventManager: Mouse events are not available in this device."); } if(compatibility & kFZEventType_MouseRight) FZLOGERROR("EventManager: Mouse right events are not available in this device."); if(compatibility & kFZEventType_Keyboard) FZLOGERROR("EventManager: Keyboard events are not available in this device."); if(compatibility & kFZEventType_Trackpad) FZLOGERROR("EventManager: Trackpad events are not available in this device."); if(compatibility & kFZEventType_Accelerometer) FZLOGERROR("EventManager: Accelerometer events are not available in this device."); if(compatibility & kFZEventType_Gyro) FZLOGERROR("EventManager: Gyroscope events are not available in this device."); #endif updateFlags(); }
NormalFwdRatePc::NormalFwdRatePc( const ext::shared_ptr<MarketModel>& marketModel, const BrownianGeneratorFactory& factory, const std::vector<Size>& numeraires, Size initialStep) : marketModel_(marketModel), numeraires_(numeraires), initialStep_(initialStep), numberOfRates_(marketModel->numberOfRates()), numberOfFactors_(marketModel_->numberOfFactors()), curveState_(marketModel->evolution().rateTimes()), forwards_(marketModel->initialRates()), initialForwards_(marketModel->initialRates()), drifts1_(numberOfRates_), drifts2_(numberOfRates_), initialDrifts_(numberOfRates_), brownians_(numberOfFactors_), correlatedBrownians_(numberOfRates_), alive_(marketModel->evolution().firstAliveRate()) { checkCompatibility(marketModel->evolution(), numeraires); Size steps = marketModel->evolution().numberOfSteps(); generator_ = factory.create(numberOfFactors_, steps-initialStep_); currentStep_ = initialStep_; calculators_.reserve(steps); for (Size j=0; j<steps; ++j) { const Matrix& A = marketModel_->pseudoRoot(j); calculators_.push_back( LMMNormalDriftCalculator(A, marketModel->evolution().rateTaus(), numeraires[j], alive_[j])); /* for (Size k=0; k<numberOfRates_; ++k) { Real variance = std::inner_product(A.row_begin(k), A.row_end(k), A.row_begin(k), 0.0); } */ } setForwards(marketModel_->initialRates()); }
bool DeviceExplorerModel::checkDeviceInstantiatable( Device::DeviceSettings& n) { // Request from the protocol factory the protocol to see // if it is compatible. auto& context = m_devicePlugin.context().app.components; auto prot = context.factory<Device::DynamicProtocolList>().get(n.protocol); if(!prot) return false; // Look for other childs in the same protocol. return std::none_of(rootNode().begin(), rootNode().end(), [&] (const Device::Node& child) { ISCORE_ASSERT(child.is<Device::DeviceSettings>()); const auto& set = child.get<Device::DeviceSettings>(); return (set.name == n.name) || (set.protocol == n.protocol && !prot->checkCompatibility(n, child.get<Device::DeviceSettings>())); }); }
ErrorOr<MipsAbiFlags> MipsAbiInfoHandler<ELFT>::createAbiFlags(uint32_t flags, const Elf_Mips_ABIFlags *sec) { ErrorOr<MipsAbiFlags> hdrFlags = createAbiFromHeaderFlags(flags); if (auto ec = hdrFlags.getError()) return ec; if (!sec) return *hdrFlags; ErrorOr<MipsAbiFlags> secFlags = createAbiFromSection(*sec); if (auto ec = secFlags.getError()) return ec; if (!checkCompatibility(*hdrFlags, *secFlags)) return *hdrFlags; _hasAbiSection = true; secFlags->_abi = hdrFlags->_abi; secFlags->_isPic = hdrFlags->_isPic; secFlags->_isCPic = hdrFlags->_isCPic; secFlags->_isNoReorder = hdrFlags->_isNoReorder; secFlags->_is32BitMode = hdrFlags->_is32BitMode; secFlags->_isNan2008 = hdrFlags->_isNan2008; return *secFlags; }
void SidTuneBase::acceptSidTune(const char* dataFileName, const char* infoFileName, buffer_t& buf, bool isSlashedFileName) { // Make a copy of the data file name and path, if available. if (dataFileName != nullptr) { const size_t fileNamePos = isSlashedFileName ? SidTuneTools::slashedFileNameWithoutPath(dataFileName) : SidTuneTools::fileNameWithoutPath(dataFileName); info->m_path = std::string(dataFileName, fileNamePos); info->m_dataFileName = std::string(dataFileName + fileNamePos); } // Make a copy of the info file name, if available. if (infoFileName != nullptr) { const size_t fileNamePos = isSlashedFileName ? SidTuneTools::slashedFileNameWithoutPath(infoFileName) : SidTuneTools::fileNameWithoutPath(infoFileName); info->m_infoFileName = std::string(infoFileName + fileNamePos); } // Fix bad sidtune set up. if (info->m_songs > MAX_SONGS) { info->m_songs = MAX_SONGS; } else if (info->m_songs == 0) { info->m_songs = 1; } if (info->m_startSong == 0 || info->m_startSong > info->m_songs) { info->m_startSong = 1; } info->m_dataFileLen = buf.size(); info->m_c64dataLen = buf.size() - fileOffset; // Calculate any remaining addresses and then // confirm all the file details are correct resolveAddrs(&buf[fileOffset]); if (checkRelocInfo() == false) { throw loadError(ERR_BAD_RELOC); } if (checkCompatibility() == false) { throw loadError(ERR_BAD_ADDR); } if (info->m_dataFileLen >= 2) { // We only detect an offset of two. Some position independent // sidtunes contain a load address of 0xE000, but are loaded // to 0x0FFE and call player at 0x1000. info->m_fixLoad = (endian_little16(&buf[fileOffset])==(info->m_loadAddr+2)); } // Check the size of the data. if (info->m_c64dataLen > MAX_MEMORY) { throw loadError(ERR_DATA_TOO_LONG); } else if (info->m_c64dataLen == 0) { throw loadError(ERR_EMPTY); } cache.swap(buf); }
//------------------------------------------------------------------------------ // DbConnection::DbConnection //------------------------------------------------------------------------------ DbConnection::DbConnection( Driver driver, const string &cfgfile) : ptr_getAuthor(NULL), ptr_getVendor(NULL), ptr_getCopyright(NULL), ptr_getDriverType(NULL), ptr_getDriverName(NULL), ptr_getDriverDesc(NULL), ptr_getDbConnectVersion(NULL), ptr_createDriverInstance(NULL), ptr_destroyDriverInstance(NULL), drvRef(NULL) { g_dbclog.open(); // Build the compatibility table. _buildCompatibilityTable(); /* Steps to finding the config file in order to determine the path and config * parameters for the drivers. * 1. Use the file iif given in configFile param. * 2. Look in the current directory for the config file. (./dbconnect.cfg on unix). * 3. Look in the systems config dir for the file. (eg /etc/dbconnect.cfg on unix). * 4. If still no library path, then use defaults. */ size_t i; string driverPath = ""; vector<string> args; // 1. Use the file iif given in configFile param. if (cfgfile.length() > 0) { // Try and read the information from the config file. ConfigFile configFile(cfgfile.c_str()); configFile.read(); if (configFile.hasKeyName("dbconnect", "driverPath")) { driverPath = configFile["dbconnect"]["driverPath"]; // Make sure we have a proper path if (driverPath[driverPath.length()-1] != DIRCHAR) driverPath += DIRCHAR; } // Check if we have a driver file name or need to use the default. if (configFile.hasKeyName(driverNames[driver], "driverFile")) driverPath += configFile[driverNames[driver]]["driverFile"]; else driverPath += driverPaths[driver]; // Check if we have a driver section and try and obtain needed values. if (configFile.hasSection(driverNames[driver])) { //Get all the driver arguments and values vector<string> keyNames = configFile.getSectionKeyNames(driverNames[driver]); for (i=0; i<keyNames.size(); i++) { args.push_back(keyNames[i].c_str()); // Name args.push_back(configFile[driverNames[driver]][keyNames[i].c_str()]); // Value } } } else // Try and find a config file. { try { // 2. Look in the current directory for the config file. (./dbconnect.cfg on unix). ConfigFile configLocalFile(LOCALCONFIG); configLocalFile.read(); if (configLocalFile.hasKeyName("dbconnect", "driverPath")) { driverPath = configLocalFile["dbconnect"]["driverPath"]; // Make sure we have a proper path if (driverPath[driverPath.length()-1] != DIRCHAR) driverPath += DIRCHAR; } // Check if we have a driver file name or need to use the default. if (configLocalFile.hasKeyName(driverNames[driver], "driverFile")) driverPath += configLocalFile[driverNames[driver]]["driverFile"]; else driverPath += driverPaths[driver]; // Check if we have a driver section and try and obtain needed values. if (configLocalFile.hasSection(driverNames[driver])) { //Get all the driver arguments and values vector<string> keyNames = configLocalFile.getSectionKeyNames(driverNames[driver]); for (i=0; i<keyNames.size(); i++) { args.push_back(keyNames[i].c_str()); // Name args.push_back(configLocalFile[driverNames[driver]][keyNames[i].c_str()]); // Value } } } catch(...) { try { // 3. Look in the systems config dir for the file. (eg /etc/dbconnect.cfg on unix). ConfigFile configSystemFile(SYSTEMCONFIG); configSystemFile.read(); if (configSystemFile.hasKeyName("dbconnect", "driverPath")) { driverPath = configSystemFile["dbconnect"]["driverPath"]; // Make sure we have a proper path if (driverPath[driverPath.length()-1] != DIRCHAR) driverPath += DIRCHAR; } // Check if we have a driver file name or need to use the default. if (configSystemFile.hasKeyName(driverNames[driver], "driverFile")) driverPath += configSystemFile[driverNames[driver]]["driverFile"]; else driverPath += driverPaths[driver]; // Check if we have a driver section and try and obtain needed values. if (configSystemFile.hasSection(driverNames[driver])) { //Get all the driver arguments and values vector<string> keyNames = configSystemFile.getSectionKeyNames(driverNames[driver]); for (i=0; i<keyNames.size(); i++) { args.push_back(keyNames[i].c_str()); // Name args.push_back(configSystemFile[driverNames[driver]][keyNames[i].c_str()]); // Value } } } catch(...) {} } } // 4. If still no library path, then use default driver name and hope its // in the systems library path. if (driverPath.length() == 0) driverPath = driverPaths[driver]; #ifndef STATIC_DBC // Load the driver and resolve the symbols to pointers. try { g_dbclog.print("driver: %s\n", driverPath.c_str()); dlLoader.loadLibrary(driverPath); //Resolve the symbols required from the library ptr_createDriverInstance = (void* (*)(int , const char**))dlLoader.resolveSymbol("createDriverInstance"); ptr_destroyDriverInstance = (void* (*)(void*)) dlLoader.resolveSymbol("destroyDriverInstance"); ptr_getAuthor = (const char* (*)())dlLoader.resolveSymbol("getAuthor"); ptr_getVendor = (const char* (*)())dlLoader.resolveSymbol("getVendor"); ptr_getCopyright = (const char* (*)())dlLoader.resolveSymbol("getCopyright"); ptr_getDriverType = (const char* (*)())dlLoader.resolveSymbol("getDriverType"); ptr_getDriverName = (const char* (*)())dlLoader.resolveSymbol("getDriverName"); ptr_getDriverDesc = (const char* (*)())dlLoader.resolveSymbol("getDriverDesc"); ptr_getDbConnectVersion = (const char* (*)())dlLoader.resolveSymbol("getDbConnectVersion"); } catch(BaseException &ex) { throw DriverError(ex.description); } #else ptr_createDriverInstance = createDriverInstance; ptr_destroyDriverInstance = destroyDriverInstance; ptr_getAuthor = getAuthor; ptr_getVendor = getVendor; ptr_getCopyright = getCopyright; ptr_getDriverType = getDriverType; ptr_getDriverName = getDriverName; ptr_getDriverDesc = getDriverDesc; ptr_getDbConnectVersion = getDbConnectVersion; #endif // Get all the driver information. driverInfo.author = ptr_getAuthor(); driverInfo.vendor = ptr_getVendor(); driverInfo.copyright = ptr_getCopyright(); driverInfo.driverType = ptr_getDriverType(); driverInfo.driverName = ptr_getDriverName(); driverInfo.driverDescription = ptr_getDriverDesc(); driverInfo.dbConnectVersion = ptr_getDbConnectVersion(); g_dbclog.print("driverName: %s,driverType: %s\n", driverInfo.driverName.c_str(),driverInfo.driverType.c_str()); // Get the version from the driver and make sure it is compatible. if (!checkCompatibility(driverInfo.dbConnectVersion.c_str()) ) { string err = "The so library "; err += driverPath; err += " with version "; err += driverInfo.dbConnectVersion.c_str(); err += " is not compatibible with version "; err += DBCONNECTVER; err += " of the DBConnect API"; throw DriverError(err); } // Obtain a pointer reference to a driver instance passing the arguments. const char** argsref = NULL; argsref = (const char**)malloc(args.size()*sizeof(const char*)); for (i=0; i<args.size(); i++) argsref[i] = args[i].c_str(); try { drvRef = (BaseConnection*)ptr_createDriverInstance((int)args.size(), argsref); } catch(...) { drvRef = NULL; } free(argsref); // If we do not have a driver reference, throw an error if (!drvRef) throw DriverError("Unable to obtain a reference to the driver object"); } // DbConnection::DbConnection
SVDDFwdRatePc::SVDDFwdRatePc(const ext::shared_ptr<MarketModel>& marketModel, const BrownianGeneratorFactory& factory, const ext::shared_ptr<MarketModelVolProcess>& volProcess, Size firstVolatilityFactor, Size volatilityFactorStep, const std::vector<Size>& numeraires, Size initialStep ) : marketModel_(marketModel), volProcess_(volProcess), firstVolatilityFactor_(firstVolatilityFactor), volFactorsPerStep_(volProcess->variatesPerStep()), numeraires_(numeraires), initialStep_(initialStep), isVolVariate_(false,volProcess->variatesPerStep()+marketModel_->numberOfFactors()), numberOfRates_(marketModel->numberOfRates()), numberOfFactors_(marketModel_->numberOfFactors()), curveState_(marketModel->evolution().rateTimes()), forwards_(marketModel->initialRates()), displacements_(marketModel->displacements()), logForwards_(numberOfRates_), initialLogForwards_(numberOfRates_), drifts1_(numberOfRates_), drifts2_(numberOfRates_), initialDrifts_(numberOfRates_), allBrownians_(volProcess->variatesPerStep()+marketModel_->numberOfFactors()), brownians_(numberOfFactors_), volBrownians_(volProcess->variatesPerStep()), correlatedBrownians_(numberOfRates_), alive_(marketModel->evolution().firstAliveRate()) { QL_REQUIRE(initialStep ==0, "initial step zero only supported currently. "); checkCompatibility(marketModel->evolution(), numeraires); Size steps = marketModel->evolution().numberOfSteps(); generator_ = factory.create(numberOfFactors_+volFactorsPerStep_, steps-initialStep_); currentStep_ = initialStep_; calculators_.reserve(steps); fixedDrifts_.reserve(steps); for (Size j=0; j<steps; ++j) { const Matrix& A = marketModel_->pseudoRoot(j); calculators_.push_back( LMMDriftCalculator(A, displacements_, marketModel->evolution().rateTaus(), numeraires[j], alive_[j])); std::vector<Real> fixed(numberOfRates_); for (Size k=0; k<numberOfRates_; ++k) { Real variance = std::inner_product(A.row_begin(k), A.row_end(k), A.row_begin(k), 0.0); fixed[k] = -0.5*variance; } fixedDrifts_.push_back(fixed); } setForwards(marketModel_->initialRates()); Size variatesPerStep = numberOfFactors_+volFactorsPerStep_; firstVolatilityFactor_ = std::min(firstVolatilityFactor_,variatesPerStep - volFactorsPerStep_); Size volIncrement = (variatesPerStep - firstVolatilityFactor_)/volFactorsPerStep_; for (Size i=0; i < volFactorsPerStep_; ++i) isVolVariate_[firstVolatilityFactor_+i*volIncrement] = true; }
bool SidTuneWrite::setInfo (const SidTuneInfo &tuneInfo) { SidTuneInfo info = tuneInfo; // Lets verify some of the data if ((info.currentSong > info.songs) || (info.currentSong == 0) || (info.songs > SIDTUNE_MAX_SONGS) || (info.startSong == 0)) { m_info.statusString = txt_songNumberExceed; return false; } if (info.loadAddr == 0) { m_info.statusString = txt_badAddr; return false; } if (info.sidModel1 > SIDTUNE_COMPATIBILITY_BASIC) { m_info.statusString = txt_invalidCompatibility; return false; } if (info.clockSpeed > SIDTUNE_CLOCK_ANY) { m_info.statusString = txt_invalidClockSpeed; return false; } if (info.sidModel1 > SIDTUNE_SIDMODEL_ANY) { m_info.statusString = txt_invalidSidModel; return false; } if (info.sidModel2 > SIDTUNE_SIDMODEL_ANY) { m_info.statusString = txt_invalidSidModel; return false; } switch (info.songSpeed) { case SIDTUNE_SPEED_CIA_1A: switch (info.compatibility) { case SIDTUNE_COMPATIBILITY_R64: case SIDTUNE_COMPATIBILITY_BASIC: m_info.statusString = txt_vbiClockSpeed; return false; } break; case SIDTUNE_SPEED_VBI: break; default: m_info.statusString = txt_invalidSongSpeed; return false; } if (!resolveAddrs(info, 0)) { m_info.statusString = info.statusString; return false; } if (!checkRelocInfo(info)) { m_info.statusString = info.statusString; return false; } if (!checkCompatibility(info)) { m_info.statusString = info.statusString; return false; } m_info = info; for ( uint_least16_t sNum = 0; sNum < m_info.numberOfInfoStrings; sNum++ ) { m_info.infoString[sNum] = infoString[sNum]; for ( uint_least16_t sPos = 0; sPos < SIDTUNE_MAX_CREDIT_STRLEN; sPos++ ) infoString[sNum][sPos] = info.infoString[sNum][sPos]; } for ( uint_least16_t sNum = m_info.numberOfInfoStrings; sNum < SIDTUNE_MAX_CREDIT_STRINGS; sNum++ ) { m_info.infoString[sNum] = infoString[sNum]; for ( uint_least16_t sPos = 0; sPos < SIDTUNE_MAX_CREDIT_STRLEN; sPos++ ) infoString[sNum][sPos] = '\0'; } songSpeed[m_info.currentSong-1] = m_info.songSpeed; return true; }