Palette::Palette(const int size) : mRainbowTime(tick_time), mColors(Colors(size)), mCharColors(), mGradVector() { mInstances.insert(this); }
DPAngVelPlot::DPAngVelPlot(int type, int system, bool hasgrid, std::string title, int plottype, int units, double linethickness) : DPPlotSettings(type, system, hasgrid, title) { PROGRAMCOLORS = Colors(); setAngVelPlotType(plottype); setUnits(units); setLineThickness(linethickness); this->colors.push_back(PROGRAMCOLORS.colorlist[DEEPORANGE]); }
void thPaletteData::Clear() { begin.Clear(); end.Clear(); beginColor.Clear(); endColor.Clear(); msg.Clear(); memset(clr, 0, Colors() * sizeof(COLORREF)); }
// Called by Rocket when it wants to render geometry that it does not wish to optimise. void RocketSDL2Renderer::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation) { // SDL uses shaders that we need to disable here glUseProgramObjectARB(0); glPushMatrix(); glTranslatef(translation.x, translation.y, 0); std::vector<Rocket::Core::Vector2f> Positions(num_vertices); std::vector<Rocket::Core::Colourb> Colors(num_vertices); std::vector<Rocket::Core::Vector2f> TexCoords(num_vertices); float texw, texh; SDL_Texture* sdl_texture = NULL; if(texture) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); sdl_texture = (SDL_Texture *) texture; SDL_GL_BindTexture(sdl_texture, &texw, &texh); } for(int i = 0; i < num_vertices; i++) { Positions[i] = vertices[i].position; Colors[i] = vertices[i].colour; if (sdl_texture) { TexCoords[i].x = vertices[i].tex_coord.x * texw; TexCoords[i].y = vertices[i].tex_coord.y * texh; } else TexCoords[i] = vertices[i].tex_coord; }; glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(2, GL_FLOAT, 0, &Positions[0]); glColorPointer(4, GL_UNSIGNED_BYTE, 0, &Colors[0]); glTexCoordPointer(2, GL_FLOAT, 0, &TexCoords[0]); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); if (sdl_texture) { SDL_GL_UnbindTexture(sdl_texture); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } glColor4f(1.0, 1.0, 1.0, 1.0); glPopMatrix(); /* Reset blending and draw a fake point just outside the screen to let SDL know that it needs to reset its state in case it wants to render a texture */ glDisable(GL_BLEND); SDL_SetRenderDrawBlendMode(mRenderer, SDL_BLENDMODE_NONE); SDL_RenderDrawPoint(mRenderer, -1, -1); }
DPAnglePlot::DPAnglePlot(int type, int system, bool hasgrid, std::string title, int plottype, double units, bool normalized, double linethickness) :DPPlotSettings(type, system, hasgrid, title) { PROGRAMCOLORS = Colors(); setAnglePlotType(plottype); setUnits(units); setNormalized(normalized); this->setLineThickness(linethickness); this->colors.push_back(PROGRAMCOLORS.colorlist[DEEPORANGE]); // set the default line color to deep orange }
// Called by Rocket when it wants to render geometry that it does not wish to optimise. void RocketSFMLRenderer::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation) { MyWindow->setActive(); glPushMatrix(); glTranslatef(translation.x, translation.y, 0); std::vector<Rocket::Core::Vector2f> Positions(num_vertices); std::vector<Rocket::Core::Colourb> Colors(num_vertices); std::vector<Rocket::Core::Vector2f> TexCoords(num_vertices); for(int i = 0; i < num_vertices; i++) { Positions[i] = vertices[i].position; Colors[i] = vertices[i].colour; TexCoords[i] = vertices[i].tex_coord; }; glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_FLOAT, 0, &Positions[0]); glColorPointer(4, GL_UNSIGNED_BYTE, 0, &Colors[0]); glTexCoordPointer(2, GL_FLOAT, 0, &TexCoords[0]); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if(texture) { glEnable(GL_TEXTURE_2D); sf::Texture::bind((sf::Texture*)texture, sf::Texture::Normalized); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); glBindTexture(GL_TEXTURE_2D, 0); }; glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glColor4f(1, 1, 1, 1); glPopMatrix(); }
//--------------------------------------------------------- void CSG_3DView_Canvas::Draw_Line(double ax, double ay, double az, double bx, double by, double bz, int aColor, int bColor) { if( (ax < 0 && bx < 0) || (ax >= m_Image_NX && bx >= m_Image_NX) || (ay < 0 && by < 0) || (ay >= m_Image_NY && by >= m_Image_NY) ) { return; } double dx = bx - ax; double dy = by - ay; double dz = bz - az; if( bz < 0.0 || az < 0.0 ) { return; } double n; if( fabs(dx) > fabs(dy) && fabs(dx) > 0.0 ) { n = fabs(dx); dx = dx < 0 ? -1 : 1; dy /= n; dz /= n; } else if( fabs(dy) > 0.0 ) { n = fabs(dy); dx /= n; dy = dy < 0 ? -1 : 1; dz /= n; } else { _Draw_Pixel((int)ax, (int)ay, az, aColor); _Draw_Pixel((int)bx, (int)by, bz, bColor); return; } //----------------------------------------------------- CSG_Colors Colors(2); Colors[0] = aColor; Colors[1] = bColor; //----------------------------------------------------- for(double i=0.0; i<=n; i++, ax+=dx, ay+=dy, az+=dz) { _Draw_Pixel((int)ax, (int)ay, az, Colors.Get_Interpolated(i / n)); } }
void Chessboard::changeColors(void) { ColorsMatrix::iterator I_row; std::vector <Colors>::iterator I_col; srand ( time(NULL) ); for(I_row = field.begin(); I_row < field.end(); I_row++) { for(I_col = I_row->begin(); I_col < I_row->end(); I_col++) { (*I_col) = Colors(rand() % 7); } } }
void CGame::Restart() { for(int i=0;i<CEntity::entity_list.size();i++) { CEntity* e=CEntity::entity_list[i]; int s=8+rand()%20; e->OnRestart(); e->setSize(Vector2d(s,s)); e->setPos(Vector2d(rand()%(SCREEN_WIDTH-s),rand()%(SCREEN_HEIGHT-s))); e->setColor(Colors(rand()%4)); } //player->OnRestart(); player->setColor(red); player->setSize(Vector2d(15,15)); player->setGoalPoint(player->getCenter()); }
//--------------------------------------------------------- void CVIEW_ScatterPlot::_Draw_Legend(wxDC &dc, wxRect r) { CSG_Colors Colors(*m_Options("DENSITY_PAL")->asColors()); Colors.Set_Count(r.GetHeight()); for(int i=0, y=r.GetBottom(); i<Colors.Get_Count(); i++, y--) { Draw_FillRect(dc, Get_Color_asWX(Colors.Get_Color(i)), r.GetLeft(), y, r.GetRight(), y + 1); } // r.Offset(0, -r.GetHeight()); Draw_Edge(dc, EDGE_STYLE_SIMPLE, r); Draw_Text(dc, TEXTALIGN_BOTTOMLEFT, 2 + r.GetRight(), r.GetBottom(), "0"); Draw_Text(dc, TEXTALIGN_TOPLEFT , 2 + r.GetRight(), r.GetTop (), wxString::Format("%d", (int)m_Count.Get_Max())); }
// CJ: change start //------------------------------------------------------------------ // EvolveMomFforce(Matrix *mom, Vector *chi, Float mass, // Float dt): // It evolves the canonical momentum mom by dt // using the fermion force. //------------------------------------------------------------------ ForceArg FdwfBase::EvolveMomFforce(Matrix *mom, Vector *chi, Float mass, Float dt){ char *fname = "EvolveMomFforce(M*,V*,F,F,F)"; VRB.Func(cname,fname); Matrix *gauge = GaugeField() ; if (Colors() != 3) ERR.General(cname,fname,"Wrong nbr of colors.") ; if (SpinComponents() != 4) ERR.General(cname,fname,"Wrong nbr of spin comp.") ; if (mom == 0) ERR.Pointer(cname,fname,"mom") ; if (chi == 0) ERR.Pointer(cname,fname,"chi") ; //---------------------------------------------------------------- // allocate space for two CANONICAL fermion fields //---------------------------------------------------------------- int f_size = FsiteSize() * GJP.VolNodeSites() ; int f_site_size_4d = 2 * Colors() * SpinComponents(); int f_size_4d = f_site_size_4d * GJP.VolNodeSites() ; char *str_v1 = "v1" ; Vector *v1 = (Vector *)fmalloc(cname,fname,str_v1,f_size*sizeof(Float)); // if (v1 == 0) ERR.Pointer(cname, fname, str_v1) ; // VRB.Smalloc(cname, fname, str_v1, v1, f_size*sizeof(Float)) ; char *str_v2 = "v2" ; Vector *v2 = (Vector *)fmalloc(cname,fname,str_v2,f_size*sizeof(Float)) ; // if (v2 == 0) ERR.Pointer(cname, fname, str_v2) ; // VRB.Smalloc(cname, fname, str_v2, v2, f_size*sizeof(Float)) ; // LatMatrix MomDiff(QFAST,4); // Matrix *mom_diff = MomDiff.Mat(); Float L1 = 0.0; Float L2 = 0.0; Float Linf = 0.0; //---------------------------------------------------------------- // Calculate v1, v2. Both v1, v2 must be in CANONICAL order after // the calculation. //---------------------------------------------------------------- VRB.Clock(cname, fname, "Before calc force vecs.\n") ; #ifdef PROFILE Float time = -dclock(); ForceFlops=0; #endif { CgArg cg_arg ; cg_arg.mass = mass ; DiracOpDwf dwf(*this, v1, v2, &cg_arg, CNV_FRM_NO) ; dwf.CalcHmdForceVecs(chi) ; Fconvert(v1,CANONICAL,WILSON); Fconvert(v2,CANONICAL,WILSON); } #ifdef PROFILE time += dclock(); print_flops(cname,fname,ForceFlops,time); #endif int mu, x, y, z, t, s, lx, ly, lz, lt, ls ; int size[5],surf[4],blklen[4],stride[4],numblk[4]; size[0] = lx = GJP.XnodeSites() ; size[1] = ly = GJP.YnodeSites() ; size[2] = lz = GJP.ZnodeSites() ; size[3] = lt = GJP.TnodeSites() ; size[4] = ls = GJP.SnodeSites() ; blklen[0] = sizeof(Float)*FsiteSize()/size[4]; numblk[0] = GJP.VolNodeSites()/size[0]*size[4]; stride[0] = blklen[0] * (size[0]-1); for (int i =1;i<4;i++){ blklen[i] = blklen[i-1] * size[i-1]; numblk[i] = numblk[i-1] / size[i]; stride[i] = blklen[i] * (size[i]-1); } for (int i =0;i<4;i++){ surf[i] = GJP.VolNodeSites()/size[i]; } //---------------------------------------------------------------- // allocate buffer space for two fermion fields that are assoc // with only one 4-D site. //---------------------------------------------------------------- unsigned long flag = QFAST; if (ls<4) flag|= QNONCACHE; char *str_site_v1 = "site_v1" ; char *str_site_v2 = "site_v2" ; Float *v1_buf[4],*v2_buf[4]; int pos[4]; Float *v1_buf_pos[4]; Float *v2_buf_pos[4]; for(int i =0;i<4;i++) { v1_buf[i]=(Float *)fmalloc(cname,fname,"v1_buf",surf[i]*FsiteSize()*sizeof(Float)) ; v2_buf[i]=(Float *)fmalloc(cname,fname,"v2_buf",surf[i]*FsiteSize()*sizeof(Float)) ; } // Matrix tmp_mat1, tmp_mat2 ; Matrix *tmp_mat1,*tmp_mat2; tmp_mat1 = (Matrix *)fmalloc(cname,fname,"tmp_mat1",sizeof(Matrix)*2); tmp_mat2 = tmp_mat1+1; SCUDirArgIR Send[4]; SCUDirArgIR Recv[4]; SCUDMAInst *dma[2]; for(int i = 0;i<2;i++) dma[i] = new SCUDMAInst; void *addr[2]; int f_bytes = sizeof(Float)*f_site_size_4d; int st_bytes = sizeof(Float)*f_size_4d - f_bytes; for (mu=0; mu<4; mu++){ if ( GJP.Nodes(mu) >1){ dma[0]->Init(v1_buf[mu],surf[mu]*ls*f_bytes); dma[1]->Init(v2_buf[mu],surf[mu]*ls*f_bytes); Recv[mu].Init(gjp_scu_dir[2*mu],SCU_REC,dma,2); dma[0]->Init(v1,blklen[mu],numblk[mu],stride[mu]); dma[1]->Init(v2,blklen[mu],numblk[mu],stride[mu]); Send[mu].Init(gjp_scu_dir[2*mu+1],SCU_SEND,dma,2); } } for(int i = 0;i<2;i++) delete dma[i]; VRB.Clock(cname, fname, "Before loop over links.\n") ; #ifdef PROFILE time = -dclock(); ForceFlops=0; #endif sys_cacheflush(0); for (mu=0; mu<4; mu++){ if ( GJP.Nodes(mu) >1){ Recv[mu].StartTrans(); Send[mu].StartTrans(); } } for (mu=0; mu<4; mu++){ for (pos[3]=0; pos[3]<size[3]; pos[3]++){ for (pos[2]=0; pos[2]<size[2]; pos[2]++){ for (pos[1]=0; pos[1]<size[1]; pos[1]++){ for (pos[0]=0; pos[0]<size[0]; pos[0]++){ int gauge_offset = offset(size,pos); int vec_offset = f_site_size_4d*gauge_offset ; gauge_offset = mu+4*gauge_offset ; // printf("%d %d %d %d %d\n",mu,pos[0],pos[1],pos[2],pos[3]); Float *v1_plus_mu ; Float *v2_plus_mu ; int vec_plus_mu_stride ; int vec_plus_mu_offset = f_site_size_4d ; Float coeff = -2.0 * dt ; vec_plus_mu_offset *= offset(size,pos,mu); if ((GJP.Nodes(mu)>1)&&((pos[mu]+1) == size[mu]) ) { } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; if ((pos[mu]+1) == size[mu]) if (GJP.NodeBc(mu)==BND_CND_APRD) coeff = -coeff ; // Float time2 = -dclock(); sproj_tr[mu]( (IFloat *)tmp_mat1, (IFloat *)v1_plus_mu, (IFloat *)v2+vec_offset, ls, vec_plus_mu_stride, f_size_4d-f_site_size_4d) ; sproj_tr[mu+4]( (IFloat *)tmp_mat2, (IFloat *)v2_plus_mu, (IFloat *)v1+vec_offset, ls, vec_plus_mu_stride, f_size_4d-f_site_size_4d) ; // time2 += dclock(); // print_flops("","sproj",2*9*16*ls,time2); *tmp_mat1 += *tmp_mat2 ; // If GJP.Snodes > 1 sum up contributions from all s nodes if(GJP.Snodes() > 1) { glb_sum_multi_dir((Float *)tmp_mat1, 4, sizeof(Matrix)/sizeof(IFloat) ) ; } tmp_mat2->DotMEqual(*(gauge+gauge_offset), *tmp_mat1) ; tmp_mat1->Dagger(*tmp_mat2) ; tmp_mat2->TrLessAntiHermMatrix(*tmp_mat1) ; *tmp_mat2 *= coeff ; *(mom+gauge_offset) += *tmp_mat2 ; Float norm = tmp_mat2->norm(); Float tmp = sqrt(norm); L1 += tmp; L2 += norm; Linf = (tmp>Linf ? tmp : Linf); } } } } } // end for x,y,z,t } // end for mu for (mu=0; mu<4; mu++){ if ( GJP.Nodes(mu) >1){ Recv[mu].TransComplete(); Send[mu].TransComplete(); } } //------------------------------------------------------------------ // start by summing first over direction (mu) and then over site // to allow SCU transfers to happen face-by-face in the outermost // loop. //------------------------------------------------------------------ for(int i = 0;i<4;i++){ v1_buf_pos[i] = v1_buf[i]; v2_buf_pos[i] = v2_buf[i]; } for (mu=0; mu<4; mu++){ for (pos[3]=0; pos[3]<size[3]; pos[3]++){ for (pos[2]=0; pos[2]<size[2]; pos[2]++){ for (pos[1]=0; pos[1]<size[1]; pos[1]++){ for (pos[0]=0; pos[0]<size[0]; pos[0]++){ int gauge_offset = offset(size,pos); int vec_offset = f_site_size_4d*gauge_offset ; gauge_offset = mu+4*gauge_offset ; Float *v1_plus_mu ; Float *v2_plus_mu ; int vec_plus_mu_stride ; int vec_plus_mu_offset = f_site_size_4d ; Float coeff = -2.0 * dt ; // printf("%d %d %d %d %d\n",mu,pos[0],pos[1],pos[2],pos[3]); vec_plus_mu_offset *= offset(size,pos,mu); if ((GJP.Nodes(mu)>1)&&((pos[mu]+1) == size[mu]) ) { v1_plus_mu = v1_buf_pos[mu] ; v2_plus_mu = v2_buf_pos[mu] ; v1_buf_pos[mu] += f_site_size_4d; v2_buf_pos[mu] += f_site_size_4d; vec_plus_mu_stride = (surf[mu] -1)*f_site_size_4d ; if (GJP.NodeBc(mu)==BND_CND_APRD) coeff = -coeff ; // Float time2 = -dclock(); sproj_tr[mu]( (IFloat *)tmp_mat1, (IFloat *)v1_plus_mu, (IFloat *)v2+vec_offset, ls, vec_plus_mu_stride, f_size_4d-f_site_size_4d) ; sproj_tr[mu+4]( (IFloat *)tmp_mat2, (IFloat *)v2_plus_mu, (IFloat *)v1+vec_offset, ls, vec_plus_mu_stride, f_size_4d-f_site_size_4d) ; // time2 += dclock(); // print_flops("","sproj",2*9*16*ls,time2); *tmp_mat1 += *tmp_mat2 ; // If GJP.Snodes > 1 sum up contributions from all s nodes if(GJP.Snodes() >1 ) { glb_sum_multi_dir((Float *)tmp_mat1, 4, sizeof(Matrix)/sizeof(IFloat) ) ; } tmp_mat2->DotMEqual(*(gauge+gauge_offset), *tmp_mat1) ; tmp_mat1->Dagger(*tmp_mat2) ; tmp_mat2->TrLessAntiHermMatrix(*tmp_mat1) ; *tmp_mat2 *= coeff ; *(mom+gauge_offset) += *tmp_mat2 ; Float norm = tmp_mat2->norm(); Float tmp = sqrt(norm); L1 += tmp; L2 += norm; Linf = (tmp>Linf ? tmp : Linf); } } } } } // end for x,y,z,t } // end for mu ForceFlops += (2*9*16*ls + 18+ 198+36+24)*lx*ly*lz*lt*4; #ifdef PROFILE time += dclock(); print_flops(cname,fname,ForceFlops,time); #endif //------------------------------------------------------------------ // deallocate smalloc'd space //------------------------------------------------------------------ for(int i =0;i<4;i++) { ffree(v1_buf[i],cname,fname,"v1_buf"); ffree(v2_buf[i],cname,fname,"v2_buf"); } VRB.Sfree(cname, fname, str_v2, v2) ; ffree(v2) ; VRB.Sfree(cname, fname, str_v1, v1) ; ffree(v1) ; ffree(tmp_mat1); glb_sum(&L1); glb_sum(&L2); glb_max(&Linf); L1 /= 4.0*GJP.VolSites(); L2 /= 4.0*GJP.VolSites(); return ForceArg(L1, sqrt(L2), Linf); }
//--------------------------------------------------------- bool CAir_Flow_Height::On_Execute(void) { CSG_Grid *pAFH; //----------------------------------------------------- m_pDEM = Parameters("DEM" )->asGrid(); pAFH = Parameters("AFH" )->asGrid(); m_maxDistance = Parameters("MAXDIST")->asDouble() * 1000.0; m_Acceleration = Parameters("ACCEL" )->asDouble(); m_dLee = Parameters("LEE" )->asDouble(); m_dLuv = Parameters("LUV" )->asDouble(); // m_bTrace = Parameters("TRACE" )->asBool(); //----------------------------------------------------- CSG_Colors Colors(5); Colors.Set_Color(0, 255, 127, 63); Colors.Set_Color(1, 255, 255, 127); Colors.Set_Color(2, 255, 255, 255); Colors.Set_Color(3, 127, 127, 175); Colors.Set_Color(4, 0, 0, 100); DataObject_Set_Colors(pAFH, Colors); //----------------------------------------------------- bool bOldVer = false; if( Parameters("DIR")->asGrid() == NULL ) { bOldVer = Parameters("OLDVER")->asBool(); m_Dir_Const.x = sin(Parameters("DIR_CONST")->asDouble() * M_DEG_TO_RAD); m_Dir_Const.y = cos(Parameters("DIR_CONST")->asDouble() * M_DEG_TO_RAD); if( fabs(m_Dir_Const.x) > fabs(m_Dir_Const.y) ) { m_Dir_Const.y /= fabs(m_Dir_Const.x); m_Dir_Const.x = m_Dir_Const.x < 0 ? -1 : 1; } else { m_Dir_Const.x /= fabs(m_Dir_Const.y); m_Dir_Const.y = m_Dir_Const.y < 0 ? -1 : 1; } } else { if( !m_DX.Create(*Get_System()) || !m_DY.Create(*Get_System()) ) { Error_Set(_TL("could not allocate sufficient memory")); return( false ); } CSG_Grid *pDir = Parameters("DIR")->asGrid(); CSG_Grid *pLen = Parameters("LEN")->asGrid(); double dRadians = Parameters("DIR_UNITS")->asInt() == 0 ? 1.0 : M_DEG_TO_RAD; double dScale = Parameters("LEN_SCALE")->asDouble(); #pragma omp parallel for for(int y=0; y<Get_NY(); y++) { for(int x=0; x<Get_NX(); x++) { if( pDir->is_NoData(x, y) ) { m_DX.Set_NoData(x, y); } else { double d = pLen ? (!pLen->is_NoData(x, y) ? dScale * pLen->asDouble(x, y) : 0.0) : 1.0; m_DX.Set_Value(x, y, d * sin(pDir->asDouble(x, y) * dRadians)); m_DY.Set_Value(x, y, d * cos(pDir->asDouble(x, y) * dRadians)); } } } } if( Parameters("PYRAMIDS")->asBool() && !bOldVer ) { m_DEM.Create(m_pDEM, 2.0); } //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { if( m_pDEM->is_NoData(x, y) ) { pAFH->Set_NoData(x, y); } else { double Luv, Luv_Lee, Lee; if( bOldVer ) { Get_Luv_Old(x, y, m_Dir_Const.x, m_Dir_Const.y, Luv); Get_Lee_Old(x, y, -m_Dir_Const.x, -m_Dir_Const.y, Luv_Lee, Lee); } else { Get_Luv(x, y, Luv); Get_Lee(x, y, Luv_Lee, Lee); } //----------------------------------------- double d, z = m_pDEM->asDouble(x, y); d = 1.0 + (z + Lee != 0.0 ? (z - Lee) / (z + Lee) : 0.0); d = (Luv > Luv_Lee ? Luv - Luv_Lee : 0.0) + z * d*d / 2.0; pAFH->Set_Value(x, y, d < 0.0 ? 0.0 : d); } } } //----------------------------------------------------- m_DX .Destroy(); m_DY .Destroy(); m_DEM.Destroy(); return( true ); }
//--------------------------------------------------------- void CVIEW_ScatterPlot::_On_Construction(void) { SYS_Set_Color_BG_Window(this); //----------------------------------------------------- if( m_pGrid ) { m_Parameters.Add_Grid("", "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT, false ); m_Parameters.Add_Shapes("", "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); m_Parameters.Add_Table_Field("POINTS", "FIELD" , _TL("Attribute"), _TL("") ); m_Parameters.Add_Choice("", "CMP_WITH" , _TL("Compare with..."), _TL(""), CSG_String::Format("%s|%s|", _TL("another grid"), _TL("points") ), 0 ); m_Parameters.Add_Choice("POINTS", "RESAMPLING", _TL("Resampling"), _TL(""), CSG_String::Format("%s|%s|%s|%s", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); } else if( m_pGrids ) { CSG_String sChoices; for(int i=0; i<m_pGrids->Get_Grid_Count(); i++) { sChoices.Append(m_pGrids->Get_Grid_Name(i, SG_GRIDS_NAME_GRID) + "|"); } m_Parameters.Add_Choice("", "BAND_X", "X", _TL(""), sChoices, 0); m_Parameters.Add_Choice("", "BAND_Y", "Y", _TL(""), sChoices, 1); } else if( m_pTable ) { CSG_String sChoices; for(int i=0; i<m_pTable->Get_Field_Count(); i++) { sChoices.Append(CSG_String::Format("%s|", m_pTable->Get_Field_Name(i))); } m_Parameters.Add_Choice("", "FIELD_X", "X", _TL(""), sChoices, 0); m_Parameters.Add_Choice("", "FIELD_Y", "Y", _TL(""), sChoices, 1); } //----------------------------------------------------- // m_Parameters.Add_Parameters("", "OPTIONS", _TL("Options"), _TL("")); m_Options.Add_Int("", "SAMPLES_MAX", _TL("Maximimum Number of Samples"), _TL(""), 100000, 0, true ); m_Options.Add_Bool("", "REG_SHOW" , _TL("Show Regression"), _TL(""), true ); m_Options.Add_String("REG_SHOW", "REG_FORMULA", _TL("Regression Formula"), _TL(""), "a + b * x" ); m_Options.Add_Color("REG_SHOW", "REG_COLOR" , _TL("Line Colour"), _TL(""), SG_COLOR_RED ); m_Options.Add_Int("REG_SHOW", "REG_SIZE" , _TL("Line Size"), _TL(""), 0, 0, true ); m_Options.Add_Info_String("REG_SHOW", "REG_INFO" , _TL("Regression Details"), _TL(""), _TL(""), true ); m_Options.Add_Choice("", "DISPLAY" , _TL("Display Type"), _TL(""), CSG_String::Format("%s|%s", _TL("Points"), _TL("Density") ), m_pGrid || m_pGrids ? 1 : 0 ); m_Options.Add_Int("DISPLAY", "DENSITY_RES" , _TL("Display Resolution"), _TL(""), 50, 10, true ); CSG_Colors Colors(7, SG_COLORS_RAINBOW); Colors.Set_Color(0, 255, 255, 255); Colors.Set_Count(100); m_Options.Add_Colors("DISPLAY", "DENSITY_PAL" , _TL("Colors"), _TL(""), &Colors ); m_Options.Add_Bool("DISPLAY", "DENSITY_LEG" , _TL("Show Legend"), _TL(""), true ); //----------------------------------------------------- m_Parameters.Set_Callback_On_Parameter_Changed(&Scatter_Plot_On_Parameter_Changed); }
//------------------------------------------------------------------ // Returns the number of fermion field components // (including real/imaginary) on a site of the 4-D lattice. //------------------------------------------------------------------ int FstagTypes::FsiteSize() const { return 2 * Colors() * SpinComponents(); // re/im * colors * spin_components }
Palette::Palette(int size) : mRainbowTime(tick_time), mColors(Colors(size)) { mInstances.insert(this); }
//------------------------------------------------------------------ // "Odd" fermion force evolution routine written by Chris Dawson, taken // verbatim, so performance will suck on qcdoc. //------------------------------------------------------------------ ForceArg FdwfBase::EvolveMomFforce( Matrix* mom, // momenta Vector* phi, // odd pseudo-fermion field Vector* eta, // very odd pseudo-fermion field Float mass, Float dt ) { char *fname = "EvolveMomFforce(M*,V*,V*,F,F)"; VRB.Func(cname,fname); Matrix *gauge = GaugeField() ; if (Colors() != 3) { ERR.General(cname,fname,"Wrong nbr of colors.") ; } if (SpinComponents()!=4) { ERR.General(cname,fname,"Wrong nbr of spin comp.") ;} if (mom == 0) { ERR.Pointer(cname,fname,"mom") ; } if (phi == 0) { ERR.Pointer(cname,fname,"phi") ; } // allocate space for two CANONICAL fermion fields // these are all full fermion vector sizes ( i.e. *not* preconditioned ) const int f_size ( FsiteSize() * GJP.VolNodeSites() ); const int f_size_cb ( f_size/2 ) ; // f_size must be multiple of 2 const int f_site_size_4d( 2 * Colors() * SpinComponents() ); const int f_size_4d ( f_site_size_4d * GJP.VolNodeSites()) ; char *str_v1 = "v1" ; Vector *v1 = (Vector *)smalloc(f_size*sizeof(Float)) ; if (v1 == 0) ERR.Pointer(cname, fname, str_v1) ; VRB.Smalloc(cname, fname, str_v1, v1, f_size*sizeof(Float)) ; char *str_v2 = "v2" ; Vector *v2 = (Vector *)smalloc(f_size*sizeof(Float)) ; if (v2 == 0) ERR.Pointer(cname, fname, str_v2) ; VRB.Smalloc(cname, fname, str_v2, v2, f_size*sizeof(Float)) ; Float L1 = 0.0; Float L2 = 0.0; Float Linf = 0.0; #ifdef PROFILE Float time = -dclock(); ForceFlops=0; #endif //Calculate v1, v2. Both must be in CANONICAL order afterwards { CgArg cg_arg ; cg_arg.mass = mass ; DiracOpDwf dwf(*this, v1, v2, &cg_arg, CNV_FRM_YES) ; Float kappa( 1.0 / ( 2 * (4 + GJP.DwfA5Inv() - GJP.DwfHeight()))); v2->CopyVec(phi,f_size_cb); // rescale the input field. As the second half of the this field // will be constructed by acting with the PC dslash on v1, this // rescales *one* of the full vectors - giving rise to an overall // rescaling of the final answer by exactly -\kappa^2 v2->VecTimesEquFloat(-kappa*kappa,f_size_cb); // only need one factor of -\kappa^2, so don't rescale the second // full vector (v2) v1->CopyVec(eta,f_size_cb); dwf.Dslash(v2+(f_size_cb/6), v2 , CHKB_ODD, DAG_YES); dwf.Dslash(v1+(f_size_cb/6), v1 , CHKB_ODD, DAG_NO); // v1 and v2 are now the vectors needed to contruct the force term // written in ( ODD, EVEN ) ordering. They will be converted back // into canonical ordering when the destructor is called. } // two fermion vectors at a single position // - these will be used to store off-node // field components char *str_site_v1 = "site_v1" ; Float *site_v1 = (Float *)smalloc(FsiteSize()*sizeof(Float)) ; if (site_v1 == 0) ERR.Pointer(cname, fname, str_site_v1) ; VRB.Smalloc(cname, fname, str_site_v1, site_v1, FsiteSize()*sizeof(Float)) ; char *str_site_v2 = "site_v2" ; Float *site_v2 = (Float *)smalloc(FsiteSize()*sizeof(Float)) ; if (site_v2 == 0) ERR.Pointer(cname, fname, str_site_v2) ; VRB.Smalloc(cname, fname, str_site_v2, site_v2, FsiteSize()*sizeof(Float)) ; // evolve the momenta by the fermion force int mu, x, y, z, t, s; const int lx(GJP.XnodeSites()); const int ly(GJP.YnodeSites()); const int lz(GJP.ZnodeSites()); const int lt(GJP.TnodeSites()); const int ls(GJP.SnodeSites()); // start by summing first over direction (mu) and then over site to // allow SCU transfers to happen face-by-face in the outermost loop. VRB.Clock(cname, fname, "Before loop over links.\n") ; for (mu=0; mu<4; mu++) { for (t=0; t<lt; t++){ for (z=0; z<lz; z++){ for (y=0; y<ly; y++){ for (x=0; x<lx; x++) { // position offset int gauge_offset = x+lx*(y+ly*(z+lz*t)); // offset for vector field at this point // (4d only, no fifth dimension) int vec_offset = f_site_size_4d*gauge_offset ; // offset for link in mu direction from this point gauge_offset = mu+4*gauge_offset ; Float *v1_plus_mu=NULL ; Float *v2_plus_mu=NULL ; int vec_plus_mu_stride=0 ; int vec_plus_mu_offset = f_site_size_4d ; // sign of coeff (look at momenta update) Float coeff = -2.0 * dt ; switch (mu) { case 0 : // next position in mu direction vec_plus_mu_offset *= (x+1)%lx+lx*(y+ly*(z+lz*t)) ; // vec_plus_mu_offset now the correct // offset for a fermion field at this point // in the lattice if ((x+1) == lx) { // off-node for (s=0; s<ls; s++) { // fill site_v1 and site_v2 with v1 and v2 data // from x=0 on next node, need loop because // data is not contiguous in memory getPlusData( (Float *)site_v1+s*f_site_size_4d, (Float *)v1+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; getPlusData( (Float*)site_v2+s*f_site_size_4d, (Float*)v2+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; } // end for s v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; vec_plus_mu_stride = 0 ; // field now contiguous // GJP.XnodeBc() gives the forward boundary // condition only (so this should work). if (GJP.XnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { // on - node // // just add offset to v1 and v2 // (they are now 1 forward in the mu direction ) // v1_plus_mu = (Float*)v1+vec_plus_mu_offset ; v2_plus_mu = (Float*)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; // explained below } break ; // Repeat for the other directions case 1 : vec_plus_mu_offset *= x+lx*((y+1)%ly+ly*(z+lz*t)) ; if ((y+1) == ly) { for (s=0; s<ls; s++) { getPlusData( (Float*)site_v1+s*f_site_size_4d, (Float*)v1+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; getPlusData( (Float*)site_v2+s*f_site_size_4d, (Float*)v2+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; } v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; vec_plus_mu_stride = 0 ; if (GJP.YnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; } break ; case 2 : vec_plus_mu_offset *= x+lx*(y+ly*((z+1)%lz+lz*t)) ; if ((z+1) == lz) { for (s=0; s<ls; s++) { getPlusData( (Float*)site_v1+s*f_site_size_4d, (Float*)v1+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; getPlusData( (Float*)site_v2+s*f_site_size_4d, (Float*)v2+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; } v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; vec_plus_mu_stride = 0 ; if (GJP.ZnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; } break ; case 3 : vec_plus_mu_offset *= x+lx*(y+ly*(z+lz*((t+1)%lt))) ; if ((t+1) == lt) { for (s=0; s<ls; s++) { getPlusData( (Float*)site_v1+s*f_site_size_4d, (Float*)v1+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; getPlusData( (Float*)site_v2+s*f_site_size_4d, (Float*)v2+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; } v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; vec_plus_mu_stride = 0 ; if (GJP.TnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; } } // end (the evil) mu switch Matrix tmp_mat1, tmp_mat2; // the non-zero stride pattern is due to domain wall // fermions ( summing up *ls* different sproj's ) // // f_size_4d-f_site_size_4d is the number of floats // between the end of one spinor at s and the start of the // spinor at s+1 // // vec_plus_mu_stride is the same, except when // this is off boundary, in that case the info // is copied into a contiguous block in the above code // and vec_plus_mu_stride set to zero // ( 1 - gamma_\mu ) Tr_s [ v1(x+\mu) v2^{\dagger}(x) ] sproj_tr[mu]( (Float *)&tmp_mat1, (Float *)v1_plus_mu, (Float *)v2+vec_offset, ls, vec_plus_mu_stride, f_size_4d-f_site_size_4d) ; // (1 + gamma_\mu) Tr_s [ v2(x+\mu) v1^{\dagger}(x) ] sproj_tr[mu+4]( (Float *)&tmp_mat2, (Float *)v2_plus_mu, (Float *)v1+vec_offset, ls, vec_plus_mu_stride, f_size_4d-f_site_size_4d) ; // exactly what is sounds like tmp_mat1 += tmp_mat2 ; if(GJP.Snodes() != 1) { for (s=0; s<(sizeof(Matrix)/sizeof(Float)); ++s) { glb_sum_dir((Float *)&tmp_mat1 + s, 4) ; } } // multiply sum by the link in the \mu direction tmp_mat2.DotMEqual(*(gauge+gauge_offset), tmp_mat1) ; // take tracless antihermitian piece // TrLessAntiHermMatrix need to be passed // the dagger of the matrix in question tmp_mat1.Dagger(tmp_mat2) ; tmp_mat2.TrLessAntiHermMatrix(tmp_mat1) ; tmp_mat2 *= coeff ; // note the minus sign. *(mom+gauge_offset) -= tmp_mat2 ; Float norm = tmp_mat2.norm(); Float tmp = sqrt(norm); L1 += tmp; L2 += norm; Linf = (tmp>Linf ? tmp : Linf); } // end for x } // end for y } // end for z } // end for t } // end for mu ForceFlops += (2*9*16*ls + 18+ 198+36+24)*lx*ly*lz*lt*4; #ifdef PROFILE time += dclock(); print_flops(cname,fname,ForceFlops,time); #endif // deallocate smalloc'd space VRB.Sfree(cname, fname, str_site_v2, site_v2) ; sfree(site_v2) ; VRB.Sfree(cname, fname, str_site_v1, site_v1) ; sfree(site_v1) ; VRB.Sfree(cname, fname, str_v2, v2) ; sfree(v2) ; VRB.Sfree(cname, fname, str_v1, v1) ; sfree(v1) ; glb_sum(&L1); glb_sum(&L2); glb_max(&Linf); L1 /= 4.0*GJP.VolSites(); L2 /= 4.0*GJP.VolSites(); VRB.FuncEnd(cname,fname); return ForceArg(L1, sqrt(L2), Linf); }
//--------------------------------------------------------- bool CGrid_Export::On_Execute(void) { //----------------------------------------------------- int y, iy, Method; double dTrans; CSG_Grid *pGrid, *pShade, Grid, Shade; //----------------------------------------------------- pGrid = Parameters("GRID" )->asGrid(); pShade = Parameters("SHADE" )->asGrid(); Method = Parameters("COLOURING" )->asInt (); dTrans = Parameters("SHADE_TRANS" )->asDouble() / 100.0; if( !pGrid ) { return( false ); } //----------------------------------------------------- if( Method == 5 ) // same as in graphical user interface { if( !SG_UI_DataObject_asImage(pGrid, &Grid) ) { Error_Set("could not retrieve colour coding from graphical user interface."); return( false ); } } else { double zMin, zScale; CSG_Colors Colors; CSG_Table LUT; if( SG_UI_Get_Window_Main() ) { Colors.Assign(Parameters("COL_PALETTE")->asColors()); } else { Colors.Set_Palette( Parameters("COL_PALETTE")->asInt (), Parameters("COL_REVERT" )->asBool(), Parameters("COL_COUNT" )->asInt () ); } switch( Method ) { case 0: // stretch to grid's standard deviation zMin = pGrid->Get_Mean() - Parameters("STDDEV")->asDouble() * pGrid->Get_StdDev(); zScale = Colors.Get_Count() / (2 * Parameters("STDDEV")->asDouble() * pGrid->Get_StdDev()); break; case 1: // stretch to grid's value range zMin = pGrid->Get_ZMin(); zScale = Colors.Get_Count() / pGrid->Get_ZRange(); break; case 2: // stretch to specified value range zMin = Parameters("STRETCH")->asRange()->Get_LoVal(); if( zMin >= (zScale = Parameters("STRETCH")->asRange()->Get_HiVal()) ) { Error_Set(_TL("invalid user specified value range.")); return( false ); } zScale = Colors.Get_Count() / (zScale - zMin); break; case 3: // lookup table if( !Parameters("LUT")->asTable() || Parameters("LUT")->asTable()->Get_Field_Count() < 5 ) { Error_Set(_TL("invalid lookup table.")); return( false ); } LUT.Create(*Parameters("LUT")->asTable()); break; case 4: // rgb coded values break; } //------------------------------------------------- Grid.Create(*Get_System(), SG_DATATYPE_Int); for(y=0, iy=Get_NY()-1; y<Get_NY() && Set_Progress(y); y++, iy--) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { double z = pGrid->asDouble(x, y); if( Method == 3 ) // lookup table { int i, iColor = -1; for(i=0; iColor<0 && i<LUT.Get_Count(); i++) { if( z == LUT[i][3] ) { Grid.Set_Value(x, iy, LUT[iColor = i].asInt(0)); } } for(i=0; iColor<0 && i<LUT.Get_Count(); i++) { if( z >= LUT[i][3] && z <= LUT[i][4] ) { Grid.Set_Value(x, iy, LUT[iColor = i].asInt(0)); } } if( iColor < 0 ) { Grid.Set_NoData(x, iy); } } else if( pGrid->is_NoData(x, y) ) { Grid.Set_NoData(x, iy); } else if( Method == 4 ) // rgb coded values { Grid.Set_Value(x, iy, z); } else { int i = (int)(zScale * (z - zMin)); Grid.Set_Value(x, iy, Colors[i < 0 ? 0 : i >= Colors.Get_Count() ? Colors.Get_Count() - 1 : i]); } } } } //----------------------------------------------------- if( !pShade || pShade->Get_ZRange() <= 0.0 ) { pShade = NULL; } else { double dMinBright, dMaxBright; dMinBright = Parameters("SHADE_BRIGHT")->asRange()->Get_LoVal() / 100.0; dMaxBright = Parameters("SHADE_BRIGHT")->asRange()->Get_HiVal() / 100.0; if( dMinBright >= dMaxBright ) { SG_UI_Msg_Add_Error(_TL("Minimum shade brightness must be lower than maximum shade brightness!")); return( false ); } int nColors = 100; CSG_Colors Colors(nColors, SG_COLORS_BLACK_WHITE, true); //------------------------------------------------- Shade.Create(*Get_System(), SG_DATATYPE_Int); for(y=0, iy=Get_NY()-1; y<Get_NY() && Set_Progress(y); y++, iy--) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { if( pShade->is_NoData(x, y) ) { Shade.Set_NoData(x, iy); } else { Shade.Set_Value (x, iy, Colors[(int)(nColors * (dMaxBright - dMinBright) * (pShade->asDouble(x, y) - pShade->Get_ZMin()) / pShade->Get_ZRange() + dMinBright)]); } } } } //----------------------------------------------------- wxImage Image(Get_NX(), Get_NY()); if( Grid.Get_NoData_Count() > 0 ) { Image.SetAlpha(); } for(y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { if( Grid.is_NoData(x, y) || (pShade != NULL && Shade.is_NoData(x, y)) ) { if( Image.HasAlpha() ) { Image.SetAlpha(x, y, wxIMAGE_ALPHA_TRANSPARENT); } Image.SetRGB(x, y, 255, 255, 255); } else { if( Image.HasAlpha() ) { Image.SetAlpha(x, y, wxIMAGE_ALPHA_OPAQUE); } int r, g, b, c = Grid.asInt(x, y); r = SG_GET_R(c); g = SG_GET_G(c); b = SG_GET_B(c); if( pShade ) { c = Shade.asInt(x, y); r = dTrans * r + SG_GET_R(c) * (1.0 - dTrans); g = dTrans * g + SG_GET_G(c) * (1.0 - dTrans); b = dTrans * b + SG_GET_B(c) * (1.0 - dTrans); } Image.SetRGB(x, y, r, g, b); } } } //------------------------------------------------- CSG_String fName(Parameters("FILE")->asString()); if( !SG_File_Cmp_Extension(fName, SG_T("bmp")) && !SG_File_Cmp_Extension(fName, SG_T("jpg")) && !SG_File_Cmp_Extension(fName, SG_T("pcx")) && !SG_File_Cmp_Extension(fName, SG_T("png")) && !SG_File_Cmp_Extension(fName, SG_T("tif")) ) { fName = SG_File_Make_Path(NULL, fName, SG_T("png")); Parameters("FILE")->Set_Value(fName); } //----------------------------------------------------- wxImageHandler *pImgHandler = NULL; if( !SG_UI_Get_Window_Main() ) { if( SG_File_Cmp_Extension(fName, SG_T("jpg")) ) pImgHandler = new wxJPEGHandler; else if( SG_File_Cmp_Extension(fName, SG_T("pcx")) ) pImgHandler = new wxPCXHandler; else if( SG_File_Cmp_Extension(fName, SG_T("tif")) ) pImgHandler = new wxTIFFHandler; #ifdef _SAGA_MSW else if( SG_File_Cmp_Extension(fName, SG_T("bmp")) ) pImgHandler = new wxBMPHandler; #endif else // if( SG_File_Cmp_Extension(fName, SG_T("png")) ) pImgHandler = new wxPNGHandler; wxImage::AddHandler(pImgHandler); } if( !Image.SaveFile(fName.c_str()) ) { Error_Set(CSG_String::Format(SG_T("%s [%s]"), _TL("could not save image file"), fName.c_str())); return( false ); } pGrid->Get_Projection().Save(SG_File_Make_Path(NULL, fName, SG_T("prj")), SG_PROJ_FMT_WKT); //----------------------------------------------------- CSG_File Stream; if( SG_File_Cmp_Extension(fName, SG_T("bmp")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("bpw")), SG_FILE_W, false); else if( SG_File_Cmp_Extension(fName, SG_T("jpg")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("jgw")), SG_FILE_W, false); else if( SG_File_Cmp_Extension(fName, SG_T("pcx")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("pxw")), SG_FILE_W, false); else if( SG_File_Cmp_Extension(fName, SG_T("png")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("pgw")), SG_FILE_W, false); else if( SG_File_Cmp_Extension(fName, SG_T("tif")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("tfw")), SG_FILE_W, false); if( Stream.is_Open() ) { Stream.Printf(SG_T("%.10f\n%f\n%f\n%.10f\n%.10f\n%.10f\n"), pGrid->Get_Cellsize(), 0.0, 0.0, -pGrid->Get_Cellsize(), pGrid->Get_XMin(), pGrid->Get_YMax() ); } //----------------------------------------------------- if( Parameters("FILE_KML")->asBool() ) { CSG_MetaData KML; KML.Set_Name("kml"); KML.Add_Property("xmlns", "http://www.opengis.net/kml/2.2"); // CSG_MetaData *pFolder = KML.Add_Child("Folder"); // pFolder->Add_Child("name" , "Raster exported from SAGA"); // pFolder->Add_Child("description", "System for Automated Geoscientific Analyses - www.saga-gis.org"); // CSG_MetaData *pOverlay = pFolder->Add_Child("GroundOverlay"); CSG_MetaData *pOverlay = KML.Add_Child("GroundOverlay"); pOverlay->Add_Child("name" , pGrid->Get_Name()); pOverlay->Add_Child("description", pGrid->Get_Description()); pOverlay->Add_Child("Icon" )->Add_Child("href", SG_File_Get_Name(fName, true)); pOverlay->Add_Child("LatLonBox" ); pOverlay->Get_Child("LatLonBox" )->Add_Child("north", pGrid->Get_YMax()); pOverlay->Get_Child("LatLonBox" )->Add_Child("south", pGrid->Get_YMin()); pOverlay->Get_Child("LatLonBox" )->Add_Child("east" , pGrid->Get_XMax()); pOverlay->Get_Child("LatLonBox" )->Add_Child("west" , pGrid->Get_XMin()); KML.Save(fName, SG_T("kml")); } //----------------------------------------------------- if( !SG_UI_Get_Window_Main() && pImgHandler != NULL) { wxImage::RemoveHandler(pImgHandler->GetName()); } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CWator::On_Execute(void) { //----------------------------------------------------- m_pWator = m_Grid_Target.Get_Grid("GRID", SG_DATATYPE_Byte); if( !m_pWator ) { Error_Set(_TL("could not create target grid")); return( false ); } //----------------------------------------------------- m_pWator->Set_Name(_TL("Wa-Tor")); m_pWator->Set_NoData_Value(-1); CSG_Colors Colors(3); Colors.Set_Color(0, SG_COLOR_BLACK); Colors.Set_Color(1, SG_COLOR_GREEN); Colors.Set_Color(2, SG_COLOR_RED ); DataObject_Add (m_pWator); DataObject_Set_Colors(m_pWator, Colors); DataObject_Update (m_pWator, 0, 2, SG_UI_DATAOBJECT_SHOW); //----------------------------------------------------- if( Parameters("REFRESH")->asBool() ) { double Fish_perc = Parameters("INIT_FISH" )->asDouble(); double Shark_perc = Parameters("INIT_SHARK")->asDouble() + Fish_perc; #pragma omp parallel for for(int y=0; y<m_pWator->Get_NY(); y++) { for(int x=0; x<m_pWator->Get_NX(); x++) { double perc = CSG_Random::Get_Uniform(0, 100); if( perc <= Fish_perc ) { m_pWator->Set_Value(x, y, FISH); } else if( perc <= Shark_perc ) { m_pWator->Set_Value(x, y, SHARK); } else { m_pWator->Set_Value(x, y, 0); } } } } //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("Wa-Tor")); pTable->Add_Field("Cycle" , SG_DATATYPE_Int); pTable->Add_Field("Fishes", SG_DATATYPE_Int); pTable->Add_Field("Sharks", SG_DATATYPE_Int); //----------------------------------------------------- m_Fish_Birth = Parameters("FISH_BIRTH" )->asInt(); m_Shark_Birth = Parameters("SHARK_BIRTH" )->asInt(); m_Shark_Starve = Parameters("SHARK_STARVE")->asInt(); m_Next .Create(m_pWator, SG_DATATYPE_Byte); m_Age .Create(m_pWator, SG_DATATYPE_Byte); m_Starve.Create(m_pWator, SG_DATATYPE_Byte); #pragma omp parallel for for(int y=0; y<m_pWator->Get_NY(); y++) { for(int x=0; x<m_pWator->Get_NX(); x++) { switch( m_pWator->asByte(x, y) ) { case FISH: m_Age .Set_Value(x, y, CSG_Random::Get_Uniform(0.0, m_Fish_Birth )); break; case SHARK: m_Age .Set_Value(x, y, CSG_Random::Get_Uniform(0.0, m_Shark_Birth )); m_Starve.Set_Value(x, y, CSG_Random::Get_Uniform(0.0, m_Shark_Starve)); break; } } } //----------------------------------------------------- int i; SG_UI_Progress_Lock(true); for(i=1; Process_Get_Okay(true) && Next_Cycle(); i++) { Process_Set_Text("%s: %d", _TL("Life Cycle"), i); CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, i); pRecord->Set_Value(1, m_nFishes); pRecord->Set_Value(2, m_nSharks); DataObject_Update(m_pWator, 0, 2); DataObject_Update(pTable); } SG_UI_Progress_Lock(false); //----------------------------------------------------- m_Next .Destroy(); m_Age .Destroy(); m_Starve.Destroy(); if( is_Progress() ) { Message_Fmt("\n%s %d %s", _TL("Dead after"), i, _TL("Life Cycles")); } return( true ); }
CPS_START_NAMESPACE /*!\file \brief Implementation of FdwfBase class. $Id: f_dwf_base_force.C,v 1.14 2012-08-31 04:55:08 chulwoo Exp $ */ //-------------------------------------------------------------------- // CVS keywords // // $Source: /home/chulwoo/CPS/repo/CVS/cps_only/cps_pp/src/util/lattice/f_dwf_base/noarch/f_dwf_base_force.C,v $ // $State: Exp $ // //-------------------------------------------------------------------- //------------------------------------------------------------------ // // f_dwf_base_force.C // // (R)HMC force term for FdwfBase // //------------------------------------------------------------------ CPS_END_NAMESPACE #include <util/qcdio.h> #include <math.h> #include <util/lattice.h> #include <util/dirac_op.h> #include <util/dwf.h> #include <util/gjp.h> #include <util/verbose.h> #include <util/vector.h> #include <util/random.h> #include <util/error.h> #include <util/time_cps.h> #include <comms/scu.h> // GRF #include <comms/glb.h> CPS_START_NAMESPACE #undef PROFILE // CJ: change start //------------------------------------------------------------------ // EvolveMomFforce(Matrix *mom, Vector *chi, Float mass, // Float dt): // It evolves the canonical momentum mom by dt // using the fermion force. //------------------------------------------------------------------ ForceArg FdwfBase::EvolveMomFforce(Matrix *mom, Vector *chi, Float mass, Float dt){ char *fname = "EvolveMomFforce(M*,V*,F,F,F)"; VRB.Func(cname,fname); Matrix *gauge = GaugeField() ; if (Colors() != 3) ERR.General(cname,fname,"Wrong nbr of colors.") ; if (SpinComponents() != 4) ERR.General(cname,fname,"Wrong nbr of spin comp.") ; if (mom == 0) ERR.Pointer(cname,fname,"mom") ; if (chi == 0) ERR.Pointer(cname,fname,"chi") ; //---------------------------------------------------------------- // allocate space for two CANONICAL fermion fields //---------------------------------------------------------------- int f_size = FsiteSize() * GJP.VolNodeSites() ; int f_site_size_4d = 2 * Colors() * SpinComponents(); int f_size_4d = f_site_size_4d * GJP.VolNodeSites() ; char *str_v1 = "v1" ; Vector *v1 = (Vector *)smalloc(f_size*sizeof(Float)) ; if (v1 == 0) ERR.Pointer(cname, fname, str_v1) ; VRB.Smalloc(cname, fname, str_v1, v1, f_size*sizeof(Float)) ; char *str_v2 = "v2" ; Vector *v2 = (Vector *)smalloc(f_size*sizeof(Float)) ; if (v2 == 0) ERR.Pointer(cname, fname, str_v2) ; VRB.Smalloc(cname, fname, str_v2, v2, f_size*sizeof(Float)) ; //---------------------------------------------------------------- // allocate buffer space for two fermion fields that are assoc // with only one 4-D site. //---------------------------------------------------------------- char *str_site_v1 = "site_v1" ; Float *site_v1 = (Float *)smalloc(FsiteSize()*sizeof(Float)) ; if (site_v1 == 0) ERR.Pointer(cname, fname, str_site_v1) ; VRB.Smalloc(cname, fname, str_site_v1, site_v1, FsiteSize()*sizeof(Float)) ; char *str_site_v2 = "site_v2" ; Float *site_v2 = (Float *)smalloc(FsiteSize()*sizeof(Float)) ; if (site_v2 == 0) ERR.Pointer(cname, fname, str_site_v2) ; VRB.Smalloc(cname, fname, str_site_v2, site_v2, FsiteSize()*sizeof(Float)) ; Float L1 = 0.0; Float L2 = 0.0; Float Linf = 0.0; //---------------------------------------------------------------- // Calculate v1, v2. Both v1, v2 must be in CANONICAL order after // the calculation. //---------------------------------------------------------------- VRB.Clock(cname, fname, "Before calc force vecs.\n") ; VRB.Flow(cname, fname, "Before calc force vecs.\n") ; { CgArg cg_arg ; cg_arg.mass = mass ; DiracOpDwf dwf(*this, v1, v2, &cg_arg, CNV_FRM_YES) ; dwf.CalcHmdForceVecs(chi) ; } VRB.Flow(cname, fname, "After calc force vecs.\n") ; #ifdef PROFILE Float time = -dclock(); ForceFlops=0; #endif int mu, x, y, z, t, s, lx, ly, lz, lt, ls ; lx = GJP.XnodeSites() ; ly = GJP.YnodeSites() ; lz = GJP.ZnodeSites() ; lt = GJP.TnodeSites() ; ls = GJP.SnodeSites() ; Matrix tmp_mat1, tmp_mat2 ; //------------------------------------------------------------------ // start by summing first over direction (mu) and then over site // to allow SCU transfers to happen face-by-face in the outermost // loop. //------------------------------------------------------------------ VRB.Clock(cname, fname, "Before loop over links.\n") ; for (mu=0; mu<4; mu++){ for (t=0; t<lt; t++){ for (z=0; z<lz; z++){ for (y=0; y<ly; y++){ for (x=0; x<lx; x++){ int gauge_offset = x+lx*(y+ly*(z+lz*t)) ; int vec_offset = f_site_size_4d*gauge_offset ; gauge_offset = mu+4*gauge_offset ; Float *v1_plus_mu ; Float *v2_plus_mu ; int vec_plus_mu_stride ; int vec_plus_mu_offset = f_site_size_4d ; Float coeff = -2.0 * dt ; switch (mu) { case 0 : vec_plus_mu_offset *= (x+1)%lx+lx*(y+ly*(z+lz*t)) ; if ((x+1) == lx) { for (s=0; s<ls; s++) { getPlusData( (IFloat *)site_v1+s*f_site_size_4d, (IFloat *)v1+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; getPlusData( (IFloat *)site_v2+s*f_site_size_4d, (IFloat *)v2+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; } // end for s v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; vec_plus_mu_stride = 0 ; if (GJP.XnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; } break ; case 1 : vec_plus_mu_offset *= x+lx*((y+1)%ly+ly*(z+lz*t)) ; if ((y+1) == ly) { for (s=0; s<ls; s++) { getPlusData( (IFloat *)site_v1+s*f_site_size_4d, (IFloat *)v1+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; getPlusData( (IFloat *)site_v2+s*f_site_size_4d, (IFloat *)v2+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; } // end for s v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; vec_plus_mu_stride = 0 ; if (GJP.YnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; } break ; case 2 : vec_plus_mu_offset *= x+lx*(y+ly*((z+1)%lz+lz*t)) ; if ((z+1) == lz) { for (s=0; s<ls; s++) { getPlusData( (IFloat *)site_v1+s*f_site_size_4d, (IFloat *)v1+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; getPlusData( (IFloat *)site_v2+s*f_site_size_4d, (IFloat *)v2+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; } // end for s v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; vec_plus_mu_stride = 0 ; if (GJP.ZnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; } break ; case 3 : vec_plus_mu_offset *= x+lx*(y+ly*(z+lz*((t+1)%lt))) ; if ((t+1) == lt) { for (s=0; s<ls; s++) { getPlusData( (IFloat *)site_v1+s*f_site_size_4d, (IFloat *)v1+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; getPlusData( (IFloat *)site_v2+s*f_site_size_4d, (IFloat *)v2+vec_plus_mu_offset+s*f_size_4d, f_site_size_4d, mu) ; } // end for s v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; vec_plus_mu_stride = 0 ; if (GJP.TnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; vec_plus_mu_stride = f_size_4d - f_site_size_4d ; } } // end switch mu sproj_tr[mu]( (IFloat *)&tmp_mat1, (IFloat *)v1_plus_mu, (IFloat *)v2+vec_offset, ls, vec_plus_mu_stride, f_size_4d-f_site_size_4d) ; sproj_tr[mu+4]( (IFloat *)&tmp_mat2, (IFloat *)v2_plus_mu, (IFloat *)v1+vec_offset, ls, vec_plus_mu_stride, f_size_4d-f_site_size_4d) ; tmp_mat1 += tmp_mat2 ; // If GJP.Snodes > 1 sum up contributions from all s nodes if(GJP.Snodes() > 1) { // if(!UniqueID())printf("%s::%s:GJP.Snodes()=%d\n",cname,fname,GJP.Snodes()); glb_sum_multi_dir((Float *)&tmp_mat1,4,sizeof(Matrix)/sizeof(IFloat)); } tmp_mat2.DotMEqual(*(gauge+gauge_offset), tmp_mat1) ; tmp_mat1.Dagger(tmp_mat2) ; tmp_mat2.TrLessAntiHermMatrix(tmp_mat1) ; tmp_mat2 *= coeff ; *(mom+gauge_offset) += tmp_mat2 ; Float norm = tmp_mat2.norm(); Float tmp = sqrt(norm); L1 += tmp; L2 += norm; Linf = (tmp>Linf ? tmp : Linf); } } } } // end for x,y,z,t } // end for mu ForceFlops += (2*9*16*ls + 18+ 198+36+24)*lx*ly*lz*lt*4; #ifdef PROFILE time += dclock(); print_flops(cname,fname,ForceFlops,time); #endif //------------------------------------------------------------------ // deallocate smalloc'd space //------------------------------------------------------------------ VRB.Sfree(cname, fname, str_site_v2, site_v2) ; sfree(site_v2) ; VRB.Sfree(cname, fname, str_site_v1, site_v1) ; sfree(site_v1) ; VRB.Sfree(cname, fname, str_v2, v2) ; sfree(v2) ; VRB.Sfree(cname, fname, str_v1, v1) ; sfree(v1) ; glb_sum(&L1); glb_sum(&L2); glb_max(&Linf); L1 /= 4.0*GJP.VolSites(); L2 /= 4.0*GJP.VolSites(); VRB.FuncEnd(cname,fname); return ForceArg(L1, sqrt(L2), Linf); }
const Colors operator * (const Colors &c1, const Colors &c2) { return Colors(c1[0]*c2[0],c1[1]*c2[1],c1[2]*c2[2]); }
const Colors operator - (const Colors &c1, const Colors &c2) { return Colors(c1[0]-c2[0],c1[1]-c2[1],c1[2]-c2[2]); }
const Colors operator * (const float f,const Colors &c) { return Colors(c[0]*f,c[1]*f,c[2]*f); }
const Colors operator / (const Colors &c, const float f) { return Colors(c[0]/f,c[1]/f,c[2]/f); }
//------------------------------------------------------------------ // EvolveMomFforce(Matrix *mom, Vector *frm, Float mass, // Float dt): // It evolves the canonical momentum mom by dt // using the fermion force. //------------------------------------------------------------------ ForceArg Fwilson::EvolveMomFforce(Matrix *mom, Vector *chi, Float mass, Float dt) { char *fname = "EvolveMomFforce(M*,V*,F,F,F)"; VRB.Func(cname,fname); Matrix *gauge = GaugeField() ; if (Colors() != 3) ERR.General(cname,fname,"Wrong nbr of colors.") ; if (SpinComponents() != 4) ERR.General(cname,fname,"Wrong nbr of spin comp.") ; if (mom == 0) ERR.Pointer(cname,fname,"mom") ; if (chi == 0) ERR.Pointer(cname,fname,"chi") ; //------------------------------------------------------------------ // allocate space for two CANONICAL fermion fields. //------------------------------------------------------------------ int f_size = FsiteSize() * GJP.VolNodeSites() ; char *str_v1 = "v1" ; Vector *v1 = (Vector *)smalloc(f_size*sizeof(Float)) ; if (v1 == 0) ERR.Pointer(cname, fname, str_v1) ; VRB.Smalloc(cname, fname, str_v1, v1, f_size*sizeof(Float)) ; char *str_v2 = "v2" ; Vector *v2 = (Vector *)smalloc(f_size*sizeof(Float)) ; if (v2 == 0) ERR.Pointer(cname, fname, str_v2) ; VRB.Smalloc(cname, fname, str_v2, v2, f_size*sizeof(Float)) ; //------------------------------------------------------------------ // allocate space for two CANONICAL fermion field on a site. //------------------------------------------------------------------ char *str_site_v1 = "site_v1"; Float *site_v1 = (Float *)smalloc(FsiteSize()*sizeof(Float)); if (site_v1 == 0) ERR.Pointer(cname, fname, str_site_v1) ; VRB.Smalloc(cname, fname, str_site_v1, site_v1, FsiteSize()*sizeof(Float)) ; char *str_site_v2 = "site_v2"; Float *site_v2 = (Float *)smalloc(FsiteSize()*sizeof(Float)); if (site_v2 == 0) ERR.Pointer(cname, fname, str_site_v2) ; VRB.Smalloc(cname, fname, str_site_v2, site_v2, FsiteSize()*sizeof(Float)) ; { CgArg cg_arg ; cg_arg.mass = mass ; DiracOpWilson wilson(*this, v1, v2, &cg_arg, CNV_FRM_YES) ; wilson.CalcHmdForceVecs(chi) ; } int x, y, z, t, lx, ly, lz, lt ; lx = GJP.XnodeSites() ; ly = GJP.YnodeSites() ; lz = GJP.ZnodeSites() ; lt = GJP.TnodeSites() ; //------------------------------------------------------------------ // start by summing first over direction (mu) and then over site // to allow SCU transfers to happen face-by-face in the outermost // loop. //------------------------------------------------------------------ int mu ; Matrix tmp, f ; Float L1 = 0.0; Float L2 = 0.0; Float Linf = 0.0; for (mu=0; mu<4; mu++) { for (t=0; t<lt; t++) for (z=0; z<lz; z++) for (y=0; y<ly; y++) for (x=0; x<lx; x++) { int gauge_offset = x+lx*(y+ly*(z+lz*t)) ; int vec_offset = FsiteSize()*gauge_offset ; gauge_offset = mu+4*gauge_offset ; Float *v1_plus_mu ; Float *v2_plus_mu ; int vec_plus_mu_offset = FsiteSize() ; Float coeff = -2.0 * dt ; switch (mu) { case 0 : vec_plus_mu_offset *= (x+1)%lx+lx*(y+ly*(z+lz*t)) ; if ((x+1) == lx) { getPlusData( (IFloat *)site_v1, (IFloat *)v1+vec_plus_mu_offset, FsiteSize(), mu) ; getPlusData( (IFloat *)site_v2, (IFloat *)v2+vec_plus_mu_offset, FsiteSize(), mu) ; v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; if (GJP.XnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; } break ; case 1 : vec_plus_mu_offset *= x+lx*((y+1)%ly+ly*(z+lz*t)) ; if ((y+1) == ly) { getPlusData( (IFloat *)site_v1, (IFloat *)v1+vec_plus_mu_offset, FsiteSize(), mu) ; getPlusData( (IFloat *)site_v2, (IFloat *)v2+vec_plus_mu_offset, FsiteSize(), mu) ; v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; if (GJP.YnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; } break ; case 2 : vec_plus_mu_offset *= x+lx*(y+ly*((z+1)%lz+lz*t)) ; if ((z+1) == lz) { getPlusData( (IFloat *)site_v1, (IFloat *)v1+vec_plus_mu_offset, FsiteSize(), mu) ; getPlusData( (IFloat *)site_v2, (IFloat *)v2+vec_plus_mu_offset, FsiteSize(), mu) ; v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; if (GJP.ZnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; } break ; case 3 : vec_plus_mu_offset *= x+lx*(y+ly*(z+lz*((t+1)%lt))) ; if ((t+1) == lt) { getPlusData( (IFloat *)site_v1, (IFloat *)v1+vec_plus_mu_offset, FsiteSize(), mu) ; getPlusData( (IFloat *)site_v2, (IFloat *)v2+vec_plus_mu_offset, FsiteSize(), mu) ; v1_plus_mu = site_v1 ; v2_plus_mu = site_v2 ; if (GJP.TnodeBc()==BND_CND_APRD) coeff = -coeff ; } else { v1_plus_mu = (Float *)v1+vec_plus_mu_offset ; v2_plus_mu = (Float *)v2+vec_plus_mu_offset ; } } // end switch mu sproj_tr[mu]( (IFloat *)&tmp, (IFloat *)v1_plus_mu, (IFloat *)v2+vec_offset, 1, 0, 0); sproj_tr[mu+4]( (IFloat *)&f, (IFloat *)v2_plus_mu, (IFloat *)v1+vec_offset, 1, 0, 0); tmp += f ; f.DotMEqual(*(gauge+gauge_offset), tmp) ; tmp.Dagger(f) ; f.TrLessAntiHermMatrix(tmp) ; f *= coeff ; *(mom+gauge_offset) += f ; Float norm = f.norm(); Float tmp = sqrt(norm); L1 += tmp; L2 += norm; Linf = (tmp>Linf ? tmp : Linf); } } //------------------------------------------------------------------ // deallocate space for two CANONICAL fermion fields on a site. //------------------------------------------------------------------ VRB.Sfree(cname, fname, str_site_v2, site_v2) ; sfree(site_v2) ; VRB.Sfree(cname, fname, str_site_v1, site_v1) ; sfree(site_v1) ; //------------------------------------------------------------------ // deallocate space for two CANONICAL fermion fields. //------------------------------------------------------------------ VRB.Sfree(cname, fname, str_v2, v2) ; sfree(v2) ; VRB.Sfree(cname, fname, str_v1, v1) ; sfree(v1) ; glb_sum(&L1); glb_sum(&L2); glb_max(&Linf); L1 /= 4.0*GJP.VolSites(); L2 /= 4.0*GJP.VolSites(); return ForceArg(L1, sqrt(L2), Linf); }
int Fwilson::FsiteSize() const { return 2 * Colors() * SpinComponents(); // re/im * colors * spin_components }
const Colors operator + (const Colors &c1, const Colors &c2) { return Colors(c1[0]+c2[0],c1[1]+c2[1],c1[2]+c2[2]); }