Exemplo n.º 1
0
void ccGenericMesh::applyGLTransformation(const ccGLMatrix& trans)
{
    //vertices should be handled another way!

    //we must take care of the triangle normals!
    if (m_triNormals && (!getParent() || !getParent()->isKindOf(CC_MESH)))
    {
        bool recoded = false;

        //if there is more triangle normals than the size of the compressed
        //normals array, we recompress the array instead of recompressing each normal
        unsigned i,numTriNormals = m_triNormals->currentSize();
        if (numTriNormals>ccNormalVectors::GetNumberOfVectors())
        {
            NormsIndexesTableType* newNorms = new NormsIndexesTableType;
            if (newNorms->reserve(ccNormalVectors::GetNumberOfVectors()))
            {
                for (i=0; i<ccNormalVectors::GetNumberOfVectors(); i++)
                {
                    CCVector3 new_n(ccNormalVectors::GetNormal(i));
                    trans.applyRotation(new_n);
                    normsType newNormIndex = ccNormalVectors::GetNormIndex(new_n.u);
                    newNorms->addElement(newNormIndex);
                }

                m_triNormals->placeIteratorAtBegining();
                for (i=0; i<numTriNormals; i++)
                {
                    m_triNormals->setValue(i,newNorms->getValue(m_triNormals->getCurrentValue()));
                    m_triNormals->forwardIterator();
                }
                recoded=true;
            }
            newNorms->clear();
            newNorms->release();
            newNorms=0;
        }

        //if there is less triangle normals than the compressed normals array size
        //(or if there is not enough memory to instantiate the temporary array),
        //we recompress each normal ...
        if (!recoded)
        {
            //on recode direct chaque normale
            m_triNormals->placeIteratorAtBegining();
            for (i=0; i<numTriNormals; i++)
            {
                normsType* _theNormIndex = m_triNormals->getCurrentValuePtr();
                CCVector3 new_n(ccNormalVectors::GetNormal(*_theNormIndex));
                trans.applyRotation(new_n.u);
                *_theNormIndex = ccNormalVectors::GetNormIndex(new_n.u);
                m_triNormals->forwardIterator();
            }
        }
    }
    else
    {
        //TODO: process failed!
    }
}
/*
 * Class:     org_sosy_lab_cpachecker_util_octagon_OctWrapper
 * Method:    J_init_n
 * Signature: (I)J
 */
JNIEXPORT jlong JNICALL Java_org_sosy_1lab_cpachecker_util_octagon_OctWrapper_J_1init_1n
(JNIEnv *env, jobject obj, jint i){
	num_t* mm = new_n(num_t, i);
	num_init_n(mm, i);
	return (jlong) mm;
}
Exemplo n.º 3
0
void outopt(int ch, int count)
{
    if (deadloop) {
	if (ch == '[') deadloop++;
	if (ch == ']') deadloop--;
	return;
    }
    if (ch == '[') {
	if (tape->is_set && tape->v == 0) {
	    deadloop++;
	    return;
	}
    }

    switch(ch)
    {
    case '[': case ']': case '!': case '~': case 'X': case '#':
    case 'I': case 'E':
	if (ch == '!') {
	    flush_tape(1,0);
	    tape->cleaned = tape->is_set = first_run = !disable_init_optim;
	} else if (ch == '~' && enable_optim && !disable_init_optim)
	    flush_tape(1,0);
	else
	    flush_tape(0,0);
	if (ch) outcmd(ch, count);

	/* Loops end with zero */
	if (ch == ']') {
	    tape->is_set = 1;
	    tape->v = 0;
	    tape->cleaned = 1;
	    tape->cleaned_val = tape->v;
	}

	/* I could save the cleaned tape state at the beginning of a loop,
	 * then when we find the matching end loop the two tapes could be
	 * merged to give a tape of known values after the loop ends.
	 * This would not break the pipeline style of this code.
	 *
	 * This would also give states where a cell is known to have one
	 * of two or more different values. */
	return;

    case '.':
	if (tape->is_set) {
	    int c = tape->v;
	    if (bytecell) c &= 0xFF;
	    if (c > 0 && c < 128) {
		add_string(c);

		/* Limit the buffer size. */
		if (sav_str_len >= 128*1024 - (tape->v=='\n')*1024)
		    flush_string();
		break;
	    }
	}
	flush_tape(0,1);
	outcmd(ch, count);
	return;

    case ',':
	flush_tape(0,1);
	clear_cell(tape);
	outcmd(ch, count);
	return;

    case '>': while(count-->0) { if (tape->n == 0) new_n(tape); tape=tape->n; curroff++; } break;
    case '<': while(count-->0) { if (tape->p == 0) new_p(tape); tape=tape->p; curroff--; } break;
    case '+':
	if (be_interface.cells_are_ints || bytecell) {
	    tape->v += count;
	    if (bytecell) tape->v %= 256; /* -255..255 */
	} else {
	    int ov=0, res;
	    res = ov_iadd(tape->v, count, &ov);
	    if (!ov)
		tape->v = res;
	    else {
		flush_tape(0,1);
		clear_cell(tape);
		outcmd(ch, count);
	    }
	}
	break;
    case '-':
	if (be_interface.cells_are_ints || bytecell) {
	    tape->v -= count;
	    if (bytecell) tape->v %= 256; /* -255..255 */
	} else {
	    int ov=0, res;
	    res = ov_isub(tape->v, count, &ov);
	    if (!ov)
		tape->v = res;
	    else {
		flush_tape(0,1);
		clear_cell(tape);
		outcmd(ch, count);
	    }
	}
	break;

    case '=': tape->v = count; tape->is_set = 1; break;

    case 'B':
	flush_tape(0,1);
	if (be_interface.disable_be_optim) be_codegen_failure();
	outcmd(ch, count);
	return;

    case 'M': case 'N': case 'S': case 'T':
	if (ch == 'N') count = -count;
	else if (ch == 'S') count = 1;
	else if (ch == 'T') count = -1;

	if (tape->is_set && tape->v == 0) {
	    tape->is_set = 0 ; tape->v = 0;

	    ch = 'C';
	    if (count == 1) ch = 'V';
	    else if (count == -1) { ch = 'W'; count = -count; }
	    else if (count < 0) { ch = 'D'; count = -count; }
	} else {
	    ch = 'M';
	    if (count == 1) ch = 'S';
	    else if (count == -1) { ch = 'T'; count = -count; }
	    else if (count < 0) { ch = 'N'; count = -count; }
	}

	flush_tape(0,1);
	clear_cell(tape);
	if (be_interface.disable_be_optim) be_codegen_failure();
	outcmd(ch, count);
	return;

    default:
	if (be_interface.disable_be_optim) be_codegen_failure();
	if (ch>=0 && ch<256)
	    fprintf(stderr, "Unknown token in bf2const.c (%d)\n", ch);
	flush_tape(0,0);
	outcmd(ch, count);
	return;
    }
}
Exemplo n.º 4
0
void strassenMM(int N) {
    pad_0_A(N);
    pad_0_B(N);
    
   
    
    
    int oldN = N;
    N = new_n(N);
 
    m1=allocMatrix(N/2);
    m2=allocMatrix(N/2);
    m3=allocMatrix(N/2);
    m4=allocMatrix(N/2);
    m5=allocMatrix(N/2);
    m6=allocMatrix(N/2);
    m7=allocMatrix(N/2);
    
    pthread_t m_threads[7];

    pthread_create(&m_threads[0],NULL, &calc_m1,(void*) N);
    pthread_create(&m_threads[1],NULL, &calc_m2,(void*) N);
    pthread_create(&m_threads[2],NULL, &calc_m3,(void*) N);
    pthread_create(&m_threads[3],NULL, &calc_m4,(void*) N);
    pthread_create(&m_threads[4],NULL, &calc_m5,(void*) N);
    pthread_create(&m_threads[5],NULL, &calc_m6,(void*) N);
    pthread_create(&m_threads[6],NULL, &calc_m7,(void*) N);
    for(int i=0; i<7; i++)
        pthread_join(m_threads[i], NULL);
    

    c1=allocMatrix(N/2);
    c2=allocMatrix(N/2);
    c3=allocMatrix(N/2);
    c4=allocMatrix(N/2);
    
    pthread_t c_threads[4];
    pthread_create(&c_threads[0],NULL,calc_c1,(void*)(N/2));
    pthread_create(&c_threads[1],NULL,calc_c2,(void*)(N/2));
    pthread_create(&c_threads[2],NULL,calc_c3,(void*)(N/2));
    pthread_create(&c_threads[3],NULL,calc_c4,(void*)(N/2));
    for(int i=0; i<4; i++)
        pthread_join(c_threads[i],NULL);


    free(m1);
    free(m2);
    free(m3);
    free(m4);
    free(m5);
    free(m6);
    free(m7);

    for(int i=0; i<oldN; i++){
        for(int j=0; j<oldN; j++){
            if(i<N/2&&j<N/2) //c1
                C[i][j]=c1[i][j];
            else if(i>=N/2&&j<N/2) //c3
                C[i][j]=c3[i-N/2][j];
            else if(i<N/2&&j>=N/2) //c2
                C[i][j]=c2[i][j-N/2];
            else if(i>=N/2&&j>=N/2) //c4
                C[i][j]=c4[i-N/2][j-N/2];

        }
    }

    free(c1);
    free(c2);
    free(c3);
    free(c4);
    
}
Exemplo n.º 5
0
void outopt(int ch, int count)
{
    if (deadloop) {
	if (ch == '[') deadloop++;
	if (ch == ']') deadloop--;
	return;
    }
    if (ch == '[' && enable_mov_optim) {
	if (tape->is_set && tape->v == 0) {
	    deadloop++;
	    return;
	}
    }

    switch(ch)
    {
    default:
	if (ch == '!') {
	    flush_tape(1,0);
	    tape->cleaned = tape->is_set = first_run = !disable_init_optim;
	} else if (ch == '~' && enable_optim && !disable_init_optim)
	    flush_tape(1,0);
	else
	    flush_tape(0,0);
	if (ch) outcmd(ch, count);

	/* Loops end with zero */
	if (ch == ']') {
	    tape->is_set = 1;
	    tape->v = 0;
	    tape->cleaned = 1;
	    tape->cleaned_val = tape->v;
	}

	/* I could save the cleaned tape state at the beginning of a loop,
	 * then when we find the matching end loop the two tapes could be
	 * merged to give a tape of known values after the loop ends.
	 * This would not break the pipeline style of this code.
	 *
	 * This would also give states where a cell is known to have one
	 * of two or more different values. */
	return;

    case '.':
	if (!disable_savestring && enable_be_optim &&
		tape->is_set && tape->v > 0 && tape->v < 128) {
	    add_string(tape->v);

	    if (sav_str_len >= 128*1024) /* Limit the buffer size. */
	    {
		add_string(0);
		outcmd('"', 0);
		sav_str_len = 0;
	    }
	    break;
	}
	flush_tape(0,1);
	outcmd(ch, count);
	return;

    case ',':
	flush_tape(0,1);
	clear_cell(tape);
	outcmd(ch, count);
	return;

    case '>': while(count-->0) { if (tape->n == 0) new_n(tape); tape=tape->n; curroff++; } break;
    case '<': while(count-->0) { if (tape->p == 0) new_p(tape); tape=tape->p; curroff--; } break;
    case '+': tape->v += count; break;
    case '-': tape->v -= count; break;

    case '=': tape->v = count; tape->is_set = 1; break;

    case 'B':
	/* Some BE are not 32 bits, try to avoid cell size mistakes */
	if (!cells_are_ints && (tape->v > 65536 || tape->v < -65536))
	    ;
	else
	if (tape->is_set) {
	    if (bytecell) tape->v %= 256; /* Note: preserves sign but limits range. */
	    reg_known = 1;
	    reg_val = tape->v;
	    break;
	}

	flush_tape(0,1);
	reg_known = 0; reg_val = 0;
	if (enable_be_optim) {
	    outcmd(ch, count);
	} else {
	    outcmd('[', 1);
	}
	return;

    case 'M':
    case 'N':
    case 'S':
    case 'Q':
    case 'm':
    case 'n':
    case 's':
    case 'E':
	if (!reg_known) {
	    flush_tape(0,1);
	    clear_cell(tape);
	    if (enable_be_optim) {
		outcmd(ch, count);
	    } else switch(ch) {
		case 'M': case 'm':
		    outcmd('+', count);
		    break;
		case 'N': case 'n':
		    outcmd('-', count);
		    break;
		case 'S': case 's':
		    outcmd('+', 1);
		    break;
		case 'Q':
		    outcmd('[', 1);
		    outcmd('-', 1);
		    outcmd(']', 1);
		    if (count)
			outcmd('+', count);
		    break;
		case 'E':
		    outcmd(']', 1);
		    break;
	    }
	    return;
	}
	switch(ch) {
	case 'm':
	case 'M':
	    tape->v += reg_val * count;
	    break;
	case 'n':
	case 'N':
	    tape->v -= reg_val * count;
	    break;
	case 's':
	case 'S':
	    tape->v += reg_val;
	    break;

	case 'Q':
	    if (reg_val != 0) {
		tape->v = count;
		tape->is_set = 1;
	    }
	    break;
	}
	if (bytecell) tape->v %= 256; /* Note: preserves sign but limits range. */
    }
}