Example #1
0
void NormalIterativeMethod::calculateTheRoot()
{
	double xCurrent(start), xNext;
	size_t iterT(1);

	while (1)
	{
		xNext = f(xCurrent);
		if (abs(xNext - xCurrent) <= precision)break;
		xCurrent = xNext;
		++iterT;
		if (iterT > 100000)break;
	}
	iterateTime = iterT;
	root = xNext;

}
Example #2
0
void NewtonIterativeMethod::calculateTheRoot(){
	double xCurrent(start), xNext(start);
	double f_d_value;
	size_t iterT(1);

	while (1){
		f_d_value = f_d(xCurrent);
		if (!f_d_value){ condition = -1; break; }
		xNext = xCurrent - f(xCurrent) / f_d_value;
		if (abs(xNext - xCurrent) <= precision){ condition = 0; break; }
		xCurrent = xNext;
		iterT++;
		if (iterT >= 100000){ condition = 1; break; }
	}
	iteraterTime = iterT;
	root = xNext;
}
Example #3
0
void TextArt::EnvelopeWarp::weight(const SkPath& path, const SkPath& top, const SkPath& bottom, SkPath* dst)
{
	SkPath::Iter    iterB(bottom, false);
	SkPath::Iter    iterT(top, false);
	SkPath::Iter    iter(path, false);

    SkPoint         tSrc[4], bSrc[4], src[4], dstP[4];
    SkPath::Verb    verbT, verbB, verb;

	const SkRect&	boundsSrc = path.getBounds();

    while (((verbT = iterT.next(tSrc)) != SkPath::kDone_Verb)	&& 
			((verbB = iterB.next(bSrc)) != SkPath::kDone_Verb)	&&
			((verb = iter.next(src)) != SkPath::kDone_Verb) )
	{
		SkASSERT(verbT==verbB);
		SkASSERT(verbT==verb);

        switch (verbT)
		{
            case SkPath::kMove_Verb:
                weight(&src[0], &tSrc[0], &bSrc[0], 1, boundsSrc, dstP);
                dst->moveTo(dstP[0]);
                break;
            case SkPath::kLine_Verb:
                weight(&src[1], &tSrc[1], &bSrc[1], 1, boundsSrc, dstP);
                dst->lineTo(dstP[0]);
                break;
            case SkPath::kQuad_Verb:
				weight(&src[1], &tSrc[1], &bSrc[1], 2, boundsSrc, dstP);
                dst->quadTo(dstP[0], dstP[1]);
                break;
            case SkPath::kCubic_Verb:
				weight(&src[1], &tSrc[1], &bSrc[1], 3, boundsSrc, dstP);
                dst->cubicTo(dstP[0], dstP[1], dstP[2]);
                break;
            case SkPath::kClose_Verb:
                dst->close();
                break;
            default:
                SkDEBUGFAIL("unknown verb");
                break;
        }
    }
}
Example #4
0
void AitkenSpeedUpIterativeMethod::calculateTheRoot()
{
	double xCurrent(start), xNext;
	double yk, zk;
	size_t iterT(0);

	while (1)
	{
		yk = f(xCurrent);
		zk = f(yk);
		xNext = xCurrent - pow(yk - xCurrent, 2) / (zk - 2 * yk + xCurrent);
		if (abs(xNext - xCurrent) <= precision)break;
		xCurrent = xNext;
		++iterT;
		if (iterT > 100000)break;
	}
	iterateTime = iterT;
	root = xNext;

}