当前位置: 首页>>代码示例>>C++>>正文


C++ IS_ZERO函数代码示例

本文整理汇总了C++中IS_ZERO函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_ZERO函数的具体用法?C++ IS_ZERO怎么用?C++ IS_ZERO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了IS_ZERO函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: calc_zero_operand

bool calc_zero_operand(tree* my_tree)
{
	assert(my_tree);
	int ret = 0;
	if (my_tree -> type == TR_SIGN && (*(int*)(my_tree -> value) == '*' || *(int*)(my_tree -> value) == '/')
		&&(
		(is_num_leaf(my_tree -> left) && IS_ZERO(*(double*)(my_tree -> left -> value)))
		||
		(is_num_leaf(my_tree -> right) && IS_ZERO(*(double*)(my_tree -> right -> value)))
		))
	{
		clear_leafs(my_tree);

		DBG_FREE fprintf(stdout, "[%08x] tree.cpp, calc_zero_operand, my_tree -> value\n", my_tree -> value);
		free(my_tree -> value);

		my_tree -> value = calloc(1, sizeof(double));
		assert(my_tree -> value);
		*(double*)(my_tree -> value) = 0.0;
		my_tree -> type = TR_N;
		return true;
	}
	return false;

}
开发者ID:ivanychev,项目名称:learning,代码行数:25,代码来源:tree.cpp

示例2: if

// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CMatrix
//
//  - prototype : void Transform(CPlane* plane)
//
//  - Purpose   : Transforms a plane.
//
// -----------------------------------------------------------------------------
void CMatrix::Transform(CPlane* plane) const
{
	CVector3 planePoint;

	// Get a point of the plane:

	if(IS_ZERO(plane->A()) == false)
	{
		planePoint.Set(-plane->D() / plane->A(), 0.0f, 0.0f);
	}
	else if(IS_ZERO(plane->B()) == false)
	{
		planePoint.Set(0.0f, -plane->D() / plane->B(), 0.0f);
	}
	else if(IS_ZERO(plane->C()) == false)
	{
		planePoint.Set(0.0f, 0.0f, -plane->D() / plane->C());
	}

	// Transform both point of the plane and plane's normal.

	CVector3 normal = plane->Normal();

	Transform(&planePoint);
	Transform(&normal, true);

	plane->Build(planePoint, normal);
}
开发者ID:fernandojsg,项目名称:sgzsourcepack,代码行数:37,代码来源:Matrix.cpp

示例3: fp_fsgldiv

struct fp_ext *
fp_fsgldiv(struct fp_ext *dest, struct fp_ext *src)
{
	int exp;
	unsigned long quot, rem;

	dprint(PINSTR, "fsgldiv\n");

	fp_dyadic_check(dest, src);

	/* calculate the correct sign now, as it's necessary for infinities */
	dest->sign = src->sign ^ dest->sign;

	/* Handle infinities */
	if (IS_INF(dest)) {
		/* infinity / infinity = NaN (quiet, as always) */
		if (IS_INF(src))
			fp_set_nan(dest);
		/* infinity / anything else = infinity (with approprate sign) */
		return dest;
	}
	if (IS_INF(src)) {
		/* anything / infinity = zero (with appropriate sign) */
		dest->exp = 0;
		dest->mant.m64 = 0;
		dest->lowmant = 0;

		return dest;
	}

	/* zeroes */
	if (IS_ZERO(dest)) {
		/* zero / zero = NaN */
		if (IS_ZERO(src))
			fp_set_nan(dest);
		/* zero / anything else = zero */
		return dest;
	}
	if (IS_ZERO(src)) {
		/* anything / zero = infinity (with appropriate sign) */
		fp_set_sr(FPSR_EXC_DZ);
		dest->exp = 0x7fff;
		dest->mant.m64 = 0;

		return dest;
	}

	exp = dest->exp - src->exp + 0x3fff;

	dest->mant.m32[0] &= 0xffffff00;
	src->mant.m32[0] &= 0xffffff00;

	/* do the 32-bit divide */
	if (dest->mant.m32[0] >= src->mant.m32[0]) {
		fp_sub64(dest->mant, src->mant);
		fp_div64(quot, rem, dest->mant.m32[0], 0, src->mant.m32[0]);
		dest->mant.m32[0] = 0x80000000 | (quot >> 1);
		dest->mant.m32[1] = (quot & 1) | rem;	/* only for rounding */
	} else {
开发者ID:Picture-Elements,项目名称:linux-2.4-peijse,代码行数:59,代码来源:fp_arith.c

示例4: fp_fsgldiv

struct fp_ext *
fp_fsgldiv(struct fp_ext *dest, struct fp_ext *src)
{
	int exp;
	unsigned long quot, rem;

	dprint(PINSTR, "fsgldiv\n");

	fp_dyadic_check(dest, src);

	/*                                                                  */
	dest->sign = src->sign ^ dest->sign;

	/*                   */
	if (IS_INF(dest)) {
		/*                                              */
		if (IS_INF(src))
			fp_set_nan(dest);
		/*                                                            */
		return dest;
	}
	if (IS_INF(src)) {
		/*                                                    */
		dest->exp = 0;
		dest->mant.m64 = 0;
		dest->lowmant = 0;

		return dest;
	}

	/*        */
	if (IS_ZERO(dest)) {
		/*                   */
		if (IS_ZERO(src))
			fp_set_nan(dest);
		/*                             */
		return dest;
	}
	if (IS_ZERO(src)) {
		/*                                                    */
		fp_set_sr(FPSR_EXC_DZ);
		dest->exp = 0x7fff;
		dest->mant.m64 = 0;

		return dest;
	}

	exp = dest->exp - src->exp + 0x3fff;

	dest->mant.m32[0] &= 0xffffff00;
	src->mant.m32[0] &= 0xffffff00;

	/*                      */
	if (dest->mant.m32[0] >= src->mant.m32[0]) {
		fp_sub64(dest->mant, src->mant);
		fp_div64(quot, rem, dest->mant.m32[0], 0, src->mant.m32[0]);
		dest->mant.m32[0] = 0x80000000 | (quot >> 1);
		dest->mant.m32[1] = (quot & 1) | rem;	/*                   */
	} else {
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:59,代码来源:fp_arith.c

示例5: dprintf

void TimerManager::DumpTimerList(int flag, const char* indent)
{
	Timer		*timer_ptr;
	const char	*ptmp;

	// we want to allow flag to be "D_FULLDEBUG | D_DAEMONCORE",
	// and only have output if _both_ are specified by the user
	// in the condor_config.  this is a little different than
	// what dprintf does by itself ( which is just 
	// flag & DebugFlags > 0 ), so our own check here:
	if ( ! IsDebugCatAndVerbosity(flag) )
		return;

	if ( indent == NULL) 
		indent = DEFAULT_INDENT;

	dprintf(flag, "\n");
	dprintf(flag, "%sTimers\n", indent);
	dprintf(flag, "%s~~~~~~\n", indent);
	for(timer_ptr = timer_list; timer_ptr != NULL; timer_ptr = timer_ptr->next)
	{
		if ( timer_ptr->event_descrip )
			ptmp = timer_ptr->event_descrip;
		else
			ptmp = "NULL";

		std::string slice_desc;
		if( !timer_ptr->timeslice ) {
			formatstr(slice_desc, "period = %d, ", timer_ptr->period);
		}
		else {
			formatstr_cat(slice_desc, "timeslice = %.3g, ",
								   timer_ptr->timeslice->getTimeslice());
			if( !IS_ZERO(timer_ptr->timeslice->getDefaultInterval()) ) {
				formatstr_cat(slice_desc, "period = %.1f, ",
								   timer_ptr->timeslice->getDefaultInterval());
			}
			if( !IS_ZERO(timer_ptr->timeslice->getInitialInterval()) ) {
				formatstr_cat(slice_desc, "initial period = %.1f, ",
								   timer_ptr->timeslice->getInitialInterval());
			}
			if( !IS_ZERO(timer_ptr->timeslice->getMinInterval()) ) {
				formatstr_cat(slice_desc, "min period = %.1f, ",
								   timer_ptr->timeslice->getMinInterval());
			}
			if( !IS_ZERO(timer_ptr->timeslice->getMaxInterval()) ) {
				formatstr_cat(slice_desc, "max period = %.1f, ",
								   timer_ptr->timeslice->getMaxInterval());
			}
		}
		dprintf(flag, 
				"%sid = %d, when = %ld, %shandler_descrip=<%s>\n", 
				indent, timer_ptr->id, (long)timer_ptr->when, 
				slice_desc.c_str(),ptmp);
	}
	dprintf(flag, "\n");
}
开发者ID:bbockelm,项目名称:htcondor,代码行数:57,代码来源:timer_manager.cpp

示例6: fp_fsglmul

struct fp_ext *
fp_fsglmul(struct fp_ext *dest, struct fp_ext *src)
{
	int exp;

	dprint(PINSTR, "fsglmul\n");

	fp_dyadic_check(dest, src);

	/* calculate the correct sign now, as it's necessary for infinities */
	dest->sign = src->sign ^ dest->sign;

	/* Handle infinities */
	if (IS_INF(dest)) {
		if (IS_ZERO(src))
			fp_set_nan(dest);
		return dest;
	}
	if (IS_INF(src)) {
		if (IS_ZERO(dest))
			fp_set_nan(dest);
		else
			fp_copy_ext(dest, src);
		return dest;
	}

	/* Of course, as we all know, zero * anything = zero.  You may
	   not have known that it might be a positive or negative
	   zero... */
	if (IS_ZERO(dest) || IS_ZERO(src)) {
		dest->exp = 0;
		dest->mant.m64 = 0;
		dest->lowmant = 0;

		return dest;
	}

	exp = dest->exp + src->exp - 0x3ffe;

	/* do a 32-bit multiply */
	fp_mul64(dest->mant.m32[0], dest->mant.m32[1],
		 dest->mant.m32[0] & 0xffffff00,
		 src->mant.m32[0] & 0xffffff00);

	if (exp >= 0x7fff) {
		fp_set_ovrflw(dest);
		return dest;
	}
	dest->exp = exp;
	if (exp < 0) {
		fp_set_sr(FPSR_EXC_UNFL);
		fp_denormalize(dest, -exp);
	}

	return dest;
}
开发者ID:Picture-Elements,项目名称:linux-2.4-peijse,代码行数:56,代码来源:fp_arith.c

示例7: assert

bool CFXRecursiveBlurTexture::DoFrame(CDemo* pDemo, float fEffectTime, float fDemoTime)
{
	assert(pDemo);

	if(!m_pTexture) return false;

	// Evaluate vars

	CVarFloat::CValueFloat valueIntensity;
	CVarFloat::CValueFloat valueWidth;
	CVarFloat::CValueFloat valueHeight;
	CVarFloat::CValueFloat valueOriginX;
	CVarFloat::CValueFloat valueOriginY;

	EvaluateVar("Intensity",  fEffectTime, &valueIntensity);
	EvaluateVar("Width",      fEffectTime, &valueWidth);
	EvaluateVar("Height",     fEffectTime, &valueHeight);
	EvaluateVar("X Origin",   fEffectTime, &valueOriginX);
	EvaluateVar("Y Origin",   fEffectTime, &valueOriginY);

	// Compute blur direction

	CVector3 v3Vector;
	v3Vector.Build(CVector3(valueOriginX.GetValue(), valueOriginY.GetValue(), 0.0f), CVector3(0.5f, 0.5f, 0.0f));

	if(!IS_ZERO(v3Vector.X()) || !IS_ZERO(v3Vector.Y()))
	{
		v3Vector.Normalize();
	}

	// Accumulate previous blur

	float fWidth  = valueWidth.GetValue();
	float fHeight = valueHeight.GetValue();

	UtilGL::Rendering::DrawCenteredQuad(m_pTexture,
										0.5f + v3Vector.X() * ((fWidth  * 0.5f) - 0.5f),
										0.5f + v3Vector.Y() * ((fHeight * 0.5f) - 0.5f),
										fWidth, fHeight,
										0.0f, CVector4(1.0f, 1.0f, 1.0f, valueIntensity.GetValue()),
										UtilGL::States::BLEND_SRCALPHA, UtilGL::States::BLEND_INVSRCALPHA);

	// Store accumulation

	m_pTexture->CopyFromFramebuffer(0, 0, 0, 0, m_pTexture->GetWidth(), m_pTexture->GetHeight());

	// Restore demo viewport

	pDemo->SetDemoViewport();

	// Clear framebuffer

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	return true;
}
开发者ID:fernandojsg,项目名称:sgzsourcepack,代码行数:56,代码来源:FXRecursiveBlurTexture.cpp

示例8: fp_fsglmul

struct fp_ext *
fp_fsglmul(struct fp_ext *dest, struct fp_ext *src)
{
	int exp;

	dprint(PINSTR, "fsglmul\n");

	fp_dyadic_check(dest, src);

	/*                                                                  */
	dest->sign = src->sign ^ dest->sign;

	/*                   */
	if (IS_INF(dest)) {
		if (IS_ZERO(src))
			fp_set_nan(dest);
		return dest;
	}
	if (IS_INF(src)) {
		if (IS_ZERO(dest))
			fp_set_nan(dest);
		else
			fp_copy_ext(dest, src);
		return dest;
	}

	/*                                                            
                                                          
            */
	if (IS_ZERO(dest) || IS_ZERO(src)) {
		dest->exp = 0;
		dest->mant.m64 = 0;
		dest->lowmant = 0;

		return dest;
	}

	exp = dest->exp + src->exp - 0x3ffe;

	/*                      */
	fp_mul64(dest->mant.m32[0], dest->mant.m32[1],
		 dest->mant.m32[0] & 0xffffff00,
		 src->mant.m32[0] & 0xffffff00);

	if (exp >= 0x7fff) {
		fp_set_ovrflw(dest);
		return dest;
	}
	dest->exp = exp;
	if (exp < 0) {
		fp_set_sr(FPSR_EXC_UNFL);
		fp_denormalize(dest, -exp);
	}

	return dest;
}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:56,代码来源:fp_arith.c

示例9: fp_fadd

struct fp_ext *
fp_fadd(struct fp_ext *dest, struct fp_ext *src)
{
	int diff;

	dprint(PINSTR, "fadd\n");

	fp_dyadic_check(dest, src);

	if (IS_INF(dest)) {
		/* infinity - infinity == NaN */
		if (IS_INF(src) && (src->sign != dest->sign))
			fp_set_nan(dest);
		return dest;
	}
	if (IS_INF(src)) {
		fp_copy_ext(dest, src);
		return dest;
	}

	if (IS_ZERO(dest)) {
		if (IS_ZERO(src)) {
			if (src->sign != dest->sign) {
				if (FPDATA->rnd == FPCR_ROUND_RM)
					dest->sign = 1;
				else
					dest->sign = 0;
			}
		} else
			fp_copy_ext(dest, src);
		return dest;
	}

	dest->lowmant = src->lowmant = 0;

	if ((diff = dest->exp - src->exp) > 0)
		fp_denormalize(src, diff);
	else if ((diff = -diff) > 0)
		fp_denormalize(dest, diff);

	if (dest->sign == src->sign) {
		if (fp_addmant(dest, src))
			if (!fp_addcarry(dest))
				return dest;
	} else {
		if (dest->mant.m64 < src->mant.m64) {
			fp_submant(dest, src, dest);
			dest->sign = !dest->sign;
		} else
			fp_submant(dest, dest, src);
	}

	return dest;
}
开发者ID:Picture-Elements,项目名称:linux-2.4-peijse,代码行数:54,代码来源:fp_arith.c

示例10: CVector3D

CVector3D CVector3D::GetVerticalVector(int m) const
{

	if(!IS_ZERO(dx))
		return CVector3D(-(m*dy+dz)/dx,m,1);
	else
		if(!IS_ZERO(dy))
			return CVector3D(1,-(dx+m*dz)/dy,m);
		else
			if(!IS_ZERO(dz))
				return CVector3D(m,1,-(m*dx+dy)/dz);
			else
				return CVector3D(0,0,0);

}
开发者ID:vujn,项目名称:chenan,代码行数:15,代码来源:GeomCalc.cpp

示例11: row0

// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CMatrix
//
//  - prototype : CMatrix Inverse()
//
//  - Purpose   : Returns the inverse transformation matrix.
//
//  - Note      : IMPORTANT: Algorithm only valid for orthogonal matrices!
//
// -----------------------------------------------------------------------------
CMatrix CMatrix::Inverse() const
{
	CMatrix result;

	// Transpose rotation submatrix

	CVector3 row0(m_fM[0][0], m_fM[1][0], m_fM[2][0]);
	CVector3 row1(m_fM[0][1], m_fM[1][1], m_fM[2][1]);
	CVector3 row2(m_fM[0][2], m_fM[1][2], m_fM[2][2]);

	CVector3 position(m_fM[0][3], m_fM[1][3], m_fM[2][3]);
	CVector3 invPosition;

	// Solve ecuation system

	invPosition.SetX((-row0) * position);
	invPosition.SetY((-row1) * position);
	invPosition.SetZ((-row2) * position);

	// Get scale values

	CVector3 scale = Scale();

	float sqrSclX = scale.X(); sqrSclX *= sqrSclX;
	float sqrSclY = scale.Y(); sqrSclY *= sqrSclY;
	float sqrSclZ = scale.Z(); sqrSclZ *= sqrSclZ;

	// Shouldn't happen:

	assert(!IS_ZERO(sqrSclX));
	assert(!IS_ZERO(sqrSclY));
	assert(!IS_ZERO(sqrSclZ));

	// Normalize axis and multiply by the inverse scale.

	row0 = row0 / sqrSclX;
	row1 = row1 / sqrSclY;
	row2 = row2 / sqrSclZ;

	// Insert values

	result.SetRow0(row0.X(), row0.Y(), row0.Z(), invPosition.X());
	result.SetRow1(row1.X(), row1.Y(), row1.Z(), invPosition.Y());
	result.SetRow2(row2.X(), row2.Y(), row2.Z(), invPosition.Z());
	result.SetRow3(  0.0f,      0.0f,      0.0f,         1.0f);

	return result;
}
开发者ID:fernandojsg,项目名称:sgzsourcepack,代码行数:59,代码来源:Matrix.cpp

示例12: solveQuadric

unsigned int Math::solveQuadric(DOUBLE coeffs[3], DOUBLE roots[2])
{
    /* x^2 + px + q = 0 */

    DOUBLE  p = coeffs[1] / (2.0 * coeffs[2]);
    DOUBLE  q = coeffs[0] / coeffs[2];

    DOUBLE  delta = p * p - q;

    if (IS_ZERO(delta))
    {
        roots[0] = -p;
        return (1);
    }
    else if (delta > 0.0)
    {
        DOUBLE  sqrt_delta = sqrt(delta);

        roots[0] = sqrt_delta - p;
        roots[1] = -sqrt_delta - p;

        return (2);
    }

    return (0);
}
开发者ID:Quentin01,项目名称:Raytracer,代码行数:26,代码来源:Math.cpp

示例13: Ray

Ray Fisheye::_getRay(const double x, const double y) 
{
    double phi, theta;

    // TODO: Force into a circle of radius = min(width,height)

    // Map x and y to [-1,1]
    double _x = 2.0 * x - 1.0;
    double _y = 2.0 * y - 1.0;
    
    double r = _x*_x + _y*_y;
    
    if (r > 1.0) {
	return Ray();
    }

    r = sqrt(r);
    if (IS_ZERO(r)) {
	phi = 0.0;
    } else {
	phi = asin(_y / r);
	if (_x < 0.0) {
	    phi = M_PI - phi;
	}
    }
    theta = r * getFieldOfView() / 2.0 ;

    Vector dir = Vector(sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta));
    dir = basis * dir;
    dir.normalize(); // TODO: Necessary?
    return Ray(position, dir, 1.0);
}
开发者ID:thabz,项目名称:RayGay,代码行数:32,代码来源:fisheye.cpp

示例14: solveQuadric

int solveQuadric(float c[3], float s[2])
{
	float p, q, D;

	/* normal form: x^2 + px + q = 0 */

	p = c[ 1 ] / (2 * c[ 2 ]);
	q = c[ 0 ] / c[ 2 ];

	D = p * p - q;

	if (IS_ZERO(D)) 
	{
		s[ 0 ] = - p;
		return 1;
	}
	else if (D > 0) 
	{
		float sqrt_D = sqrt(D);

		s[ 0 ] =   sqrt_D - p;
		s[ 1 ] = - sqrt_D - p;
		return 2;
	}
	else /* if (D < 0) */
		return 0;
}
开发者ID:RyanAdamsGD,项目名称:RayTracer,代码行数:27,代码来源:HelperFunctions.cpp

示例15: solver_second_degree

inline double	solver_second_degree(double a, double b, double c)
{
  double	res;
  double	det;
  double	tmp[4];

  det = b * b - 4.0 * a * c;
  if (IS_ZERO(det))
    {
      res = -1.0 * b / (2.0 * a);
      res = CHECK_SOLUTION(res);
    }
  else if (det > 0.0)
    {
      tmp[2] = sqrt(det);
      tmp[3] = 2.0 * a;
      tmp[0] = -(b - tmp[2]) / tmp[3];
      tmp[1] = -(b + tmp[2]) / tmp[3];
      tmp[0] = CHECK_SOLUTION(tmp[0]);
      tmp[1] = CHECK_SOLUTION(tmp[1]);
      res = check_solution_equation(tmp[0], tmp[1]);
    }
  else
    {
      res = NOT_A_SOLUTION;
    }
  return (res);
}
开发者ID:Antonito,项目名称:Raytracer,代码行数:28,代码来源:second_degree.c


注:本文中的IS_ZERO函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。