Exemplo n.º 1
1
double f2(double din,int iin) { 
  return(f1(iin,din));  // f1() is interpreted
}
Exemplo n.º 2
0
int f3 (void) {return f1();}
Exemplo n.º 3
0
bool f2(int x){
	if(f1(x)>0) return true; //используем функцию f1 внутри функции f2
	/*else*/ return false; //прототипы могут быть объявлены в любом порядке. если писать без прототипов, то f1 должна быть реализована до того как она будет
							//использоваться внутри f2
}
Exemplo n.º 4
0
int f3 (void)
{
    *g_6 = 1;
    f2 (f1 (&g_7));
    return 0;
}
Exemplo n.º 5
0
Arquivo: main.cpp Projeto: CCJY/coliru
int main()
{
    foo f0;
    foo f1(f0);
}
Exemplo n.º 6
0
int main(void) {
        f0();
    f1();
    f2();
    f3();
    f4();
    f5();
    f6();
    f7();
    f8();
    f9();
    f10();
    f11();
    f12();
    f13();
    f14();
    f15();
    f16();
    f17();
    f18();
    f19();
    f20();
    f21();
    f22();
    f23();
    f24();
    f25();
    f26();
    f27();
    f28();
    f29();
    f30();
    f31();
    f32();
    f33();
    f34();
    f35();
    f36();
    f37();
    f38();
    f39();
    f40();
    f41();
    f42();
    f43();
    f44();
    f45();
    f46();
    f47();
    f48();
    f49();
    f50();
    f51();
    f52();
    f53();
    f54();
    f55();
    f56();
    f57();
    f58();
    f59();
    f60();
    f61();
    f62();
    f63();
    f64();
    f65();
    f66();
    f67();
    f68();
    f69();
    f70();
    f71();
    f72();
    f73();
    f74();
    f75();
    f76();
    f77();
    f78();
    f79();
    f80();
    f81();
    f82();
    f83();
    f84();
    f85();
    f86();
    f87();
    f88();
    f89();
    f90();
    f91();
    f92();
    f93();
    f94();
    f95();
    f96();
    f97();
    f98();
    f99();
    f100();
    f101();
    f102();
    f103();
    f104();
    f105();
    f106();
    f107();
    f108();
    f109();
    f110();
    f111();
    f112();
    f113();
    f114();
    f115();
    f116();
    f117();
    f118();
    f119();
    f120();
    f121();
    f122();
    f123();
    f124();
    f125();
    f126();
    f127();
    f128();
    f129();
    f130();
    f131();
    f132();
    f133();
    f134();
    f135();
    f136();
    f137();
    f138();
    f139();
    f140();
    f141();
    f142();
    f143();
    f144();
    f145();
    f146();
    f147();
    f148();
    f149();
    f150();
    f151();
    f152();
    f153();
    f154();
    f155();
    f156();
    f157();
    f158();
    f159();
    f160();
    f161();
    f162();
    f163();
    f164();
    f165();
    f166();
    f167();
    f168();
    f169();
    f170();
    f171();
    f172();
    f173();
    f174();
    f175();
    f176();
    f177();
    f178();
    f179();
    f180();
    f181();
    f182();
    f183();
    f184();
    f185();
    f186();
    f187();
    f188();
    f189();
    f190();
    f191();
    f192();
    f193();
    f194();
    f195();
    f196();
    f197();
    f198();
    f199();


    return 0;
}
Exemplo n.º 7
0
const Vector &
SSPquadUP::getResistingForce(void)
// this function computes the resisting force vector for the element
{
	Vector f1(8);
	Vector f2(4);
	Vector mStress(3); 
	
	// get stress from the material
	mStress = theMaterial->getStress();

	// get trial displacement
	const Vector &mDisp_1 = theNodes[0]->getTrialDisp();
	const Vector &mDisp_2 = theNodes[1]->getTrialDisp();
	const Vector &mDisp_3 = theNodes[2]->getTrialDisp();
	const Vector &mDisp_4 = theNodes[3]->getTrialDisp();

	Vector d(8);
	d(0) = mDisp_1(0);
	d(1) = mDisp_1(1);
	d(2) = mDisp_2(0);
	d(3) = mDisp_2(1);
	d(4) = mDisp_3(0);
	d(5) = mDisp_3(1);
	d(6) = mDisp_4(0);
	d(7) = mDisp_4(1);

	// add stabilization force to internal force vector 
	f1 = Kstab*d;

	// add internal force from the stress
	f1.addMatrixTransposeVector(1.0, Mmem, mStress, 4.0*mThickness*J0);

	// get mass density from the material
	double density = theMaterial->getRho();

	// subtract body forces from internal force vector 
	double xi[4];
	double eta[4];
	xi[0]  = -1.0; xi[1]  =  1.0; xi[2]  = 1.0; xi[3]  = -1.0;
	eta[0] = -1.0; eta[1] = -1.0; eta[2] = 1.0; eta[3] =  1.0;

	if (applyLoad == 0) {
		for (int i = 0; i < 4; i++) {
			f1(2*i)   -= density*b[0]*mThickness*(J0 + J1*xi[i] + J2*eta[i]);
			f1(2*i+1) -= density*b[1]*mThickness*(J0 + J1*xi[i] + J2*eta[i]);
		}
	} else {
		for (int i = 0; i < 4; i++) {
			f1(2*i)   -= density*appliedB[0]*mThickness*(J0 + J1*xi[i] + J2*eta[i]);
			f1(2*i+1) -= density*appliedB[1]*mThickness*(J0 + J1*xi[i] + J2*eta[i]);
		}
	}

	// account for fluid body forces
	Matrix k(2,2);
	Vector body(2);
	// permeability tensor
	k(0,0) = perm[0];
	k(1,1) = perm[1];
	// body force vector
	if (applyLoad == 0) {
		body(0) = b[0];
		body(1) = b[1];
	} else {
		body(0) = appliedB[0];
		body(1) = appliedB[1];
	}
	f2 = 4.0*J0*mThickness*fDens*dN*k*body;

	// assemble full internal force vector for the element
	mInternalForces(0)  = f1(0);
	mInternalForces(1)  = f1(1);
	mInternalForces(2)  = f2(0);
	mInternalForces(3)  = f1(2);
	mInternalForces(4)  = f1(3);
	mInternalForces(5)  = f2(1);
	mInternalForces(6)  = f1(4);
	mInternalForces(7)  = f1(5);
	mInternalForces(8)  = f2(2);
	mInternalForces(9)  = f1(6);
	mInternalForces(10) = f1(7);
	mInternalForces(11) = f2(3);

	// inertial unbalance load
	mInternalForces.addVector(1.0, Q, -1.0);

	return mInternalForces;
}
Exemplo n.º 8
0
int main()
{
	try {
		{
			std::cout << "Test execution" << std::endl;
			TEST(!called_);
			booster::thread t(caller);
			t.join();
			TEST(called_);
		}
		std::cout << "Test recursive mutex" << std::endl;
		{
			booster::recursive_mutex m;
			m.lock();
			m.lock();
			TEST("Double lock works");
			m.unlock();
			m.unlock();
			TEST("Got there");
		}
		{
			variable = 0;
			booster::recursive_mutex m;
			incrementer<booster::recursive_mutex> inc = { &m };
			booster::thread t1(inc);
			booster::thread t2(inc);
			t1.join();
			t2.join();
			TEST(variable == 10);
		}
		std::cout << "Test mutex" << std::endl;
		{
			variable = 0;
			booster::mutex m;
			incrementer<booster::mutex> inc = { &m };
			booster::thread t1(inc);
			booster::thread t2(inc);
			t1.join();
			t2.join();
			TEST(variable == 10);
		}
		std::cout << "Test thread specific" << std::endl;
		{
			booster::thread_specific_ptr<tls_object> p;
			tls_functor f1(p);
			tls_functor f2(p);
			tls_functor f3(p);
			booster::thread t1(f1);
			booster::thread t2(f2);
			booster::thread t3(f3);

			t1.join();
			t2.join();
			t3.join();

			TEST(tls_ok);
			TEST(dtor_called == 3);
		}
		std::cout << "Non synchronous thread specific" << std::endl;
		{
			dtor_called = 0;
			booster::thread_specific_ptr<tls_object> *p = new booster::thread_specific_ptr<tls_object>();
			
			tls_functor2 f1(*p);
			tls_functor2 f2(*p);
			tls_functor2 f3(*p);

			booster::thread t1(f1);
			booster::thread t2(f2);
			booster::thread t3(f3);

			booster::ptime::millisleep(300);
			delete p;
			
			t1.join();
			t2.join();
			t3.join();

			TEST(dtor_called == 3);
		}
		std::cout << "Thest conditional variable notify one" << std::endl;
		{
			int counter = 0;
			booster::mutex m;
			booster::condition_variable c;
			cond_incrementer inc = { &counter, &m , &c };
			booster::thread t1(inc);
			booster::thread t2(inc);
			booster::thread t3(inc);
			booster::ptime::millisleep(100);
			TEST(counter == 0);
			c.notify_one();
			booster::ptime::millisleep(100);
			TEST(counter == 1);
			c.notify_one();
			booster::ptime::millisleep(100);
			TEST(counter == 2);
			c.notify_one();
			booster::ptime::millisleep(100);
			TEST(counter == 3);
			t1.join();
			t2.join();
			t3.join();
		}
		std::cout << "Thest conditional variable notify all" << std::endl;
		{
			int counter[3] = { 0, 0 , 0 };
			booster::mutex m;
			booster::condition_variable c;
			cond_incrementer inc = { counter, &m , &c };
			booster::thread t1(inc);
			inc.counter++;
			booster::thread t2(inc);
			inc.counter++;
			booster::thread t3(inc);
			booster::ptime::millisleep(100);
			TEST(counter[0]==0 && counter[1]==0 && counter[2]==0);
			c.notify_all();
			booster::ptime::millisleep(100);
			TEST(counter[0]==1 && counter[1]==1 && counter[2]==1);
			t1.join();
			t2.join();
			t3.join();
		}
		std::cout << "Test shared_mutex write lock" << std::endl;
		{
			variable = 0;
			booster::shared_mutex m;
			incrementer<booster::shared_mutex> inc = { &m };
			booster::thread t1(inc);
			booster::thread t2(inc);
			t1.join();
			t2.join();
			TEST(variable == 10);
		}
		std::cout << "Test recursive_shared_mutex write lock" << std::endl;
		{
			variable = 0;
			booster::shared_mutex m;
			incrementer<booster::shared_mutex> inc = { &m };
			booster::thread t1(inc);
			booster::thread t2(inc);
			t1.join();
			t2.join();
			TEST(variable == 10);
		}
		std::cout << "Test shared_mutex shared/write lock" << std::endl;
		{
			booster::mutex fm;
			booster::shared_mutex sm;
			bool flags[3] = {false,false,false};
			bool mread_happened  = false;
			bool write_happened = false;
			bool error_occured = false ;
			rw_executor<booster::shared_mutex> exec1 = { flags + 0, true, &fm, &sm };
			rw_executor<booster::shared_mutex> exec2 = { flags + 1, true, &fm, &sm };
			rw_executor<booster::shared_mutex> exec3 = { flags + 2, true, &fm, &sm };
			booster::thread t1(exec1);
			booster::thread t2(exec2);
			booster::thread t3(exec3);

			for(int i=0;i<100;i++) {
				booster::ptime::millisleep(1);
				{
					booster::unique_lock<booster::mutex> l(fm);
					if(flags[0] && flags[1])
						mread_happened = true;
					if(flags[2])
						write_happened = true;
					if((flags[0] || flags[1]) && flags[2])
						error_occured = true;
				}
			}

			t1.join();
			t2.join();
			t3.join();

			TEST(mread_happened);
			TEST(write_happened);
			TEST(error_occured);
		}
		std::cout << "Test recursive_shared_mutex shared/write lock" << std::endl;
		{
			booster::mutex fm;
			booster::recursive_shared_mutex sm;
			bool flags[3] = {false,false,false};
			bool mread_happened  = false;
			bool write_happened = false;
			bool error_occured = false ;
			rw_executor<booster::recursive_shared_mutex> exec1 = { flags + 0, true, &fm, &sm };
			rw_executor<booster::recursive_shared_mutex> exec2 = { flags + 1, true, &fm, &sm };
			rw_executor<booster::recursive_shared_mutex> exec3 = { flags + 2, true, &fm, &sm };
			booster::thread t1(exec1);
			booster::thread t2(exec2);
			booster::thread t3(exec3);

			for(int i=0;i<100;i++) {
				booster::ptime::millisleep(1);
				{
					booster::unique_lock<booster::mutex> l(fm);
					if(flags[0] && flags[1])
						mread_happened = true;
					if(flags[2])
						write_happened = true;
					if((flags[0] || flags[1]) && flags[2])
						error_occured = true;
				}
			}

			t1.join();
			t2.join();
			t3.join();

			TEST(mread_happened);
			TEST(write_happened);
			TEST(error_occured);
		}
		std::cout << "Test recursive_shared_mutex recursive shared lock" << std::endl;
		{
			booster::recursive_shared_mutex l;
			bool read  = false;
			bool write = false;
			rw_shared_thread t1c = { &l, &read };
			rw_unique_thread t2c = { &l, &write };
			booster::thread t1(t1c);
			booster::thread t2(t2c);
			t1.join();
			t2.join();
			TEST(read);
			TEST(write);
		}

}
	catch(std::exception const &e)
	{
		std::cerr << "Fail:" <<e.what();
		return EXIT_FAILURE;
	}
	std::cout << "Ok" << std::endl;
	return EXIT_SUCCESS;
	
}
Exemplo n.º 9
0
//3GPP TS 35.205/6/7/8/9 and RFC 3310
int tsip_challenge_get_akares(tsip_challenge_t *self, char const *password, char** result)
{
#define SQN_XOR_AK() (AUTN + 0)
#define SERVER_DATA() (nonce + AKA_RAND_SIZE + AKA_AUTN_SIZE)

    // § ==> XOR
    // || ==> append

    AKA_RES_T akares;

    int ret = -1;
    tsk_size_t n;
    char *nonce = tsk_null;

    AKA_XXX_DECLARE(RAND);
    AKA_XXX_DECLARE(AK);
    AKA_XXX_DECLARE(AMF);
    AKA_XXX_DECLARE(CK);
    AKA_XXX_DECLARE(IK);
    AKA_XXX_DECLARE(K);
    AKA_XXX_DECLARE(SQN);
    AKA_XXX_DECLARE(MAC_A);
    AKA_XXX_DECLARE(AUTN);

    AKA_XXX_BZERO(RAND);
    AKA_XXX_BZERO(AK);
    AKA_XXX_BZERO(AMF);
    AKA_XXX_BZERO(CK);
    AKA_XXX_BZERO(IK);
    AKA_XXX_BZERO(K);
    AKA_XXX_BZERO(SQN);
    AKA_XXX_BZERO(MAC_A);
    AKA_XXX_BZERO(AUTN);

    /* RFC 3310 subclause 3.2: nonce = base64(RAND || AUTN || SERV_DATA) */
    n = tsk_base64_decode((const uint8_t*)self->nonce, tsk_strlen(self->nonce), &nonce);
    if(n > TSK_MD5_STRING_SIZE) {
        TSK_DEBUG_ERROR("The IMS CORE returned an invalid nonce.");
        goto bail;
    }
    if(n < AKA_RAND_SIZE + AKA_AUTN_SIZE) {
        TSK_DEBUG_ERROR("The nonce returned by the IMS CORE is too short to contain both [RAND] and [AUTHN]");
        goto bail;
    }
    else {
        /* Get RAND and AUTN */
        memcpy(RAND, nonce, AKA_RAND_SIZE);
        memcpy(AUTN, (nonce + AKA_RAND_SIZE), AKA_AUTN_SIZE);
    }

    /* Secret key */
    memcpy(K, password, (tsk_strlen(password) > AKA_K_SIZE ? AKA_K_SIZE : tsk_strlen(password)));

    /* 3GPP TS 35.205: AUTN = SQN[§AK] || AMF || MAC-A */
    memcpy(AMF, (AUTN + AKA_SQN_SIZE), AKA_AMF_SIZE);
    memcpy(MAC_A, (AUTN + AKA_SQN_SIZE + AKA_AMF_SIZE), AKA_MAC_A_SIZE);

    /* compute OP */
    ComputeOP(TSIP_CHALLENGE_STACK(self)->security.operator_id);

    /* Checks that we hold the same AMF */
    for(n=0; n<AKA_AMF_SIZE; n++) {
        if(AMF[n] != TSIP_CHALLENGE_STACK(self)->security.amf[n]) {
            TSK_DEBUG_ERROR("IMS-AKA error: AMF <> XAMF");
            goto bail;
        }
    }

    /* Calculate CK, IK and AK */
    f2345(K, RAND, akares, CK, IK, AK);

    /* Calculate SQN from SQN_XOR_AK */
    for(n=0; n<AKA_SQN_SIZE; n++) {
        SQN[n] = (uint8_t) (SQN_XOR_AK()[n] ^ AK[n]);
    }

    /* Calculate XMAC_A */
    {
        AKA_MAC_A_T XMAC_A;
        memset(XMAC_A, '\0', sizeof(XMAC_A));

        f1(K, RAND, SQN, AMF, XMAC_A);
        if(!tsk_strnequals(MAC_A, XMAC_A, AKA_MAC_A_SIZE)) {
            TSK_DEBUG_ERROR("IMS-AKA error: XMAC_A [%s] <> MAC_A[%s]", XMAC_A, MAC_A);
            goto bail;
        }
    }

    /* RFC 4169 subclause 3
    	The HTTP Digest password is derived from base64 encoded PRF(RES || IK||CK, "http-digest-akav2-password")
    	or
    	PRF(XRES||IK||CK, "http-digest-akav2-password") instead of (RES) or (XRES) respectively.
    	Where PRF ==> HMAC_MD5 function.
    */
    if(TSIP_CHALLENGE_IS_AKAv2(self)) {
        uint8_t res_ik_ck[AKA_RES_SIZE + AKA_IK_SIZE + AKA_CK_SIZE];
        tsk_md5digest_t md5_digest;

        memcpy(res_ik_ck, akares, AKA_RES_SIZE);
        memcpy((res_ik_ck + AKA_RES_SIZE), IK, AKA_IK_SIZE);
        memcpy((res_ik_ck + AKA_RES_SIZE + AKA_IK_SIZE), CK, AKA_CK_SIZE);

        if((ret = hmac_md5digest_compute((const uint8_t*)"http-digest-akav2-password", 26, (const char*)res_ik_ck, sizeof(res_ik_ck), md5_digest))) { /* PRF(RES||IK||CK, ...) */
            TSK_DEBUG_ERROR("hmac_md5digest_compute() failed. AKAv2 response will be invalid.");

            ret = -3;
            goto bail;
        }
        else { /* b64(PRF(...)) */
            if(!tsk_base64_encode(md5_digest, sizeof(md5_digest), result)) {
                TSK_DEBUG_ERROR("tsk_base64_encode() failed. AKAv2 response will be invalid.");

                ret = -4;
                goto bail;
            }
        }
    }
    else {
        *result = tsk_calloc(1, AKA_RES_SIZE + 1);
        memcpy(*result, akares, AKA_RES_SIZE);

        ret = 0;
    }

    /* Copy CK and IK */
    memcpy(self->ck, CK, AKA_CK_SIZE);
    memcpy(self->ik, IK, AKA_IK_SIZE);

bail:
    TSK_FREE(nonce);
    return ret;

#undef SQN_XOR_AK
#undef SERVER_DATA
}
Exemplo n.º 10
0
DG_INLINE void dgSolver::BuildJacobianMatrix(dgJointInfo* const jointInfo, dgLeftHandSide* const leftHandSide, dgRightHandSide* const rightHandSide, dgJacobian* const internalForces)
{
	const dgInt32 m0 = jointInfo->m_m0;
	const dgInt32 m1 = jointInfo->m_m1;
	const dgInt32 index = jointInfo->m_pairStart;
	const dgInt32 count = jointInfo->m_pairCount;
	const dgDynamicBody* const body0 = (dgDynamicBody*)m_bodyArray[m0].m_body;
	const dgDynamicBody* const body1 = (dgDynamicBody*)m_bodyArray[m1].m_body;
	const bool isBilateral = jointInfo->m_joint->IsBilateral();

	const dgMatrix invInertia0 = body0->m_invWorldInertiaMatrix;
	const dgMatrix invInertia1 = body1->m_invWorldInertiaMatrix;
	const dgVector invMass0(body0->m_invMass[3]);
	const dgVector invMass1(body1->m_invMass[3]);

	dgSoaFloat force0(m_soaZero);
	if (body0->IsRTTIType(dgBody::m_dynamicBodyRTTI)) {
		//force0 = dgSoaFloat(body0->m_externalForce, body0->m_externalTorque);
		dgJacobian& f = (dgJacobian&)force0[0]; 
		f.m_linear = body0->m_externalForce;
		f.m_angular = body0->m_externalTorque;
	}

	dgSoaFloat force1(m_soaZero);
	if (body1->IsRTTIType(dgBody::m_dynamicBodyRTTI)) {
		//force1 = dgSoaFloat(body1->m_externalForce, body1->m_externalTorque);
		dgJacobian& f = (dgJacobian&)force1[0];
		f.m_linear = body1->m_externalForce;
		f.m_angular = body1->m_externalTorque;
	}

	jointInfo->m_preconditioner0 = dgFloat32(1.0f);
	jointInfo->m_preconditioner1 = dgFloat32(1.0f);
	if ((invMass0.GetScalar() > dgFloat32(0.0f)) && (invMass1.GetScalar() > dgFloat32(0.0f)) && !(body0->GetSkeleton() && body1->GetSkeleton())) {
		const dgFloat32 mass0 = body0->GetMass().m_w;
		const dgFloat32 mass1 = body1->GetMass().m_w;
		if (mass0 > (DG_DIAGONAL_PRECONDITIONER * mass1)) {
			jointInfo->m_preconditioner0 = mass0 / (mass1 * DG_DIAGONAL_PRECONDITIONER);
		} else if (mass1 > (DG_DIAGONAL_PRECONDITIONER * mass0)) {
			jointInfo->m_preconditioner1 = mass1 / (mass0 * DG_DIAGONAL_PRECONDITIONER);
		}
	}

	dgSoaFloat forceAcc0(m_soaZero);
	dgSoaFloat forceAcc1(m_soaZero);

	const dgSoaFloat weight0(m_bodyProxyArray[m0].m_weight * jointInfo->m_preconditioner0);
	const dgSoaFloat weight1(m_bodyProxyArray[m1].m_weight * jointInfo->m_preconditioner0);

	const dgFloat32 forceImpulseScale = dgFloat32(1.0f);
	const dgFloat32 preconditioner0 = jointInfo->m_preconditioner0;
	const dgFloat32 preconditioner1 = jointInfo->m_preconditioner1;

	for (dgInt32 i = 0; i < count; i++) {
		dgLeftHandSide* const row = &leftHandSide[index + i];
		dgRightHandSide* const rhs = &rightHandSide[index + i];

		row->m_JMinv.m_jacobianM0.m_linear = row->m_Jt.m_jacobianM0.m_linear * invMass0;
		row->m_JMinv.m_jacobianM0.m_angular = invInertia0.RotateVector(row->m_Jt.m_jacobianM0.m_angular);
		row->m_JMinv.m_jacobianM1.m_linear = row->m_Jt.m_jacobianM1.m_linear * invMass1;
		row->m_JMinv.m_jacobianM1.m_angular = invInertia1.RotateVector(row->m_Jt.m_jacobianM1.m_angular);

		const dgSoaFloat& JMinvM0 = (dgSoaFloat&)row->m_JMinv.m_jacobianM0;
		const dgSoaFloat& JMinvM1 = (dgSoaFloat&)row->m_JMinv.m_jacobianM1;
		const dgSoaFloat tmpAccel((JMinvM0 * force0).MulAdd(JMinvM1, force1));

		dgFloat32 extenalAcceleration = -tmpAccel.AddHorizontal();
		rhs->m_deltaAccel = extenalAcceleration * forceImpulseScale;
		rhs->m_coordenateAccel += extenalAcceleration * forceImpulseScale;
		dgAssert(rhs->m_jointFeebackForce);
		const dgFloat32 force = rhs->m_jointFeebackForce->m_force * forceImpulseScale;
		rhs->m_force = isBilateral ? dgClamp(force, rhs->m_lowerBoundFrictionCoefficent, rhs->m_upperBoundFrictionCoefficent) : force;
		rhs->m_maxImpact = dgFloat32(0.0f);

		const dgSoaFloat& JtM0 = (dgSoaFloat&)row->m_Jt.m_jacobianM0;
		const dgSoaFloat& JtM1 = (dgSoaFloat&)row->m_Jt.m_jacobianM1;
		const dgSoaFloat tmpDiag((weight0 * JMinvM0 * JtM0).MulAdd(weight1, JMinvM1 * JtM1));
			
		dgFloat32 diag = tmpDiag.AddHorizontal();
		dgAssert(diag > dgFloat32(0.0f));
		rhs->m_diagDamp = diag * rhs->m_stiffness;
		diag *= (dgFloat32(1.0f) + rhs->m_stiffness);
		rhs->m_invJinvMJt = dgFloat32(1.0f) / diag;

		dgSoaFloat f0(rhs->m_force * preconditioner0);
		dgSoaFloat f1(rhs->m_force * preconditioner1);
		forceAcc0 = forceAcc0.MulAdd(JtM0, f0);
		forceAcc1 = forceAcc1.MulAdd(JtM1, f1);
	}

	if (m0) {
		dgSoaFloat& out = (dgSoaFloat&)internalForces[m0];
		dgScopeSpinPause lock(&m_bodyProxyArray[m0].m_lock);
		out = out + forceAcc0;
	}
	if (m1) {
		dgSoaFloat& out = (dgSoaFloat&)internalForces[m1];
		dgScopeSpinPause lock(&m_bodyProxyArray[m1].m_lock);
		out = out + forceAcc1;
	}
}
Exemplo n.º 11
0
void f3() { f1(); f2(0); }
int f0(int i)
{
	return f1(i) - i;
}
Exemplo n.º 13
0
__attribute__ ((noinline)) int
main1 (void)
{
  int i, j;

  for (j = 0; j < 8; j++)
    {
      for (i = 0; i <= N; i++)
	{
	  ia[i] = i + 3;
	  ib[i] = i + N + 3;
	  asm ("");
	}

      switch (j)
	{
	case 0: f1 (); break;
	case 1: f2 (); break;
	case 2: f3 (); break;
	case 3: f4 (); break;
	case 4: f5 (); break;
	case 5: f6 (); break;
	case 6: f7 (); break;
	case 7: f8 (); break;
	}

      for (i = 0; i <= N; i++)
	{
	  int ea = i + 3;
	  int eb = i + N + 3;
	  switch (j)
	    {
	    case 0:
	      if (i) ea = 1;
	      if (i == 0) eb = 3;
	      else if (i != N) eb = 1;
	      break;
	    case 1:
	      if (i != N) ea = 1;
	      if (i != N) eb = i + 4;
	      break;
	    case 2:
	      if (i) ea = 1;
	      if (i != N) eb = i + 3;
	      break;
	    case 3:
	      if (i != N) ea = 1;
	      if (i < N - 1) eb = 1;
	      else if (i == N - 1) eb = 67;
	      break;
	    case 4:
	      ea = 1 + (i != N);
	      break;
	    case 5:
	      ea = 2 - (i != N);
	      break;
	    case 6:
	      ea = 1 + (i == 0);
	      break;
	    case 7:
	      ea = 2 - (i == 0);
	      break;
	    }
	  if (ia[i] != ea || ib[i] != eb)
	    abort ();
	}
    }

  return 0;
}
Exemplo n.º 14
0
__attribute__((bnd_legacy)) int f2 (int *p)
{
  return f1 (p);
}
Exemplo n.º 15
0
TreeRingViewItem::TreeRingViewItem(QGLContext* ctx, QGraphicsItem* p)
    : QVTKGraphicsItem(ctx, p)
{
    QPalette pal = this->palette();
    pal.setColor(QPalette::Window, QColor(255,255,255,250));
    this->setPalette(pal);

    TreeRingView.TakeReference(vtkTreeRingView::New());
    TreeRingView->SetInteractor(this->GetInteractor());
    TreeRingView->SetRenderWindow(this->GetRenderWindow());

    QFile f1(":/Data/vtkclasses.xml");
    f1.open(QIODevice::ReadOnly);
    QByteArray f1_data = f1.readAll();

    QFile f2(":/Data/vtklibrary.xml");
    f2.open(QIODevice::ReadOnly);
    QByteArray f2_data = f2.readAll();

    vtkSmartPointer<vtkXMLTreeReader> reader1 = vtkSmartPointer<vtkXMLTreeReader>::New();
    reader1->SetXMLString(f1_data.data());
    reader1->SetEdgePedigreeIdArrayName("graph edge");
    reader1->GenerateVertexPedigreeIdsOff();
    reader1->SetVertexPedigreeIdArrayName("id");

    vtkSmartPointer<vtkXMLTreeReader> reader2 = vtkSmartPointer<vtkXMLTreeReader>::New();
    reader2->SetXMLString(f2_data.data());
    reader2->SetEdgePedigreeIdArrayName("tree edge");
    reader2->GenerateVertexPedigreeIdsOff();
    reader2->SetVertexPedigreeIdArrayName("id");

    reader1->Update();
    reader2->Update();

    TreeRingView->DisplayHoverTextOn();
    TreeRingView->SetTreeFromInputConnection(reader2->GetOutputPort());
    TreeRingView->SetGraphFromInputConnection(reader1->GetOutputPort());

    TreeRingView->SetAreaColorArrayName("VertexDegree");

    // Uncomment for edge colors
    //TreeRingView->SetEdgeColorArrayName("graph edge");
    //TreeRingView->SetColorEdges(true);

    // Uncomment for edge labels
    //TreeRingView->SetEdgeLabelArrayName("graph edge");
    //TreeRingView->SetEdgeLabelVisibility(true);

    TreeRingView->SetAreaLabelArrayName("id");
    TreeRingView->SetAreaLabelVisibility(true);
    TreeRingView->SetAreaHoverArrayName("id");
    TreeRingView->SetAreaSizeArrayName("VertexDegree");
    vtkRenderedTreeAreaRepresentation::SafeDownCast(TreeRingView->GetRepresentation())->SetGraphHoverArrayName("graph edge");

    vtkViewTheme* const theme = vtkViewTheme::CreateMellowTheme();
    theme->SetLineWidth(1);
    theme->GetPointTextProperty()->ShadowOn();
    TreeRingView->ApplyViewTheme(theme);
    theme->Delete();

    this->TreeRingView->GetRenderer()->SetGradientBackground(0);
    this->TreeRingView->GetRenderer()->SetBackground(0.1,0.1,0.1);

    TreeRingView->ResetCamera();


}
/* Call functions through pointers and and check against expected results.  */
void
test (void)
{

  CHECK_VOID_RESULT (v0 (), 1.0);
  CHECK_VOID_RESULT (v1 (1.0), 2.0);
  CHECK_VOID_RESULT (v5 (5.0, 6.0), 12.0);
  CHECK_VOID_RESULT (v9 (9.0, 10.0), 20.0);
  CHECK_VOID_RESULT (v2 (2.0), 3.0);
  CHECK_VOID_RESULT (v6 (6.0, 7.0), 14.0);
  CHECK_VOID_RESULT (v10 (10.0, 11.0), 22.0);

  CHECK_RESULT (f0 (), 1.0);
  CHECK_RESULT (f1 (1.0), 2.0);
  CHECK_RESULT (f5 (5.0, 6.0), 12.0);
  CHECK_RESULT (f9 (9.0, 10.0), 20.0);
  CHECK_RESULT (f2 (2.0), 3.0);
  CHECK_RESULT (f6 (6.0, 7.0), 14.0);
  CHECK_RESULT (f10 (10.0, 11.0), 22.0);

  CHECK_RESULT (d0 (), 1.0);
  CHECK_RESULT (d1 (1.0), 2.0);
  CHECK_RESULT (d5 (5.0, 6.0), 12.0);
  CHECK_RESULT (d9 (9.0, 10.0), 20.0);
  CHECK_RESULT (d2 (2.0), 3.0);
  CHECK_RESULT (d6 (6.0, 7.0), 14.0);
  CHECK_RESULT (d10 (10.0, 11.0), 22.0);

  CHECK_RESULT (cf0 (), 1.0 + 0.0i);
  CHECK_RESULT (cf1 (1.0), 2.0 + 1.0i);
  CHECK_RESULT (cf5 (5.0, 6.0), 12.0 + 5.0i);
  CHECK_RESULT (cf9 (9.0, 10.0), 20.0 + 9.0i);
  CHECK_RESULT (cf2 (2.0), 3.0 + 2.0i);
  CHECK_RESULT (cf6 (6.0, 7.0), 14.0 + 6.0i);
  CHECK_RESULT (cf10 (10.0, 11.0), 22.0 + 10.0i);

  CHECK_RESULT (cd0 (), 1.0 + 0.0i);
  CHECK_RESULT (cd1 (1.0), 2.0 + 1.0i);
  CHECK_RESULT (cd5 (5.0, 6.0), 12.0 + 5.0i);
  CHECK_RESULT (cd9 (9.0, 10.0), 20.0 + 9.0i);
  CHECK_RESULT (cd2 (2.0), 3.0 + 2.0i);
  CHECK_RESULT (cd6 (6.0, 7.0), 14.0 + 6.0i);
  CHECK_RESULT (cd10 (10.0, 11.0), 22.0 + 10.0i);

  CHECK_VOID_RESULT ((*pv0) (), 1.0);
  CHECK_VOID_RESULT ((*pv1) (1.0), 2.0);
  CHECK_VOID_RESULT ((*pv5) (5.0, 6.0), 12.0);
  CHECK_VOID_RESULT ((*pv9) (9.0, 10.0), 20.0);
  CHECK_VOID_RESULT ((*pv2) (2.0), 3.0);
  CHECK_VOID_RESULT ((*pv6) (6.0, 7.0), 14.0);
  CHECK_VOID_RESULT ((*pv10) (10.0, 11.0), 22.0);

  CHECK_RESULT ((*pf0) (), 1.0);
  CHECK_RESULT ((*pf1) (1.0), 2.0);
  CHECK_RESULT ((*pf5) (5.0, 6.0), 12.0);
  CHECK_RESULT ((*pf9) (9.0, 10.0), 20.0);
  CHECK_RESULT ((*pf2) (2.0), 3.0);
  CHECK_RESULT ((*pf6) (6.0, 7.0), 14.0);
  CHECK_RESULT ((*pf10) (10.0, 11.0), 22.0);

  CHECK_RESULT ((*pd0) (), 1.0);
  CHECK_RESULT ((*pd1) (1.0), 2.0);
  CHECK_RESULT ((*pd5) (5.0, 6.0), 12.0);
  CHECK_RESULT ((*pd9) (9.0, 10.0), 20.0);
  CHECK_RESULT ((*pd2) (2.0), 3.0);
  CHECK_RESULT ((*pd6) (6.0, 7.0), 14.0);
  CHECK_RESULT ((*pd10) (10.0, 11.0), 22.0);

  CHECK_RESULT ((*pcf0) (), 1.0 + 0.0i);
  CHECK_RESULT ((*pcf1) (1.0), 2.0 + 1.0i);
  CHECK_RESULT ((*pcf5) (5.0, 6.0), 12.0 + 5.0i);
  CHECK_RESULT ((*pcf9) (9.0, 10.0), 20.0 + 9.0i);
  CHECK_RESULT ((*pcf2) (2.0), 3.0 + 2.0i);
  CHECK_RESULT ((*pcf6) (6.0, 7.0), 14.0 + 6.0i);
  CHECK_RESULT ((*pcf10) (10.0, 11.0), 22.0 + 10.0i);

  CHECK_RESULT ((*pcd0) (), 1.0 + 0.0i);
  CHECK_RESULT ((*pcd1) (1.0), 2.0 + 1.0i);
  CHECK_RESULT ((*pcd5) (5.0, 6.0), 12.0 + 5.0i);
  CHECK_RESULT ((*pcd9) (9.0, 10.0), 20.0 + 9.0i);
  CHECK_RESULT ((*pcd2) (2.0), 3.0 + 2.0i);
  CHECK_RESULT ((*pcd6) (6.0, 7.0), 14.0 + 6.0i);
  CHECK_RESULT ((*pcd10) (10.0, 11.0), 22.0 + 10.0i);
}
Exemplo n.º 17
0
int
main ()
{
  int i;

  check_vect ();

  for (i = 0; i < N; i++)
    {
      switch (i % 9)
	{
	case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break;
	case 1: a[i] = 0; b[i] = 0; break;
	case 2: a[i] = i + 1; b[i] = - i - 1; break;
	case 3: a[i] = i; b[i] = i + 7; break;
	case 4: a[i] = i; b[i] = i; break;
	case 5: a[i] = i + 16; b[i] = i + 3; break;
	case 6: a[i] = - i - 5; b[i] = - i; break;
	case 7: a[i] = - i; b[i] = - i; break;
	case 8: a[i] = - i; b[i] = - i - 7; break;
	}
    }
  for (i = 0; i < N; i++)
    {
      switch ((i / 9) % 3)
	{
	case 0: c[i] = a[i / 9]; d[i] = b[i / 9]; break;
	case 1: c[i] = a[i / 9 + 3]; d[i] = b[i / 9 + 3]; break;
	case 2: c[i] = a[i / 9 + 6]; d[i] = b[i / 9 + 6]; break;
	}
    }
  f1 ();
  for (i = 0; i < N; i++)
    if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (j, -6, sizeof (j));
  f2 ();
  for (i = 0; i < N; i++)
    if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (j, -6, sizeof (j));
  f3 ();
  for (i = 0; i < N; i++)
    if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (j, -6, sizeof (j));
  f4 ();
  for (i = 0; i < N; i++)
    if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (k, -6, sizeof (k));
  f5 ();
  for (i = 0; i < N; i++)
    if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (k, -6, sizeof (k));
  f6 ();
  for (i = 0; i < N; i++)
    if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (j, -6, sizeof (j));
  f7 ();
  for (i = 0; i < N; i++)
    if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (j, -6, sizeof (j));
  f8 ();
  for (i = 0; i < N; i++)
    if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (j, -6, sizeof (j));
  f9 ();
  for (i = 0; i < N; i++)
    if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (k, -6, sizeof (k));
  f10 ();
  for (i = 0; i < N; i++)
    if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
      abort ();
  __builtin_memset (k, -6, sizeof (k));

  return 0;
}
Exemplo n.º 18
0
void sha1_32(unsigned *hash,
			 unsigned k00, unsigned k01, unsigned k02, unsigned k03,
			 unsigned k04, unsigned k05, unsigned k06, unsigned k07,
			 unsigned k08, unsigned k09, unsigned k0A, unsigned k0B,
			 unsigned k0C, unsigned k0D, unsigned k0E, unsigned k0F)
{
	unsigned a, b, c, d, e;
	unsigned t;


	a = 0x67452301U;
	b = 0xEFCDAB89U;
	c = 0x98BADCFEU;
	d = 0x10325476U;
	e = 0xC3D2E1F0U;

	t = ROL(5, a) + f0(b, c, d) + e + k00; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k01; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k02; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k03; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k04; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k05; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k06; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k07; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k08; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k09; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k0A; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k0B; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k0C; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k0D; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k0E; e = d; d = c; c = ROL(30, b); b = a; a = t;
	t = ROL(5, a) + f0(b, c, d) + e + k0F; e = d; d = c; c = ROL(30, b); b = a; a = t;

	k00 = ROL(1, k00 ^ k02 ^ k08 ^ k0D); t = ROL(5, a) + f0(b, c, d) + e + k00; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k01 = ROL(1, k01 ^ k03 ^ k09 ^ k0E); t = ROL(5, a) + f0(b, c, d) + e + k01; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k02 = ROL(1, k02 ^ k04 ^ k0A ^ k0F); t = ROL(5, a) + f0(b, c, d) + e + k02; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k03 = ROL(1, k03 ^ k05 ^ k0B ^ k00); t = ROL(5, a) + f0(b, c, d) + e + k03; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k04 = ROL(1, k04 ^ k06 ^ k0C ^ k01); t = ROL(5, a) + f1(b, c, d) + e + k04; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k05 = ROL(1, k05 ^ k07 ^ k0D ^ k02); t = ROL(5, a) + f1(b, c, d) + e + k05; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k06 = ROL(1, k06 ^ k08 ^ k0E ^ k03); t = ROL(5, a) + f1(b, c, d) + e + k06; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k07 = ROL(1, k07 ^ k09 ^ k0F ^ k04); t = ROL(5, a) + f1(b, c, d) + e + k07; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k08 = ROL(1, k08 ^ k0A ^ k00 ^ k05); t = ROL(5, a) + f1(b, c, d) + e + k08; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k09 = ROL(1, k09 ^ k0B ^ k01 ^ k06); t = ROL(5, a) + f1(b, c, d) + e + k09; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0A = ROL(1, k0A ^ k0C ^ k02 ^ k07); t = ROL(5, a) + f1(b, c, d) + e + k0A; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0B = ROL(1, k0B ^ k0D ^ k03 ^ k08); t = ROL(5, a) + f1(b, c, d) + e + k0B; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0C = ROL(1, k0C ^ k0E ^ k04 ^ k09); t = ROL(5, a) + f1(b, c, d) + e + k0C; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0D = ROL(1, k0D ^ k0F ^ k05 ^ k0A); t = ROL(5, a) + f1(b, c, d) + e + k0D; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0E = ROL(1, k0E ^ k00 ^ k06 ^ k0B); t = ROL(5, a) + f1(b, c, d) + e + k0E; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0F = ROL(1, k0F ^ k01 ^ k07 ^ k0C); t = ROL(5, a) + f1(b, c, d) + e + k0F; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k00 = ROL(1, k00 ^ k02 ^ k08 ^ k0D); t = ROL(5, a) + f1(b, c, d) + e + k00; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k01 = ROL(1, k01 ^ k03 ^ k09 ^ k0E); t = ROL(5, a) + f1(b, c, d) + e + k01; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k02 = ROL(1, k02 ^ k04 ^ k0A ^ k0F); t = ROL(5, a) + f1(b, c, d) + e + k02; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k03 = ROL(1, k03 ^ k05 ^ k0B ^ k00); t = ROL(5, a) + f1(b, c, d) + e + k03; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k04 = ROL(1, k04 ^ k06 ^ k0C ^ k01); t = ROL(5, a) + f1(b, c, d) + e + k04; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k05 = ROL(1, k05 ^ k07 ^ k0D ^ k02); t = ROL(5, a) + f1(b, c, d) + e + k05; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k06 = ROL(1, k06 ^ k08 ^ k0E ^ k03); t = ROL(5, a) + f1(b, c, d) + e + k06; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k07 = ROL(1, k07 ^ k09 ^ k0F ^ k04); t = ROL(5, a) + f1(b, c, d) + e + k07; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k08 = ROL(1, k08 ^ k0A ^ k00 ^ k05); t = ROL(5, a) + f2(b, c, d) + e + k08; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k09 = ROL(1, k09 ^ k0B ^ k01 ^ k06); t = ROL(5, a) + f2(b, c, d) + e + k09; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0A = ROL(1, k0A ^ k0C ^ k02 ^ k07); t = ROL(5, a) + f2(b, c, d) + e + k0A; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0B = ROL(1, k0B ^ k0D ^ k03 ^ k08); t = ROL(5, a) + f2(b, c, d) + e + k0B; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0C = ROL(1, k0C ^ k0E ^ k04 ^ k09); t = ROL(5, a) + f2(b, c, d) + e + k0C; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0D = ROL(1, k0D ^ k0F ^ k05 ^ k0A); t = ROL(5, a) + f2(b, c, d) + e + k0D; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0E = ROL(1, k0E ^ k00 ^ k06 ^ k0B); t = ROL(5, a) + f2(b, c, d) + e + k0E; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0F = ROL(1, k0F ^ k01 ^ k07 ^ k0C); t = ROL(5, a) + f2(b, c, d) + e + k0F; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k00 = ROL(1, k00 ^ k02 ^ k08 ^ k0D); t = ROL(5, a) + f2(b, c, d) + e + k00; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k01 = ROL(1, k01 ^ k03 ^ k09 ^ k0E); t = ROL(5, a) + f2(b, c, d) + e + k01; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k02 = ROL(1, k02 ^ k04 ^ k0A ^ k0F); t = ROL(5, a) + f2(b, c, d) + e + k02; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k03 = ROL(1, k03 ^ k05 ^ k0B ^ k00); t = ROL(5, a) + f2(b, c, d) + e + k03; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k04 = ROL(1, k04 ^ k06 ^ k0C ^ k01); t = ROL(5, a) + f2(b, c, d) + e + k04; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k05 = ROL(1, k05 ^ k07 ^ k0D ^ k02); t = ROL(5, a) + f2(b, c, d) + e + k05; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k06 = ROL(1, k06 ^ k08 ^ k0E ^ k03); t = ROL(5, a) + f2(b, c, d) + e + k06; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k07 = ROL(1, k07 ^ k09 ^ k0F ^ k04); t = ROL(5, a) + f2(b, c, d) + e + k07; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k08 = ROL(1, k08 ^ k0A ^ k00 ^ k05); t = ROL(5, a) + f2(b, c, d) + e + k08; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k09 = ROL(1, k09 ^ k0B ^ k01 ^ k06); t = ROL(5, a) + f2(b, c, d) + e + k09; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0A = ROL(1, k0A ^ k0C ^ k02 ^ k07); t = ROL(5, a) + f2(b, c, d) + e + k0A; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0B = ROL(1, k0B ^ k0D ^ k03 ^ k08); t = ROL(5, a) + f2(b, c, d) + e + k0B; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0C = ROL(1, k0C ^ k0E ^ k04 ^ k09); t = ROL(5, a) + f3(b, c, d) + e + k0C; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0D = ROL(1, k0D ^ k0F ^ k05 ^ k0A); t = ROL(5, a) + f3(b, c, d) + e + k0D; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0E = ROL(1, k0E ^ k00 ^ k06 ^ k0B); t = ROL(5, a) + f3(b, c, d) + e + k0E; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0F = ROL(1, k0F ^ k01 ^ k07 ^ k0C); t = ROL(5, a) + f3(b, c, d) + e + k0F; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k00 = ROL(1, k00 ^ k02 ^ k08 ^ k0D); t = ROL(5, a) + f3(b, c, d) + e + k00; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k01 = ROL(1, k01 ^ k03 ^ k09 ^ k0E); t = ROL(5, a) + f3(b, c, d) + e + k01; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k02 = ROL(1, k02 ^ k04 ^ k0A ^ k0F); t = ROL(5, a) + f3(b, c, d) + e + k02; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k03 = ROL(1, k03 ^ k05 ^ k0B ^ k00); t = ROL(5, a) + f3(b, c, d) + e + k03; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k04 = ROL(1, k04 ^ k06 ^ k0C ^ k01); t = ROL(5, a) + f3(b, c, d) + e + k04; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k05 = ROL(1, k05 ^ k07 ^ k0D ^ k02); t = ROL(5, a) + f3(b, c, d) + e + k05; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k06 = ROL(1, k06 ^ k08 ^ k0E ^ k03); t = ROL(5, a) + f3(b, c, d) + e + k06; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k07 = ROL(1, k07 ^ k09 ^ k0F ^ k04); t = ROL(5, a) + f3(b, c, d) + e + k07; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k08 = ROL(1, k08 ^ k0A ^ k00 ^ k05); t = ROL(5, a) + f3(b, c, d) + e + k08; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k09 = ROL(1, k09 ^ k0B ^ k01 ^ k06); t = ROL(5, a) + f3(b, c, d) + e + k09; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0A = ROL(1, k0A ^ k0C ^ k02 ^ k07); t = ROL(5, a) + f3(b, c, d) + e + k0A; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0B = ROL(1, k0B ^ k0D ^ k03 ^ k08); t = ROL(5, a) + f3(b, c, d) + e + k0B; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0C = ROL(1, k0C ^ k0E ^ k04 ^ k09); t = ROL(5, a) + f3(b, c, d) + e + k0C; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0D = ROL(1, k0D ^ k0F ^ k05 ^ k0A); t = ROL(5, a) + f3(b, c, d) + e + k0D; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0E = ROL(1, k0E ^ k00 ^ k06 ^ k0B); t = ROL(5, a) + f3(b, c, d) + e + k0E; e = d; d = c; c = ROL(30, b); b = a; a = t;
	k0F = ROL(1, k0F ^ k01 ^ k07 ^ k0C); t = ROL(5, a) + f3(b, c, d) + e + k0F; e = d; d = c; c = ROL(30, b); b = a; a = t;

	hash[0] = 0x67452301U + a;
	hash[1] = 0xEFCDAB89U + b;
	hash[2] = 0x98BADCFEU + c;
}
Exemplo n.º 19
0
int main(int argc, char** argv)
{

// Execute the tests only if trace calls are included

#ifdef PEGASUS_REMOVE_TRACE
    cout << argv[0] << " +++++ passed all tests" << endl;
    return 0;
#else

    const char* tmpDir = getenv ("PEGASUS_TMP");
    if (tmpDir == NULL)
    {
        tmpDir = ".";
    }
    String f1 (tmpDir);
    f1.append("/testtracer1.trace");
    FILE1 = f1.getCString();
    String f2 (tmpDir);
    f2.append("/testtracer2.trace");
    FILE2 = f2.getCString();
    String f3 (tmpDir);
    f3.append("/testtracer3.trace");
    FILE3 = f3.getCString();
    String f4 (tmpDir);
    f4.append("/testtracer4.trace");
    FILE4 = f4.getCString();

    System::removeFile(FILE1);
    System::removeFile(FILE2);
    System::removeFile(FILE3);
    System::removeFile(FILE4);
    if (test1() == 0)
    {
       cout << "Tracer test (test1) failed" << endl;
       exit(1);
    }
    if (test2() == 0)
    {
       cout << "Tracer test (test2) failed" << endl;
       exit(1);
    }
    if (test3() == 0)
    {
       cout << "Tracer test (test3) failed" << endl;
       exit(1);
    }
    if (test4() != 0)
    {
       cout << "Tracer test (test4) failed" << endl;
       exit(1);
    }
    if (test5() != 0)
    {
       cout << "Tracer test (test5) failed" << endl;
       exit(1);
    }
    if (test6() != 0)
    {
       cout << "Tracer test (test6) failed" << endl;
       exit(1);
    }
    if (test7() != 0)
    {
       cout << "Tracer test (test7) failed" << endl;
       exit(1);
    }
    if (test8() != 0)
    {
       cout << "Tracer test (test8) failed" << endl;
       exit(1);
    }
    if (test9() != 0)
    {
       cout << "Tracer test (test9) failed" << endl;
       exit(1);
    }
    if (test10() != 0)
    {
       cout << "Tracer test (test10) failed" << endl;
       exit(1);
    }
    if (test11() != 0)
    {
       cout << "Tracer test (test11) failed" << endl;
       exit(1);
    }
    if (test12() != 0)
    {
       cout << "Tracer test (test12) failed" << endl;
       exit(1);
    }
    if (test13() != 0)
    {
       cout << "Tracer test (test13) failed" << endl;
       exit(1);
    }
    if (test14() != 0)
    {
       cout << "Tracer test (test14) failed" << endl;
       exit(1);
    }
    if (test15() != 0)
    {
       cout << "Tracer test (test15) failed" << endl;
       exit(1);
    }
    if (test16() != 0)
    {
       cout << "Tracer test (test16) failed" << endl;
       exit(1);
    }
    if (test17() != 0)
    {
       cout << "Tracer test (test17) failed" << endl;
       exit(1);
    }
    if (test18() != 0)
    {
       cout << "Tracer test (test18) failed" << endl;
       exit(1);
    }
    if (test19() != 0)
    {
       cout << "Tracer test (test19) failed" << endl;
       exit(1);
    }
    if (test20() != 0)
    {
       cout << "Tracer test (test20) failed" << endl;
       exit(1);
    }
    if (test21() != 0)
    {
       cout << "Tracer test (test21) failed" << endl;
       exit(1);
    }
    if (test22() != 0)
    {
       cout << "Tracer test (test22) failed" << endl;
       exit(1);
    }
    cout << argv[0] << " +++++ passed all tests" << endl;
    System::removeFile(FILE1);
    System::removeFile(FILE2);
    System::removeFile(FILE3);
    System::removeFile(FILE4);
    return 0;
#endif
}
void bar(void)
{
  f1(ext, loc_small, loc_big[0]);
  clobber;
  f2(&ext, &loc_small, &loc_big[0]);
}
EpcS1uDlTestSuite::EpcS1uDlTestSuite ()
  : TestSuite ("epc-s1u-downlink", SYSTEM)
{  
  std::vector<EnbDlTestData> v1;  
  EnbDlTestData e1;
  UeDlTestData f1 (1, 100);
  e1.ues.push_back (f1);
  v1.push_back (e1);
  AddTestCase (new EpcS1uDlTestCase ("1 eNB, 1UE", v1), TestCase::QUICK);


  std::vector<EnbDlTestData> v2;  
  EnbDlTestData e2;
  UeDlTestData f2_1 (1, 100);
  e2.ues.push_back (f2_1);
  UeDlTestData f2_2 (2, 200);
  e2.ues.push_back (f2_2);
  v2.push_back (e2);
  AddTestCase (new EpcS1uDlTestCase ("1 eNB, 2UEs", v2), TestCase::QUICK);


  std::vector<EnbDlTestData> v3;  
  v3.push_back (e1);
  v3.push_back (e2);
  AddTestCase (new EpcS1uDlTestCase ("2 eNBs", v3), TestCase::QUICK);


  EnbDlTestData e3;
  UeDlTestData f3_1 (3, 50);
  e3.ues.push_back (f3_1);
  UeDlTestData f3_2 (5, 1472);
  e3.ues.push_back (f3_2);
  UeDlTestData f3_3 (1, 1);
  e3.ues.push_back (f3_2);
  std::vector<EnbDlTestData> v4;  
  v4.push_back (e3);
  v4.push_back (e1);
  v4.push_back (e2);
  AddTestCase (new EpcS1uDlTestCase ("3 eNBs", v4), TestCase::QUICK);

  std::vector<EnbDlTestData> v5;  
  EnbDlTestData e5;
  UeDlTestData f5 (10, 3000);
  e5.ues.push_back (f5);
  v5.push_back (e5);
  AddTestCase (new EpcS1uDlTestCase ("1 eNB, 10 pkts 3000 bytes each", v5), TestCase::QUICK);

  std::vector<EnbDlTestData> v6;  
  EnbDlTestData e6;
  UeDlTestData f6 (50, 3000);
  e6.ues.push_back (f6);
  v6.push_back (e6);
  AddTestCase (new EpcS1uDlTestCase ("1 eNB, 50 pkts 3000 bytes each", v6), TestCase::QUICK);
  
  std::vector<EnbDlTestData> v7;  
  EnbDlTestData e7;
  UeDlTestData f7 (10, 15000);
  e7.ues.push_back (f7);
  v7.push_back (e7);
  AddTestCase (new EpcS1uDlTestCase ("1 eNB, 10 pkts 15000 bytes each", v7), TestCase::QUICK);

  std::vector<EnbDlTestData> v8;  
  EnbDlTestData e8;
  UeDlTestData f8 (100, 15000);
  e8.ues.push_back (f8);
  v8.push_back (e8);
  AddTestCase (new EpcS1uDlTestCase ("1 eNB, 100 pkts 15000 bytes each", v8), TestCase::QUICK);
}
Exemplo n.º 22
0
void NOINLINE f2 ()
{
  v4si t = var2;
  f1 ();
  var2 = t;
}
Exemplo n.º 23
0
/// process 64 bytes
void SHA1::processBlock(const void* data)
{
  // get last hash
  uint32_t a = m_hash[0];
  uint32_t b = m_hash[1];
  uint32_t c = m_hash[2];
  uint32_t d = m_hash[3];
  uint32_t e = m_hash[4];

  // data represented as 16x 32-bit words
  const uint32_t* input = (uint32_t*) data;
  // convert to big endian
  uint32_t words[80];
  for (int i = 0; i < 16; i++)
#if defined(__BYTE_ORDER) && (__BYTE_ORDER != 0) && (__BYTE_ORDER == __BIG_ENDIAN)
    words[i] = input[i];
#else
    words[i] = swap(input[i]);
#endif

  // extend to 80 words
  for (int i = 16; i < 80; i++)
    words[i] = rotate(words[i-3] ^ words[i-8] ^ words[i-14] ^ words[i-16], 1);

  // first round
  for (int i = 0; i < 4; i++)
  {
    int offset = 5*i;
    e += rotate(a,5) + f1(b,c,d) + words[offset  ] + 0x5a827999; b = rotate(b,30);
    d += rotate(e,5) + f1(a,b,c) + words[offset+1] + 0x5a827999; a = rotate(a,30);
    c += rotate(d,5) + f1(e,a,b) + words[offset+2] + 0x5a827999; e = rotate(e,30);
    b += rotate(c,5) + f1(d,e,a) + words[offset+3] + 0x5a827999; d = rotate(d,30);
    a += rotate(b,5) + f1(c,d,e) + words[offset+4] + 0x5a827999; c = rotate(c,30);
  }

  // second round
  for (int i = 4; i < 8; i++)
  {
    int offset = 5*i;
    e += rotate(a,5) + f2(b,c,d) + words[offset  ] + 0x6ed9eba1; b = rotate(b,30);
    d += rotate(e,5) + f2(a,b,c) + words[offset+1] + 0x6ed9eba1; a = rotate(a,30);
    c += rotate(d,5) + f2(e,a,b) + words[offset+2] + 0x6ed9eba1; e = rotate(e,30);
    b += rotate(c,5) + f2(d,e,a) + words[offset+3] + 0x6ed9eba1; d = rotate(d,30);
    a += rotate(b,5) + f2(c,d,e) + words[offset+4] + 0x6ed9eba1; c = rotate(c,30);
  }

  // third round
  for (int i = 8; i < 12; i++)
  {
    int offset = 5*i;
    e += rotate(a,5) + f3(b,c,d) + words[offset  ] + 0x8f1bbcdc; b = rotate(b,30);
    d += rotate(e,5) + f3(a,b,c) + words[offset+1] + 0x8f1bbcdc; a = rotate(a,30);
    c += rotate(d,5) + f3(e,a,b) + words[offset+2] + 0x8f1bbcdc; e = rotate(e,30);
    b += rotate(c,5) + f3(d,e,a) + words[offset+3] + 0x8f1bbcdc; d = rotate(d,30);
    a += rotate(b,5) + f3(c,d,e) + words[offset+4] + 0x8f1bbcdc; c = rotate(c,30);
  }

  // fourth round
  for (int i = 12; i < 16; i++)
  {
    int offset = 5*i;
    e += rotate(a,5) + f2(b,c,d) + words[offset  ] + 0xca62c1d6; b = rotate(b,30);
    d += rotate(e,5) + f2(a,b,c) + words[offset+1] + 0xca62c1d6; a = rotate(a,30);
    c += rotate(d,5) + f2(e,a,b) + words[offset+2] + 0xca62c1d6; e = rotate(e,30);
    b += rotate(c,5) + f2(d,e,a) + words[offset+3] + 0xca62c1d6; d = rotate(d,30);
    a += rotate(b,5) + f2(c,d,e) + words[offset+4] + 0xca62c1d6; c = rotate(c,30);
  }

  // update hash
  m_hash[0] += a;
  m_hash[1] += b;
  m_hash[2] += c;
  m_hash[3] += d;
  m_hash[4] += e;
}
Exemplo n.º 24
0
int main(void) {
        f0();
    f1();
    f2();
    f3();
    f4();
    f5();
    f6();
    f7();
    f8();
    f9();
    f10();
    f11();
    f12();
    f13();
    f14();
    f15();
    f16();
    f17();
    f18();
    f19();
    f20();
    f21();
    f22();
    f23();
    f24();
    f25();
    f26();
    f27();
    f28();
    f29();
    f30();
    f31();
    f32();
    f33();
    f34();
    f35();
    f36();
    f37();
    f38();
    f39();
    f40();
    f41();
    f42();
    f43();
    f44();
    f45();
    f46();
    f47();
    f48();
    f49();
    f50();
    f51();
    f52();
    f53();
    f54();
    f55();
    f56();
    f57();
    f58();
    f59();
    f60();
    f61();
    f62();
    f63();
    f64();
    f65();
    f66();
    f67();
    f68();
    f69();
    f70();
    f71();
    f72();
    f73();
    f74();
    f75();
    f76();
    f77();
    f78();
    f79();
    f80();
    f81();
    f82();
    f83();
    f84();
    f85();
    f86();
    f87();
    f88();
    f89();
    f90();
    f91();
    f92();
    f93();
    f94();
    f95();
    f96();
    f97();
    f98();
    f99();
    f100();
    f101();
    f102();
    f103();
    f104();
    f105();
    f106();
    f107();
    f108();
    f109();
    f110();
    f111();
    f112();
    f113();
    f114();
    f115();
    f116();
    f117();
    f118();
    f119();
    f120();
    f121();


    return 0;
}
Exemplo n.º 25
0
void test_basic_template(
  ForwardIterator first,ForwardIterator last
  BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
{
  typedef typename Flyweight::value_type value_type;

  ForwardIterator it;

  for(it=first;it!=last;++it){
    /* construct/copy/destroy */

    Flyweight                            f1(*it);
    Flyweight                            f2;
    Flyweight                            c1(f1);
    Flyweight                            c2(static_cast<const Flyweight&>(f2));
    value_type                           v1(*it);
    boost::value_initialized<value_type> v2;
    BOOST_TEST(f1.get_key()==*it);
    BOOST_TEST((f1==f2)==(f1.get()==v2.data()));
    BOOST_TEST(f1==c1);
    BOOST_TEST(f2==c2);

    f1=f1;
    BOOST_TEST(f1==f1);

    c1=f2;
    BOOST_TEST(c1==f2);

    c1=f1;
    BOOST_TEST(c1==f1);

    /* convertibility to underlying type */

    BOOST_TEST(f1.get()==v1);

    /* identity of reference */

    BOOST_TEST(&f1.get()==&c1.get());

    /* modifiers */

    f1.swap(f1);
    BOOST_TEST(f1==c1);

    f1.swap(f2);
    BOOST_TEST(f1==c2);
    BOOST_TEST(f2==c1);

    boost::flyweights::swap(f1,f2);
    BOOST_TEST(f1==c1);
    BOOST_TEST(f2==c2);

    /* specialized algorithms */

    std::ostringstream oss1;
    oss1<<f1;
    std::ostringstream oss2;
    oss2<<f1.get();
    BOOST_TEST(oss1.str()==oss2.str());
  }
}
Exemplo n.º 26
0
Arquivo: main.cpp Projeto: CCJY/coliru
 void init()
 {
     f1();
     f2();
 }
Exemplo n.º 27
0
void ShapeFunctionTriangleSigned::calc()
{
    // based on the answer in http://answers.unity3d.com/questions/383804/calculate-uv-coordinates-of-3d-point-on-plane-of-m.html
    // check out also: http://www.had2know.com/academics/triangle-area-perimeter-angle-3-coordinates.html
    lmx::Vector<double> f(dim), p1(dim), p2(dim), p3(dim);
    f.writeElement(gp->getX(),0);
    f.writeElement(gp->getY(),1);
    f.writeElement(gp->getZ(),2);
    p1.writeElement(gp->getSupportNodes()[0]->getX(), 0);
    p1.writeElement(gp->getSupportNodes()[0]->getY(), 1);
    p1.writeElement(gp->getSupportNodes()[0]->getZ(), 2);
    p2.writeElement(gp->getSupportNodes()[1]->getX(), 0);
    p1.writeElement(gp->getSupportNodes()[1]->getY(), 1);
    p1.writeElement(gp->getSupportNodes()[1]->getZ(), 2);
    p3.writeElement(gp->getSupportNodes()[2]->getX(), 0);
    p1.writeElement(gp->getSupportNodes()[2]->getY(), 1);
    p1.writeElement(gp->getSupportNodes()[2]->getZ(), 2);

    lmx::Vector<double> f1(dim), f2(dim), f3(dim); // calculate vectors from point f to vertices p1, p2 and p3:
    f1.subs( p1, f);
    f2.subs( p2, f);
    f3.subs( p3, f);
    lmx::Vector<double> va(dim), va1(dim), va2(dim), va3(dim);
    double a, a1, a2, a3;
    va.multElements(p1-p2, p1-p3);
    va1.multElements(f2, f3);
    va2.multElements(f3, f1);
    va3.multElements(f1, f2);
    lmx::Vector<double> vaa1(dim), vaa2(dim), vaa3(dim);
    a = va.norm2();
    a1 = std::copysign( va1.norm2()/a, va*va1 );
    a2 = std::copysign( va2.norm2()/a, va*va2 );
    a3 = std::copysign( va3.norm2()/a, va*va3 );

    phi.writeElement( a1, 0, 0 );
    phi.writeElement( a2, 0, 0 );
    phi.writeElement( a3, 0, 0 );
    //////////////////////////////////////////////////////////////////
    // FIRST DERIVATIVES:
    //////////////////////////////////////////////////////////////////
//   phi.writeElement(
//       ( gp->supportNodes[1]->gety() - gp->supportNodes[2]->gety() )
//       / ( 2*gp->jacobian ), 1, 0 );
//   phi.writeElement(
//       ( gp->supportNodes[2]->getx() - gp->supportNodes[1]->getx() )
//       / ( 2*gp->jacobian ), 2, 0 );
//   //////////////////////////////////////////////////////////////////
//   phi.writeElement(
//       ( gp->supportNodes[2]->gety() - gp->supportNodes[0]->gety() )
//       / ( 2*gp->jacobian ), 1, 1 );
//   phi.writeElement(
//       ( gp->supportNodes[0]->getx() - gp->supportNodes[2]->getx() )
//       / ( 2*gp->jacobian ), 2, 1 );
//   //////////////////////////////////////////////////////////////////
//   phi.writeElement(
//       ( gp->supportNodes[0]->gety() - gp->supportNodes[1]->gety() )
//       / ( 2*gp->jacobian ), 1, 2 );
//   phi.writeElement(
//       ( gp->supportNodes[1]->getx() - gp->supportNodes[0]->getx() )
//       / ( 2*gp->jacobian ), 2, 2 );

//   cout << "phi = " << phi << endl;
}
Exemplo n.º 28
0
Arquivo: main.cpp Projeto: CCJY/coliru
 Setting(){
  f1();
  f2();
  //...
 }
Exemplo n.º 29
0
 int __cdecl f6(int a1, int a2, int a3, int a4, int a5, int a6) {
     f5(a1, a2, a3, a4, a5);
     f1(a6);
     return 0;
 }
Exemplo n.º 30
0
void __fastcall f4(void) {
// CHECK-LABEL: define x86_fastcallcc void @f4()
  f1();
// CHECK: call x86_fastcallcc void @f1()
}