void SoSFEngine::setValue(SoEngine *newValue) // //////////////////////////////////////////////////////////////////////// { setVal(newValue); valueChanged(); }
void Keymapper::Domain::addKeymap(Keymap *map) { iterator it = find(map->getName()); if (it != end()) delete it->_value; setVal(map->getName(), map); }
/* ------------------------------------------------------------------------- */ int readBoard(board_t *pB) { char line[MAX_LINE+1]; int y = 0; int n = 0; int n1, n2, n3, n4, n5, n6, n7, n8, n9; if(!fpIn) { // No input file found printf("Ooops, can't find input file %s\n", fnIn); return(ERROR); } while(fgets(line, MAX_LINE, fpIn) != NULL) { printf("Line #%d: %s\n", y+1, line); n = sscanf(line, "%d %d %d %d %d %d %d %d %d", &n1, &n2, &n3, &n4, &n5, &n6, &n7, &n8, &n9 ); if(n < MAX_BOARD_ROWS) { // skip this row ... input file has blanks printf("--- this line has less than %d input values\n", MAX_BOARD_ROWS); } else { setVal(pB, 0, y, n1); setVal(pB, 1, y, n2); setVal(pB, 2, y, n3); setVal(pB, 3, y, n4); setVal(pB, 4, y, n5); setVal(pB, 5, y, n6); setVal(pB, 6, y, n7); setVal(pB, 7, y, n8); setVal(pB, 8, y, n9); y++; } } fclose(fpIn); return(SUCCESS); }
bool CLuaBinary::skipWrite(const unsigned int iLens) { if (Q_INIT_NUMBER == iLens) { return true; } return setVal(NULL, iLens);; }
/** \brief Function associated with the widget. */ static int configure ( Tcl_Interp *interp, EntryParams *para, GnoclOption options[] ) { #ifdef DEBUG_ENTRY printf ( "entry/staticFuncs/configure\n" ); #endif gnoclAttacheOptCmdAndVar ( &options[onChangedIdx], ¶->onChanged, &options[variableIdx], ¶->variable, "changed", G_OBJECT ( para->entry ), G_CALLBACK ( changedFunc ), interp, traceFunc, para ); if ( options[variableIdx].status == GNOCL_STATUS_CHANGED && options[valueIdx].status == 0 /* value is handled below */ && para->variable != NULL ) { /* if variable does not exist -> set it, else set widget state */ const char *val = Tcl_GetVar ( interp, para->variable, TCL_GLOBAL_ONLY ); if ( val == NULL ) { val = gtk_entry_get_text ( para->entry ); setVariable ( para, val ); } else setVal ( para->entry, val ); } if ( options[valueIdx].status == GNOCL_STATUS_CHANGED ) { char *str = options[valueIdx].val.str; setVal ( para->entry, str ); setVariable ( para, str ); } return TCL_OK; }
bool CLuaBinary::setString(const char *pszVal) { bool bOk = setVal(pszVal, strlen(pszVal)); if (bOk) { bOk = skipWrite(1); } return bOk; }
void ApplicationWindow::updateCtrl(unsigned id) { unsigned ctrl_class = V4L2_CTRL_ID2CLASS(id); if (ctrl_class == V4L2_CID_PRIVATE_BASE) ctrl_class = V4L2_CTRL_CLASS_USER; if (m_ctrlMap[id].flags & CTRL_FLAG_DISABLED) return; if (!m_haveExtendedUserCtrls && ctrl_class == V4L2_CTRL_CLASS_USER) { struct v4l2_control c; c.id = id; c.value = getVal(id); if (ioctl(VIDIOC_S_CTRL, &c)) { errorCtrl(id, errno, c.value); } else if (m_ctrlMap[id].flags & V4L2_CTRL_FLAG_UPDATE) refresh(ctrl_class); return; } struct v4l2_ext_control c; struct v4l2_ext_controls ctrls; memset(&c, 0, sizeof(c)); memset(&ctrls, 0, sizeof(ctrls)); c.id = id; if (m_ctrlMap[id].type == V4L2_CTRL_TYPE_INTEGER64) c.value64 = getVal64(id); else if (m_ctrlMap[id].type == V4L2_CTRL_TYPE_STRING) { c.size = m_ctrlMap[id].maximum + 1; c.string = (char *)malloc(c.size); strcpy(c.string, getString(id).toLatin1()); } else c.value = getVal(id); ctrls.count = 1; ctrls.ctrl_class = ctrl_class; ctrls.controls = &c; if (ioctl(VIDIOC_S_EXT_CTRLS, &ctrls)) { errorCtrl(id, errno, c.value); } else if (m_ctrlMap[id].flags & V4L2_CTRL_FLAG_UPDATE) refresh(ctrl_class); else { if (m_ctrlMap[id].type == V4L2_CTRL_TYPE_INTEGER64) setVal64(id, c.value64); else if (m_ctrlMap[id].type == V4L2_CTRL_TYPE_STRING) { setString(id, c.string); free(c.string); } else setVal(id, c.value); } }
void IArrayBox::resize (const Box& b, int N) { BaseFab<int>::resize(b,N); // // For debugging purposes set values to QNAN when possible. // if ( do_initval ) setVal(0); }
void ApplicationWindow::updateCtrl(unsigned id) { unsigned ctrl_class = V4L2_CTRL_ID2CLASS(id); if (ctrl_class == V4L2_CID_PRIVATE_BASE) ctrl_class = V4L2_CTRL_CLASS_USER; if (ctrlMap[id].flags & (V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_INACTIVE)) return; if (ctrl_class == V4L2_CTRL_CLASS_USER) { struct v4l2_control c; c.id = id; c.value = getVal(id); if (::ioctl(fd, VIDIOC_S_CTRL, &c)) { int err = errno; char buf[200]; sprintf(buf, "Error %08x (%s): %s", id, ctrlMap[id].name, strerror(err)); statusBar()->message(buf, 10000); } return; } struct v4l2_ext_control c; struct v4l2_ext_controls ctrls; memset(&c, 0, sizeof(c)); memset(&ctrls, 0, sizeof(ctrls)); c.id = id; if (ctrlMap[id].type == V4L2_CTRL_TYPE_INTEGER64) c.value64 = getVal64(id); else c.value = getVal(id); ctrls.count = 1; ctrls.ctrl_class = ctrl_class; ctrls.controls = &c; if (::ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls)) { int err = errno; char buf[200]; sprintf(buf, "Error %08x (%s): %s", id, ctrlMap[id].name, strerror(err)); statusBar()->message(buf, 10000); } else if (ctrlMap[id].flags & V4L2_CTRL_FLAG_UPDATE) refresh(ctrl_class); else { if (ctrlMap[id].type == V4L2_CTRL_TYPE_INTEGER64) setVal64(id, c.value64); else setVal(id, c.value); } }
iMultiFab::iMultiFab (const BoxArray& bxs, int ncomp, int ngrow, FabAlloc alloc) : FabArray<IArrayBox>(bxs,ncomp,ngrow,alloc) { Initialize(); if ((check_for_nan || check_for_inf) && alloc == Fab_allocate) setVal(0); }
void ApplicationWindow::setDefaults(unsigned ctrl_class) { for (unsigned i = 0; i < classMap[ctrl_class].size(); i++) { unsigned id = classMap[ctrl_class][i]; if (ctrlMap[id].type != V4L2_CTRL_TYPE_INTEGER64 && ctrlMap[id].type != V4L2_CTRL_TYPE_BUTTON) setVal(id, ctrlMap[id].default_value); } ctrlAction(ctrl_class | CTRL_UPDATE); }
void SoSFEngine::fixCopy(SbBool copyConnections) // //////////////////////////////////////////////////////////////////////// { if (value != NULL) { SoEngine *engineCopy = (SoEngine *) SoFieldContainer::findCopy(value, copyConnections); if (engineCopy != NULL) setVal(engineCopy); } }
void VoxelField::setPerlinNoise( int num ) { float scale = 0.1f; for( int xx = 0; xx < sizeX; xx++ ) { for( int yy = 0; yy < sizeY; yy++ ) { for( int zz = 0; zz < sizeZ; zz++ ) { float val = snoise3( (float)xx*scale, (float)yy*scale, (float)zz*scale ); // val += (1.0f/127.8f); setVal( xx, yy, zz, val ); } } } }
int main() { int a[] = {1, 4, 3 ,8, 9}; for(int i=0; i<5; ++i) { setVal(a[i]); } std::cout << testVal(5) << std::endl; return 0; }
bool CLuaBinary::setUint64(const char *pszVal) { uint64_t uiVal = Q_INIT_NUMBER; m_objStream.clear(); m_objStream.str(""); m_objStream << pszVal; m_objStream >> uiVal; uiVal = ntohl64(uiVal); return setVal((const char *)&uiVal, sizeof(uiVal)); }
bool CLuaBinary::setSint64(const char *pszVal) { int64_t iVal = Q_INIT_NUMBER; m_objStream.clear(); m_objStream.str(""); m_objStream << pszVal; m_objStream >> iVal; iVal = ntohl64(iVal); return setVal((const char *)&iVal, sizeof(iVal)); }
DiscreteValueVect& DiscreteValueVect::operator+=(const DiscreteValueVect &other) { PRECONDITION(other.d_length==d_length,"length mismatch"); unsigned int maxVal = (1<<d_bitsPerVal) - 1; for(unsigned int i=0;i<d_length;i++){ unsigned int v=getVal(i)+other.getVal(i); if(v>maxVal){ v=maxVal; } setVal(i,v); } return *this; }
IArrayBox::IArrayBox (const Box& b, int n) : BaseFab<int>(b,n) { // // For debugging purposes set values to QNAN when possible. // IArrayBox::Initialize(); if ( do_initval ) setVal(0); }
IArrayBox::IArrayBox (const Box& b, int n, bool alloc, bool shared) : BaseFab<int>(b,n,alloc,shared) { // // For debugging purposes set values to QNAN when possible. // if ( alloc && do_initval ) setVal(0); }
void OrbLB::quicksort(int x) { int y = (x+1)%3; int z = (x+2)%3; setVal(x, y, z); qsort(x, 0, nObjs-1); #if 0 CmiPrintf("result for :%d\n", x); for (int i=0; i<nObjs; i++) CmiPrintf("%d ", computeLoad[vArray[x][i].id].tv); CmiPrintf("\n"); #endif }
NombreContraint<TypeNumerique>::NombreContraint(TypeNumerique valeur, TypeNumerique min , TypeNumerique max) { if(max>min) { m_min=min,m_max=max; setVal(valeur); } else { throw "error" ; } }
ArrayData* StructArray::SetStr( ArrayData* ad, StringData* k, Cell v, bool copy ) { auto structArray = asStructArray(ad); auto shape = structArray->shape(); auto result = structArray; auto offset = shape->offsetFor(k); bool isNewProperty = offset == PropertyTable::kInvalidOffset; auto convertToMixedAndAdd = [&]() { auto mixed = copy ? ToMixedCopy(structArray) : ToMixed(structArray); return mixed->addValNoAsserts(k, v); }; if (isNewProperty) { StringData* staticKey; // We don't support adding non-static strings yet. if (k->isStatic()) { staticKey = k; } else { staticKey = lookupStaticString(k); if (!staticKey) return convertToMixedAndAdd(); } auto newShape = shape->transition(staticKey); if (!newShape) return convertToMixedAndAdd(); result = copy ? CopyAndResizeIfNeeded(structArray, newShape) : ResizeIfNeeded(structArray, newShape); offset = result->shape()->offsetFor(staticKey); assert(offset != PropertyTable::kInvalidOffset); // TODO(#3888164): we should restructure things so we don't have // to check KindOfUninit here. initVal(result->data()[offset], v); return result; } if (copy) { result = asStructArray(Copy(structArray)); } assert(offset != PropertyTable::kInvalidOffset); // TODO(#3888164): we should restructure things so we don't have to // check KindOfUninit here. setVal(result->data()[offset], v); return result; }
NombreContraint<TypeNumerique>::NombreContraint(TypeNumerique val, TypeNumerique min, TypeNumerique max) { if (min <= max) { m_min = min; m_max = max; setVal(val); } else { throw ("min > max"); } }
/** \brief Function associated with the widget. */ static char *traceFunc ( ClientData data, Tcl_Interp *interp, const char *name1, const char *name2, int flags ) { EntryParams *para = ( EntryParams * ) data; if ( para->inSetVar == 0 && name1 ) { const char *txt = name1 ? Tcl_GetVar2 ( interp, name1, name2, 0 ) : NULL; if ( txt ) { setVal ( para->entry, txt ); doCommand ( para, txt, 1 ); } } return NULL; }
void ApplicationWindow::setDefaults(unsigned ctrl_class) { for (unsigned i = 0; i < m_classMap[ctrl_class].size(); i++) { unsigned id = m_classMap[ctrl_class][i]; if (m_ctrlMap[id].flags & V4L2_CTRL_FLAG_READ_ONLY) continue; if (m_ctrlMap[id].flags & V4L2_CTRL_FLAG_GRABBED) continue; if (m_ctrlMap[id].type == V4L2_CTRL_TYPE_INTEGER64) setVal64(id, 0); else if (m_ctrlMap[id].type == V4L2_CTRL_TYPE_STRING) setString(id, QString(' ', m_ctrlMap[id].minimum)); else if (m_ctrlMap[id].type != V4L2_CTRL_TYPE_BUTTON) setVal(id, m_ctrlMap[id].default_value); } ctrlAction(ctrl_class | CTRL_UPDATE); }
/* * Copy Constructor * Allocate and copy a new data array * rather than copying the pointer */ Image::Image(Image & I) { int i,j; //Set number of rows and cols num_rows = I.num_rows; num_cols = I.num_cols; //Allocate and copy new data array data = new float[num_rows*num_cols]; for(i=0;i<num_rows;i++) { for(j=0;j<num_cols;j++) { setVal(i,j,I.getVal(i,j)); } } }
template < > void BaseFab<Real>::define() { CH_assert(m_nvar > 0); CH_assert(m_dptr == 0); // CH_assert(m_numpts > 0); // petermc, 8 Dec 2010: Allow empty BaseFab<Real>. if (m_numpts == 0) return; CH_assert(!m_aliased); //CH_assert(!(The_FAB_Arena == 0)); // not a sufficient test!!! #ifdef CH_USE_MEMORY_TRACKING if (s_Arena == NULL) { s_Arena = new BArena(name().c_str()); } #else if (s_Arena == NULL) { s_Arena = new BArena(""); } #endif // if (s_Arena == NULL) // { // MayDay::Error("malloc in basefab failed"); // } m_truesize = m_nvar * m_numpts; m_dptr = static_cast<Real*>(s_Arena->alloc(m_truesize * sizeof(Real))); #ifdef CH_USE_MEMORY_TRACKING s_Arena->bytes += m_truesize * sizeof(Real) + sizeof(BaseFab<Real>); CH_assert(s_Arena->bytes >= 0); if (s_Arena->bytes > s_Arena->peak) { s_Arena->peak = s_Arena->bytes; } #endif #ifdef CH_USE_SETVAL setVal(BaseFabRealSetVal); #endif }
void par_vector_vector_multiply() { int i,j,k; int sum,aik,bkj; for(i=0;i<nrows;i++) { for(j=0;j<ncols;j++) { sum=0.0; for(k=0;k<ncols;k++) { aik=getVal(ma,i,k); bkj=getVal(mb,k,j); sum+=aik*bkj; } setVal(mc,i,j,sum); } } }
double* product(int m1rowCount,int m1colCount,int m2rowCount,int m2colCount,double* m1, double* m2) { int i,j,k,s =0; double* m3 = createMatrix(m1rowCount,m2colCount); for(i=0;i<m1rowCount;i++) { for(j=0;j<m2colCount;j++) { s=0; for(k=0;k<m1colCount;k++) { s+=getVal(m1rowCount,m1colCount,m1,i,k)*getVal(m2rowCount,m2colCount,m2,k,j); } setVal(m1rowCount,m2colCount,m3,i,j,s); } } return m3; }
void Mat_Mat_Multiplication_Sequential() { int i,j,k; int sum,aik,bkj; for(i=0;i<nrows;i++) { for(j=0;j<ncols;j++) { sum=0.0; for(k=0;k<ncols;k++) { aik=getVal(mapA,i,k); bkj=getVal(mapB,k,j); sum+=aik*bkj; } setVal(mapC,i,j,sum); } } }