static void CALLBACK Paint(void) { glViewport(0,0,windW,windH); glDisable(GL_SCISSOR_TEST); glPushAttrib(GL_COLOR_BUFFER_BIT); glColorMask(1,1,1,1); glIndexMask((GLuint)~0); glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glPopAttrib(); if(mode1)glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); if(mode2)glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); else glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); Viewport(0,0); Point(); Viewport(0,1); Lines(); Viewport(0,2); LineStrip(); Viewport(0,3); LineLoop(); Viewport(1,0); Bitmap(); Viewport(1,1); TriangleFan(); Viewport(1,2); Triangles(); Viewport(1,3); TriangleStrip(); Viewport(2,0); Rect(); Viewport(2,1); xPolygon(); Viewport(2,2); Quads(); Viewport(2,3); QuadStrip(); glFlush(); if(doubleBuffer)auxSwapBuffers(); }
void HiJitCube::computePoly() { // Compute sample and line coordinates in the focal plane int samp0,sampN; if (originst) { samp0=jdata.fpSamp0 + jdata.sampOffset; sampN=samp0 + npSamps[jdata.cpmmNumber] - 1; } else { samp0=jdata.fpSamp0 + jdata.sampOffset; sampN=samp0 + Samples() - 1; } int line0(jdata.fpLine0 + jdata.lineOffset), lineN(line0 + Lines() - 1); // Allocate a new coordinate sequence and define it geos::geom::CoordinateSequence *pts = new geos::geom::CoordinateArraySequence(); pts->add(geos::geom::Coordinate(samp0, lineN)); pts->add(geos::geom::Coordinate(sampN, lineN)); pts->add(geos::geom::Coordinate(sampN, line0)); pts->add(geos::geom::Coordinate(samp0, line0)); pts->add(geos::geom::Coordinate(samp0, lineN)); // Make this reentrant and delete previous one if it exists and get the // new one delete fpGeom; fpGeom = geosFactory.createPolygon(geosFactory.createLinearRing(pts), 0); return; }
static void Draw(EGLDisplay dpy, EGLSurface surf) { glViewport(0, 0, windW, windH); glDisable(GL_SCISSOR_TEST); glPushAttrib(GL_COLOR_BUFFER_BIT); glColorMask(1, 1, 1, 1); glIndexMask(~0); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glPopAttrib(); if (mode1) { glShadeModel(GL_SMOOTH); } else { glShadeModel(GL_FLAT); } if (mode2) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } else { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } Viewport(0, 0); Point(); Viewport(0, 1); Lines(); Viewport(0, 2); LineStrip(); Viewport(0, 3); LineLoop(); Viewport(1, 0); Bitmap(); Viewport(1, 1); TriangleFan(); Viewport(1, 2); Triangles(); Viewport(1, 3); TriangleStrip(); Viewport(2, 0); Rect(); Viewport(2, 1); PolygonFunc(); Viewport(2, 2); Quads(); Viewport(2, 3); QuadStrip(); glFlush(); if (doubleBuffer) { eglSwapBuffers(dpy, surf); } }
// Load a the BIT sets file void CBITManager::LoadBITSetsFromFile(const QString BITSetsFileName) { try { CQStringList Lines(BITSetsFileName); ClearBITSets(); CBITSet *CurrentSet = NULL; // Process each line... for(unsigned i = 0; i < Lines.Count(); i++) { // Ignore blank lines if(Lines[i] == "") continue; // Check if the format of the line matches BIT set name if(IsSetNameStrFormat(Lines[i])) { // Add current set to the list if(CurrentSet) m_BITSetList.push_back(CurrentSet); // Create a new set object CurrentSet = new CBITSet(StripBITSetName(Lines[i])); } else { // A set must be initialized by now if(CurrentSet == NULL) { QMonitor.ErrorMessage("Invalid BIT set file format"); break; } // Add group/test combo to current set CurrentSet->Add(Lines[i]); } } // Add last set if(CurrentSet) m_BITSetList.push_back(CurrentSet); } catch(...) { // Don't yell on error } }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ sf::VertexArray GenerateLunarSurface( const unsigned WindowWidth, const unsigned WindowHeight) { sf::VertexArray Lines(sf::LinesStrip, 0); auto LandingSpots = GenerateLandingSpots(4, WindowWidth); std::default_random_engine Generator( std::chrono::high_resolution_clock::now().time_since_epoch().count()); std::uniform_int_distribution<int> Distribution(0, 1); auto Random = [&Generator, &Distribution] { return Distribution(Generator); }; auto InLandingSpot = [&LandingSpots] (const int Width) { return std::any_of( LandingSpots.begin(), LandingSpots.end(), [Width] (int Value) { return Width >= Value && Width < Value + 40;}); }; auto Height = WindowHeight * .75; for (auto Width = 0u; Width < WindowWidth; Width += 4) { if (!InLandingSpot(Width)) { if (Random()) { Height += 18; } else { Height -= 18; } if (Height <= 0) { Height = 1; } } Lines.append(sf::Vector2f(Width, Height)); } return Lines; }
Lines DBWinReader::CheckHandleCache() { if ((m_timer.Get() - m_handleCacheTime) < HandleCacheTimeout) return Lines(); Lines lines; Pids removedPids = m_handleCache.Cleanup(); for (auto i = removedPids.begin(); i != removedPids.end(); i++) { DWORD pid = *i; if (m_lineBuffers.find(pid) != m_lineBuffers.end()) { if (!m_lineBuffers[pid].empty()) lines.push_back(Line(m_timer.Get(), GetSystemTimeAsFileTime(), pid, "<flush>", m_lineBuffers[pid])); m_lineBuffers.erase(pid); } } m_handleCacheTime = m_timer.Get(); return lines; }
void clsTieNDye::TieNDyeMain(IplImage **pImgSrc,int iSoftColor, int iHardColor,int*iErrCode,GlobalHelper &g_GH) { pImgSource = *pImgSrc; m_iSoftColor = iSoftColor; m_iHardColor = iHardColor; if(!pImgSource) { //g_GH.DebugOut("TieNDye: Source Image NULL",FALSE); *iErrCode = 1; return; } iNC = pImgSource->width; iNR = pImgSource->height; Threshold(g_GH); Lines(g_GH); g_GH.cvReleaseImageProxy(&pImgSource); *pImgSrc = pImgCanvas; }
void WithDefinitionNode::setDefinitionPosition(int first, int last) { setDefinitionPosition(Lines(first, last)); }
Renderable* Renderable::LineSegment(const Vec3f& a, const Vec3f& b, Material *material) { std::vector<Vec3f> vertices(2); vertices[0] = a; vertices[1] = b; return Lines(vertices, material); }
int main(int argc, char **argv) { int i,j,k = 0;//counters if(argc == 1) { //printing instructions printf("\n"); printf("Forward propagation of sentences in a file delimited by \\n\n\n"); printf("Parameters:\n"); printf("\tValue for the vocabulary size that resulted from training (first number in the output file of word2vec):\n"); printf("\t\t-vocab_size <int>\n"); printf("\tValue for the layer size used in training (second number in the output file of word2vec):\n"); printf("\t\t-layer_size <int>\n"); printf("\tValue for the window size:\n"); printf("\t\t-window <int>\n\n"); return 0; } //reading command line arguments if ((i = ArgPos((char *)"-layer_size", argc, argv)) > 0) layer1_size = atoi(argv[i + 1]); if ((i = ArgPos((char *)"-vocab_size", argc, argv)) > 0) vocab_size = atoi(argv[i + 1]); if ((i = ArgPos((char *)"-window", argc, argv)) > 0) window = atoi(argv[i + 1]); // allocating memory to store the network elements syn0 = (real *)calloc(layer1_size*vocab_size,sizeof(real)); syn1 = (real *)calloc(layer1_size*vocab_size,sizeof(real)); neu1 = (real *)calloc(layer1_size,sizeof(real)); index_buff = (char *)calloc(MAX_INDEX_BUFF_SIZE,sizeof(char)); // reading the network from file read_syn0(); read_syn1(); expTable = (real *)malloc((EXP_TABLE_SIZE + 1) * sizeof(real)); //allocating memory for expTable for (i = 0; i < EXP_TABLE_SIZE; i++) { expTable[i] = exp((i / (real)EXP_TABLE_SIZE * 2 - 1) * MAX_EXP); // Precompute the exp() table in the same way as in word2vec expTable[i] = expTable[i] / (expTable[i] + 1); // Precompute f(x) = x / (x + 1) } //building the vocabulary and the vocabulary hash from the files it was stored in BuildVocabFromFile(); BuildVocabHashFromFile(); int length = 0; //word lenght of sentence variable int syno_length = 0; //how many synonyms/replacements long long * sen; //sentence variable where words are represented as vocabualry indices long long * sen_temp; //temporary sentence variable where words are represented as vocabulary indices sen_temp = (long long *)calloc(MAX_SENTENCE_LENGTH,sizeof(long long)); //allocating memory for sen_temp long long * synonym; //replacement word (in vocabulary index form) long double prob = 0; //probability variable long long ptr = 0, ptr_temp = 0; //pointer used to go through the sentences file long long syno_ptr = 0, syno_ptr_temp = 0; //pointer used to go through the synonyms/replacements file FILE *sentfile = fopen("sentences","r"); FILE *indices = fopen("indices","r"); FILE *synfile = fopen("synonyms","r"); FILE *fo = fopen("wordprobs","w"); int lines = 0; char line[MAX_SENTENCE_LENGTH]; // buffer to store current sentence char synline[MAX_SENTENCE_LENGTH]; // buffer to store synonyms lines = Lines(sentfile); // how many lines in the sentences file, which is used as the outer loop delimiter //(this can be done) since all the files "sentences", "synonyms" and "indices" have the same number of lines delimited by "\n" rewind(sentfile); rewind(synfile); for(i = 0; i<lines; i++) { //outer loop iterating through "sentences", "synonyms" and "indices" line by line // read sentence ptr = ftell(sentfile); // store beginning of line if (readLine(sentfile,line) < 0) break; length = LineWordCount(line); //printf("sent words %d\n",length); // read word replacements syno_ptr = ftell(synfile); // store beginning of line if (readLine(synfile,synline) < 0) break; syno_length = LineWordCount(synline); printf("synline %s\n",synline); fseek(sentfile,ptr,SEEK_SET); // move the pointer back to the beginning of the line sen = FileToSen(length,sentfile); //sen is an array of longs with the words of the sentence in a vocabulary index format fseek(synfile,syno_ptr,SEEK_SET); synonym = FileToSen(syno_length,synfile); //synonym is an array of longs with the replacements/synonyms from the "synonyms" file in vocabulary index format fseek(sentfile,1,SEEK_CUR); // added to get past newline fseek(synfile,1,SEEK_CUR); ReadIndexFromFile(indices); //reads the index and puts it in the char array "index_buff" target_index = GetIndex(); //returns a numerical value from what is in the char array "index_buff" for(k=0; k<syno_length; k++) { //repeats forward propagation for each synonym in the line memcpy(sen_temp,sen,MAX_SENTENCE_LENGTH*sizeof(long long)); //copying the sentence into sen_temp where synonyms will be changed sen_temp[target_index] = synonym[k]; //replacing the target word with a synonym/replacement prob = ForwardPropagate(length,sen_temp); //doing forward propagation to get the probability //prob = prob * 100000; // multiplying the probabilty by 100000 or taking the negative log is done in this line fprintf(fo,"%s %Lf\n",vocab[synonym[k]].word,prob); // SEA the replacement word and its probability } } fclose(fo); fclose(sentfile); fclose(synfile); fclose(indices); return 0; }
void HiJitCube::Init() throw (iException &) { // Get required keywords from instrument group Pvl *label(Label()); Isis::PvlGroup inst; Isis::PvlGroup idinst; jdata.filename = Filename(); Isis::PvlGroup &archive = label->FindGroup ("Archive",Isis::Pvl::Traverse); jdata.productId = (string) archive["ProductId"]; jdata.lines = Lines(); if (label->FindObject("IsisCube").HasGroup("OriginalInstrument")) { inst = label->FindGroup ("OriginalInstrument",Isis::Pvl::Traverse); originst = true; } else { inst = label->FindGroup ("Instrument",Isis::Pvl::Traverse); originst = false; } jdata.tdiMode = inst["Tdi"]; jdata.summing = inst["Summing"]; if (label->FindObject("IsisCube").HasGroup("Instrument") && originst) { idinst = label->FindGroup ("Instrument",Isis::Pvl::Traverse); jdata.pixpitch = idinst["PixelPitch"]; jdata.summing = (int) (jdata.pixpitch/.012); } if (originst && jdata.summing != 1 && !sampinit) { for (int i=0; i<14; i++) { npSamps[i] = (int) (npSamps[i]/(float)jdata.summing + 0.5); npSamp0[i] = (int) (npSamp0[i]/(float)jdata.summing + 0.5); } sampinit = true; } jdata.channelNumber = inst["ChannelNumber"]; jdata.cpmmNumber = inst["CpmmNumber"]; if (originst) { jdata.samples = npSamps[jdata.cpmmNumber]; } else { jdata.samples = Samples(); } jdata.ccdName = Instrument::CCD_NAMES[jdata.cpmmNumber]; jdata.dltCount = inst["DeltaLineTimerCount"]; jdata.UTCStartTime = (string) inst["StartTime"]; jdata.scStartTime = (string) inst["SpacecraftClockStartCount"]; try { if (originst) { jdata.fpSamp0 = npSamp0[jdata.cpmmNumber]; } else { jdata.fpSamp0 = Instrument::focal_plane_x_offset(jdata.cpmmNumber, jdata.summing); } } catch (Exception hiExc) { ostringstream msg; msg << "Summing mode (" << jdata.summing << ") is illegal (must be > 0) or CPMM number (" << jdata.cpmmNumber << ") is invalid in file " << Filename() << endl; throw iException::Message(iException::User,msg.str(),_FILEINFO_); } // It is assumed all images start at the line location in the focal plane jdata.fpLine0 = 0; // Validate channel number and adjust starting sample if ((jdata.channelNumber > 2) || (jdata.channelNumber < 0)) { ostringstream msg; msg << "Channel number (" << jdata.channelNumber << ") is invalid (must be 0, 1 or 2) in file " << Filename() << endl; throw iException::Message(iException::User,msg.str(),_FILEINFO_); } else { if (originst) { if (jdata.channelNumber == 0) jdata.fpSamp0 += npSamps[jdata.cpmmNumber]; } else { if (jdata.channelNumber == 0) jdata.fpSamp0 += Samples(); } } // Determine starting time of image and compute the binning rates computeStartTime(); // Compute the focal plane polygon for this image computePoly(); return; }
static void CALLBACK Paint(void) { glDisable(GL_SCISSOR_TEST); glClearColor(1.0,1.0,1.0,1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); AUX_SETCOLOR(windType,AUX_BLACK); if(antialiasing) { glBlendFunc(GL_SRC_ALPHA,GL_ZERO); glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); } if(depthTesting) glEnable(GL_DEPTH_TEST); if(fogging) { glEnable(GL_FOG); glHint(GL_FOG_HINT,(niceFogging)?GL_NICEST:GL_FASTEST); } if(lighting) { static GLfloat ambient[4]={1,0.5,0.5,0}; glEnable(GL_NORMALIZE); glNormal3f(1.0,1.0,1.0); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } (shading)?glShadeModel(GL_SMOOTH):glShadeModel(GL_FLAT); if(texturing) { static GLfloat modulate[1]={GL_DECAL}; static GLfloat clamp[1]={GL_CLAMP}; static GLfloat linear[1]={GL_LINEAR}; glPixelStorei(GL_UNPACK_ALIGNMENT,1); glTexImage2D(GL_TEXTURE_2D,0,3,2,2,0,GL_RGB ,GL_UNSIGNED_BYTE,(GLvoid*)texture); glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,modulate); glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,clamp); glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,clamp); glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,linear); glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,linear); glEnable(GL_TEXTURE_2D); } Viewport(0,0); Points(); Viewport(0,1); Lines(); Viewport(0,2); Triangles(); Viewport(0,3); Rects(); glFlush(); if(doubleBuffer) auxSwapBuffers(); }