Exemplo n.º 1
62
int main()
{
	system("cls");
	do
	{
		// requests prime number from the user.
	printf("Enter a prime number: ");			
	scanf("%d",&ptest);
		// checks if it is prime before assigning it to the 'p' variable.
	flag=prime(ptest);
	}while(flag==0);
	if(flag==1)
	p=ptest;
	do
	{
		// requests another prime number from the user.
	printf("\nEnter a second prime number: ");
	scanf("%d",&qtest);
		// checks if it is prime before assigning it to the 'q' variable.
	flag=prime(qtest);
	}while(flag==0);
	if(flag==1)
	q=qtest;
		// gets the message from the user.
	printf("\nEnter message: ");
	fflush(stdin);
	scanf("%[^\n]%*c",Msg);
	len=strlen(Msg);
	for(i=0;i!=len;i++)
	m[i]=Msg[i];
		// calculates the modulus and phi.
	n=p*q;
	phi=(p-1)*(q-1);
		// then e and d.
	calcE();
	printf("\nPossible values of e and d: ");
	for(i=0;i<j-1;i++)
	printf("\n%ld\t%ld",e[i],d[i]);
	encrypt();
	decrypt();
	getch();
	return(0);
}
Exemplo n.º 2
0
int main() {
    Particle particle;
    std::ofstream ofs;
    ofs.open( "kep" );
    for (int i=0;i<1000000;i++) {
            double x = particle.qx;
            double y = particle.qy;
//            for (int s=0;i<sympI;i++) {
                symp2(&particle, dT);
                /*
                particle.px+=calc(x, y) *symp_u[i]* dT;
                particle.py+=calc(y, x) *symp_u[i]* dT;

                particle.qx+=particle.px/M*symp_k[i]* dT;
                particle.qy+=particle.py/M*symp_k[i]* dT;
                */
 //           }
            //   std::cout << "px = " << particle.px << ", py = " << particle.py << std::endl;
            //        std::cout << "qx = " << particle.qx << ", px = " << particle.px << std::endl;

        if (i%500==0) {
            ofs << particle.qx << " " << particle.qy << " " << 0.0 << " " << calcE(particle) << " " << a_length(particle) << std::endl;
        }
     }
    ofs.close();
}
Exemplo n.º 3
0
//Update
static void update(void)
{

  calcJD();
  calcE();
  field_defaultIncidence(Ez);
  calcMB();  
  calcH();
}
Exemplo n.º 4
0
static inline void update(void)
{
  calcJD();

  calcE();

  calcMB();

  calcH();

  field_defaultIncidence(Hz);
}
Exemplo n.º 5
0
static inline void update(void)
{
  calcJD();

  calcE();

  scatteredWave(Ey, EPS_EY);
  
  calcMB();

  calcH();
}
Exemplo n.º 6
0
void reportElement_toFile(FILE* f,FILE* reso, bool J2, double theta, Particle pa) {
    double q = hypot(hypot(pa.qx, pa.qy), pa.qz);
    double p = hypot(hypot(pa.px, pa.py), pa.pz);

    double a = a_length(q, p);
    double Energy = 0;
    if (J2) {
        Energy = calcE_J2(q, p, pa);
    } else {
        Energy = calcE(q, p);
    }
    double h = h_moment(pa);
    double e = e_anomaly(a, h);
    double I = I_anomaly(h, pa);
    double OMEGA = OMEGA_anomaly(I, h, pa);

    fprintf(f, "%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n", pa.qx, pa.qy, pa.qz, Energy, a, h, e, I, theta);
    fprintf(reso, "%f %f\n", a*(pa.qx/q*cos(theta)+pa.qy/q*sin(theta)), a*(pa.qy/q*cos(theta)-pa.qx/q*sin(theta))); 
}
Exemplo n.º 7
0
//Update
static void update(void)
{
//  _CalcJD();
    calcJD();
    calcE();

//  MPI_Barrier(MPI_COMM_WORLD); //いらない?
    scatteredWave(Ez, EPS_EZ);
    //planeWave(Ez, EPS_EZ);


    //Connection_SendRecvE();
    Connection_ISend_IRecvE();

//  _CalcMB();
    calcMB();
    calcH();
    Connection_ISend_IRecvH();
    //Connection_SendRecvH();

    ntff();
}
Exemplo n.º 8
0
Arquivo: fdtdTM.c Projeto: rennone/C
static void update(){
  calcE();
  field_defaultIncidence(Ezx);
  field_defaultIncidence(Ezy);
  calcH();
}