Beispiel #1
0
//__________________________________________________________________________________
void mpiBgmLoop (int rank, int size)
{
    long        senderID    = 0;
    _String *   resStr      = nil;

    ReportWarning (_String ("MPI Node:") & (long)rank & " is ready for MPIBgmCacheNodeScores tasks");

    // receive serialized Bgm
    _String* theMessage = MPIRecvString (-1, senderID);

    while (theMessage->sLength) {
        _ExecutionList  exL (*theMessage);
        _PMathObj       res = exL.Execute();    // should send this process into CacheNodeScores()

        resStr = res ? (_String*)res->toStr() : new _String ("0");
        ReportWarning (_String ("MPI Node: ") & (long)rank & " executed HBL with result:\n" & resStr);

        if (bgmNamesList.lLength < 1) {
            _String errMsg ("Malformed HBL. No valid BGM has been defined.\n");
            FlagError (errMsg);
            break;
        }
    }

    DeleteObject (theMessage);
}
Beispiel #2
0
//__________________________________________________________________________________
void mpiOptimizerLoop (int rank, int size)
{
	long		 senderID = 0;
			
	ReportWarning (_String ("MPI Node:") & (long)rank & " is ready for MPIParallelOptimizer tasks");
				
	if (mpiPartitionOptimizer)
		ReportWarning (_String("MPI Partitions mode"));
	
	//printf ("Node %d waiting for a string\n", rank);
	_String* theMessage = MPIRecvString (-1,senderID);
	while (theMessage->sLength)
	{
		if (theMessage->beginswith ("#NEXUS"))
		{
			ReadDataSetFile (nil,true,theMessage);
			if (likeFuncNamesList.lLength!=1)
			{
				_String errMsg ("Malformed MPI likelihood function paraller optimizer startup command. No valid LF has been defined.n\n\n");
				FlagError (errMsg);
				break;						
			}
			
			// send back the list of independent variables
			
			_LikelihoodFunction * theLF = (_LikelihoodFunction*)likeFuncList (0);
			
			if (mpiParallelOptimizer && theLF->GetCategoryVars().lLength)
			{
				_String errMsg ("Likelihood functions spawned off to slave MPI nodes can't have category variables.n\n\n");
				FlagError (errMsg);
				break;						
			}
			
			_SimpleList* ivl = & theLF->GetIndependentVars();
			
			_String		 variableSpec (128L, true);
			
			(variableSpec) << LocateVar(ivl->lData[0])->GetName();

			for (long kk = 1; kk < ivl->lLength; kk++)
			{
				(variableSpec) << ';';
				(variableSpec) << LocateVar(ivl->lData[kk])->GetName();	
			}
			
			ReportWarning 		  (variableSpec);
			MPISendString		  (variableSpec,senderID);
			theLF->PrepareToCompute();
			theLF->MPI_LF_Compute (senderID, mpiPartitionOptimizer);
			theLF->DoneComputing();
			PurgeAll (true);
		}
		DeleteObject (theMessage);
		theMessage = MPIRecvString (-1,senderID);
	}	
	DeleteObject (theMessage);		
}
Beispiel #3
0
//__________________________________________________________________________________
void mpiOptimizerLoop (int rank, int size)
{
    long		 senderID = 0;

    ReportWarning (_String ("[MPI] Node:") & (long)rank & " is ready for MPIParallelOptimizer tasks");

    if (hyphyMPIOptimizerMode == _hyphyLFMPIModePartitions)
        ReportWarning ("[MPI] MPI Partitions mode");

    //printf ("Node %d waiting for a string\n", rank);
    _String* theMessage = MPIRecvString (-1,senderID);
    while (theMessage->sLength)
    {
        if (theMessage->beginswith ("#NEXUS"))
        {
            //ReportWarning (*theMessage);
            ReadDataSetFile (nil,true,theMessage);
            if (likeFuncNamesList.lLength!=1)
            {
                FlagError ("[MPI] Malformed MPI likelihood function paraller optimizer startup command. Exactly ONE valid LF must be defined.n\n\n");
                break;
            }

            // send back the list of independent variables

            _LikelihoodFunction * theLF = (_LikelihoodFunction*)likeFuncList (0);
            if (hyphyMPIOptimizerMode == _hyphyLFMPIModeREL && theLF->CountObjects (4))
            {
                FlagError (_String("[MPI] Likelihood functions spawned off to slave MPI nodes can't have category variables.n\n\n"));
                break;
            }

            _SimpleList* ivl = & theLF->GetIndependentVars();
            _String		 variableSpec (128L, true);

            (variableSpec) << LocateVar(ivl->lData[0])->GetName();

            for (long kk = 1; kk < ivl->lLength; kk++)
            {
                (variableSpec) << ';';
                (variableSpec) << LocateVar(ivl->lData[kk])->GetName();
            }
            variableSpec.Finalize();
            ReportWarning 		  (_String("[MPI] Sending back the following variable list\n") & variableSpec);
            MPISendString		  (variableSpec,senderID);
            theLF->PrepareToCompute();
            theLF->MPI_LF_Compute (senderID, !(hyphyMPIOptimizerMode == _hyphyLFMPIModeREL ||
                                               hyphyMPIOptimizerMode  == _hyphyLFMPIModeSiteTemplate));
            theLF->DoneComputing();
            PurgeAll (true);
        }
        DeleteObject (theMessage);
        theMessage = MPIRecvString (-1,senderID);
    }
    DeleteObject (theMessage);
}
Beispiel #4
0
void Device::Open(QString path, bool close) {
	this->path = path;
	problemReported = false;

	if(close)
		Close();

	// skip opening device pointing to result file
	if(path.length() == 0)
		return;

	// open device file
	fd = open(path.toUtf8(), O_RDONLY | O_LARGEFILE | O_SYNC);
	if(fd < 0) {
		ReportWarning();
	}

	DropCaches();

	// get drive size
	device_size = lseek64(fd, 0, SEEK_END);

	// set pos to begin of device
	SetPos(0);

	DriveInfo();
}
Beispiel #5
0
void Device::DropCaches() {
	// give advice to disable caching
	int ret = posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
	if(ret)
		ReportWarning();

	// empty caches
	QFile caches("/proc/sys/vm/drop_caches");
	caches.open(QIODevice::WriteOnly);
	if(caches.isOpen()) {
		caches.putChar('3');
		caches.close();
	} else {
		ReportWarning();
	}
}
/**
 * Reports errors related to unplugged joysticks
 * Throttles the errors so that they don't overwhelm the DS
 */
void DriverStation::ReportJoystickUnpluggedWarning(std::string message) {
  double currentTime = Timer::GetFPGATimestamp();
  if (currentTime > m_nextMessageTime) {
    ReportWarning(message);
    m_nextMessageTime = currentTime + JOYSTICK_UNPLUGGED_MESSAGE_INTERVAL;
  }
}
Beispiel #7
0
_PMathObj  _Variable::Compute (void) // compute or return the value
{
    if (varFormula == nil) { // no formula, just return the value
        if (varValue) {
            return varValue->Compute();
        }

        if (varFlags & HY_VARIABLE_NOTSET) {
            ReportWarning (_String ("Variable '") & *GetName() & "' was not initialized prior to being used");
        }

        varValue =  new _Constant(theValue);
    } else {
        //printf ("Recomputing value of %s\n", theName->sData);
        if (useGlobalUpdateFlag) {
            if ((varFlags & HY_DEP_V_COMPUTED) && varValue) {
                return varValue;
            } else if (varFormula->HasChanged()||!varValue) {
                DeleteObject (varValue);
                varValue = (_PMathObj)varFormula->Compute()->makeDynamic();
            }

            varFlags |= HY_DEP_V_COMPUTED;
        } else if (varFormula->HasChanged()||!varValue) {
            DeleteObject (varValue);
            varValue = (_PMathObj)varFormula->Compute()->makeDynamic();
        }

    }

    return varValue;
}
void _HYPlatformGraphicPane::_DrawPicRes (_HYRect& r, long id)
{
	PicHandle  aPic = GetPicture (id);
	if (aPic)
	{
		Rect		aRect = HYRect2Rect (r);
		PictInfo	pInfo; 
		GetPictInfo (aPic,&pInfo,0,0,0,0);
		
		if (aRect.right-aRect.left<=0)
			r.right = aRect.right = aRect.left + pInfo.sourceRect.right - pInfo.sourceRect.left;

		if (aRect.bottom-aRect.top<=0)
			r.bottom = aRect.bottom = aRect.top + pInfo.sourceRect.bottom - pInfo.sourceRect.top;

		DrawPicture (aPic, &aRect);
		
		ReleaseResource ((Handle)aPic);
	}
	else
	{
		_String errMsg = _String ("No picture resource with ID ") & id;
		ReportWarning (errMsg);
	}
}		
Beispiel #9
0
/****************************************************************************\
**
**  tInputFile::ReadItem
**
**  Reads one parameter from the file. The format is assumed to be a line
**  of text that begins with the code "itemCode", followed by a line containing
**  the parameter to be read. The function is overloaded according to the
**  type of data desired (datType simply governs which overloaded function
**  will be called; it is not used by the routines).
**
**  Inputs:  datType -- dummy variable indicating the data type to be read
**                      (in the case of the string version, the string read
**                      is placed here)
**           itemCode -- string that describes the parameter to be read
**  Returns:  the item read (except in the case of the string version)
**  Modifications:
**    - revised to allow arbitrary ordering of items in infile and/or
**      ReadItem calls in code; routine searches through
**      list until it either finds the right itemCode or reaches EOF.
**      12/23/97 SL
**    - rewritten 11/07/2003 AD
**    - can merely issue warning and return zero-value if bool reqParam = 
**      true. 9/12/03 SL
**
\****************************************************************************/
static
void ReportNonExistingKeyWord(const char *itemCode, bool reqParam ){
  std::cerr << "Cannot find  '" << itemCode
       << "' in the input file." << std::endl;
  if( reqParam )
      ReportFatalError( "Missing parameter in input file" );
  else
      ReportWarning( "Missing parameter in input file, use zero or default value" );
}
Beispiel #10
0
Texture::Texture(const char* filename, GLenum image_format, GLint internal_format, GLint level, GLint border)
{
	glGenTextures(1, &this->id);

	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	FIBITMAP *dib(0);
	BYTE* bits(0);
	unsigned int width(0), height(0);
	GLuint gl_texID;

	fif = FreeImage_GetFileType(filename, 0);  //pobieranie typu tekstury
	if (fif == FIF_UNKNOWN)
		fif = FreeImage_GetFIFFromFilename(filename);
	if (fif == FIF_UNKNOWN){
		ReportWarning("Texture file format undefined");
		return;
	}


	if (FreeImage_FIFSupportsReading(fif))	//sprawdza czy moze odczytac
		dib = FreeImage_Load(fif, filename);	//odczytuje

	if (!dib)
		ReportWarning("Could not load texture");

	bits = FreeImage_GetBits(dib); //rozmiar piksela
	width = FreeImage_GetWidth(dib);	//wielkosc tekstury
	height = FreeImage_GetHeight(dib);

	//if((bits == 0) || (width == 0) || (height == 0))
	//ReportWarning("Wrong bits");
	glBindTexture(GL_TEXTURE_2D, this->id);		//bindowanie i ustawianie parametrow tekstury
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);


	glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height,	//generowanie tekstury
		border, image_format, GL_UNSIGNED_BYTE, bits);


	FreeImage_Unload(dib);
}
Beispiel #11
0
int main(void)
{
  char str[BUFSIZ + 1];
  int ErrorCode;

  ErrorCode = 1;
  while (ErrorMessage[ErrorCode - 1] != NULL) {
    sprintf(str, "Test -- Code %d", ErrorCode);
    ReportWarning(str, ErrorCode);
    ++ErrorCode;
  }
  fprintf(stderr, "\n");
  ReportWarning("", 3);
  fprintf(stderr,
	  "\nThe test is SUCCESSFUL if the next line is the same as the line "
	  "above:\n\n");
  ReportError("", 3);

  return EXIT_SUCCESS;
}
Beispiel #12
0
//__________________________________________________________________________________
_PMathObj _Constant::CChi2 (_PMathObj n)
// chi^2 n d.f. probability up to x
{
    _Constant halfn (((_Constant*)n)->theValue*.5),
              halfx (theValue*0.5);

    if (theValue < 0. || halfn.theValue <= 0.) {
        ReportWarning ("CChi2(x,n) only makes sense for both arguments positive");
        return new _Constant (0.0);
    }
    return halfn.IGamma( &halfx);
}
Beispiel #13
0
//__________________________________________________________________________________
void	ProcessConfigStr (_String& conf)
{
	_String errMsg;
	for (long i=1; i<conf.sLength; i++)
	{
		switch (conf.sData[i])
		{
			case 'p':
			case 'P':
			{
				usePostProcessors = true;
				break;
			}
			case 'c':
			case 'C':
			{
				calculatorMode = true;
				break;
			}
			case 'd':
			case 'D':
			{
				dropIntoDebugMode = true;
				break;
			}
			case 'u':
			case 'U':
			{
				updateMode = true;
				break;
			}
			case 'l':
			case 'L':
			{
				logInputMode = true;
				break;
			}
			//case 'i':
			//case 'I':
			//{
				//pipeMode = true;
				//break;
			//}
			default:
			{
				errMsg = "Option ";
				errMsg = errMsg & conf.sData[i] & " is not valid and is ignored";
				ReportWarning (errMsg);
			}
		}
	}
}
Beispiel #14
0
//__________________________________________________________________________________
_PMathObj _Constant::InvChi2 (_PMathObj n)
// chi^2 n d.f. probability up to x
{
    if (!chi2) {
        _String fla ("IGamma(_n_,_x_)");
        chi2 = new _Formula (fla, nil);
        fla = "_x_^(_n_-1)/Gamma(_n_)/Exp(_x_)";
        derchi2 = new _Formula (fla,nil);
    }
    _Constant halfn (((_Constant*)n)->theValue*.5);
    if ((theValue<0)||(halfn.theValue<0)||(theValue>1.0)) {
        _String warnMsg ("InvChi2(x,n) only makes sense for n positive, and x in [0,1]");
        ReportWarning (warnMsg);
        return new _Constant (0.0);
    }
    LocateVar(dummyVariable2)->SetValue (&halfn);
    halfn.SetValue(chi2->Newton(*derchi2,theValue,1e-25,1.e100,LocateVar(dummyVariable1))*2);
    return (_PMathObj)halfn.makeDynamic();
}
Beispiel #15
0
	void MPISwitchNodesToMPIMode (long totalNodeCount)
	{
		_String message = mpiLoopSwitchToOptimize & hyphyMPIOptimizerMode;
		
			// send a context switch signal
		for (long ni = 1; ni <= totalNodeCount; ni++)
			MPISendString (message, ni);
		// receive confirmation of successful switch
		for (long ni = 1; ni <= totalNodeCount; ni++)
		{
			long fromNode = ni;
			_String t (MPIRecvString (ni,fromNode));
			if (!t.Equal (&mpiLoopSwitchToOptimize))
			{
				WarnError (_String("[MPI] Failed to confirm MPI mode switch at node ") & ni);
				return;
			}
			else
				ReportWarning (_String("[MPI] Successful mode switch to mode ") & hyphyMPIOptimizerMode & " confirmed from node " & ni);	
		}
	}
Beispiel #16
0
bool InitWindow( uint32_t hWnd )
{
    if ( !InitialiseOpenGLWindow( hWnd, 0, 0,  OpenGL.WindowWidth, OpenGL.WindowHeight ) ) {
        Error( "Failed to Initialise OpenGL Window!\n" );
        return false;
    }

    if ( !strcmp( (char*)glGetString( GL_RENDERER ), "GDI Generic" ) )
        ReportWarning("You are running in a Non-Accelerated OpenGL!!!\nThings can become really slow");

    ValidateUserConfig( );

    GlideMsg( OGL_LOG_SEPARATE );
    GlideMsg( " Setting in Use: \n" );
    GlideMsg( OGL_LOG_SEPARATE );
    GlideMsg( "Init Full Screen = %s\n", InternalConfig.InitFullScreen ? "true" : "false" );
    GlideMsg( "Fog = %s\n", InternalConfig.FogEnable ? "true" : "false" );
    GlideMsg( "Precision Fix = %s\n", InternalConfig.PrecisionFix ? "true" : "false" );
    GlideMsg( "Wrap 565 to 5551 = %s\n", InternalConfig.Wrap565to5551 ? "true" : "false" );
    GlideMsg( "Texture Memory Size = %d Mb\n", InternalConfig.TextureMemorySize );
    GlideMsg( "Frame Buffer Memory Size = %d Mb\n", InternalConfig.FrameBufferMemorySize );
    GlideMsg( "MMX is %s\n", InternalConfig.MMXEnable ? "present" : "not present" );
    GlideMsg( OGL_LOG_SEPARATE );

#ifdef OGL_DEBUG
    GlideMsg( OGL_LOG_SEPARATE );
    GlideMsg( "GlideState size = %d\n", sizeof( GlideState ) );
    GlideMsg( "GrState size = %d\n", sizeof( GrState ) );
    GlideMsg( OGL_LOG_SEPARATE );
#endif

    GlideMsg( OGL_LOG_SEPARATE );
    GlideMsg( "** Glide Calls **\n" );
    GlideMsg( OGL_LOG_SEPARATE );

    return true;
}
Beispiel #17
0
void         TrainModelNN   (_String* model, _String* matrix)
{
    _String         errMsg;

    long            modelIdx = modelNames.Find(model);

    _Parameter      verbI;

    checkParameter (VerbosityLevelString, verbI, 0.0);

    char            buffer [128];

    if (modelIdx < 0) {
        errMsg = *model & " did not refer to an existring model";
    } else {
        _Variable*    boundsMatrix              =   FetchVar  (LocateVarByName (*matrix));

        if (boundsMatrix && (boundsMatrix->ObjectClass() == MATRIX)) {
            _Matrix  *    bmatrix               =   (_Matrix*)      boundsMatrix->GetValue ();

            if (bmatrix->IsAStringMatrix() && (bmatrix->GetVDim () == 3)) {
                _Variable*    modelMatrix           =   LocateVar       (modelMatrixIndices.lData[modelIdx]);
                _SimpleList   modelVariableList;
                {
                    _AVLList mvla (&modelVariableList);
                    modelMatrix->ScanForVariables       (mvla, true);
                    mvla.ReorderList();
                }

                if (bmatrix->GetHDim () == modelVariableList.lLength) {
                    // now map model variables to bounds matrix
                    _SimpleList          variableMap;
                    _String             *myName;

                    for (long k = 0; k < modelVariableList.lLength; k++) {
                        myName = ((_FString*)bmatrix->GetFormula(k,0)->Compute())->theString;
                        long      vID    = LocateVarByName (*myName);

                        if (vID < 0) {
                            break;
                        }

                        vID = variableNames.GetXtra (vID);
                        vID = modelVariableList.Find(vID);

                        if (vID < 0) {
                            break;
                        }

                        variableMap << vID;
                    }

                    if (variableMap.lLength == modelVariableList.lLength) {
                        _Matrix     vBounds (variableMap.lLength,2, false, true);

                        long        k2 = 0;

                        for (; k2 < variableMap.lLength; k2++) {
                            _Parameter lb = ((_FString*)bmatrix->GetFormula(k2,1)->Compute())->theString->toNum(),
                                       ub = ((_FString*)bmatrix->GetFormula(k2,2)->Compute())->theString->toNum();

                            if ( ub>lb || k2) {
                                vBounds.Store (k2,0,lb);
                                vBounds.Store (k2,1,ub);
                                if (ub<=lb && vBounds (k2-1,0) <= vBounds (k2-1,1) && (!CheckEqual(vBounds (k2-1,0),0.0) || !CheckEqual(vBounds (k2-1,1),1.0))) {
                                    break;
                                }
                            }

                        }
                        if (k2 == modelVariableList.lLength) {
                            // set up the sampling now
                            _String             fName       = ProcessLiteralArgument (&ModelNNFile,nil);
                            FILE*               nnFile      = doFileOpen (fName.getStr(), "w");
                            if (nnFile) {
                                _Matrix*            modelMatrix = (_Matrix*) LocateVar(modelMatrixIndices.lData[modelIdx])->GetValue();

                                _Parameter          mainSteps,
                                                    checkSteps,
                                                    errorTerm,
                                                    loopMax,
                                                    hiddenNodes,
                                                    absError,
                                                    nn1,
                                                    nn2;

                                long                fullDimension = modelMatrix->GetHDim() * modelMatrix->GetVDim();


                                checkParameter      (ModelNNTrainingSteps,      mainSteps,      10000.0);
                                checkParameter      (ModelNNVerificationSample, checkSteps,     500.0);
                                checkParameter      (ModelNNPrecision,          errorTerm,      0.01);
                                checkParameter      (ModelNNTrainingSteps,      loopMax,        10);
                                checkParameter      (ModelNNHiddenNodes,        hiddenNodes,    5);
                                checkParameter      (ModelNNLearningRate,       nn1,            .3);
                                checkParameter      (ModelNNPersistenceRate,    nn2,            .1);

                                Net**               matrixNet = new Net* [fullDimension] ;

                                for (long i = 0; i < fullDimension; i++) {
                                    checkPointer (matrixNet [i] = new Net (variableMap.lLength,(long)hiddenNodes,1,errorTerm,nn1,nn2,100,200,true));
                                    //matrixNet[i]->verbose = true;
                                }

                                checkPointer        (matrixNet);

                                _List               tIn,
                                                    tOut;

                                FILE*               varSamples = doFileOpen ("variableSamples.out", "w");

                                fprintf (varSamples, "%s" ,LocateVar(modelVariableList.lData[0])->GetName()->getStr());
                                for (long vc = 1; vc < modelVariableList.lLength; vc++) {
                                    fprintf (varSamples, ",%s" ,LocateVar(modelVariableList.lData[variableMap.lData[vc]])->GetName()->getStr());
                                }

                                fprintf (varSamples, "\n");

                                for (long itCount = 0; itCount < loopMax; itCount ++) {
                                    if (verbI > 5) {
                                        snprintf (buffer, sizeof(buffer), "\nNeural Network Pass %ld. Building a training set...\n", itCount);
                                        BufferToConsole (buffer);
                                    }

                                    while   (tIn.countitems() < mainSteps) {
                                        NNMatrixSampler     (0, vBounds, modelVariableList, variableMap, modelMatrix, tIn, tOut);
                                    }

                                    _Matrix             inData (mainSteps, variableMap.lLength, false, true);
                                    _Parameter          *md = inData.theData;

                                    for (long matrixC = 0; matrixC < mainSteps; matrixC++) {
                                        _Parameter  *   ed = ((_Matrix*)tIn (matrixC))->theData;
                                        fprintf (varSamples, "\n%g",*ed);
                                        *md = *ed;
                                        ed++;
                                        md++;
                                        for (long entryC = 1; entryC < variableMap.lLength; entryC++, ed++, md++) {
                                            *md = *ed;
                                            fprintf (varSamples, ",%g", *md);
                                        }
                                    }

                                    tIn.Clear();

                                    if (verbI > 5) {
                                        BufferToConsole ( "Done Building Training Set. Training...\n");
                                    }

                                    long lastDone = 0;

                                    for (long cellCount = 0; cellCount < fullDimension; cellCount++) {
                                        Net* thisCell = matrixNet[cellCount];
                                        _Matrix outVector (mainSteps, 1, false, true);

                                        for (long oc = 0; oc < mainSteps; oc++) {
                                            outVector.theData[oc] = ((_Matrix*)tOut(oc))->theData[cellCount];
                                        }

                                        thisCell->studyAll (inData.theData, outVector.theData, mainSteps);

                                        long    nowDone = (cellCount+1)*100./fullDimension;
                                        if (nowDone > lastDone) {
                                            snprintf (buffer, sizeof(buffer),"%ld%% done\n", lastDone = nowDone);
                                            BufferToConsole (buffer);
                                        }
                                    }
                                    tOut.Clear();

                                    if (verbI > 5) {
                                        BufferToConsole ( "Done Training. Resampling...\n");
                                    }

                                    _PMathObj  tObj = _Constant(0).Time();
                                    _Parameter time1 = tObj->Value(),
                                               time2;

                                    while   (tIn.countitems() < checkSteps) {
                                        NNMatrixSampler     (0, vBounds, modelVariableList, variableMap, modelMatrix, tIn, tOut);
                                    }

                                    absError = 0.0;

                                    DeleteObject (tObj);
                                    tObj = _Constant(0).Time();
                                    time2 = tObj->Value();

                                    if (verbI > 5) {
                                        snprintf (buffer, sizeof(buffer),"Done Resampling in %g seconds. Computing Error...\n", time2-time1);
                                        BufferToConsole (buffer);
                                    }

                                    _Parameter  maxValT,
                                                maxValE;

                                    for (long verCount = 0; verCount < checkSteps; verCount++) {
                                        _Parameter*  inData     = ((_Matrix*)tIn(verCount))->theData,
                                                     *  outData  = ((_Matrix*)tOut(verCount))->theData;

                                        for (long cellCount = 0; cellCount < fullDimension; cellCount++) {
                                            Net         *thisCell = matrixNet[cellCount];

                                            _Parameter estVal     = thisCell->eval(inData)[0],
                                                       trueVal      = outData[cellCount],
                                                       localError;

                                            localError = estVal-trueVal;

                                            if (localError < 0) {
                                                localError = -localError;
                                            }

                                            if (absError < localError) {
                                                maxValT  = trueVal;
                                                maxValE  = estVal;
                                                absError = localError;
                                            }
                                        }
                                    }

                                    DeleteObject (tObj);
                                    tObj = _Constant(0).Time();
                                    time1 = tObj->Value();
                                    DeleteObject (tObj);


                                    if (verbI > 5) {
                                        snprintf (buffer, sizeof(buffer), "Done Error Checking in %g seconds. Got max abs error %g on the pair %g %g\n", time1-time2, absError, maxValT, maxValE);
                                        BufferToConsole (buffer);
                                    }
                                    if (absError <= errorTerm) {
                                        break;
                                    }
                                }

                                if (absError > errorTerm) {
                                    ReportWarning (_String("Couldn't achive desired precision in TrainModelNN. Achieved error of ") & absError);
                                }
                                fclose  (varSamples);
                                fprintf (nnFile,"{{\n\"%s\"", LocateVar(modelVariableList.lData[0])->GetName()->getStr());
                                _Matrix newBounds (modelVariableList.lLength, 2, false, true);
                                if (vBounds(0,0)>vBounds(0,1)) {
                                    newBounds.Store (variableMap.lData[0],0,0.);
                                    newBounds.Store (variableMap.lData[0],1,1.);
                                } else {
                                    newBounds.Store (variableMap.lData[0],0,vBounds(0,0));
                                    newBounds.Store (variableMap.lData[0],1,vBounds(0,1));
                                }
                                for (long varCounter = 1; varCounter < modelVariableList.lLength; varCounter ++) {
                                    fprintf (nnFile,",\n\"%s\"", LocateVar(modelVariableList.lData[varCounter])->GetName()->getStr());
                                    if (vBounds(varCounter,0)>vBounds(varCounter,1)) {
                                        newBounds.Store (variableMap.lData[varCounter],0,0.);
                                        newBounds.Store (variableMap.lData[varCounter],1,1.);
                                    } else {
                                        newBounds.Store (variableMap.lData[varCounter],0,vBounds(varCounter,0));
                                        newBounds.Store (variableMap.lData[varCounter],1,vBounds(varCounter,1));
                                    }
                                }

                                fprintf (nnFile,"\n}}\n");
                                newBounds.toFileStr (nnFile);


                                for (long i2 = 0; i2 < fullDimension; i2++) {
                                    matrixNet[i2]->save(nnFile);
                                    delete matrixNet [i2];
                                }

                                fclose (nnFile);
                                delete              matrixNet;
                            } else {
                                errMsg = _String ("Failed to open ") & fName & " for writing";
                            }
                        } else {
                            errMsg = _String ("Invalid variable bounds in row ") & (k2+1) & " of the bounds matrix";
                        }
                    } else {
                        errMsg = *myName & " was not one of the model parameters";
                    }

                } else {
                    errMsg = *matrix & " must be a have the same number of rows as the number of model parameters";
                }

            } else {
                errMsg = *matrix & " must be a string matrix with 3 columns";
            }
        } else {
            errMsg = *matrix & " was not the identifier of a valid matrix variable";
        }



    }

    if (errMsg.sLength) {
        errMsg = errMsg & _String(" in call to TrainModelNN.");
        WarnError (errMsg);
    }
}
	void MessageBoxReporter::ReportError(const std::wstring& message)
	{
		ReportWarning(message, m_wsDefaultTitle);
	}
Beispiel #19
0
//__________________________________________________________________________________
void mpiNormalLoop    (int rank, int size, _String & baseDir)
{
    long         senderID = 0;

    ReportWarning ("[MPI] Entered mpiNormalLoop");

    _String* theMessage     = MPIRecvString (-1,senderID),  // listen for messages from any node
             * resStr        = nil;

    while (theMessage->sLength) {
        setParameter    (mpiNodeID,    (_Parameter)rank);
        setParameter    (mpiNodeCount, (_Parameter)size);

        //ReportWarning (*theMessage);
        DeleteObject (resStr);
        resStr       = nil;
        if (theMessage->startswith (mpiLoopSwitchToOptimize) ) {
            hyphyMPIOptimizerMode   = theMessage->Cut(mpiLoopSwitchToOptimize.sLength,-1).toNum();

            ReportWarning           (_String("[MPI] Switched to mpiOptimizer loop with mode ") & hyphyMPIOptimizerMode);
            MPISendString           (mpiLoopSwitchToOptimize,senderID);
            mpiOptimizerLoop        (rank,size);
            ReportWarning           ("[MPI] Returned from mpiOptimizer loop");
            hyphyMPIOptimizerMode   = _hyphyLFMPIModeNone;
            pathNames               && & baseDir;
        } else if ( theMessage->Equal (&mpiLoopSwitchToBGM) ) {
            ReportWarning       ("[MPI] Received signal to switch to mpiBgmLoop");
            MPISendString       (mpiLoopSwitchToBGM, senderID); // feedback to source to confirm receipt of message
            mpiBgmLoop          (rank, size);
            ReportWarning       ("[MPI] Returned from mpiBgmLoop");
        } else {
            if (theMessage->beginswith ("#NEXUS")) {
                _String             msgCopy (*theMessage);
                ReportWarning       ("[MPI] Received a function to optimize");
                ReadDataSetFile     (nil,true,theMessage);
                ReportWarning       ("[MPI] Done with the optimization");
                _Variable*          lfName = FetchVar(LocateVarByName(MPI_NEXUS_FILE_RETURN));

                if (lfName) {
                    resStr = (_String*)(lfName->Compute()->toStr());
                } else {
                    _FString        *lfID = (_FString*)FetchObjectFromVariableByType (&lf2SendBack, STRING);

                    if (!lfID) {
                        FlagError (_String("[MPI] Malformed MPI likelihood function optimization request - did not specify the LF name to return in variable ") & lf2SendBack & ".\n\n\n" );
                        break;
                    }

                    long f = likeFuncNamesList.Find (lfID->theString);

                    if (f<0) {
                        FlagError ("[MPI] Malformed MPI likelihood function optimization request - LF name to return did not refer to a well-defined likelihood function.\n\n\n");
                        break;
                    }
                    _Parameter      pv;
                    checkParameter (shortMPIReturn, pv ,0);
                    resStr       = (_String*)checkPointer(new _String (1024L,true));
                    ((_LikelihoodFunction*)likeFuncList (f))->SerializeLF(*resStr,pv>0.5?_hyphyLFSerializeModeShortMPI:_hyphyLFSerializeModeLongMPI);
                    resStr->Finalize();
                }
            } else {
                _ExecutionList exL (*theMessage);
                _PMathObj res = exL.Execute();
                resStr = res?(_String*)res->toStr():new _String ("0");
            }

            checkPointer (resStr);
            MPISendString(*resStr,senderID);

            _Parameter      keepState = 0.0;
            checkParameter  (preserveSlaveNodeState, keepState, 0.0);

            if (keepState < 0.5) {
                PurgeAll (true);
                pathNames && & baseDir;
            }
        }
        DeleteObject (theMessage);
        theMessage = MPIRecvString (-1,senderID);
    }
    /*MPISendString(empty,senderID);*/
    DeleteObject (resStr);
    DeleteObject (theMessage);
}
Beispiel #20
0
//__________________________________________________________________________________
void  _Variable::SetValue (_PMathObj theP, bool dup) // set the value of the var
{
    //hasBeenChanged = true;
    varFlags &= HY_VARIABLE_SET;
    varFlags |= HY_VARIABLE_CHANGED;

    long     valueClass = theP->ObjectClass();

    if (valueClass==NUMBER) {
        if (varFormula) {

            // also update the fact that this variable is no longer dependent in all declared
            // variable containers which contain references to this variable
            long i;
            for (i = 0; i<variablePtrs.lLength; i++) {
                if (freeSlots.Find(i)>=0) {
                    continue;
                }
                _Variable* theV = (_Variable*)variablePtrs(i);
                if (theV->IsContainer()) {
                    _VariableContainer* theVC = (_VariableContainer*)theV;
                    if (!theVC->RemoveDependance (theIndex)) {
                        ReportWarning ((_String("Can't make variable ")&*GetName()&" independent in the context of "&*theVC->GetName()&" because its template variable is not independent."));
                        continue;
                    }
                }
            }
            for (i = 0; i<likeFuncList.lLength; i++)
                if (((_String*)likeFuncNamesList(i))->sLength) {
                    ((_LikelihoodFunction*)likeFuncList(i))->UpdateDependent(theIndex);
                }

            //_Formula::Clear();
            delete (varFormula);
            varFormula = nil;
        }
        if (varValue) {
            DeleteObject (varValue);
            varValue=nil;
        }

        theValue = theP->Value();

        if (!dup) {
            DeleteObject (theP);
        }

        if (theValue<lowerBound || theValue>upperBound) {
            if (theValue <= lowerBound+1e-50) {
                theValue = lowerBound;
            } else {
                theValue = upperBound;
            }
        }
    } else {
        if (varFormula) {
            delete (varFormula);
            varFormula = nil;
            //theFormula.Clear();
        }
        if (varValue) {
            DeleteObject (varValue);
            varValue=nil;
        }
        if (valueClass==TREE) {
            variablePtrs.lData[theIndex] = (long)(((_TheTree*)theP)->makeDynamicCopy(GetName()));
            DeleteObject(this);
        } else {
            if (dup) {
                varValue = (_PMathObj)theP->makeDynamic();
            } else {
                varValue = theP;
            }
        }
    }
}
Beispiel #21
0
void  _Variable::SetFormula (_Formula& theF) // set the value of the var to a formula
{
    bool changeMe    = false,
         isAConstant = theF.IsAConstant();

    _Formula* myF = &theF;

    if (isAConstant) {
        _PMathObj theP = theF.Compute();
        if (theP) {
            myF = new _Formula ((_PMathObj)theP->makeDynamic(),false);
            checkPointer (myF);
        } else {
            return;
        }
    }

    _SimpleList vars;
    {
        _AVLList vA (&vars);
        theF.ScanFForVariables (vA,true);
        vA.ReorderList();
    }

    if (vars.BinaryFind(theIndex)>=0) {
        _String * sf = (_String*)theF.toStr();
        WarnError ((_String("Can't set variable ")&*GetName()&" to "&*sf&" because it would create a circular dependance."));
        DeleteObject(sf);
        if (&theF!=myF) {
            delete myF;
        }
        return;
    }

    varFlags &= HY_VARIABLE_SET;

    if (varFlags & HY_VARIABLE_CHANGED) {
        varFlags -= HY_VARIABLE_CHANGED;
    }


    if (varFormula) {
        delete (varFormula);
        varFormula = nil;
    } else {
        changeMe = true;
    }

    if (varValue) {
        DeleteObject (varValue);
        varValue=nil;
    }

    //_Formula::Duplicate ((BaseRef)myF);
    varFormula = new _Formula;
    varFormula->Duplicate ((BaseRef)myF);

    // mod 20060125 added a call to simplify constants
    varFormula->SimplifyConstants ();

    // also update the fact that this variable is no longer independent in all declared
    // variable containers which contain references to this variable
    if (changeMe)
        if (deferSetFormula) {
            *deferSetFormula << theIndex;
            deferIsConstant  << isAConstant;
        } else {
            long i;
            _SimpleList tcache;
            long        iv;

            i = variableNames.Traverser (tcache,iv,variableNames.GetRoot());

            for (; i >= 0; i = variableNames.Traverser (tcache,iv)) {
                _Variable* theV = FetchVar(i);
                if (theV->IsContainer()) {
                    _VariableContainer* theVC = (_VariableContainer*)theV;
                    if (theVC->SetDependance(theIndex) == -2) {
                        ReportWarning ((_String("Can't make variable ")&*GetName()&" dependent in the context of "&*theVC->GetName()&" because its template variable is bound by another relation in the global context."));
                        continue;
                    }
                }
            }
            {
                for (long i = 0; i<likeFuncList.lLength; i++)
                    if (((_String*)likeFuncNamesList(i))->sLength) {
                        ((_LikelihoodFunction*)likeFuncList(i))->UpdateIndependent(theIndex,isAConstant);
                    }
            }
        }

    if (&theF!=myF) {
        delete myF;
    }
}
Beispiel #22
0
void dng_info::PostParse (dng_host &host)
	{
	
	uint32 index;
	
	fExif->PostParse (host, *fShared.Get ());
	
	fShared->PostParse (host, *fExif.Get ());
	
	for (index = 0; index < fIFDCount; index++)
		{
		
		fIFD [index]->PostParse ();
		
		}
		
	for (index = 0; index < fChainedIFDCount; index++)
		{
		
		fChainedIFD [index]->PostParse ();
		
		}
		
	if (fShared->fDNGVersion != 0)
		{
	
		// Find main IFD.
		
		fMainIndex = -1;
		
		for (index = 0; index < fIFDCount; index++)
			{
			
			if (fIFD [index]->fUsesNewSubFileType &&
				fIFD [index]->fNewSubFileType == sfMainImage)
				{
				
				if (fMainIndex == -1)
					{
					
					fMainIndex = index;
					
					}
					
				#if qDNGValidate
					
				else
					{

					ReportError ("Multiple IFDs marked as main image");
					
					}
					
				#endif
						
				}
				
			else if (fIFD [index]->fNewSubFileType == sfPreviewImage ||
					 fIFD [index]->fNewSubFileType == sfAltPreviewImage)
				{
				
				// Fill in default color space for DNG previews if not included.
				
				if (fIFD [index]->fPreviewInfo.fColorSpace == previewColorSpace_MaxEnum)
					{
					
					if (fIFD [index]->fSamplesPerPixel == 1)
						{
						
						fIFD [index]->fPreviewInfo.fColorSpace = previewColorSpace_GrayGamma22;
						
						}
						
					else
						{
						
						fIFD [index]->fPreviewInfo.fColorSpace = previewColorSpace_sRGB;
						
						}
					
					}
					
				}
				
			}
			
		// Deal with lossless JPEG bug in early DNG versions.
		
		if (fShared->fDNGVersion < dngVersion_1_1_0_0)
			{
			
			if (fMainIndex != -1)
				{
				
				fIFD [fMainIndex]->fLosslessJPEGBug16 = true;
				
				}
				
			}
			
		// Warn about Chained IFDs.
			
		#if qDNGValidate
					
		if (fChainedIFDCount > 0)
			{
			
			ReportWarning ("This file has Chained IFDs, which will be ignored by DNG readers");
			
			}
			
		#endif
		
		}
		
	}
Beispiel #23
0
void dng_info::ParseIFD (dng_host &host,
						 dng_stream &stream,
						 dng_exif *exif,
						 dng_shared *shared,
						 dng_ifd *ifd,
						 uint64 ifdOffset,
						 int64 offsetDelta,
						 uint32 parentCode)
	{
	
	#if qDNGValidate

	bool isMakerNote = (parentCode >= tcFirstMakerNoteIFD &&
						parentCode <= tcLastMakerNoteIFD);
	
	#endif

	stream.SetReadPosition (ifdOffset);
	
	if (ifd)
		{
		ifd->fThisIFD = ifdOffset;
		}
	
	uint32 ifdEntries = stream.Get_uint16 ();
	
	#if qDNGValidate
	
	if (gVerbose)
		{
		
		printf ("%s: Offset = %u, Entries = %u\n\n",
				LookupParentCode (parentCode),
			    (unsigned) ifdOffset, 
			    (unsigned) ifdEntries);
		
		}
		
	if ((ifdOffset & 1) && !isMakerNote)
		{
		
		char message [256];
	
		sprintf (message,
				 "%s has odd offset (%u)",
				 LookupParentCode (parentCode),
				 (unsigned) ifdOffset);
					 
		ReportWarning (message);
		
		}
		
	#endif
		
	uint32 prev_tag_code = 0;
		
	for (uint32 tag_index = 0; tag_index < ifdEntries; tag_index++)
		{
		
		stream.SetReadPosition (ifdOffset + 2 + tag_index * 12);
		
		uint32 tagCode  = stream.Get_uint16 ();
		uint32 tagType  = stream.Get_uint16 ();
		
		// Minolta 7D files have a bug in the EXIF block where the count
		// is wrong, and we run off into next IFD link.  So if abort parsing
		// if we get a zero code/type combinations.
		
		if (tagCode == 0 && tagType == 0)
			{
			
			#if qDNGValidate
			
			char message [256];
	
			sprintf (message,
					 "%s had zero/zero tag code/type entry",
					 LookupParentCode (parentCode));
					 
			ReportWarning (message);
			
			#endif
			
			return;
			
			}
		
		uint32 tagCount = stream.Get_uint32 ();
		
		#if qDNGValidate

			{
		
			if (tag_index > 0 && tagCode <= prev_tag_code && !isMakerNote)
				{
				
				char message [256];
		
				sprintf (message,
						 "%s tags are not sorted in ascending numerical order",
						 LookupParentCode (parentCode));
						 
				ReportWarning (message);
				
				}
				
			}
			
		#endif
			
		prev_tag_code = tagCode;
		
		uint32 tag_type_size = TagTypeSize (tagType);
		
		if (tag_type_size == 0)
			{
			
			#if qDNGValidate
			
				{
			
				char message [256];
		
				sprintf (message,
						 "%s %s has unknown type (%u)",
						 LookupParentCode (parentCode),
						 LookupTagCode (parentCode, tagCode),
						 (unsigned) tagType);
						 
				ReportWarning (message);
							 
				}
				
			#endif
					 
			continue;
			
			}
			
		uint64 tagOffset = ifdOffset + 2 + tag_index * 12 + 8;
		
		if (tagCount * tag_type_size > 4)
			{
			
			tagOffset = stream.Get_uint32 ();
			
			#if qDNGValidate
			
				{
			
				if (!(ifdOffset & 1) && 
				     (tagOffset & 1) &&
				    !isMakerNote     &&
				    parentCode != tcKodakDCRPrivateIFD &&
					parentCode != tcKodakKDCPrivateIFD)
					{
					
					char message [256];
		
					sprintf (message,
							 "%s %s has odd data offset (%u)",
						 	 LookupParentCode (parentCode),
						 	 LookupTagCode (parentCode, tagCode),
							 (unsigned) tagOffset);
							 
					ReportWarning (message);
						 
					}
					
				}
				
			#endif
				
			tagOffset += offsetDelta;
				
			stream.SetReadPosition (tagOffset);
			
			}
			
		ParseTag (host,
				  stream,
			      exif,
				  shared,
				  ifd,
				  parentCode,
				  tagCode,
				  tagType,
				  tagCount,
				  tagOffset,
				  offsetDelta);
			
		}
		
	stream.SetReadPosition (ifdOffset + 2 + ifdEntries * 12);
	
	uint32 nextIFD = stream.Get_uint32 ();
	
	#if qDNGValidate
		
	if (gVerbose)
		{
		printf ("NextIFD = %u\n", (unsigned) nextIFD);
		}
		
	#endif
		
	if (ifd)
		{
		ifd->fNextIFD = nextIFD;
		}
		
	#if qDNGValidate

	if (nextIFD)
		{
		
		if (parentCode != 0 &&
				(parentCode < tcFirstChainedIFD ||
				 parentCode > tcLastChainedIFD  ))
			{

			char message [256];

			sprintf (message,
					 "%s has an unexpected non-zero NextIFD (%u)",
				 	 LookupParentCode (parentCode),
				 	 (unsigned) nextIFD);
					 
			ReportWarning (message);
					 
			}

		}
		
	if (gVerbose)
		{
		printf ("\n");
		}

	#endif
		
	}
Beispiel #24
0
void dng_info::Parse (dng_host &host,
					  dng_stream &stream)
	{
	
	fTIFFBlockOffset = stream.Position ();
	
	fTIFFBlockOriginalOffset = stream.PositionInOriginalFile ();
	
	// Check byte order indicator.
	
	uint16 byteOrder = stream.Get_uint16 ();
	
	if (byteOrder == byteOrderII)
		{
		
		fBigEndian = false;
		
		#if qDNGValidate
		
		if (gVerbose)
			{
			printf ("\nUses little-endian byte order\n");
			}
			
		#endif
			
		stream.SetLittleEndian ();
		
		}
		
	else if (byteOrder == byteOrderMM)
		{

		fBigEndian = true;
		
		#if qDNGValidate
		
		if (gVerbose)
			{
			printf ("\nUses big-endian byte order\n");
			}
			
		#endif
			
		stream.SetBigEndian ();
		
		}
		
	else
		{
		
		#if qDNGValidate
		
		ReportError ("Unknown byte order");
					 
		#endif
					 
		ThrowBadFormat ();

		}
		
	// Check "magic number" indicator.
		
	fMagic = stream.Get_uint16 ();
	
	#if qDNGValidate
	
	if (gVerbose)
		{
		printf ("Magic number = %u\n\n", (unsigned) fMagic);
		}
		
	#endif
	
	ValidateMagic ();
	
	// Parse IFD 0.
	
	uint64 next_offset = stream.Get_uint32 ();
	
	fExif.Reset (host.Make_dng_exif ());
	
	fShared.Reset (host.Make_dng_shared ());
	
	fIFD [0].Reset (host.Make_dng_ifd ());
	
	ParseIFD (host,
			  stream,
			  fExif.Get (),
			  fShared.Get (),
			  fIFD [0].Get (),
			  fTIFFBlockOffset + next_offset,
			  fTIFFBlockOffset,
			  0);
			  	
	next_offset = fIFD [0]->fNextIFD;
	
	fIFDCount = 1;
	
	// Parse chained IFDs.
	
	while (next_offset)
		{
		
		if (next_offset >= stream.Length ())
			{
			
			#if qDNGValidate
			
				{
				
				ReportWarning ("Chained IFD offset past end of stream");

				}
				
			#endif
			
			break;
			
			}
		
		// Some TIFF file writers forget about the next IFD offset, so
		// validate the IFD at that offset before parsing it.
		
		if (!ValidateIFD (stream,
						  fTIFFBlockOffset + next_offset,
						  fTIFFBlockOffset))
			{
			
			#if qDNGValidate
			
				{
				
				ReportWarning ("Chained IFD is not valid");

				}
				
			#endif
			
			break;
			
			}

		if (fChainedIFDCount == kMaxChainedIFDs)
			{
			
			#if qDNGValidate
			
				{
				
				ReportWarning ("Chained IFD count exceeds DNG SDK parsing limit");

				}
				
			#endif
			
			break;
			
			}
			
		fChainedIFD [fChainedIFDCount].Reset (host.Make_dng_ifd ());
		
		ParseIFD (host,
				  stream,
				  NULL,
				  NULL,
				  fChainedIFD [fChainedIFDCount].Get (),
				  fTIFFBlockOffset + next_offset,
				  fTIFFBlockOffset,
				  tcFirstChainedIFD + fChainedIFDCount);
											   
		next_offset = fChainedIFD [fChainedIFDCount]->fNextIFD;
		
		fChainedIFDCount++;
		
		}
		
	// Parse SubIFDs.
	
	uint32 searchedIFDs = 0;
	
	bool tooManySubIFDs = false;
	
	while (searchedIFDs < fIFDCount && !tooManySubIFDs)
		{
		
		uint32 searchLimit = fIFDCount;
		
		for (uint32 searchIndex = searchedIFDs;
			 searchIndex < searchLimit && !tooManySubIFDs;
			 searchIndex++)
			{
			
			for (uint32 subIndex = 0;
			     subIndex < fIFD [searchIndex]->fSubIFDsCount;
			     subIndex++)
				{
				
				if (fIFDCount == kMaxSubIFDs + 1)
					{
					
					tooManySubIFDs = true;
					
					break;
					
					}
				
				stream.SetReadPosition (fIFD [searchIndex]->fSubIFDsOffset +
							 			subIndex * 4);
				
				uint32 sub_ifd_offset = stream.Get_uint32 ();
				
				fIFD [fIFDCount].Reset (host.Make_dng_ifd ());
				
				ParseIFD (host,
						  stream,
						  fExif.Get (),
						  fShared.Get (),
						  fIFD [fIFDCount].Get (),
						  fTIFFBlockOffset + sub_ifd_offset,
						  fTIFFBlockOffset,
						  tcFirstSubIFD + fIFDCount - 1);
				
				fIFDCount++;
					
				}
									
			searchedIFDs = searchLimit;
			
			}
		
		}
		
	#if qDNGValidate

		{
		
		if (tooManySubIFDs)
			{
			
			ReportWarning ("SubIFD count exceeds DNG SDK parsing limit");

			}
		
		}
		
	#endif
		
	// Parse EXIF IFD.
		
	if (fShared->fExifIFD)
		{
		
		ParseIFD (host,
				  stream,
				  fExif.Get (),
				  fShared.Get (),
				  NULL,
				  fTIFFBlockOffset + fShared->fExifIFD,
				  fTIFFBlockOffset,
				  tcExifIFD);
		
		}

	// Parse GPS IFD.
		
	if (fShared->fGPSInfo)
		{
		
		ParseIFD (host,
				  stream,
				  fExif.Get (),
				  fShared.Get (),
				  NULL,
				  fTIFFBlockOffset + fShared->fGPSInfo,
				  fTIFFBlockOffset,
				  tcGPSInfo);
		
		}

	// Parse Interoperability IFD.
		
	if (fShared->fInteroperabilityIFD)
		{
		
		// Some Kodak KDC files have bogus Interoperability IFDs, so
		// validate the IFD before trying to parse it.
		
		if (ValidateIFD (stream,
						 fTIFFBlockOffset + fShared->fInteroperabilityIFD,
						 fTIFFBlockOffset))
			{
		
			ParseIFD (host,
					  stream,
					  fExif.Get (),
					  fShared.Get (),
					  NULL,
					  fTIFFBlockOffset + fShared->fInteroperabilityIFD,
					  fTIFFBlockOffset,
					  tcInteroperabilityIFD);
					  
			}
			
		#if qDNGValidate
		
		else
			{
			
			ReportWarning ("The Interoperability IFD is not a valid IFD");
		
			}
			
		#endif
					   	 
		}

	// Parse Kodak DCR Private IFD.
		
	if (fShared->fKodakDCRPrivateIFD)
		{
		
		ParseIFD (host,
				  stream,
				  fExif.Get (),
				  fShared.Get (),
				  NULL,
				  fTIFFBlockOffset + fShared->fKodakDCRPrivateIFD,
				  fTIFFBlockOffset,
				  tcKodakDCRPrivateIFD);
		
		}

	// Parse Kodak KDC Private IFD.
		
	if (fShared->fKodakKDCPrivateIFD)
		{
		
		ParseIFD (host,
				  stream,
				  fExif.Get (),
				  fShared.Get (),
				  NULL,
				  fTIFFBlockOffset + fShared->fKodakKDCPrivateIFD,
				  fTIFFBlockOffset,
				  tcKodakKDCPrivateIFD);
		
		}

	// Parse MakerNote tag.
	
	if (fShared->fMakerNoteCount)
		{
		
		ParseMakerNote (host,
						stream,
						(uint32) (fTIFFBlockOffset + fShared->fMakerNoteCount),
						fShared->fMakerNoteOffset,
						fTIFFBlockOffset,
						0,
						stream.Length ());
		
		}

	// Parse DNGPrivateData tag.
	
	if (fShared->fDNGPrivateDataCount &&
		fShared->fDNGVersion)
		{
		
		ParseDNGPrivateData (host, stream);
				
		}

	#if qDNGValidate
	
	// If we are running dng_validate on stand-alone camera profile file,
	// complete the validation of the profile.
	
	if (fMagic == magicExtendedProfile)
		{
		
		dng_camera_profile_info &profileInfo = fShared->fCameraProfile;
		
		dng_camera_profile profile;
		
		profile.Parse (stream, profileInfo);
		
		if (profileInfo.fColorPlanes < 3 || !profile.IsValid (profileInfo.fColorPlanes))
			{
			
			ReportError ("Invalid camera profile file");
		
			}
			
		}
		
	#endif
		
	}
void        _HYChartWindow::_PrintChart(void)
{
    _String printTBI ("Chart printing has not yet been implemented\n");
    ReportWarning (printTBI);
}
Beispiel #26
0
/*******************************************************************************
  Function name: Read2DMatrixNetCDF()

  Purpose      : Function to read a 2D array from a file.

  Required     :
    FileName   - name of input file
    Matrix     - address of array data into
    NumberType - code for number type (taken from HDF, see comments at the
                 beginning of InitFileIO.c for more detail)
    NY         - Number of rows
    NX         - Number of columns
    NDataSet   - number of the dataset to read, i.e. the first matrix in a 
                 file is number 0, etc. (this is not used for the NetCDF file,
		 since we can retrieve the variable by name).
    VarName    - Name of variable to retrieve

  Returns      : Number of elements read

  Modifies     : Matrix

  Comments     : NOTE that we cannot modify anything other than the returned
                 Matrix, because we have to stay compatible with Read2DMatrixBin 
*******************************************************************************/
 int Read2DMatrixNetCDF(char *FileName, void *Matrix, int NumberType, int NY,
		       int NX, int NDataSet, ...) 
{
  const char *Routine = "Read2DMatrixNetCDF";
  char Str[BUFSIZE + 1];
  char dimname[NC_MAX_NAME + 1];
  char *VarName;
  int dimids[3];
  int ndims;
  int ncid;
  int ncstatus;
  nc_type TempNumberType;
  int varid;
  size_t index;	
  double time;
  int timid;
  size_t count[3];
  size_t start[3] = { 0, 0, 0 };
  size_t dimlen;
  size_t timelen;
  va_list ap;
  double *Ycoord;
  double *Xcoord;  /* lat, lon variables */
  int	LatisAsc, LonisAsc, flag;    /* flag */
  int lon_varid, lat_varid;
  count[0] = 1;
  count[1] = NY;
  count[2] = NX;

  /****************************************************************************/
  /*                   GO THROUGH VARIABLE ARGUMENT LIST                      */
  /****************************************************************************/
  va_start(ap, NDataSet);
  VarName = va_arg(ap, char *);
  index = va_arg(ap, int);
  /****************************************************************************/
  /*                           QUERY NETDCF FILE                              */
  /****************************************************************************/

  ncstatus = nc_open(FileName, NC_NOWRITE, &ncid);
  /* debugging if any file fails to be opened */
  //printf("Trying to open %s\n", FileName);
  nc_check_err(ncstatus, __LINE__, __FILE__);

  /* check whether the variable exists and get its parameters */
  ncstatus = nc_inq_varid(ncid, VarName, &varid);
  nc_check_err(ncstatus, __LINE__, __FILE__);

  ncstatus = nc_inq_var(ncid, varid, 0, &TempNumberType, &ndims, dimids, NULL);
  nc_check_err(ncstatus, __LINE__, __FILE__);
  if (TempNumberType != NumberType) {
    sprintf(Str, "%s: nc_type for %s is different than expected.\n",
	    FileName, VarName);
    ReportWarning(Str, 58);
  }

  /* make sure that the x and y dimensions have the correct sizes */
  ncstatus = nc_inq_dim(ncid, dimids[1], dimname, &dimlen);  
  nc_check_err(ncstatus, __LINE__, __FILE__);
  ncstatus = nc_inq_varid(ncid, dimname, &lat_varid);
  nc_check_err(ncstatus, __LINE__, __FILE__);
  if (dimlen != NY)
	  ReportError(VarName, 59);
  Ycoord = (double *) calloc(dimlen, sizeof(double));
  if (Ycoord == NULL)
    ReportError((char *) Routine, 1);
    /* Read the latitude coordinate variable data. */
  ncstatus = nc_get_var_double(ncid, lat_varid, Ycoord);
  nc_check_err(ncstatus, __LINE__, __FILE__);
  /* A quick check if the lat, long are in a ascending order. 
  If so, matrix must be flipped so the first value in the matrix will be 
  assigned to the lower left corner cell that has lowest X (lon) & Y (lat) value. 
  (see more comments in the header of this C file). */
  LatisAsc = 1;
  if( Ycoord[0] > Ycoord[NY - 1] ) 
	  LatisAsc = 0;

  ncstatus = nc_inq_dim(ncid, dimids[2], dimname, &dimlen);
  nc_check_err(ncstatus, __LINE__, __FILE__);
  ncstatus = nc_inq_varid(ncid, dimname, &lon_varid);
  nc_check_err(ncstatus, __LINE__, __FILE__);
  if (dimlen != NX)
    ReportError(VarName, 60);
  Xcoord = (double *) calloc(NX, sizeof(double));
  if (Xcoord == NULL)
    ReportError((char *) Routine, 1);
  /* Read the latitude coordinate variable data. */
  ncstatus = nc_get_var_double(ncid, lon_varid, Xcoord);
  nc_check_err(ncstatus, __LINE__, __FILE__);
  LonisAsc = 1;
  if( Xcoord[0] > Xcoord[NX - 1] ) 
	  LonisAsc = 0;

  if (LonisAsc == 0){
	  printf("The current program does not handle the cases when longitude or X \
values in the .nc input in an descending order. You can either change the input \
.nc file format outside of this program. or you can easily modify this program to \
fit your needs. \n");
	  ReportError("Improper NetCDF input files", 58);
  }
Beispiel #27
0
//__________________________________________________________________________________
_PMathObj _Constant::IBeta (_PMathObj arg1, _PMathObj arg2)
{
    if (theValue<=0.0) {
        if (theValue < 0.0) {
            _String     errMsg;
            errMsg = _String ("IBeta is defined for x betweeen 0 and 1. Had: ") & theValue;
            ReportWarning   (errMsg);
        }
        return new _Constant (0.0);
    }

    if (theValue>=1.0) {
        if (theValue>1.0) {
            _String     errMsg;
            errMsg = _String ("IBeta is defined for x betweeen 0 and 1. Had: ") & theValue;
            ReportWarning   (errMsg);
        }
        return new _Constant (1.0);
    }


    if ((arg1->ObjectClass()!=NUMBER)||(arg2->ObjectClass()!=NUMBER)) {
        _String     errMsg ("IBeta called with a non-scalar argument.");
        WarnError   (errMsg);
        return      nil;
    }

    _Constant       *ga = (_Constant*)arg1->Gamma(),
                     *gb = (_Constant*)arg2->Gamma();

    if (ga&&gb) {
        _Constant   *ac = (_Constant*)arg1,
                     *bc = (_Constant*)arg2;

        _Parameter  a = ac->Value(),
                    b = bc->Value(),
                    x = theValue,
                    aa,
                    c,
                    d,
                    del,
                    h,
                    qab,
                    qam,
                    qap,
                    FPMIN = 1e-100;

        bool        swap = false;

        long        m,
                    m2;

        if (x >= (a+1.)/(a+b+2.)) {
            swap = true;
            c = b;
            b = a;
            a = c;
            x = 1. - x;
        }

        qab = a+b;
        qap = a+1.;
        qam = a-1.;
        c   = 1.;
        d   = 1. - qab*x/qap;
        if  ((d<FPMIN)&&(d>-FPMIN)) {
            d = FPMIN;
        }
        d   = 1./d;
        h   = d;

        for (m=1; m<100; m++) {
            m2 = 2*m;
            aa = m*(b-m)*x / ((qam+m2)*(a+m2));
            d = 1.+aa*d;
            if  ((d<FPMIN)&&(d>-FPMIN)) {
                d = FPMIN;
            }
            c = 1.+aa/c;
            if  ((c<FPMIN)&&(c>-FPMIN)) {
                c = FPMIN;
            }
            d = 1./d;
            h*= d*c;
            aa = -(a+m)*(qab+m)*x/((a+m2)*(qap+m2));
            d = 1.+aa*d;
            if  ((d<FPMIN)&&(d>-FPMIN)) {
                d = FPMIN;
            }
            c = 1.+aa/c;
            if  ((c<FPMIN)&&(c>-FPMIN)) {
                c = FPMIN;
            }
            d = 1./d;
            del = d*c;
            h*= del;
            del -= 1.;
            if  ((del<1.e-14)&&(del>-1.e-14))   {
                break;
            }
        }

        _Constant   * res = new _Constant (a+b);
        ac  = (_Constant*)res->Gamma();
        c   = ac->Value()/(ga->Value()*gb->Value()) *
              exp (a*log(x)+b*log(1-x));

        if (swap) {
            res->theValue = 1.-c*h/a;
        } else {
            res->theValue = c*h/a;
        }

        DeleteObject (ac);
        DeleteObject (ga);
        DeleteObject (gb);
        return  res;
    }
    DeleteObject (ga);
    DeleteObject (gb);
    return nil;
}
Beispiel #28
0
void ValidateIISxpressFiles()
{
	RS::WinSecurity::SmartSid sidIISWPG;
	if (!RS::WinSecurity::WinSecurity::GetAccountSid(_T("IIS_WPG"), sidIISWPG))
	{
		ReportError(_T("Unable to get the SID for the IIS_WPG group, is IIS installed?"));
	}

	CRegKey regFilter;
	if (regFilter.Open(HKEY_LOCAL_MACHINE, IISXPRESSFILTER_REGKEY, KEY_READ) == ERROR_SUCCESS)
	{		
		if (sidIISWPG.IsValid())
		{
			RS::WinSecurity::SmartSecurityDescriptor SD;
			if (RS::WinSecurity::WinSecurity::GetKeySecurity(regFilter, SD))
			{
				if (!RS::WinSecurity::WinSecurity::CheckPermissons(SD, sidIISWPG, READ_CONTROL))
				{
					ReportWarning(_T("The IIS_WPG group does not have permissions for the IISxpress ISAPI filter registry entry"));
				}
			}
			else
			{
				ReportError(_T("Unable to get the SD for IISxpress ISAPI filter registry entry"));
			}
		}	
 
		TCHAR szFilterInstallPath[512] = _T("");
		ULONG nFilterInstallPathSize = _countof(szFilterInstallPath);
		if (regFilter.QueryStringValue(IISXPRESS_INSTALLPATH, szFilterInstallPath, &nFilterInstallPathSize) == ERROR_SUCCESS)
		{
			CPath ISAPIDLLPath(szFilterInstallPath);
			ISAPIDLLPath.Append(_T("IISxpress.dll"));
			if (ISAPIDLLPath.FileExists())
			{
				if (sidIISWPG.IsValid())
				{
					RS::WinSecurity::SmartSecurityDescriptor SD;
					if (RS::WinSecurity::WinSecurity::GetFileSecurity(ISAPIDLLPath, SD))
					{
						if (!RS::WinSecurity::WinSecurity::CheckPermissons(SD, sidIISWPG, STANDARD_RIGHTS_READ))
						{
							ReportWarning(_T("The IIS_WPG group does not have permissions for the IISxpress ISAPI DLL"));
						}
					}
					else
					{
						ReportError(_T("Unable to get the SD for the IISxpress ISAPI DLL"));
					}
				}
			}
			else
			{
				ReportError(_T("The file '%s' could not be found"), ISAPIDLLPath.m_strPath);
			}

			CPath ISAPIPerfDLLPath(szFilterInstallPath);
			ISAPIPerfDLLPath.Append(_T("IISxpressPerf.dll"));
			if (ISAPIPerfDLLPath.FileExists())
			{
				if (sidIISWPG.IsValid())
				{
					RS::WinSecurity::SmartSecurityDescriptor SD;
					if (RS::WinSecurity::WinSecurity::GetFileSecurity(ISAPIPerfDLLPath, SD))
					{
						if (!RS::WinSecurity::WinSecurity::CheckPermissons(SD, sidIISWPG, STANDARD_RIGHTS_READ))
						{
							ReportWarning(_T("The IIS_WPG group does not have permissions for the IISxpress Perf DLL"));
						}
					}
					else
					{
						ReportError(_T("Unable to get the SD for the IISxpress Perf DLL"));
					}
				}
			}
			else
			{
				ReportError(_T("The file '%s' could not be found"), ISAPIPerfDLLPath.m_strPath);
			}
		}
		else
		{
			ReportError(_T("Unable to locate the IISxpress ISAPI filter path registry key"));			
		}		
	}
	else
	{
		ReportError(_T("Unable to locate the IISxpress ISAPI filter registry key"));
	}	

	CRegKey regServer;
	if (regServer.Open(HKEY_LOCAL_MACHINE, IISXPRESSSERVER_REGKEY, KEY_READ) == ERROR_SUCCESS)
	{
		TCHAR szServerInstallPath[512] = _T("");
		ULONG nServerInstallPathSize = _countof(szServerInstallPath);
		if (regServer.QueryStringValue(IISXPRESS_INSTALLPATH, szServerInstallPath, &nServerInstallPathSize) == ERROR_SUCCESS)
		{
			CPath ServerPSPath(szServerInstallPath);
			ServerPSPath.Append(_T("IISxpressServerPS.dll"));
			if (ServerPSPath.FileExists())
			{
				if (sidIISWPG.IsValid())
				{
					RS::WinSecurity::SmartSecurityDescriptor SD;
					if (RS::WinSecurity::WinSecurity::GetFileSecurity(ServerPSPath, SD))
					{
						if (!RS::WinSecurity::WinSecurity::CheckPermissons(SD, sidIISWPG, STANDARD_RIGHTS_READ))
						{
							ReportWarning(_T("The IIS_WPG group does not have permissions for the IISxpress PS DLL"));
						}
					}
					else
					{
						ReportError(_T("Unable to get the SD for the IISxpress PS DLL"));
					}
				}
			}
			else
			{
				ReportError(_T("The file '%s' could not be found"), ServerPSPath.m_strPath);
			}
		}
		else
		{
			ReportError(_T("Unable to locate the IISxpress ISAPI filter path registry key"));			
		}	
	}
	else
	{
		ReportError(_T("Unable to locate the IISxpress Server registry key"));		
	}
}
Beispiel #29
0
void ValidateIISSetup()
{
	CIISMetaBase MetaBase;
	CComPtr<IMSAdminBase> pAdminBase;
	if (MetaBase.Init() != true || MetaBase.GetAdminBase(&pAdminBase) != true)
	{
		ReportError(_T("Unable to establish a connection to the IIS metabase"));
		return;
	}
	
	CIISMetaBaseData LoadOrderData;
	if (LoadOrderData.ReadData(pAdminBase, L"/LM/W3SVC/Filters", MD_FILTER_LOAD_ORDER))
	{
		std::wstring sLoadOrder;
		if (LoadOrderData.GetAsString(sLoadOrder))
		{
			std::wstring::size_type nPos = sLoadOrder.find(IISXPRESS_FILTERNAMEW);
			if (nPos != std::wstring::npos)
			{
				std::wstring::size_type expectedLocation = sLoadOrder.size();
				expectedLocation -= _countof(IISXPRESS_FILTERNAMEW) - 1;
				if (nPos != expectedLocation)
				{
					ReportWarning(_T("The IISxpress ISAPI filter entry should be the last defined module, please run repair"));
				}	
			}
			else
			{
				ReportError(_T("Unable to find the IISxpress ISAPI entry in the filter load order"));	
			}
		}
		else
		{
			ReportWarning(_T("Unable to read the ISAPI filter load order"));		
		}
	}
	else
	{
		ReportError(_T("Unable to query the ISAPI filter data"));		
	}				

	const std::wstring sMBFilterPath = L"/LM/W3SVC/Filters/" IISXPRESS_FILTERNAMEW;

	CIISMetaBaseData FilterPathData;
	if (FilterPathData.ReadData(pAdminBase, sMBFilterPath.c_str(), MD_FILTER_IMAGE_PATH))
	{
		std::wstring sFilterPath;
		if (FilterPathData.GetAsString(sFilterPath))
		{
			CFile file;
			if (!file.Open(sFilterPath.c_str(), CFile::modeRead | CFile::shareDenyNone))
			{
				ReportWarning(_T("Unable to open the IISxpress ISAPI filter DLL ('%s'), check that the file exists"), sFilterPath.c_str());		
			}
			file.Close();
		}
		else
		{
			ReportWarning(_T("Unable to read the IISxpress ISAPI filter path"));		
		}		
	}
	else
	{
		ReportWarning(_T("Unable to query the IISxpress ISAPI filter path"));		
	}		

	CIISMetaBaseData FilterStatusData;
	if (FilterStatusData.ReadData(pAdminBase, sMBFilterPath.c_str(), MD_FILTER_STATE) == true)
	{
		DWORD dwFilterState = 0;
		if (FilterStatusData.GetAsDWORD(&dwFilterState))
		{
			if (dwFilterState != 1)
			{
				ReportWarning(_T("IIS reports that the filter state is %d"), dwFilterState);			
			}
		}
		else
		{
			ReportWarning(_T("Unable to read the IISxpress ISAPI filter state"));			
		}
	}
	else
	{
		ReportError(_T("Unable to query the IISxpress ISAPI filter state"));
	}		

	CIISMetaBaseData FilterWin32StatusData;
	if (FilterWin32StatusData.ReadData(pAdminBase, sMBFilterPath.c_str(), MD_WIN32_ERROR) == true)
	{
		DWORD dwWIN32FilterState = 0;
		if (FilterWin32StatusData.GetAsDWORD(&dwWIN32FilterState))
		{
			if (dwWIN32FilterState != 0)
			{
				TCHAR szErrorMessage[512] = _T("");
				::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwWIN32FilterState, 0x0409, szErrorMessage, _countof(szErrorMessage), NULL);

				TCHAR* pchWhitespace = NULL;
				while ((pchWhitespace = _tcschr(szErrorMessage, '\n')))
				{
					*pchWhitespace = ' ';
				}

				while ((pchWhitespace = _tcschr(szErrorMessage, '\r')))
				{
					*pchWhitespace = ' ';
				}

				ReportWarning(_T("IIS reports that the filter WIN32 state is %d, the error is: '%s'"), dwWIN32FilterState, szErrorMessage);
			}
		}
		else
		{
			ReportWarning(_T("Unable to read the IISxpress ISAPI filter Win32 state"));			
		}
	}
	else
	{
		ReportError(_T("Unable to query the IISxpress ISAPI filter Win32 state"));
	}

	std::vector<std::wstring> AppPools;
	if (MetaBase.EnumKeys(L"/LM/W3SVC/AppPools", AppPools))
	{
		for (size_t i = 0; i < AppPools.size(); i++)
		{
			std::wstring appPoolPath = L"/LM/W3SVC/AppPools/" + AppPools[i];

			CIISMetaBaseData AppPoolIdentityData;
			if (AppPoolIdentityData.ReadData(pAdminBase, appPoolPath.c_str(), MD_APPPOOL_IDENTITY_TYPE) == true)
			{
				DWORD dwIdentityType = 0;
				AppPoolIdentityData.GetAsDWORD(&dwIdentityType);

				ReportInfo(_T("AppPool '%s' has identity type %d"), AppPools[i].c_str(), dwIdentityType);

				if (dwIdentityType == MD_APPPOOL_IDENTITY_TYPE_SPECIFICUSER)
				{
					CIISMetaBaseData AppPoolUserData;
					if (AppPoolUserData.ReadData(pAdminBase, appPoolPath.c_str(), MD_WAM_USER_NAME) == true)
					{
						std::wstring sUserName;
						if (AppPoolUserData.GetAsString(sUserName))
						{
							ReportWarning(
								_T("The AppPool '%s' has been configured to use user account '%s', ensure this account or IIS_WPG ")
								_T("has read/execute permissions to the IISxpress directory ")
								_T("and full permissions to the IISxpress Logs directory"),
								AppPools[i].c_str(), sUserName.c_str());
						}
						else
						{
							ReportError(_T("Unable to read the user name of the AppPool"));
						}
					}
					else
					{
						ReportError(_T("Unable to query the user name of the AppPool"));
					}
				}
			}
			else
			{
				ReportInfo(_T("AppPool '%s' does not have an identity type"), AppPools[i].c_str());
			}
		}
	}
	else
	{
		ReportError(_T("Unable to query the ISAPI AppPool data"));
	}
}
void dng_hue_sat_map::SetDelta (uint32 hueDiv,
								uint32 satDiv,
								uint32 valDiv,
								const HSBModify &modify)
	{

	if (hueDiv >= fHueDivisions ||
		satDiv >= fSatDivisions ||
		valDiv >= fValDivisions ||
		fDeltas.Buffer () == NULL)
		{
		
		DNG_REPORT ("Bad parameters to dng_hue_sat_map::SetDelta");
		
		ThrowProgramError ();
		
		}
		
	// Set this entry.
		
	int32 offset = valDiv * fValStep +
				   hueDiv * fHueStep +
				   satDiv;

	GetDeltas () [offset] = modify;
	
	// The zero saturation entry is required to have a value scale
	// of 1.0f.
	
	if (satDiv == 0)
		{
		
		if (modify.fValScale != 1.0f)
			{
			
			#if qDNGValidate
		
			ReportWarning ("Value scale for zero saturation entries must be 1.0");
						 
			#endif
			
			GetDeltas () [offset] . fValScale = 1.0f;
		
			}
		
		}
		
	// If we are settings the first saturation entry and we have not
	// set the zero saturation entry yet, fill in the zero saturation entry
	// by extrapolating first saturation entry.
	
	if (satDiv == 1)
		{
		
		HSBModify zeroSatModify;
		
		GetDelta (hueDiv, 0, valDiv, zeroSatModify);
		
		if (zeroSatModify.fValScale != 1.0f)
			{
			
			zeroSatModify.fHueShift = modify.fHueShift;
			zeroSatModify.fSatScale = modify.fSatScale;
			zeroSatModify.fValScale = 1.0f;
			
			SetDelta (hueDiv, 0, valDiv, zeroSatModify);
			
			}
		
		}

	}