Пример #1
0
bool
HLAfloat64Interval::isEpsilon() const
{
  double value = HLAfloat64IntervalImpl::getValue(_impl);
  if (isNaN(value))
    throw InvalidLogicalTimeInterval(L"Can not compare with NaN!");
  return value == std::numeric_limits<double>::denorm_min();
}
Пример #2
0
int64_t compareDoublesL(uint64_t bi, uint64_t ai)
{
  double a = vm::bitsToDouble(ai);
  double b = vm::bitsToDouble(bi);

  if (isNaN(a) or isNaN(b)) {
    return -1;
  } else if (a < b) {
    return -1;
  } else if (a > b) {
    return 1;
  } else if (a == b) {
    return 0;
  } else {
    return -1;
  }
}
Пример #3
0
void assertEqualsEpsilon(const double & expected, const double & result
                         , const double & epsilon, const char * file, int line)
{
  if ( ( isNaN(expected) && isNaN(result) )
      ||
      ( !isNaN(expected) && !isNaN(result)
      && fuzzyEquals( expected, result, epsilon ) ) )
  {
    return;
  }

  std::stringstream errmsg;
  errmsg.str("");
  errmsg << "assertEquals(double) failed in " << file << ", line #" << line;
  errmsg << " expecting '" << expected << "' got '" << result << "'";
  TestsListener::testHasFailed(errmsg.str());
}
Пример #4
0
bool
HLAfloat64Interval::isZero() const
{
  double value = HLAfloat64IntervalImpl::getValue(_impl);
  if (isNaN(value))
    throw InvalidLogicalTimeInterval(L"Can not compare with NaN!");
  return 0 == value;
}
Пример #5
0
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) {
    // Compute the angular distance between the two orientations
    float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB)));
    if (isNaN(angleOrientation)) {
        angleOrientation = 0.0f;
    }
    return (angleOrientation <= similarEnough);
}
Пример #6
0
void
Math_isnan(void *fp)
{
	F_Math_isnan *f;

	f = fp;

	*f->ret = isNaN(f->x);
}
Пример #7
0
int64_t compareFloatsL(uint32_t bi, uint32_t ai)
{
  float a = vm::bitsToFloat(ai);
  float b = vm::bitsToFloat(bi);

  if (isNaN(a) or isNaN(b)) {
    return -1;
  }
  if (a < b) {
    return -1;
  } else if (a > b) {
    return 1;
  } else if (a == b) {
    return 0;
  } else {
    return -1;
  }
}
 void AnimationState::setCurrentTime(Number value)
 {
     if(value < 0 || isNaN(value))
     {
         value = 0;
     }
     //
     _currentTime = value;
 }
Пример #9
0
int32_t toInt32(double d, bool &ok)
{
    ok = true;
    if (isNaN(d) || isInf(d)) {
        ok = false;
        return 0;
    }
    return toInt32(d);
}
Пример #10
0
double
errcheck(double d, char* s)	/* check result of library call */
{
	if(isNaN(d))
		execerror(s, "argument out of domain");
	if(isInf(d, 0))
		execerror(s, "result out of range");
	return d;
}
Пример #11
0
//static const Point3 MAX_POS(10, 5, 0);
void PlayerEntity::onSimulation(SimTime absoluteTime, SimTime deltaTime) {
    // Do not call Entity::onSimulation; that will override with spline animation

    if (! isNaN(deltaTime) && (deltaTime > 0)) {
        m_previousFrame = m_frame;
    }
    simulatePose(absoluteTime, deltaTime);

    //m_velocity = m_frame.vectorToWorldSpace(m_desiredOSVelocity);
    //m_frame.translation += m_velocity * (float)deltaTime;
    if (! isNaN(deltaTime)) {
        slideMove(deltaTime);
        m_heading           += m_desiredYawVelocity * (float)deltaTime;
        m_frame.rotation     = Matrix3::fromAxisAngle(Vector3::unitY(), m_heading);

        m_headTilt = clamp(m_headTilt + m_desiredPitchVelocity, -80 * units::degrees(), 80 * units::degrees());
    }

}
Пример #12
0
bool checkObligatoryParams(LoginParams *loginParams, SampleParams *sampleParams)
{
    /* Check login parameters. */
    if (strlen(loginParams->getLogin()) == 0)
    {
        std::cout << LoginParams::Strings::loginNotSpecified << std::endl;
        return false;
    }
    if (strlen(loginParams->getPassword()) == 0)
    {
        std::cout << LoginParams::Strings::passwordNotSpecified << std::endl;
        return false;
    }
    if (strlen(loginParams->getURL()) == 0)
    {
        std::cout << LoginParams::Strings::urlNotSpecified << std::endl;
        return false;
    }
    if (strlen(loginParams->getConnection()) == 0)
    {
        std::cout << LoginParams::Strings::connectionNotSpecified << std::endl;
        return false;
    }

    /* Check other parameters. */
    if (strlen(sampleParams->getInstrument()) == 0)
    {
        std::cout << SampleParams::Strings::instrumentNotSpecified << std::endl;
        return false;
    }
    if (isNaN(sampleParams->getRateStop()))
    {
        std::cout << SampleParams::Strings::ratestopNotSpecified << std::endl;
        return false;
    }
    if (isNaN(sampleParams->getRateLimit()))
    {
        std::cout << SampleParams::Strings::ratelimitNotSpecified << std::endl;
        return false;
    }

    return true;
}
Пример #13
0
    /**
    * Return the TextureDisplay.
    * @example 
    * <listing>
    * var texturedisplay:Object = factory.getTextureDisplay('dragon');
    * </listing>
    * @param    The name of this Texture.
    * @param    The name of the TextureAtlas.
    * @param    The registration pivotX position.
    * @param    The registration pivotY position.
    * @return An Object.
    */
    Object* BaseFactory::getTextureDisplay(const String &textureName, const String &textureAtlasName, Number pivotX, Number pivotY)
    {
        ITextureAtlas* textureAtlas = 0;
        if(!textureAtlasName.empty())
        {
            std::map<String , ITextureAtlas*>::iterator iter = _textureAtlasDic.find(textureAtlasName);
            if(iter != _textureAtlasDic.end())
            {
                textureAtlas = iter->second;
            }
        }
        //if(!textureAtlas && !textureAtlasName)
        //{
        //    for (textureAtlasName in _textureAtlasDic)
        //    {
        //        textureAtlas = _textureAtlasDic[textureAtlasName];
        //        if(textureAtlas.getRegion(textureName))
        //        {
        //            break;
        //        }
        //        textureAtlas = null;
        //    }
        //}
        if(textureAtlas)
        {
            if(isNaN(pivotX) || isNaN(pivotY))
            {
                SkeletonData* data = _dataDic[textureAtlasName];
                if(data)
                {
                    Point *pivot = data->getSubTexturePivot(textureName);
                    if(pivot)
                    {
                        pivotX = pivot->x;
                        pivotY = pivot->y;
                    }
                }
            }

            return generateDisplay(textureAtlas, textureName, pivotX, pivotY);
        }
        return nullptr;
    }
Пример #14
0
void printSampleParams(std::string &sProcName, LoginParams *loginParams, SampleParams *sampleParams)
{
    std::cout << "Running " << sProcName << " with arguments:" << std::endl;

    // Login (common) information
    if (loginParams)
    {
        std::cout << loginParams->getLogin() << " * "
                  << loginParams->getURL() << " "
                  << loginParams->getConnection() << " "
                  << loginParams->getSessionID() << " "
                  << loginParams->getPin() << std::endl;
    }

    // Sample specific information
    if (sampleParams)
    {
        std::cout << "Instrument='" << sampleParams->getInstrument() << "', "
                  << "Timeframe='" << sampleParams->getTimeframe() << "', ";
        if (isNaN(sampleParams->getDateFrom()))
        {
            std::cout << "DateFrom='', ";
        }
        else
        {
            char sDateFrom[20];
            formatDate(sampleParams->getDateFrom(), sDateFrom);
            std::cout << "DateFrom='" << sDateFrom << "', ";
        }
        if (isNaN(sampleParams->getDateTo()))
        {
            std::cout << "DateTo='', ";
        }
        else
        {
            char sDateTo[20];
            formatDate(sampleParams->getDateTo(), sDateTo);
            std::cout << "DateTo='" << sDateTo << "', ";
        }
        std::cout << std::endl;
    }
}
Пример #15
0
		static inline double ulp(double const & x)
		{
			if (isInfinite(x))
			{
				return POS_INFTY();
			}
			else if (isNaN(x))
			{
				return x;
			}
			else
			{
				a_diee ulpx;
				ulpx.f = x;
				ulpx.ieee.sign = 0;

				/**
				 * x is zero or denormalized
				 **/
				if (ulpx.ieee.expo == 0)
				{
					ulpx.ieee.mant0 = 0;
					ulpx.ieee.mant1 = 1;
					return ulpx.f;
				}
				/**
				 * non-underflow case
				 **/
				else if (ulpx.ieee.expo > 52)
				{
					ulpx.ieee.expo -= 52;
					ulpx.ieee.mant0 = 0;
					ulpx.ieee.mant1 = 0;
					return ulpx.f;
				}
				/**
				 * underflow case
				 **/
				else
				{
					unsigned int n = 52-ulpx.ieee.expo;
					ulpx.ieee.expo = 0;
					if (n < 20)
					{
						ulpx.ieee.mant0 = (0x80000 >> n);
						ulpx.ieee.mant1 = 0;
					}
					else
					{
						ulpx.ieee.mant0 = 0;
						ulpx.ieee.mant1 = (0x80000000 >> (n-20));
					}
					return ulpx.f;
				}
Пример #16
0
 bool areAllElementsNan() const
 {
     unsigned index = 0;
     for (ElementIterator it = first_; index < NumElements; ++it, ++index)
     {
         if (!isNaN(*it))
         {
             return false;
         }
     }
     return true;
 }
	string LinearCostFunctionDuration::toString() {
		return (
			(
			"expected value: "
			+ itos(expectedValue)
			+ "; actual value: "
			+ (!isNaN(actualValue) ? "UNDEFINED" :
			"" + itos(actualValue))) +
			("; minimum value: "
			+ itos(minimumValue)
			+ "; maximum value : "
			+ (isInfinity(maximumValue) ?
			"INFINITY" : "" + itos(maximumValue))
			+ "; computed value: "
			+ (!isNaN(computedValue) ? "UNDEFINED"
			: "" + itos(computedValue)))
			+ "; shrinking cost rate: "
			+ itos(getShrinkingCostRate())
			+ "; stretching cost rate: "
			+ itos(getStretchingCostRate()));
	}
Пример #18
0
bool Flow::getJointPositionInWorldFrame(const AnimPoseVec& absolutePoses, int jointIndex, glm::vec3& position, glm::vec3 translation, glm::quat rotation) const {
    if (jointIndex >= 0 && jointIndex < (int)absolutePoses.size()) {
        glm::vec3 poseSetTrans = absolutePoses[jointIndex].trans();
        position = (rotation * poseSetTrans) + translation;
        if (!isNaN(position)) {
            return true;
        } else {
            position = glm::vec3(0.0f);
        }
    }
    return false;
}
Пример #19
0
	static bool SAAccept( double lastValue, double currentValue, double temperature ) {
		if( isNaN( temperature ) || temperature < 0 )
			throw std::invalid_argument( "Non-negative temperature expected" );

		// assumes maximising...
		if( currentValue > lastValue )
			return true;			
		else if( temperature == 0 )
			return currentValue >= lastValue;
		else {
			assert( currentValue <= lastValue );
			assert( temperature > 0 );
			
			const double diffDivT = ( currentValue - lastValue ) / temperature;
			assert( diffDivT <= 0 );
			
			const double p = std::exp( diffDivT );
			assert( !isNaN( p ) );
			return RNG::nextDouble() < p;
		}
	}	
Пример #20
0
Datum getNextReturnTupleViaDatums(const struct GridPointData * data, TupleDesc tuple_desc)
{
    HeapTuple    tuple;

    Datum values[4];
    GridPointDataGetDatum(values, data);

    bool isNull[4] = {false, isNaN(data->value), false,false};

    tuple = heap_form_tuple(tuple_desc, values, isNull);
    return HeapTupleGetDatum(tuple);
}
std::string _test_measure_vertical_node() {
	struct LayoutProperties layoutProperties;
	layoutPropertiesInitialize(&layoutProperties);
	struct Element* element = createElement(vertical);
	layoutProperties.width = {fixed, 100};
	layoutProperties.height = {fixed, 100};
	measureNodeForVerticalLayout(layoutProperties, element);
	// width height rule
	ut_assert("error, layout width coefficient x1", (*element)._layoutCoefficients.width.x1 == 0);
	ut_assert("error, layout width coefficient x2", (*element)._layoutCoefficients.width.x2 == 100);
	ut_assert("error, layout height coefficient x1", (*element)._layoutCoefficients.height.x1 == 0);
	ut_assert("error, layout height coefficient x2", (*element)._layoutCoefficients.height.x2 == 100);
	// min-width min-height rule
	ut_assert("error, layout min width coefficient x1", isNaN((*element)._layoutCoefficients.minWidth.x1));
	ut_assert("error, layout min width coefficient x2", isNaN((*element)._layoutCoefficients.minWidth.x2));
	ut_assert("error, layout min width coefficient x3", isNaN((*element)._layoutCoefficients.minWidth.x3));
	ut_assert("error, layout min height coefficient x1", isNaN((*element)._layoutCoefficients.minHeight.x1));
	ut_assert("error, layout min height coefficient x2", isNaN((*element)._layoutCoefficients.minHeight.x2));
	ut_assert("error, layout min height coefficient x3", isNaN((*element)._layoutCoefficients.minHeight.x3));
	// top left rule
	ut_assert("error, layout width coefficient x1", (*element)._layoutCoefficients.top.x1 == 0.5);
	ut_assert("error, layout width coefficient x2", (*element)._layoutCoefficients.top.x2 == -0.5);
	ut_assert("error, layout height coefficient x1", (*element)._layoutCoefficients.left.x1 == 0.5);
	ut_assert("error, layout height coefficient x2", (*element)._layoutCoefficients.left.x2 == -0.5);
	return "";
}
Пример #22
0
void  Interval::expandToInclude( const double & value )
{
	if ( isNaN(value) )
		return ;

	if ( isEmpty() ){
		_lower = value ;
		_upper = value ;
	}else{
		_lower = std::min( _lower, value ) ;
		_upper = std::max( _upper, value ) ;
	}
}
Пример #23
0
/*
 *	r e m o v e N a N s
 */
returnValue removeNaNs( real_t* const data, unsigned int dim )
{
    unsigned int i;

    if ( data == 0 )
        return RET_INVALID_ARGUMENTS;

    for ( i=0; i<dim; ++i )
        if ( isNaN(data[i]) == BT_TRUE )
            data[i] = qpOASES::INFTY;

    return SUCCESSFUL_RETURN;
}
Пример #24
0
uint16_t toUInt16(double dd)
{
    double d = roundValue(dd);
    if (isNaN(d) || isInf(d)) {
        return 0;
    }
    double d16 = fmod(d, D16);

    if (d16 < 0) {
        d16 += D16;
    }

    return static_cast<uint16_t>(d16);
}
Пример #25
0
uint32_t toUInt32(double dd)
{
    double d = roundValue(dd);
    if (isNaN(d) || isInf(d)) {
        return 0;
    }
    double d32 = fmod(d, D32);

    if (d32 < 0) {
        d32 += D32;
    }

    return static_cast<uint32_t>(d32);
}
Пример #26
0
// set_yaw(self, radians)
int ObjectRef::l_set_yaw(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	LuaEntitySAO *co = getluaobject(ref);

	if (co == NULL) return 0;
	if (isNaN(L, 2))
		throw LuaError("ObjectRef::set_yaw: NaN value is not allowed.");

	float yaw = readParam<float>(L, 2) * core::RADTODEG;
	co->setRotation(v3f(0, yaw, 0));
	return 0;
}
Пример #27
0
inline bool operator==(const Point3D &p1, const Point3D &p2)
{
	return (fuzzyCompare(p1.m_x, p2.m_x)
			|| (isNaN(p1.m_x) && isNaN(p2.m_x)))
		   && (fuzzyCompare(p1.m_y, p2.m_y)
			   || (isNaN(p1.m_y) && isNaN(p2.m_y)))
		   && (fuzzyCompare(p1.m_z, p2.m_z)
			   || (isNaN(p1.m_z) && isNaN(p2.m_z)));
}
Пример #28
0
unsigned long UString::toULong(bool *ok, bool tolerateEmptyString) const
{
  double d = toDouble(false, tolerateEmptyString);
  bool b = true;

  if (isNaN(d) || d != static_cast<unsigned long>(d)) {
    b = false;
    d = 0;
  }

  if (ok)
    *ok = b;

  return static_cast<unsigned long>(d);
}
Пример #29
0
uint32_t UString::toUInt32(bool *ok) const
{
  double d = toDouble();
  bool b = true;

  if (isNaN(d) || d != static_cast<uint32_t>(d)) {
    b = false;
    d = 0;
  }

  if (ok)
    *ok = b;

  return static_cast<uint32_t>(d);
}
Пример #30
0
int32_t toInt32(double d)
{
    if (isNaN(d) || isInf(d)) {
        return 0;
    }
    double d32 = fmod(roundValue(d), D32);

    if (d32 >= D32 / 2) {
        d32 -= D32;
    } else if (d32 < -D32 / 2) {
        d32 += D32;
    }

    return static_cast<int32_t>(d32);
}