STDMETHODIMP CXRecord::SetFormat(BSTR newFmt) { m_nDocFormat = CXTypeManager::GetFormatHash(newFmt); if(m_nDocFormat == -1)return E_NOTIMPL; return InitField(CXTypeManager::GetFormat(m_nDocFormat)); }
/* * Class: sun_java2d_SurfaceData * Method: initIDs * Signature: ()V */ JNIEXPORT void JNICALL Java_sun_java2d_SurfaceData_initIDs(JNIEnv *env, jclass sd) { jclass pICMClass; InitGlobalClassRef(pInvalidPipeClass, env, "sun/java2d/InvalidPipeException"); InitGlobalClassRef(pNullSurfaceDataClass, env, "sun/java2d/NullSurfaceData"); InitField(pDataID, env, sd, "pData", "J"); InitField(validID, env, sd, "valid", "Z"); InitClass(pICMClass, env, "java/awt/image/IndexColorModel"); InitField(allGrayID, env, pICMClass, "allgrayopaque", "Z"); }
int TestFieldDG(void){ int test = (1==1); Field f; f.model.m=1; // only one conservative variable f.model.NumFlux=TransportNumFlux; f.model.BoundaryFlux=TestTransportBoundaryFlux; f.model.InitData=TestTransportInitData; f.model.ImposedData=TestTransportImposedData; f.varindex=GenericVarindex; f.interp.interp_param[0]=1; // _M f.interp.interp_param[1]=2; // x direction degree f.interp.interp_param[2]=2; // y direction degree f.interp.interp_param[3]=2; // z direction degree f.interp.interp_param[4]=1; // x direction refinement f.interp.interp_param[5]=1; // y direction refinement f.interp.interp_param[6]=1; // z direction refinement ReadMacroMesh(&(f.macromesh),"test/testcube.msh"); BuildConnectivity(&(f.macromesh)); PrintMacroMesh(&(f.macromesh)); //AffineMapMacroMesh(&(f.macromesh)); PrintMacroMesh(&(f.macromesh)); InitField(&f); CheckMacroMesh(&(f.macromesh),f.interp.interp_param+1); dtField(&f); DisplayField(&f); int yes_compare = 1; int no_compare = 0; PlotField(0,no_compare,&f,"visu.msh"); PlotField(0,yes_compare,&f,"error.msh"); // test the time derivative with the exact solution for(int i=0;i<f.model.m * f.macromesh.nbelems * NPG(f.interp.interp_param+1);i++){ test = test && fabs(4*f.wn[i]-pow(f.dtwn[i],2))<1e-2; assert(test); } return test; };
/* * Function: main * * See inline comments describing steps. */ int main () { // Set the parameters of the kernel smoother. // the valid region is from // corner (kernelwidth, kernelwidth) to // corner (dimension-kernelwidth-1, dimension-kernelwidth-1) unsigned dimension = 2064; unsigned kernelwidth = 8; // These are good small values to use. //unsigned dimension = 8; //unsigned kernelwidth = 1; // Create the input field float *field = (float *) malloc ( dimension * dimension * sizeof(float)); InitField ( dimension, field ); // Create the output field float *out = (float *) malloc ( dimension * dimension * sizeof(float)); memset ( out, 0, dimension * dimension *sizeof(float)); // Collect timing information struct timeval ta, tb; gettimeofday ( &ta, NULL ); // Invoke the kernel smoother SmoothField ( dimension, kernelwidth, field, out ); // Report timing information gettimeofday ( &tb, NULL ); if ( ta.tv_usec < tb.tv_usec ) { printf ("Elapsed total time (s/m): %ld:%d\n", tb.tv_sec - ta.tv_sec, tb.tv_usec - ta.tv_usec ); } else { printf ("Elapsed total time (s/m): %ld:%d\n", tb.tv_sec - ta.tv_sec - 1, 1000000 - tb.tv_usec + ta.tv_usec ); } // See what happened. for ( unsigned j=dimension; j< dimension; j++ ) { for ( unsigned i=0; i< dimension; i++ ) { printf ("%4.4f, ", out[j*dimension + i]); } printf ("\n"); } // Free the allocated fields free(field); free(out); }
SaveSelectionDlg::SaveSelectionDlg(Project* project_s, wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) : project(project_s), grid_base(project_s->GetGridBase()), m_all_init(false), is_space_time(project_s->GetGridBase()->IsTimeVariant()) { SetParent(parent); CreateControls(); Centre(); InitTime(); FillColIdMap(); InitField(); m_all_init = true; }
void SaveSelectionDlg::OnSaveFieldChoiceTm( wxCommandEvent& event ) { if (!is_space_time) return; int prev_col = -1; if (m_save_field_choice->GetSelection() != wxNOT_FOUND) { prev_col = col_id_map[m_save_field_choice->GetSelection()]; } InitField(); if (prev_col != -1) { for (int i=0; i<col_id_map.size(); i++) { if (prev_col == col_id_map[i]) { m_save_field_choice->SetSelection(i); } } } CheckApplySaveSettings(); }
void SaveSelectionDlg::OnAddField( wxCommandEvent& event ) { DataViewerAddColDlg dlg(grid_base, this, false, true, "SELECT"); if (dlg.ShowModal() != wxID_OK) return; int col = dlg.GetColId(); if (grid_base->GetColType(col) != GeoDaConst::long64_type && grid_base->GetColType(col) != GeoDaConst::double_type) return; FillColIdMap(); InitField(); for (int i=0; i<col_id_map.size(); i++) { if (col == col_id_map[i]) { m_save_field_choice->SetSelection(i); } } EnableTimeField(); CheckApplySaveSettings(); }
GC XCreateGC( Display *display, Drawable d, unsigned long mask, XGCValues *values) { GC gp; /* * In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars * are defined, which is invisible from the outside. The list is assumed * to end with a 0-char, so this must be set explicitely during * initialization. */ #define MAX_DASH_LIST_SIZE 10 gp = (XGCValues *) ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE); if (!gp) { return None; } #define InitField(name,maskbit,default) \ (gp->name = (mask & (maskbit)) ? values->name : (default)) InitField(function, GCFunction, GXcopy); InitField(plane_mask, GCPlaneMask, (unsigned long)(~0)); InitField(foreground, GCForeground, BlackPixelOfScreen(DefaultScreenOfDisplay(display))); InitField(background, GCBackground, WhitePixelOfScreen(DefaultScreenOfDisplay(display))); InitField(line_width, GCLineWidth, 1); InitField(line_style, GCLineStyle, LineSolid); InitField(cap_style, GCCapStyle, 0); InitField(join_style, GCJoinStyle, 0); InitField(fill_style, GCFillStyle, FillSolid); InitField(fill_rule, GCFillRule, WindingRule); InitField(arc_mode, GCArcMode, ArcPieSlice); InitField(tile, GCTile, None); InitField(stipple, GCStipple, None); InitField(ts_x_origin, GCTileStipXOrigin, 0); InitField(ts_y_origin, GCTileStipYOrigin, 0); InitField(font, GCFont, None); InitField(subwindow_mode, GCSubwindowMode, ClipByChildren); InitField(graphics_exposures, GCGraphicsExposures, True); InitField(clip_x_origin, GCClipXOrigin, 0); InitField(clip_y_origin, GCClipYOrigin, 0); InitField(dash_offset, GCDashOffset, 0); InitField(dashes, GCDashList, 4); (&(gp->dashes))[1] = 0; gp->clip_mask = None; if (mask & GCClipMask) { TkpClipMask *clip_mask = AllocClipMask(gp); clip_mask->type = TKP_CLIP_PIXMAP; clip_mask->value.pixmap = values->clip_mask; } return gp; }