//============================================================================= Epetra_IntVector::Epetra_IntVector(const Epetra_BlockMap& map, bool zeroOut) : Epetra_DistObject(map, "Epetra::IntVector"), Values_(0), UserAllocated_(false), Allocated_(false) { AllocateForCopy(); if(zeroOut) PutValue(0); // Zero out values }
// ReadHdropData() reads CF_HDROP data from the passed-in data object, and // puts all dropped files/folders into the specified XML meter. bool CDropTargetController::ReadHdropData (IDataObject* pDataObject) { FORMATETC formatEtc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; STGMEDIUM stgMedium; HDROP hdrop; UINT uNumFiles; TCHAR szNextFile [MAX_PATH]; _bstr_t fileset; bool ret = false; // Get the HDROP data from the data object. if (SUCCEEDED(pDataObject->GetData(&formatEtc, &stgMedium)) && stgMedium.tymed == TYMED_HGLOBAL) { hdrop = (HDROP) ::GlobalLock(stgMedium.hGlobal); if (hdrop != NULL) { // Get the # of files being dropped. uNumFiles = ::DragQueryFile (hdrop, -1, NULL, 0); fileset = "<?xml version=\"1.0\"?>\n<fileset>\n"; for (UINT uFile = 0; uFile < uNumFiles; uFile++) { // Get the next filename from the HDROP info. if (::DragQueryFile ( hdrop, uFile, szNextFile, MAX_PATH ) > 0) { // Insert it into the list! fileset += "<file><path>"; SysStatsUtils::EncodeXMLString(szNextFile, &fileset); fileset += "</path></file>\n"; } } // end for fileset += "</fileset>"; #ifdef _DEBUG FILE *file = fopen("droptarget.xml", "w"); fprintf(file, "%s\n", (char*)fileset); ::fflush(file); fclose(file); #endif PutValue(fileset); ret = true; } ::GlobalUnlock(stgMedium.hGlobal); } return ret; }
//============================================================================= Epetra_LongLongVector::Epetra_LongLongVector(const Epetra_BlockMap& map, bool zeroOut) : Epetra_DistObject(map, "Epetra::LongLongVector"), Values_(0), UserAllocated_(false), Allocated_(false) { if(!map.GlobalIndicesLongLong()) throw ReportError("Epetra_LongLongVector::Epetra_LongLongVector: cannot be called with non long long map index type", -1); AllocateForCopy(); if(zeroOut) PutValue(0); // Zero out values }
bool Object_writer::PutLine(Environment &env, const ValueList &valList) { Signal &sig = env.GetSignal(); foreach_const (ValueList, pValue, valList) { if (pValue != valList.begin()) { _pStreamDst->PutChar(sig, ','); if (sig.IsSignalled()) return false; } if (!PutValue(env, *pValue)) return false; } _pStreamDst->PutChar(sig, '\n'); return !sig.IsSignalled(); }
void IntegrateFromGeometry() { int i,j,k,CE,n=0; double Residual,sum=0.0,*ViewFactorRowScale,*R,*P,*AP; FILE *fp; for( i=0; i<NGeomElem; i++ ) { Geometry[i].Area = BiCubicArea( &Geometry[i] ); Geometry[i].Flags |= GEOMETRY_FLAG_LEAF; } for( i=0; i<NGeomElem; i++ ) for( j=i; j<NGeomElem; j++ ) ComputeViewFactors( &Geometry[i],&Geometry[j],0,0,&CE ); for( i=8; i<12; i++ ) PutValue( &Geometry[i],1.0 ); for( i=0; i<NGeomElem; i++ ) NumerateLeaves( &Geometry[i] ); R = (double *)calloc( NMAX,sizeof(double) ); P = (double *)calloc( NMAX,sizeof(double) ); AP = (double *)calloc( NMAX,sizeof(double) ); ViewFactorRowScale = (double *)calloc( NMAX,sizeof(double) ); for( i=0; i<NGeomElem; i++ ) ComputeViewFactorRowSums( &Geometry[i],0.0,ViewFactorRowScale ); #ifdef OUTPUT_EQU fprintf( stderr, "NMAX: %d\n", NMAX ); A = (double *)calloc( NMAX*NMAX,sizeof(double) ); Y = (double *)calloc( NMAX,sizeof(double) ); S = (double *)calloc( NMAX,sizeof(double) ); for( i=0; i<NGeomElem; i++ ) MakeMatrix( &Geometry[i] ); for( i=0; i<NMAX; i++ ) fprintf( stderr, "ROWSUM1: %g\n", R[i] ); for( i=0; i<NMAX; i++ ) { sum = 0.0; for( j=0; j<NMAX; j++ ) sum += A[i*NMAX+j]; fprintf( stderr, "ROWSUM2: %g\n", sum ); } fprintf( stdout, "%d\n", NMAX ); for( i=0; i<NMAX; i++ ) fprintf( stdout, "%g\n",S[i] ); for( i=0; i<NMAX; i++ ) fprintf( stdout, "%g\n",Y[i] ); for( i=0; i<NMAX; i++ ) { for( j=0; j<NMAX; j++ ) { if ( i==j ) A[i*NMAX+j] = S[i]*(1-0.85*A[i*NMAX+j]/R[i]); else A[i*NMAX+j] = -0.85*A[i*NMAX+j]*S[i]/R[i]; fprintf( stdout, "%g\n", A[i*NMAX+j] ); } Y[i] *= S[i]; S[i] = 0.0; } #endif #ifndef JACOB { double T,second(),Alpha,Beta,RNorm,R1Norm; T = second(); #ifndef OUTPUT_EQU for( i=0; i<NGeomElem; i++ ) LinearSolveResidual( &Geometry[i],0.0,ViewFactorRowScale,R ); for( i=0; i<NGeomElem; i++ ) LinearSolveUpdateB( &Geometry[i],0.0 ); for( i=0; i<NGeomElem; i++ ) LinearSolveUpdateRP( &Geometry[i],0.0,0.0,R,AP ); #else for( i=0; i<NMAX; i++ ) { R[i] = Y[i]; P[i] = Y[i]; } #endif for( j=0; j<200; j++ ) { #ifndef OUTPUT_EQU for( i=0; i<NGeomElem; i++ ) LinearSolveGather( &Geometry[i],0.0,ViewFactorRowScale,P,AP ); #else for( i=0; i<NMAX; i++ ) { AP[i] = 0.0; for( k=0; k<NMAX; k++ ) AP[i] += A[i*NMAX+k]*P[k]; } #endif RNorm = R1Norm = Alpha = Beta = 0.0; for( i=0; i<NMAX; i++ ) RNorm += R[i]*R[i]; for( i=0; i<NMAX; i++ ) Alpha += P[i]*AP[i]; Alpha = RNorm/Alpha; for( i=0; i<NMAX; i++ ) R1Norm += (R[i]-Alpha*AP[i])*(R[i]-Alpha*AP[i]); Beta = R1Norm/RNorm; fprintf( stderr, "ITERATION: %d, RES: %g,%g,%g,%g\n", j,R1Norm,Alpha,Beta,RNorm ); #ifdef OUTPUT_EQU for( i=0; i<NMAX; i++ ) S[i] += Alpha*P[i]; for( i=0; i<NMAX; i++ ) R[i] -= Alpha*AP[i]; for( i=0; i<NMAX; i++ ) P[i] = R[i] + Beta*P[i]; #else for( i=0; i<NGeomElem; i++ ) LinearSolveUpdateB( &Geometry[i],Alpha ); for( i=0; i<NGeomElem; i++ ) LinearSolveUpdateRP( &Geometry[i],Alpha,Beta,R,AP ); #endif if ( R1Norm < 1.0E-11 || j==199 ) { sprintf( str, "b%d.p", j ); fp = fopen( str, "w" ); n = 0; for( i=0; i<NGeomElem; i++ ) PrintGeometry(&Geometry[i],&n); fprintf( fp, "%d %d 1 1\n", n,n/4 ); for( i=0; i<n; i++ )fprintf( fp, "%g %g %g\n",XX[i],YY[i],ZZ[i] ); for( i=0; i<n/4; i++ ) { fprintf( fp, "1 404 %d %d %d %d\n",4*i,4*i+1,4*i+2,4*i+3 ); } for( i=0; i<n; i++ ) fprintf( fp, "%g\n", LL[i] ); fclose( fp ); break; } } fprintf( stderr, "LINSOLVE TIME: %g\n", second()-T ); } #else { double T,second(); T = second(); for( j=0; j<200; j++ ) { for( i=0; i<NGeomElem; i++ ) LinearSolveGather( &Geometry[i], 0.0, 0.0 ); Residual = 0.0; for( i=0; i<NGeomElem; i++ ) LinearSolveUpdate( &Geometry[i],&Residual ); fprintf( stderr, "ITERATION: %d, RES: %g\n", j,Residual ); if ( Residual < 1.0E-11 || j==199 ) { sprintf( str, "b%d.p", j ); fp = fopen( str, "w" ); n = 0; for( i=0; i<NGeomElem; i++ ) PrintGeometry(&Geometry[i],&n); fprintf( fp, "%d %d 1 1\n", n,n/4 ); for( i=0; i<n; i++ )fprintf( fp, "%g %g %g\n",XX[i],YY[i],ZZ[i] ); for( i=0; i<n/4; i++ ) { fprintf( fp, "1 404 %d %d %d %d\n",4*i,4*i+1,4*i+2,4*i+3 ); } for( i=0; i<n; i++ ) fprintf( fp, "%g\n", LL[i] ); fclose( fp ); break; } } fprintf( stderr, "LINSOLVE TIME: %g\n", second()-T ); }
void NetworkTable::PutValue(std::string key, ComplexData& value){ EntryValue eValue; eValue.ptr = &value; PutValue(key, &value.GetType(), eValue); }
void NetworkTable::PutBoolean(std::string key, bool value) { EntryValue eValue; eValue.b = value; PutValue(key, &DefaultEntryTypes::BOOLEAN, eValue); }
void NetworkTable::PutString(std::string key, std::string value) { EntryValue eValue; eValue.ptr = &value; PutValue(key, &DefaultEntryTypes::STRING, eValue); }
void NetworkTable::PutNumber(std::string key, double value) { EntryValue eValue; eValue.f = value; PutValue(key, &DefaultEntryTypes::DOUBLE, eValue); }
void NetworkTableNode::PutComplex(std::string& name, ComplexData& value){ EntryValue eValue; eValue.ptr = &value; PutValue(name, &value.GetType(), eValue); }
void NetworkTableNode::PutString(std::string& name, std::string& value){ EntryValue eValue; eValue.ptr = &value; PutValue(name, &DefaultEntryTypes::STRING, eValue); }
void NetworkTableNode::PutDouble(std::string& name, double value){ EntryValue eValue; eValue.f = value; PutValue(name, &DefaultEntryTypes::DOUBLE, eValue); }
/* finds the value of every led saves it in data structure and in Array (used for drawing screen) */ void findOutput(){ int i, n1, n2, value; output * optr; node * nptr; for(i = 0; i < c.li; i++) { init(&s); MakeStack(i); while(!empty(&s)) { nptr = pop(&s); switch(nptr->type) { case INPUT : PutValue(nptr, value); break; case OUTPUT : GetInputs(&n1, &n2, nptr->ptr); /* Calculating Output */ optr = nptr->ptr; switch(optr->type) { case NAND : value = nand(n1, n2); break; case XNOR : value = xnor(n1, n2); break; case NOR : value = nor(n1, n2); break; case AND : value = and(n1, n2); break; case OR : value = or(n1, n2); break; case XOR : value = xor(n1, n2); break; case NOT : value = not(n1); break; default : break; PutValue(nptr, value); } break; case SWITCH : value = GetValue(nptr->ptr); break; case LED : PutValue(nptr, value); break; } } } ChangeOnscreen(); }