예제 #1
0
inline void fast_Ring<TNum,kdefs>::accMultAddr( TNum* a ,const TNum* b , const TNum* c)  const
{
	#ifdef SAFE
		assert(Convert(a)==a);
		assert(Convert(b)==b);
		assert(Convert(c)==c);
	#endif
	*a = additionTable[getPairIndex(*a, multiplicationTable[ getPairIndex(*b, *c)]) ];
}
예제 #2
0
inline void fast_Ring<TNum,kdefs>::accMult( TNum& a ,const TNum b , const TNum c)  const
{
	#ifdef SAFE
		assert(Convert(a)==a);
		assert(Convert(b)==b);
		assert(Convert(c)==c);
	#endif
	#ifdef COUNT
		accMultCount=accMultCount+1;
	#endif
	a=additionTable[ getPairIndex (a, multiplicationTable[ getPairIndex(b, c)] ) ];
}
예제 #3
0
inline void  fast_Ring< TNum, kdefs>::multiplyInPlace(TNum &a, const TNum b) const
{
	#ifdef SAFE
		assert(Convert(a)==a);
		assert(Convert(b)==b);
	#endif
	a = multiplicationTable[ getPairIndex(a, b) ];
}
예제 #4
0
inline TNum 	fast_Ring< TNum, kdefs>::add( const TNum a, const  TNum b) const
{
	#ifdef SAFE
		assert(Convert(a)==a);
		assert(Convert(b)==b);
	#endif
	return additionTable[ getPairIndex(a, b) ];
}
예제 #5
0
inline void  
fast_Ring< TNum, kdefs>::scalarMultiplyInPlace(const FieldType::ElementType 	a,
												TNum & b ) const
{
	#ifdef SAFE
		assert(Convert(TNum(a))==a);
		assert(Convert(b)==b);
	#endif
	b = multiplicationTable[ getPairIndex(a, b) ];
}
예제 #6
0
inline  TNum   
fast_Ring< TNum, kdefs>::scalarMultiply(const FieldType::ElementType a, const TNum b) const
{
	#ifdef SAFE
		assert(Convert(TNum(a))==a);
		assert(Convert(b)==b);
	#endif

	return multiplicationTable[getPairIndex(a, b)];
}
예제 #7
0
inline void fast_Ring< TNum, kdefs>::addInPlace(TNum& a, const TNum b) const
{
	#ifdef SAFE
		assert(Convert(a)==a);
		assert(Convert(b)==b);
	#endif

	a= this->additionTable[ getPairIndex(a, b) ];
	return;

	
}
예제 #8
0
inline void 
fast_Ring<TNum,kdefs>::accMultSpec( TNum* const a ,const TNum b , const TNum * const c)  const
{
	#ifdef SAFE
		assert(Convert(*a)==*a);
		assert(Convert(b)==b);
		assert(Convert(*c)==*c);
	#endif

	#ifdef COUNT
		accMultCount=accMultCount+1;
	#endif 

	*a=additionTable[ getPairIndex(*a, multiplicationTable[ getPairIndex(b, *c)]) ];

	/*
	#if EPSPRECISION==1
	
		register TNum tmp=multiplicationTable[getPairIndex(b, *c)];
		register short a2=tmp.getX()+a->getX();
		if (a2>=getCharacteristic())
			a->setX(a2-getCharacteristic());
		else
			a->setX(a2);
		a2=tmp.getEps()+a->getEps();
		if (a2>=getCharacteristic())
			a->setEps(a2-getCharacteristic());
		else
			a->setEps(a2);
	
	#else
		//  on Pentiums following code has catastrophic performance: but on hoech its fast
		int tmp=(*a).getX()+multiplicationTable[getPairIndex(b, *c)].getX();
		if (tmp>=getCharacteristic())
			(a)->setX(tmp-getCharacteristic());
		else
			(a)->setX(tmp);
	#endif*/

}
예제 #9
0
 TNum * fast_Ring<TNum, kdefs>::createAdditionTable()
{

	unsigned short i, j, k , l;  // sollte nicht unb short sein, sondern vom basistyp abhaengen

	TNum * tAdditionTable=0;

	size_t tableSize = getMaxPairIndex() + 1;

	#ifdef DEBUG
	std::cerr << "createAdditionTable::tableSize = " << tableSize << std::endl;
	#endif

	tAdditionTable = new TNum[tableSize];

	for (i=0; i<getCharacteristic(); i++)
		for (j=0; j<((getCharacteristic()-1)*getEpsPrecision())+1; j++)
			for (k=0; k<getCharacteristic(); k++)
				for (l=0; l<((getCharacteristic()-1)*getEpsPrecision())+1; l++)
				{
					TNum 	z1(i, j);
					TNum 	z2(k, l);
					size_t index = getPairIndex(z1, z2);
					assert(index < 	tableSize && index>=0);

					tAdditionTable[index].setX   (
										  ( (int)z1.getX() + (int)z2.getX()  )
										% getCharacteristic() 
									);

					tAdditionTable[index].setEps ( 
										  ((int)z1.getEps() + (int)z2.getEps())
										% getCharacteristic() 
									);
				}
	return tAdditionTable;
}
예제 #10
0
bool
gfxScriptItemizer::Next(PRUint32& aRunStart, PRUint32& aRunLimit,
                        PRInt32& aRunScript)
{
    /* if we've fallen off the end of the text, we're done */
    if (scriptLimit >= textLength) {
        return PR_FALSE;
    }

    SYNC_FIXUP();
    scriptCode = HB_SCRIPT_COMMON;

    for (scriptStart = scriptLimit; scriptLimit < textLength; scriptLimit += 1) {
        PRUint32 ch;
        PRInt32 sc;
        PRInt32 pairIndex;
        PRUint32 startOfChar = scriptLimit;

        ch = textPtr[scriptLimit];

        /*
         * MODIFICATION for Gecko - clear the paired-character stack
         * when we see a space character, because we cannot trust
         * context outside the current "word" when doing textrun
         * construction
         */
        if (ch == 0x20) {
            while (STACK_IS_NOT_EMPTY()) {
                pop();
            }
            sc = HB_SCRIPT_COMMON;
            pairIndex = -1;
        } else {
            /* decode UTF-16 (may be surrogate pair) */
            if (NS_IS_HIGH_SURROGATE(ch) && scriptLimit < textLength - 1) {
                PRUint32 low = textPtr[scriptLimit + 1];
                if (NS_IS_LOW_SURROGATE(low)) {
                    ch = SURROGATE_TO_UCS4(ch, low);
                    scriptLimit += 1;
                }
            }

            sc = gfxUnicodeProperties::GetScriptCode(ch);

            pairIndex = getPairIndex(ch);

            /*
             * Paired character handling:
             *
             * if it's an open character, push it onto the stack.
             * if it's a close character, find the matching open on the
             * stack, and use that script code. Any non-matching open
             * characters above it on the stack will be poped.
             */
            if (pairIndex >= 0) {
                if ((pairIndex & 1) == 0) {
                    push(pairIndex, scriptCode);
                } else {
                    PRInt32 pi = pairIndex & ~1;

                    while (STACK_IS_NOT_EMPTY() && TOP().pairIndex != pi) {
                        pop();
                    }

                    if (STACK_IS_NOT_EMPTY()) {
                        sc = TOP().scriptCode;
                    }
                }
            }
        }

        if (sameScript(scriptCode, sc)) {
            if (scriptCode <= HB_SCRIPT_INHERITED && sc > HB_SCRIPT_INHERITED) {
                scriptCode = sc;

                fixup(scriptCode);
            }

            /*
             * if this character is a close paired character,
             * pop the matching open character from the stack
             */
            if (pairIndex >= 0 && (pairIndex & 1) != 0) {
                pop();
            }
        } else {
            /*
             * reset scriptLimit in case it was advanced during reading a
             * multiple-code-unit character
             */
            scriptLimit = startOfChar;

            break;
        }
    }

    aRunStart = scriptStart;
    aRunLimit = scriptLimit;
    aRunScript = scriptCode;

    return PR_TRUE;
}
예제 #11
0
TNum * fast_Ring<TNum, kdefs>::createMultiplicationTable()
{	
	int i, j, k, l; 

	TNum * tMultiplicationTable = NULL;
	
	size_t tableSize = getMaxPairIndex() + 1;

	tMultiplicationTable = new TNum[tableSize];

	for (i=0; i< getCharacteristic(); i++)
		for (j=0; j<( (getCharacteristic()-1)*getEpsPrecision() )+1; j++)
			for (k=0; k < getCharacteristic(); k++)
				for (l=0; l<( (getCharacteristic() - 1)* getEpsPrecision() ) + 1; l++)
				{
					TNum 	z1 (i,j);
					TNum 	z2 (k,l);

					size_t 	index = getPairIndex(z1, z2);

					assert(index < 	tableSize && index>=0 );

					TNum result;

					result.setX  (  	((int) z1.getX() * (int)z2.getX() ) 
								% getCharacteristic()
							);
			
					result.setEps( (   (int)z1.getX() * (int)z2.getEps() 
							       + (int)z2.getX() * (int)z1.getEps() 
						         ) % getCharacteristic()	
							);
				
					if (j==0 && l==0 && i==k )
					{
						if (result.getX()==getCharacteristic()-1)
						{
							bContainsImagNum_m=true;
							imagNum_m=z1;
						}
					}

					tMultiplicationTable[ index ] = result;
				}


	/*for (i=0; i< getCharacteristic(); i++)
			for (k=0; k < getCharacteristic(); k++)
				{
					TNum 	z1 (i,0);
					TNum 	z2 (k,0);

					size_t 	index = getPairIndex(z1, z2);

					assert(index < 	tableSize && index>=0 );

					TNum result;

					result.setX  (  	((int) z1.getX() * (int)z2.getX() ) 
								% getCharacteristic()
							);
			
					assert(tMultiplicationTable[ index ] == result);
				}*/

	return tMultiplicationTable;
}