void GfxFeatureMapRequestPacket::printPacket() const { cout << "GfxFeatureMapRequestPacket::printPacket() for map " << getMapID() << endl; cout << "Bounding box for the GfxFeatureMapRequestPacket:" << endl; MC2BoundingBox bbox; getMC2BoundingBox(&bbox); bbox.dump(); uint16 x, y; getScreenSize(x, y); cout << "Screen size (x = " << x << ", y = " << y << ")" << endl; cout << "max scaleLevel = " << getMaxScaleLevel() << endl; cout << "min scaleLevel = " << getMinScaleLevel() << endl; cout << "filt scaleLevel = " << getFiltScaleLevel() << endl; cout << "language = " << (int)getLanguage() << endl; cout << "nbrNodeIDs " << getNbrNodeIDs() << endl; cout << " isStartAndEnd byte 0x" << hex << int( readByte(isStartAndEnd_POS)) << dec << endl; cout << "IgnoreStartOffset " << BP(getIgnoreStartOffset()) << endl; cout << " isStartAndEnd byte 0x" << hex << int(readByte(isStartAndEnd_POS)) << dec << endl; cout << "IgnoreEndOffset " << BP(getIgnoreEndOffset()) << endl; cout << "StartOffset " << getStartOffset() << endl; cout << "EndOffset " << getEndOffset() << endl; cout << "NbrReqPackets " << int(getNbrReqPackets()) << endl; cout << "DrawOverviewContents " << BP(getDrawOverviewContents()) << endl; }
void findSplitCommon( std::string const & filename, uint64_t const low, uint64_t const high, int64_t middle = -1 ) { if ( middle < 0 ) middle = (high+low)/2; // uint64_t const p = n/2; uint64_t const n = high-low; uint64_t const m = high-middle; std::ifstream istrn(filename.c_str(),std::ios::binary); istrn.seekg(low); std::ifstream istrm(filename.c_str(),std::ios::binary); istrm.seekg(middle); // dynamically growing best prefix table ::libmaus::util::KMP::BestPrefix<std::istream> BP(istrm,m); // adapter for accessing pattern in BP ::libmaus::util::KMP::BestPrefix<std::istream>::BestPrefixXAdapter xadapter = BP.getXAdapter(); // call KMP adaption std::pair<uint64_t, uint64_t> Q = ::libmaus::util::KMP::PREFIX_SEARCH_INTERNAL_RESTRICTED(xadapter,m,BP,istrn,n,n-m); uint64_t const showlen = std::min(Q.second,static_cast<uint64_t>(20)); std::cerr << "low=" << low << " Q.second=" << Q.second << " Q.first=" << Q.first << " middle=" << middle << " m=" << m << " pref=" << std::string(BP.x.begin(),BP.x.begin()+showlen) << std::endl; }
void testSimpleDynamic() { std::string const needle = "needlene"; std::string const haystack = "find the need in the haystack"; std::pair<uint64_t, uint64_t> P = ::libmaus::util::KMP::PREFIX_SEARCH( needle.begin(),needle.size(), haystack.begin(),haystack.size()); std::cerr << "result: " << haystack.substr(P.first,P.second) << std::endl; std::istringstream needlestr(needle); ::libmaus::util::KMP::BestPrefix<std::istream> BP(needlestr,needle.size()); ::libmaus::util::KMP::BestPrefix<std::istream>::BestPrefixXAdapter xadapter = BP.getXAdapter(); for ( uint64_t i = 0; i < needle.size(); ++i ) std::cerr << xadapter[i]; std::cerr << std::endl; std::string const thestack = "somewhere in needleneedlene"; std::istringstream thestackstr(thestack); std::pair<uint64_t, uint64_t> Q = ::libmaus::util::KMP::PREFIX_SEARCH_INTERNAL_RESTRICTED(xadapter,needle.size(),BP,thestackstr,thestack.size(), thestack.size()-needle.size()); std::cerr << "Q result: " << thestack.substr(Q.first,Q.second) << " position " << Q.first << " of " << thestack.size() << " patlen " << needle.size() << std::endl; std::cerr << thestack << std::endl; std::cerr << "pre " << thestack.substr(0,Q.first) << std::endl; std::cerr << "suf " << thestack.substr(Q.first+Q.second) << std::endl; }
// Checks whether 3D points p lies inside or outside of the triangle ABC bool includePointTriangle(Vec3r& P, Vec3r& A, Vec3r& B, Vec3r& C) { Vec3r AB(B - A); Vec3r BC(C - B); Vec3r CA(A - C); Vec3r AP(P - A); Vec3r BP(P - B); Vec3r CP(P - C); Vec3r N(AB ^ BC); // triangle's normal N.normalize(); Vec3r J(AB ^ AP), K(BC ^ BP), L(CA ^ CP); J.normalize(); K.normalize(); L.normalize(); if(J * N < 0) return false; // on the right of AB if(K * N < 0) return false; // on the right of BC if(L * N < 0) return false; // on the right of CA return true; }
void uvm_ml_run_test(const std::vector<std::string>& tops, const char * test, const sc_time & duration) { int top_n = tops.size(); const char ** local_tops = new const char*[top_n]; for (int i = 0; i < top_n; ++i) { local_tops[i] = tops[i].c_str(); } BP(run_test)(framework_id, top_n, const_cast<char**>(local_tops), const_cast<char*>(test)); delete[] local_tops; sc_simcontext * context = sc_get_curr_simcontext(); context->co_simulate(duration); }
bool GP32FilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { assert(_isDirectory); GPDIRENTRY dirEntry; GPFILEATTR attr; GP32FilesystemNode entry; uint32 read; if (mode == FilesystemNode::kListAll) LP("listDir(kListAll)"); else LP("listDir(kListDirectoriesOnly)"); int startIdx = 0; // current file String listDir(_path); //listDir += "/"; while (GpDirEnumList(listDir.c_str(), startIdx++, 1, &dirEntry, &read) == SM_OK) { if (dirEntry.name[0] == '.') continue; entry._displayName = dirEntry.name; entry._path = _path; entry._path += dirEntry.name; GpFileAttr(entry._path.c_str(), &attr); entry._isDirectory = attr.attr & (1 << 4); // Honor the chosen mode if ((mode == FilesystemNode::kListFilesOnly && entry._isDirectory) || (mode == FilesystemNode::kListDirectoriesOnly && !entry._isDirectory)) continue; if (entry._isDirectory) entry._path += "\\"; myList.push_back(new GP32FilesystemNode(entry)); } BP("Dir... %s", listDir.c_str()); return true; }
MyRoom::MyRoom(Server *server):QObject() { backEngine = new BackgroundEngine(); testUI = new TestUIex(NULL); this->serverModule = server; engineThr = new MyThread; backEngine->moveToThread(engineThr); engineThr->start(); //connect(backEngine,SIGNAL(askForActSIG(QList<CardEntity*>,int)),testUI,SLOT(actSLOT(QList<CardEntity*>,int))); //connect(backEngine,SIGNAL(askForReply(QList<CardEntity*>,QString,int)),testUI,SLOT(replySLOT(QList<CardEntity*>,QString,int))); //connect(backEngine,SIGNAL(askForHeal(int,int)),testUI,SLOT(healSLOT(int,int))); connect(backEngine,SIGNAL(toInforDisplay(QString)),testUI,SLOT(toDisplay(QString))); connect(serverModule,SIGNAL(seatArrangeSIG()),backEngine,SLOT(seatArrange())); connect(serverModule,SIGNAL(seatPrearrangeSIG(int,int,QString)),backEngine,SLOT(seatPrearrange(int,int,QString))); connect(this->serverModule,SIGNAL(toDisplay(QString)),this->testUI,SLOT(toDisplay(QString))); connect(backEngine,SIGNAL(sendMessageSIG(int,QString)),this->serverModule,SLOT(sendMessage(int,QString))); connect(&coder,SIGNAL(sendMessage(int,QString)),this->serverModule,SLOT(sendMessage(int,QString))); switch(serverModule->getRoleStrategy()) { case 0: connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine,SLOT(roleRandom())); break; case 1: connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine,SLOT(role3Pick1())); connect(serverModule,SIGNAL(role3Pick1ReplySIG(int,int)),backEngine,SLOT(role3Pick1Reply(int,int))); connect(serverModule,SIGNAL(gameStartSIG()),this->backEngine,SLOT(gameStart())); connect(this->serverModule,SIGNAL(roleNoticeSIG()),backEngine,SLOT(seatPostarrange())); break; case 2: connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine, SLOT(BP())); } // emit this->serverModule->toDisplayPublic("server IP:" + this->serverModule->serverAddress().toString()); emit this->serverModule->toDisplayPublic("server port:" + QString::number(this->serverModule->serverPort())); }
GP32FilesystemNode::GP32FilesystemNode(const String &path) { const char *dsplName = NULL, *pos = NULL; char convPath[256]; gpMakePath(path.c_str(), convPath); _path = convPath; pos = convPath; while (*pos) if (*pos++ == '\\') dsplName = pos; BP("FS: path name: %s", path.c_str()); if (strcmp(path.c_str(), "gp:\\") == 0) { _isRoot = true; _displayName = "GP32 Root"; } else { _displayName = String(dsplName); } _isDirectory = true; }
bool Triangle::Intersects(const a2de::Vector2D& position) const { Vector3D A(GetPointA().GetX(), GetPointA().GetY()); Vector3D B(GetPointB().GetX(), GetPointB().GetY()); Vector3D C(GetPointC().GetX(), GetPointC().GetY()); Vector3D AB(A - B); Vector3D BC(B - C); Vector3D CA(C - A); Vector3D AP(A - position); Vector3D BP(B - position); Vector3D CP(C - position); Vector3D resultABAP(Vector3D::CrossProduct(AB, AP)); Vector3D resultBCBP(Vector3D::CrossProduct(BC, BP)); Vector3D resultCACP(Vector3D::CrossProduct(CA, CP)); bool resultPos = (resultABAP.GetZ() > 0.0) && (resultBCBP.GetZ() > 0.0) && (resultCACP.GetZ() > 0.0); bool resultZero = (Math::IsEqual(resultABAP.GetZ(), 0.0) && Math::IsEqual(resultBCBP.GetZ(), 0.0) && Math::IsEqual(resultCACP.GetZ(), 0.0)); bool resultNeg = (resultABAP.GetZ() < 0.0) && (resultBCBP.GetZ() < 0.0) && (resultCACP.GetZ() < 0.0); //bool isOn = point.IsOnLine(GetLineAB()) || point.IsOnLine(GetLineBC()) || point.IsOnLine(GetLineCA()); return (/*isOn ||*/ resultPos || resultZero || resultNeg); }
** Very few strings should be located here. Most strings are ** put in the compressed embedded boot image. That saves space, ** reduces tampering, and allows UTF8 encoding. See ../boot dir. ** ***********************************************************************/ #include "sys-core.h" #define BP (REBYTE*) const REBYTE Str_Banner[] = "REBOL 3 %d.%d.%d.%d.%d"; const char Str_REBOL[] = "REBOL"; const REBYTE * Str_Stack_Misaligned = { BP("!! Stack misaligned: %d") }; const REBYTE * const Crash_Msgs[] = { BP"REBOL System Error", BP"boot failure", BP"internal problem", BP"assertion failed", BP"invalid datatype %d", BP"unspecific", BP"\n\nProgram terminated abnormally.\nThis should never happen.\nPlease contact www.REBOL.com with details." }; const REBYTE * const Str_Dump[] = { BP"%s Series %x \"%s\": wide: %2d size: %6d bias: %d tail: %d rest: %d flags: %x" };
bool NavMapHandler::handleMap( UserItem* userItem, NavRequestPacket* req, NavReplyPacket* reply ) { if ( !checkExpectations( req->getParamBlock(), reply ) ) { return false; } bool ok = true; // The params const NParamBlock& params = req->getParamBlock(); NParamBlock& rparams = reply->getParamBlock(); // The user UserUser* user = userItem->getUser(); uint32 startTime = TimeUtility::getCurrentTime(); // Start parameter printing mc2log << info << "handleMap:"; StringTable::languageCode language = user->getLanguage(); if ( params.getParam( 6 ) ) { language = NavUtil::mc2LanguageCode( params.getParam( 6 )->getUint16() ); mc2log << " Lang " << StringTable::getString( StringTable::getLanguageAsStringCode( language ), StringTable::ENGLISH ); } // MapBoundingbox MC2BoundingBox mapBbox; if ( params.getParam( 1600 ) ) { MC2Coordinate topLeft( Nav2Coordinate( params.getParam( 1600 )->getInt32Array( 0 ), params.getParam( 1600 )->getInt32Array( 1 ) ) ); MC2Coordinate bottomRight( Nav2Coordinate( params.getParam( 1600 )->getInt32Array( 2 ), params.getParam( 1600 )->getInt32Array( 3 ) ) ); mapBbox.setMaxLat( topLeft.lat ); mapBbox.setMinLon( topLeft.lon ); mapBbox.setMinLat( bottomRight.lat ); mapBbox.setMaxLon( bottomRight.lon ); mc2log << " MapBoundingbox " << mapBbox; } MC2Coordinate mapPos; if ( params.getParam( 1601 ) ) { mapPos = MC2Coordinate( Nav2Coordinate( params.getParam( 1601 )->getInt32Array( 0 ), params.getParam( 1601 )->getInt32Array( 1 ) ) ); mc2log << " MapPosition " << mapPos; } float32 speed = 666.999; if ( params.getParam( 1602 ) ) { if ( params.getParam( 1602 )->getUint16() < MAX_INT16 ) { speed = float32(params.getParam( 1602 )->getUint16())/32; mc2log << " speed " << speed; } else { mc2log << " speed N/A"; } } uint16 heading = MAX_UINT16; if ( params.getParam( 1603 ) ) { if ( params.getParam( 1603 )->getUint16() < 256 ) { heading = uint16( rint( params.getParam( 1603 )->getUint16() * 360.0 / 256.0 ) ); mc2log << " heading " << heading << "°"; } else { mc2log << " heading N/A"; } } uint32 mapRadius = MAX_UINT32; if ( params.getParam( 1604 ) ) { mapRadius = params.getParam( 1604 )->getUint32(); mc2log << " Map radius " << mapRadius; } MC2String routeIDStr; RouteID routeID( 0, 0 ); if ( params.getParam( 1605 ) ) { routeIDStr = params.getParam( 1605 )->getString( m_thread->clientUsesLatin1()); routeID = RouteID( routeIDStr.c_str() ); mc2log << " routeID " << routeIDStr; if ( routeID.isValid() == 0 ) { mc2log << " INVALID"; } } uint16 imageWidth = 160; uint16 imageHeight = 120; if ( params.getParam( 1606 ) ) { imageWidth = params.getParam( 1606 )->getUint16Array( 0 ); imageHeight = params.getParam( 1606 )->getUint16Array( 1 ); mc2log << " imageSize " << imageWidth << "," << imageHeight; } if ( params.getParam( 1607 ) ) { mc2log << " imageVbox " << params.getParam( 1607 )->getUint16Array( 0 ) << "," << params.getParam( 1607 )->getUint16Array( 1 ); } ImageDrawConfig::imageFormat imageFormat = ImageDrawConfig::GIF; if ( params.getParam( 1608 ) ) { // Image Format imageFormat = navImgFmtToMC2( params.getParam( 1608 )->getByte() ); mc2log << " imageFormat " << ImageDrawConfig::getImageFormatAsString( imageFormat); } vector< pair<MC2Coordinate, uint16 > > mapItems; if ( params.getParam( 1609 ) ) { vector< const NParam* > pmapItems; params.getAllParams( 1609, pmapItems ); for ( uint32 i = 0 ; i < pmapItems.size() ; ++i ) { mapItems.push_back( make_pair( MC2Coordinate( Nav2Coordinate( pmapItems[ i ]->getInt32( 2 ), pmapItems[ i ]->getInt32( 6 ) ) ), pmapItems[ i ]->getUint16( 0 ) ) ); mc2log << " MapItem " << mapItems[ i ].first << "," << mapItems[ i ].second; } } MapSettings mapSettings; uint16 angle = 0; bool showMap = mapSettings.getShowMap(); bool showTopographMap = mapSettings.getShowTopographMap(); bool showPOI = mapSettings.getShowPOI(); bool showRoute = mapSettings.getShowRoute(); if ( params.getParam( 1610 ) ) { vector< const NParam* > pmapInfos; params.getAllParams( 1610, pmapInfos ); for ( uint32 i = 0 ; i < pmapInfos.size() ; ++i ) { uint16 type = pmapInfos[ i ]->getUint16( 0 ); uint32 value = pmapInfos[ i ]->getUint32( 2 ); mc2log << " mapInfo "; switch ( type ) { case 0 : mc2log << "Invalid " << value; break; case 1 : mc2log << "Category " << value; break; case 2 : mapSettings.setShowTraffic( value != 0 ); mc2log << "TrafficInformation " << BP(value); break; case 3 : mapSettings.setDrawScale( value != 0 ); mc2log << "Scale " << BP(value); break; case 4 : showTopographMap = value != 0; mc2log << "Topographic " << BP(value); break; case 5 : mc2log << "MapFormat " << value; break; case 6 : angle = uint16( rint( 360.0 / 256.0 * value ) ); mc2log << "Rotate " << angle; break; } } mapSettings.setMapContent( showMap, showTopographMap, showPOI, showRoute ); } const ClientSetting* clientSetting = m_thread->getClientSetting(); if ( clientSetting != NULL ) { mapSettings.setImageSet( clientSetting->getImageSet() ); } mc2log << endl; // Get AURA set< uint32 >* allowedMaps = NULL; if ( ok ) { if ( !m_thread->getMapIdsForUserRegionAccess( user, allowedMaps ) ) { ok = false; mc2log << warn << "handleMap: getMapIdsForUserRegionAccess" << " failed. Error: "; if ( TimeUtility::getCurrentTime() - startTime > 3000 ) { reply->setStatusCode( NavReplyPacket::NAV_STATUS_REQUEST_TIMEOUT ); mc2log << "Timeout"; } else { reply->setStatusCode( NavReplyPacket::NAV_STATUS_NOT_OK ); mc2log << "Error"; } mc2log << endl; } } // Store user position?? (mapPos) // Get Route ExpandRouteRequest* expReq = NULL; PacketContainer* expandRouteCont = NULL; RouteReplyPacket* routePack = NULL; if ( ok && routeID.isValid() != 0 ) { uint32 expandType = (ROUTE_TYPE_STRING | ROUTE_TYPE_NAVIGATOR | ROUTE_TYPE_ITEM_STRING | ROUTE_TYPE_GFX); routePack = m_thread->getStoredRouteAndExpand( routeID, expandType, language, false/*abbreviate*/, false/*landmarks*/, true/*removeAheadIfDiff*/, false/*nameChangeAsWP*/, expReq, expandRouteCont ); if ( routePack == NULL || expReq == NULL || expandRouteCont == NULL ) { mc2log << warn << "handleMap: getStoredRouteAndExpand failed "; if ( TimeUtility::getCurrentTime() - startTime > 3000 ) { mc2log << "Timeout"; } else { // No such route? mc2log << "Error"; } mc2log << endl; } } // End if ok to get stored route // Make Map bbox MC2BoundingBox bbox; MC2String inputDebitStr; char tmpStr[ 256 ]; if ( ok ) { // Boundingbox -- A complete bounding box. if ( mapBbox.isValid() ) { bbox = mapBbox; inputDebitStr = "BoundingBox [("; sprintf( tmpStr, "%d", mapBbox.getMaxLat() ); inputDebitStr.append( tmpStr ); inputDebitStr.append( "," ); sprintf( tmpStr, "%d", mapBbox.getMinLon() ); inputDebitStr.append( tmpStr ); inputDebitStr.append( "),(" ); sprintf( tmpStr, "%d", mapBbox.getMinLat() ); inputDebitStr.append( tmpStr ); inputDebitStr.append( "," ); sprintf( tmpStr, "%d", mapBbox.getMaxLon() ); inputDebitStr.append( tmpStr ); inputDebitStr.append( ")]" ); mc2log << info << "handleMap: Boundingbox " << bbox << endl; } // VectorBox -- The bounding box will be calculated from the // current position, heading, speed and Route ID. else if ( mapPos.isValid() && speed < 500 && heading != MAX_UINT16 ) { bbox = m_mapHelp->handleNavMapVectorBox( mapRadius, uint16(rint(speed*32)), mapPos, heading, expandRouteCont ); inputDebitStr = "VectorBox Coord ("; sprintf( tmpStr, "%d", mapPos.lat ); inputDebitStr.append( tmpStr ); inputDebitStr.append( "," ); sprintf( tmpStr, "%d", mapPos.lon ); inputDebitStr.append( tmpStr ); inputDebitStr.append( ") speed " ); sprintf( tmpStr, "%hu", uint16(rint(speed*32)) ); inputDebitStr.append( tmpStr ); inputDebitStr.append( " hdg " ); sprintf( tmpStr, "%hu", heading ); inputDebitStr.append( tmpStr ); inputDebitStr.append( " radius " ); sprintf( tmpStr, "%hu", mapRadius ); inputDebitStr.append( tmpStr ); mc2log << info << "handleMap: VectorBox " << bbox << endl; } // RadiusBox -- The bounding box will contain a circle // centered on the current position and with the // specified map radius. else if ( mapPos.isValid() ) { uint32 posSize = 60000; if ( mapRadius != 0 && mapRadius < 100000000 ) { // Not less than 100m posSize = uint32( rint( GfxConstants::METER_TO_MC2SCALE * MAX( 100, mapRadius ) ) ); } bbox.setMaxLat( mapPos.lat + posSize ); bbox.setMinLon( mapPos.lon - posSize ); bbox.setMinLat( mapPos.lat - posSize ); bbox.setMaxLon( mapPos.lon + posSize ); inputDebitStr = "RadiusBox Coord (" ; sprintf( tmpStr, "%d", mapPos.lat ); inputDebitStr.append( tmpStr ); inputDebitStr.append( "," ); sprintf( tmpStr, "%d", mapPos.lon ); inputDebitStr.append( tmpStr ); inputDebitStr.append( ") radius " ); sprintf( tmpStr, "%hu", mapRadius ); inputDebitStr.append( tmpStr ); mc2log << info << "handleMap: RadiusBox " << bbox << endl; } // RouteBox -- The bounding box will contain the entire route // specified by the Route ID. else if ( routeID.isValid() != 0 ) { if ( expandRouteCont != NULL && static_cast<ReplyPacket*>(expandRouteCont->getPacket() ) ->getStatus() == StringTable::OK ) { ExpandRouteReplyPacket* expand = static_cast< ExpandRouteReplyPacket* > ( expandRouteCont->getPacket() ); ExpandItemID* exp = expand->getItemID(); ExpandStringItem** stringItems = expand->getStringDataItem(); uint32 numStringItems = expand->getNumStringData(); int32 minLat = 0; int32 maxLat = 0; int32 minLon = 0; int32 maxLon = 0; // uint16 angle = 0; // FullRoute HttpUtility::getRouteMC2BoundingBox( expand, exp, 0, numStringItems - 1, minLat, maxLat, minLon, maxLon ); // Set bbox bbox.setMaxLat( maxLat ); bbox.setMinLon( minLon ); bbox.setMinLat( minLat ); bbox.setMaxLon( maxLon ); inputDebitStr = "RouteBox "; sprintf( tmpStr, "%u", routeID.getRouteIDNbr() ); inputDebitStr.append( tmpStr ); inputDebitStr.append( "," ); sprintf( tmpStr, "%u", routeID.getCreationTime() ); inputDebitStr.append( tmpStr ); mc2log << info << "handleMap: RouteBox " << bbox << endl; delete exp; for ( uint32 i = 0 ; i < numStringItems ; ++i ) { delete stringItems[ i ]; } delete [] stringItems; } else { // Error route specified but now available. ok = false; mc2log << warn << "handleMap: Have routeID but not route: "; if ( TimeUtility::getCurrentTime() - startTime > 3000 ) { reply->setStatusCode( NavReplyPacket::NAV_STATUS_REQUEST_TIMEOUT ); mc2log << "Timeout"; } else { if ( routePack != NULL ) { // Expansion failed reply->setStatusCode( NavReplyPacket::NAV_STATUS_NOT_OK ); mc2log << "Expansion failed"; } else { // No such route reply->setStatusCode( NavReplyPacket::NAV_STATUS_PARAMETER_INVALID ); reply->setStatusMessage( "RouteID not valid" ); mc2log << "RouteID not valid"; } } mc2log << endl; } } // Nothing to make map with, send error else { mc2log << warn << "handleMap: Nothing to make map with." << endl; reply->setStatusCode( NavReplyPacket::NAV_STATUS_MISSING_PARAMETER ); reply->setStatusMessage( "Nothing to make map with" ); ok = false; } if ( ok && bbox.isValid() ) { // Make sure that the bbox is proportional with the width, height int32 lla = bbox.getMinLat(); int32 llo = bbox.getMinLon(); int32 ula = bbox.getMaxLat(); int32 ulo = bbox.getMaxLon(); uint16 w = imageWidth; uint16 h = imageHeight; GfxUtility::getDisplaySizeFromBoundingbox( lla, llo, ula, ulo, w, h ); // Set bbox bbox.setMaxLat( ula ); bbox.setMinLon( llo ); bbox.setMinLat( lla ); bbox.setMaxLon( ulo ); // This is nessesary! bbox.updateCosLat(); // Make real request! uint32 size = imageWidth * imageHeight / 8 + 4096; MC2BoundingBox ccBBox; GfxFeatureMapImageRequest* gfxReq = new GfxFeatureMapImageRequest( m_thread->getNextRequestID(), &bbox, imageWidth, imageHeight, ItemTypes::getLanguageCodeAsLanguageType( language ), routePack, true, true, true,/*drawCopyRight*/ imageFormat, size, &mapSettings, m_thread->getTopRegionRequest(), ccBBox ); for ( uint32 i = 0 ; i < mapItems.size() ; ++i ) { const char* symbolImage = ""; GfxSymbolFeature::symbols symbolType = GfxSymbolFeature::PIN; gfxReq->addSymbolToMap( mapItems[ i ].first.lat, mapItems[ i ].first.lon, "", symbolType, symbolImage ); } gfxReq->setMapRotation( angle ); // Limit map area gfxReq->setAllowedMaps( allowedMaps ); // Wait for the answer m_thread->putRequest( gfxReq ); PacketContainer* gfxReqAnswer = gfxReq->getAnswer(); if ( gfxReqAnswer == NULL || StringTable::stringCode( static_cast<ReplyPacket*>( gfxReqAnswer->getPacket() )->getStatus() ) != StringTable::OK ) { // Error if ( gfxReqAnswer == NULL ) { mc2log << warn << "handleMap: " << " gfxReq NULL answer: "; if ( TimeUtility::getCurrentTime() - startTime > 3000 ) { reply->setStatusCode( NavReplyPacket::NAV_STATUS_REQUEST_TIMEOUT ); mc2log << "Timeout"; } else { reply->setStatusCode( NavReplyPacket::NAV_STATUS_NOT_OK ); mc2log << "Error"; } mc2log << endl; } else { if ( StringTable::stringCode( static_cast<ReplyPacket*>( gfxReqAnswer ->getPacket() )->getStatus() ) == StringTable::TIMEOUT_ERROR ) { mc2log << warn << "handleMap: " << " gfxReq timed out status." << endl; reply->setStatusCode( NavReplyPacket::NAV_STATUS_REQUEST_TIMEOUT ); } else { StringTable::stringCode errCode = StringTable::stringCode( static_cast<ReplyPacket*>( gfxReqAnswer->getPacket() ) ->getStatus() ); mc2log << warn << "handleMap: " << " gfxReq not ok \"" << StringTable::getString( errCode, StringTable::ENGLISH ) << "\" (" << int(errCode) << ")" << endl; reply->setStatusCode( NavReplyPacket::NAV_STATUS_NOT_OK ); } } } else { uint32 size = static_cast< GfxFeatureMapImageReplyPacket* >( gfxReqAnswer->getPacket() )->getSize(); byte* imageBuff = static_cast< GfxFeatureMapImageReplyPacket* > ( gfxReqAnswer->getPacket() )->getImageData(); mc2log << info << "handleMap: " << "reply: map size " << size << " bytes Boundingbox: " << bbox << endl; // Set reply data // MapBoundingbox NParam& pbbox = rparams.addParam( NParam( 1700 ) ); Nav2Coordinate topLeft( MC2Coordinate( bbox.getMaxLat(), bbox.getMinLon() ) ); Nav2Coordinate bottomRight( MC2Coordinate( bbox.getMinLat(), bbox.getMaxLon() ) ); pbbox.addInt32( topLeft.nav2lat ); pbbox.addInt32( topLeft.nav2lon ); pbbox.addInt32( bottomRight.nav2lat ); pbbox.addInt32( bottomRight.nav2lon ); // Image size NParam& piwh = rparams.addParam( NParam( 1701 ) ); piwh.addUint16( imageWidth ); piwh.addUint16( imageHeight ); // Real world size uint32 widthInMeters = uint32( rint( GfxConstants::MC2SCALE_TO_METER * ( bbox.getMaxLon() - bbox.getMinLon() ) * GfxUtility::getCoslat( bbox.getMinLat(), bbox.getMaxLat() ) ) ); uint32 heightInMeters = uint32( rint( GfxConstants::MC2SCALE_TO_METER * ( bbox.getMaxLat() - bbox.getMinLat() ) ) ); NParam& prwh = rparams.addParam( NParam( 1702 ) ); prwh.addUint32( widthInMeters ); prwh.addUint32( heightInMeters ); // Image Format rparams.addParam( NParam( 1703, mc2ImgFmtToNav( imageFormat ) ) ); // Image NParam& pimage = rparams.addParam( NParam( 1704 ) ); pimage.addByteArray( imageBuff, size ); // Checkpoint for VectorMap with route following // 1705 // Debit MC2Coordinate posCoord = MC2Coordinate::invalidCoordinate; if ( mapItems.size() > 0 ) { posCoord = mapItems[ 0 ].first; } MC2String extraInfo = m_userHelp->makeExtraUserInfoStr( params ); // Set debitamount here untill module sets it ok uint32 debitAmount = TimeUtility::getCurrentTime() - startTime; if ( !m_thread->getDebitHandler()->makeMapDebit( userItem, extraInfo.c_str(), size, debitAmount, bbox, inputDebitStr.c_str(), imageWidth, imageHeight, true, imageFormat, routeID.getRouteIDNbr(), routeID.getCreationTime(), mapSettings.getShowMap(), mapSettings.getShowPOI(), mapSettings.getShowTopographMap(), mapSettings.getShowRoute(), mapSettings.getShowTraffic(), posCoord ) ) { mc2log << warn << "handleMap: failed to debit Map." << endl; } delete [] imageBuff; } delete gfxReqAnswer; delete gfxReq; } // End if ok to make gfx request } // End if ok to make map delete allowedMaps; delete expReq; delete expandRouteCont; delete routePack; return ok; }
int main(int argc, char * argv[]) { try { testBorderArray(); testSuccinctBorderArray(); ::libmaus::util::ArgInfo const arginfo(argc,argv); std::string const fn = arginfo.getRestArg<std::string>(0); // std::string const fn = "1"; uint64_t const n = ::libmaus::util::GetFileSize::getFileSize(fn); uint64_t const tpacks = 128; uint64_t const packsize = (n+tpacks-1)/tpacks; uint64_t const packs = (n + packsize-1)/packsize; #if 0 && defined(_OPENMP) #pragma omp parallel for #endif for ( uint64_t i = 0; i < packs; ++i ) { uint64_t const low = std::min(i * packsize,n); uint64_t const high = std::min(low+packsize,n); findSplitCommon(fn,low,high); } } catch(std::exception const & ex) { std::cerr << ex.what() << std::endl; return EXIT_FAILURE; } #if 0 std::string const fn = "X"; uint64_t const n = ::libmaus::util::GetFileSize::getFileSize(fn); uint64_t const p = n/2; uint64_t const m = n-p; std::ifstream istrn(fn.c_str(),std::ios::binary); std::ifstream istrm(fn.c_str(),std::ios::binary); istrm.seekg(p); ::libmaus::util::KMP::BestPrefix<std::istream> BP(istrm,m); ::libmaus::util::KMP::BestPrefix<std::istream>::BestPrefixXAdapter xadapter = BP.getXAdapter(); std::pair<uint64_t, uint64_t> Q = ::libmaus::util::KMP::PREFIX_SEARCH_INTERNAL_RESTRICTED( xadapter,m,BP, istrn,n, n-m ); uint64_t const printmax = 30; if ( Q.second <= printmax ) std::cerr << "pos " << Q.first << " len " << Q.second << " p=" << p << " m=" << m << " common prefix " << std::string(BP.x.begin(),BP.x.begin()+Q.second) << std::endl; else std::cerr << "pos " << Q.first << " len " << Q.second << " p=" << p << " m=" << m << " common length " << Q.second << std::endl; istrn.clear(); istrn.seekg(Q.first); istrm.clear(); istrm.seekg(p); for ( uint64_t i = 0; i < Q.second /* std::min(Q.second, static_cast<uint64_t>(20)) */; ++i ) { int const cn = istrn.get(); int const cm = istrm.get(); assert ( cn == cm ); //std::cerr.put(cn); //std::cerr.put(cm); } // std::cerr << std::endl; int const cn = istrn.get(); int const cm = istrm.get(); assert ( (cn < 0 && cm < 0) || (cn != cm) ); if ( Q.second+1 <= m ) { istrm.clear(); istrm.seekg(p); ::libmaus::autoarray::AutoArray<char> cs(Q.second+1); istrm.read(cs.begin(),cs.size()); std::string s(cs.begin(),cs.begin()+cs.size()); if ( Q.second <= printmax ) std::cerr << "extending common prefix by next character in pattern: " << s << std::endl; istrn.clear(); istrn.seekg(0); ::libmaus::autoarray::AutoArray<char> cc(n); istrn.read(cc.begin(),n); std::string t(cc.begin(),cc.begin()+cc.size()); size_t pos = 0; while ( pos != std::string::npos ) { pos = t.find(s,pos); if ( pos != std::string::npos ) { std::cerr << "found " << pos << std::endl; pos += 1; } } } return 0; testLazyFailureFunctionRandom("abaabaababaabab"); testLazyFailureFunctionRandom("alabar_a_la_alabarda"); #endif }
double Math::Triangle::distance(const Point2D& p, Point2D* closestPoint) { //Source is: http://wonderfl.net/c/b27F Vector2D AB(_b.x - _a.x, _b.y - _a.y); Vector2D AP(p.x - _a.x, p.y - _a.y); double ABXAP = (AB.x * AP.y) - (AB.y * AP.x); Vector2D BC(_c.x - _b.x, _c.y - _b.y); Vector2D BP(p.x - _b.x, p.y - _b.y); double BCXBP = (BC.x * BP.y) - (BC.y * BP.x); Vector2D CA(_a.x - _c.x, _a.y - _c.y); Vector2D CP(p.x - _c.x, p.y - _c.y); double CAXCP = (CA.x * CP.y) - (CA.y * CP.x); double distance = 0; //+++ //inside if (ABXAP >= 0 && BCXBP >= 0 && CAXCP >=0) { if(closestPoint) { closestPoint->x = p.x; closestPoint->y = p.y; } } //-+- //vertex else if (ABXAP < 0 && BCXBP >= 0 && CAXCP < 0) { distance = AP.x * AP.x + AP.y * AP.y; if(closestPoint) { closestPoint->x = _a.x; closestPoint->y = _a.y; } } //--+ //vertex else if (ABXAP < 0 && BCXBP < 0 && CAXCP >= 0) { distance = BP.x * BP.x + BP.y * BP.y; if(closestPoint) { closestPoint->x = _b.x; closestPoint->y = _b.y; } } //+-- //vertex else if (ABXAP >= 0 && BCXBP < 0 && CAXCP < 0) { distance = CP.x * CP.x + CP.y * CP.y; if(closestPoint) { closestPoint->x = _c.x; closestPoint->y = _c.y; } } //-++ //edge else if (ABXAP < 0 && BCXBP >= 0 && CAXCP >= 0) { double wd = ((AB.x * AP.x) + (AB.y * AP.y) ) / ((AB.x * AB.x) + (AB.y * AB.y)); if (wd < 0) { wd = 0; } if (wd > 1) { wd = 1; } Point2D r; r.x = _a.x + (_b.x - _a.x) * wd; r.y = _a.y + (_b.y - _a.y) * wd; if (closestPoint) { closestPoint->x = r.x; closestPoint->y = r.y; } r.x = p.x - r.x; r.y = p.y - r.y; distance = r.x * r.x + r.y * r.y; } //+-+ //edge else if (ABXAP >= 0 && BCXBP < 0 && CAXCP >= 0) { double wd = ((BC.x * BP.x) + (BC.y * BP.y) ) / ((BC.x * BC.x) + (BC.y * BC.y)); if (wd < 0) { wd = 0; } if (wd > 1) { wd = 1; } Point2D r; r.x = _b.x + (_c.x - _b.x) * wd; r.y = _b.y + (_c.y - _b.y) * wd; if (closestPoint) { closestPoint->x = r.x; closestPoint->y = r.y; } r.x = p.x - r.x; r.y = p.y - r.y; distance = r.x * r.x + r.y * r.y; } //++- //edge else if (ABXAP >= 0 && BCXBP >= 0 && CAXCP < 0) { double wd = ((CA.x * CP.x) + (CA.y * CP.y) ) / ((CA.x * CA.x) + (CA.y * CA.y)); if (wd < 0) { wd = 0; } if (wd > 1) { wd = 1; } Point2D r; r.x = _c.x + (_a.x - _c.x) * wd; r.y = _c.y + (_a.y - _c.y) * wd; if (closestPoint) { closestPoint->x = r.x; closestPoint->y = r.y; } r.x = p.x - r.x; r.y = p.y - r.y; distance = r.x * r.x + r.y * r.y; } return distance; }
bool NavFavHandler::handleFav( UserItem* userItem, NavRequestPacket* req, NavReplyPacket* reply ) { if ( !checkExpectations( req->getParamBlock(), reply ) ) { return false; } bool ok = true; // The params const NParamBlock& params = req->getParamBlock(); NParamBlock& rparams = reply->getParamBlock(); // The user UserUser* user = userItem->getUser(); uint32 startTime = TimeUtility::getCurrentTime(); // Start parameter printing mc2log << info << "handleFav:"; mc2log << " Ver " << int(req->getReqVer()); StringTable::languageCode language = user->getLanguage(); if ( params.getParam( 6 ) ) { language = NavUtil::mc2LanguageCode( params.getParam( 6 )->getUint16() ); mc2log << " Lang " << StringTable::getString( StringTable::getLanguageAsStringCode( language ), StringTable::ENGLISH ); } bool noSync = false; UserFavoritesRequest* ureq = new UserFavoritesRequest( m_thread->getNextRequestID(), userItem->getUIN() ); if ( params.getParam( 4800 ) ) { noSync = BitUtility::getBit( params.getParam( 4800 )->getUint32(), 0 ); // Bit 1 fetchAutoDest not supported anymore 20051011 mc2log << " noSync " << BP(noSync); } if ( noSync ) { ureq->setNoSync(); } if ( params.getParam( 4801 ) ) { const NParam* pa = params.getParam( 4801 ); mc2log << " nbrSyncIds " << (pa->getLength() / 4); for ( uint16 i = 0 ; i < pa->getLength() / 4 ; ++i ) { ureq->addFavSync( pa->getUint32Array( i ) ); mc2dbg8 << " ID " << pa->getUint32Array( i ); } } if ( params.getParam( 4802 ) ) { const NParam* pd = params.getParam( 4802 ); mc2log << " nbrDelIds " << (pd->getLength() / 4); for ( uint16 i = 0 ; i < pd->getLength() / 4 ; ++i ) { ureq->addFavSync( pd->getUint32Array( i ) ); ureq->addFavDelete( pd->getUint32Array( i ) ); mc2dbg8 << " ID " << pd->getUint32Array( i ); } } if ( params.getParam( 4803 ) ) { const NParam* pa = params.getParam( 4803 ); uint32 pos = 0; uint32 nbrAdd = 0; while ( pos < pa->getLength() ) { pos += 4; // ID int32 navLat = pa->getUint32( pos ); pos += 4; int32 navLon = pa->getUint32( pos ); pos += 4; MC2Coordinate coord( Nav2Coordinate( navLat, navLon ) ); MC2String name = pa->incGetString( m_thread->clientUsesLatin1(), pos ); MC2String shortName = pa->incGetString( m_thread->clientUsesLatin1(), pos ); MC2String description = pa->incGetString( m_thread->clientUsesLatin1(), pos ); MC2String category = pa->incGetString( m_thread->clientUsesLatin1(), pos ); MC2String mapIconName = pa->incGetString( m_thread->clientUsesLatin1(), pos ); UserFavorite::InfoVect v; if ( req->getReqVer() > 1 ) { // reqVer 2+ // Read infos uint16 nbrInfos = pa->getUint16( pos ); pos += 2; ItemInfoEnums::InfoType type; MC2String key; MC2String val; for ( uint32 i = 0 ; i < nbrInfos ; ++i ) { type = NavInfoHandler::additionalInfoTypeToInfoType( pa->incGetUint16( pos ), req->getReqVer() > 3 ? 2 : 1 ); key = pa->incGetString( m_thread->clientUsesLatin1(), pos ); val = pa->incGetString( m_thread->clientUsesLatin1(), pos ); v.push_back( ItemInfoEntry( key, val, type ) ); } } ureq->addFavNew( new UserFavorite( 0, coord.lat, coord.lon, name.c_str(), shortName.c_str(), description.c_str(), category.c_str(), mapIconName.c_str(), v ) ); mc2dbg8 << " Coord " << coord << " name " << name << " shortName " << shortName << " description " << description << " category " << category << " mapIconName " << mapIconName; mc2dbg8 << " " << v.size() << " infos "; for ( UserFavorite::InfoVect::const_iterator it = v.begin() ; it != v.end() ; ++it ) { mc2dbg8 << " " << ItemInfoEnums::infoTypeToString( LangTypes::english, (*it).getInfoType() ) << ":" << (*it).getKey() << ":" << (*it).getVal() << ";"; } ++nbrAdd; } mc2log << " nbrAddFavs " << nbrAdd; } mc2log << endl; // XXX: Check if backup user // if ( !rd.backupUser ) { ... } else { status = NOT_ON_BACKUP_SERVER } m_thread->putRequest( ureq ); if ( ureq->getStatus() == StringTable::OK ) { mc2log << info << "handleFav: Reply"; const UserFavorite* fav = NULL; fav = ureq->getAddFav(); if ( fav != NULL ) { NParam pa( 4900 ); uint32 nbrAdd = 0; while ( fav != NULL ) { // Check if not to add this favorite bool locFav = false; uint32 decLen = strlen( fav->getDescription() ) + 1; char locUserID[ decLen ]; char locPIN[ decLen ]; if ( sscanf( fav->getDescription(), "LOC:%[^:\n]:%[^:\n]", locUserID, locPIN ) == 2 ) { // The temporary Locator favorites. locFav = true; } if ( req->getReqVer() == 1 && (fav->hasInfoType( ItemInfoEnums::special_flag) || locFav) ) { mc2dbg8 << " Skipping ID " << fav->getID(); fav = ureq->getAddFav(); continue; } if ( pa.getLength() + fav->getSize() + 4 > MAX_UINT16 ) { rparams.addParam( pa ); pa.clear(); } pa.addUint32( fav->getID() ); Nav2Coordinate coord( MC2Coordinate( fav->getLat(), fav->getLon() ) ); pa.addInt32( coord.nav2lat ); pa.addInt32( coord.nav2lon ); pa.addString( fav->getName(), m_thread->clientUsesLatin1() ); pa.addString( fav->getShortName(), m_thread->clientUsesLatin1() ); MC2String desc( fav->getDescription() ); if ( req->getReqVer() == 1 ) { // Add infos to description and cut at 255 bytes. for ( uint16 i = 0 ; i < fav->getInfos().size() ; ++i ) { if ( !desc.empty() ) { desc.append( ", " ); } desc.append( fav->getInfos()[ i ].getKey() ); desc.append( ": " ); desc.append( fav->getInfos()[ i ].getVal() ); } if ( desc.size() > 255 ) { desc.erase( 255 ); } } pa.addString( desc, m_thread->clientUsesLatin1() ); pa.addString( fav->getCategory(), m_thread->clientUsesLatin1() ); pa.addString( fav->getMapIconName(), m_thread->clientUsesLatin1() ); if ( req->getReqVer() > 1 ) { // reqVer 2+ // Write infos uint16 size = MIN( fav->getInfos().size() + (locFav ? 1 : 0), MAX_UINT16 ); pa.addUint16( size ); uint16 i = 0; // The temporary Locator favorites. if ( locFav ) { i = 1; pa.addUint16( ItemInfoEnums::special_flag ); pa.addString( "", m_thread->clientUsesLatin1() ); pa.addString( "", m_thread->clientUsesLatin1() ); } // Add fav infos for ( /**/ ; i < size ; ++i ) { pa.addUint16( fav->getInfos()[ i ].getInfoType() ); pa.addString( fav->getInfos()[ i ].getKey(), m_thread->clientUsesLatin1() ); pa.addString( fav->getInfos()[ i ].getVal(), m_thread->clientUsesLatin1() ); } } mc2dbg8<< " ID " << fav->getID() << " coord (" << fav->getLat() << "," << fav->getLon() << ")" << " name " << fav->getName() << " description " << desc << " category " << fav->getCategory() << " shortname " << fav->getShortName() << " mapiconname " << fav->getMapIconName(); if ( req->getReqVer() > 1 ) { // reqVer 2+ mc2dbg8 << " " << fav->getInfos().size() << " infos "; for ( UserFavorite::InfoVect::const_iterator it = fav->getInfos().begin() ; it != fav->getInfos().end() ; ++it ) { mc2dbg8 << ItemInfoEnums::infoTypeToString( LangTypes::english, (*it).getInfoType() ) << ":" << (*it).getKey() << ":" << (*it).getVal() << ";"; } } fav = ureq->getAddFav(); ++nbrAdd; } mc2log << " nbrFavAdd " << nbrAdd; rparams.addParam( pa ); } fav = ureq->getDelFav(); if ( fav != NULL ) { NParam& pd = rparams.addParam( NParam( 4901 ) ); uint32 nbrDel = 0; while ( fav != NULL ) { mc2dbg8 << " " << fav->getID(); pd.addUint32( fav->getID() ); fav = ureq->getDelFav(); ++nbrDel; } mc2log << " nbrFavDel " << nbrDel; } if ( req->getReqVer() > 2 ) { // 3+ MC2String crcStr; STLStringUtility::uint2strAsHex( m_thread->getUserHandler()-> getUserFavCRC( user->getUIN() ), crcStr ); mc2log << " crc " << crcStr; rparams.addParam( NParam( 4903, crcStr, m_thread->clientUsesLatin1() ) ); } mc2log << endl; } else { mc2log << warn << "handleFav: UserFavoritesRequest failed "; if ( ureq->getStatus() == StringTable::UNKNOWN && (TimeUtility::getCurrentTime() - startTime) > 3000 ) { reply->setStatusCode( NavReplyPacket::NAV_STATUS_REQUEST_TIMEOUT ); mc2log << "Timeout"; } else { reply->setStatusCode( NavReplyPacket::NAV_STATUS_NOT_OK ); mc2log << "Error"; } mc2log << endl; } delete ureq; return ok; }
/* Subroutine */ int dspgst_(integer *itype, char *uplo, integer *n, doublereal *ap, doublereal *bp, integer *info) { /* -- LAPACK routine (version 2.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University March 31, 1993 Purpose ======= DSPGST reduces a real symmetric-definite generalized eigenproblem to standard form, using packed storage. If ITYPE = 1, the problem is A*x = lambda*B*x, and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T) If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or B*A*x = lambda*x, and A is overwritten by U*A*U**T or L**T*A*L. B must have been previously factorized as U**T*U or L*L**T by DPPTRF. Arguments ========= ITYPE (input) INTEGER = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T); = 2 or 3: compute U*A*U**T or L**T*A*L. UPLO (input) CHARACTER = 'U': Upper triangle of A is stored and B is factored as U**T*U; = 'L': Lower triangle of A is stored and B is factored as L*L**T. N (input) INTEGER The order of the matrices A and B. N >= 0. AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) On entry, the upper or lower triangle of the symmetric matrix A, packed columnwise in a linear array. The j-th column of A is stored in the array AP as follows: if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. On exit, if INFO = 0, the transformed matrix, stored in the same format as A. BP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) The triangular factor from the Cholesky factorization of B, stored in the same format as A, as returned by DPPTRF. INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value ===================================================================== Test the input parameters. Parameter adjustments Function Body */ /* Table of constant values */ static integer c__1 = 1; static doublereal c_b9 = -1.; static doublereal c_b11 = 1.; /* System generated locals */ integer i__1, i__2; doublereal d__1; /* Local variables */ extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, integer *); extern /* Subroutine */ int dspr2_(char *, integer *, doublereal *, doublereal *, integer *, doublereal *, integer *, doublereal *); static integer j, k; extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, integer *); extern logical lsame_(char *, char *); extern /* Subroutine */ int daxpy_(integer *, doublereal *, doublereal *, integer *, doublereal *, integer *), dspmv_(char *, integer *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, doublereal *, integer *); static logical upper; static integer j1, k1; extern /* Subroutine */ int dtpmv_(char *, char *, char *, integer *, doublereal *, doublereal *, integer *), dtpsv_(char *, char *, char *, integer *, doublereal *, doublereal *, integer *); static integer jj, kk; static doublereal ct; extern /* Subroutine */ int xerbla_(char *, integer *); static doublereal ajj; static integer j1j1; static doublereal akk; static integer k1k1; static doublereal bjj, bkk; #define BP(I) bp[(I)-1] #define AP(I) ap[(I)-1] *info = 0; upper = lsame_(uplo, "U"); if (*itype < 1 || *itype > 3) { *info = -1; } else if (! upper && ! lsame_(uplo, "L")) { *info = -2; } else if (*n < 0) { *info = -3; } if (*info != 0) { i__1 = -(*info); xerbla_("DSPGST", &i__1); return 0; } if (*itype == 1) { if (upper) { /* Compute inv(U')*A*inv(U) J1 and JJ are the indices of A(1,j) and A(j,j) */ jj = 0; i__1 = *n; for (j = 1; j <= *n; ++j) { j1 = jj + 1; jj += j; /* Compute the j-th column of the upper triangle of A */ bjj = BP(jj); dtpsv_(uplo, "Transpose", "Nonunit", &j, &BP(1), &AP(j1), & c__1); i__2 = j - 1; dspmv_(uplo, &i__2, &c_b9, &AP(1), &BP(j1), &c__1, &c_b11, & AP(j1), &c__1); i__2 = j - 1; d__1 = 1. / bjj; dscal_(&i__2, &d__1, &AP(j1), &c__1); i__2 = j - 1; AP(jj) = (AP(jj) - ddot_(&i__2, &AP(j1), &c__1, &BP(j1), & c__1)) / bjj; /* L10: */ } } else { /* Compute inv(L)*A*inv(L') KK and K1K1 are the indices of A(k,k) and A(k+1,k+1) */ kk = 1; i__1 = *n; for (k = 1; k <= *n; ++k) { k1k1 = kk + *n - k + 1; /* Update the lower triangle of A(k:n,k:n) */ akk = AP(kk); bkk = BP(kk); /* Computing 2nd power */ d__1 = bkk; akk /= d__1 * d__1; AP(kk) = akk; if (k < *n) { i__2 = *n - k; d__1 = 1. / bkk; dscal_(&i__2, &d__1, &AP(kk + 1), &c__1); ct = akk * -.5; i__2 = *n - k; daxpy_(&i__2, &ct, &BP(kk + 1), &c__1, &AP(kk + 1), &c__1) ; i__2 = *n - k; dspr2_(uplo, &i__2, &c_b9, &AP(kk + 1), &c__1, &BP(kk + 1) , &c__1, &AP(k1k1)); i__2 = *n - k; daxpy_(&i__2, &ct, &BP(kk + 1), &c__1, &AP(kk + 1), &c__1) ; i__2 = *n - k; dtpsv_(uplo, "No transpose", "Non-unit", &i__2, &BP(k1k1), &AP(kk + 1), &c__1); } kk = k1k1; /* L20: */ } } } else { if (upper) { /* Compute U*A*U' K1 and KK are the indices of A(1,k) and A(k,k) */ kk = 0; i__1 = *n; for (k = 1; k <= *n; ++k) { k1 = kk + 1; kk += k; /* Update the upper triangle of A(1:k,1:k) */ akk = AP(kk); bkk = BP(kk); i__2 = k - 1; dtpmv_(uplo, "No transpose", "Non-unit", &i__2, &BP(1), &AP( k1), &c__1); ct = akk * .5; i__2 = k - 1; daxpy_(&i__2, &ct, &BP(k1), &c__1, &AP(k1), &c__1); i__2 = k - 1; dspr2_(uplo, &i__2, &c_b11, &AP(k1), &c__1, &BP(k1), &c__1, & AP(1)); i__2 = k - 1; daxpy_(&i__2, &ct, &BP(k1), &c__1, &AP(k1), &c__1); i__2 = k - 1; dscal_(&i__2, &bkk, &AP(k1), &c__1); /* Computing 2nd power */ d__1 = bkk; AP(kk) = akk * (d__1 * d__1); /* L30: */ } } else { /* Compute L'*A*L JJ and J1J1 are the indices of A(j,j) and A(j+1,j+1) */ jj = 1; i__1 = *n; for (j = 1; j <= *n; ++j) { j1j1 = jj + *n - j + 1; /* Compute the j-th column of the lower triangle of A */ ajj = AP(jj); bjj = BP(jj); i__2 = *n - j; AP(jj) = ajj * bjj + ddot_(&i__2, &AP(jj + 1), &c__1, &BP(jj + 1), &c__1); i__2 = *n - j; dscal_(&i__2, &bjj, &AP(jj + 1), &c__1); i__2 = *n - j; dspmv_(uplo, &i__2, &c_b11, &AP(j1j1), &BP(jj + 1), &c__1, & c_b11, &AP(jj + 1), &c__1); i__2 = *n - j + 1; dtpmv_(uplo, "Transpose", "Non-unit", &i__2, &BP(jj), &AP(jj), &c__1); jj = j1j1; /* L40: */ } } } return 0; /* End of DSPGST */ } /* dspgst_ */
void transmit_menu(void){ SPILCD_Clear(WHITE); Show_MenuTheme(); Show_TranMenuMode(1); Show_Select(); int as1=1; int tran_mode; buttonsPressed=0; while (!(buttonsPressed & BUTTON_S4)) { buttonsPressed = 0; int ai; for(ai=0;ai<30;ai++) { myDelay(); } if (buttonsPressed & BUTTON_S3) { Show_ButtonS3(); if(as1==4){ as1=1; Show_TranMenuMode(as1); }else{ if(as1==1){ as1=2; Show_TranMenuMode(as1); }else{ if(as1==2){ as1=3; Show_TranMenuMode(as1); }else{ if(as1==3){ as1=4; Show_TranMenuMode(as1); } } } } buttonsPressed=0; Show_Select(); } if (buttonsPressed & BUTTON_S2) { Show_ButtonS2(); if(as1==2){ as1=1; Show_TranMenuMode(as1); }else{ if(as1==1){ as1=4; Show_TranMenuMode(as1); }else{ if(as1==4){ as1=3; Show_TranMenuMode(as1); }else{ if(as1==3){ as1=2; Show_TranMenuMode(as1); } } } } buttonsPressed=0; Show_Select(); } if (buttonsPressed & BUTTON_S1) { Show_ButtonS1(); if(as1==1){ tran_mode=1; tran_mode_SP=1; } if(as1==2){ tran_mode=2; tran_mode_SP=2; } if(as1==3){ tran_mode=3; tran_mode_SP=3; } if(as1==4){ tran_mode=4; tran_mode_SP=4; } if(menu_select==1){ UCA0IE &= ~UCRXIE; HR(tran_mode); menu_select=1; } if(menu_select==2){ BP(tran_mode); menu_select=2; } if(menu_select==3){ SPO2H(tran_mode); menu_select=3; } if(menu_select==4){ ACCELMENU(tran_mode); menu_select=4; } as1=1; tran_mode=1; buttonsPressed=0; BUTTON_S4=0; SPILCD_Clear(WHITE); Show_MenuTheme(); Show_TranMenuMode(1); Show_Select(); } } if(buttonsPressed & BUTTON_S4){ Show_ButtonS4(); } }