예제 #1
0
void DiskEditDialog::OnSubVolume(void)
{
    SubVolumeDialog subv(this);
    bool showAsBlocks;

    subv.Setup(fpDiskFS);
    if (subv.DoModal() == IDOK) {
        LOGI("SELECTED subv %d", subv.fListBoxIndex);
        DiskFS::SubVolume* pSubVol = fpDiskFS->GetNextSubVolume(NULL);
        if (pSubVol == NULL)
            return;

        while (subv.fListBoxIndex-- > 0) {
            pSubVol = fpDiskFS->GetNextSubVolume(pSubVol);
        }
        ASSERT(pSubVol != NULL);

        BlockEditDialog blockEdit;
        SectorEditDialog sectorEdit;
        DiskEditDialog* pEditDialog;

        showAsBlocks = pSubVol->GetDiskImg()->ShowAsBlocks();
        if (showAsBlocks)
            pEditDialog = &blockEdit;
        else
            pEditDialog = &sectorEdit;
        CString volumeID(fpDiskFS->GetVolumeID());
        pEditDialog->Setup(pSubVol->GetDiskFS(), volumeID);
        pEditDialog->SetPositionShift(8);
        (void) pEditDialog->DoModal();
    }
}
예제 #2
0
static void prev_dog_bot(void)
{
    int DBi=DogBot;
    DogBotDist=0;
    do {
        if (--DogBot<0) DogBot=NBBOT-1;
        if (DogBot!=controlled_bot) {
            copyv(&DogBotDir,&obj[bot[DogBot].vion].pos);
            subv(&DogBotDir,&obj[bot[controlled_bot].vion].pos);
            DogBotDist=renorme(&DogBotDir);
        }
    } while (DogBot!=DBi && (DogBotDist>DOGDISTMAX || bot[DogBot].camp==-1 || DogBot==controlled_bot));
}
예제 #3
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
    mexPrintf("C PROGRAM START\n");
    double *A, *y, *x;
    int i, j, tmp, N;
    double *a,*b;
    /*para in: A, y*/
    /*para out: x*/
    /*mxget*/
    A = mxGetPr(prhs[0]);
    N = mxGetN(prhs[0]);
    y = mxGetPr(prhs[1]);
    plhs[0] = mxCreateDoubleMatrix(1,N,mxREAL);
    x = mxGetPr(plhs[0]);
    /*back*/
    x[N-1] = y[N-1] / A[(N-1)*N+N-1];
    for (i=N-2;i>=0;i--) {
        a = subv(x, -1, i+1, N-1, N);
        b = subv(A, i, i+1, N-1, N);
        x[i] = (y[i] - mysumdot(a, b)) /A[i*N+i];
        free(a);
        free(b);
    }
}
예제 #4
0
파일: mydtrsm.c 프로젝트: lihebi/lapacktest
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
    /*para in: A, b, pvt*/
    /*para out: y*/
    double *A, *b, *y, *x;
    double *pvt, *va, *vb;
    int i, tmp;
    int flag;
    int N;
    A = mxGetPr(prhs[0]);
    N = mxGetN(prhs[0]);
    b = mxGetPr(prhs[1]);
    pvt= mxGetPr(prhs[2]);
    plhs[0] = mxCreateDoubleMatrix(1,N,mxREAL);
    y = mxGetPr(mxCreateDoubleMatrix(1,N,mxREAL));
    x = mxGetPr(plhs[0]);
    /*forward*/
    tmp = pvt[0]-1;
    y[0] = b[tmp];
    for (i=1;i<N;i++) {
        tmp=pvt[i]-1;
        va = subv(y, -1, 0, i-1, N);
        vb = subv(A, i, 0, i-1, N);
        y[i] = b[tmp] - mysumdot(va, vb);
        free(va);
        free(vb);
    }
    /*back*/
    x[N-1] = y[N-1] / A[(N-1)*N+N-1];
    for (i=N-2;i>=0;i--) {
        va = subv(x, -1, i+1, N-1, N);
        vb = subv(A, i, i+1, N-1, N);
        x[i] = (y[i] - mysumdot(va, vb)) /A[i*N+i];
        free(va);
        free(vb);
    }
}
예제 #5
0
파일: main.c 프로젝트: karlyeurl/ulg-hpc
int main(int argc, char* argv[]){

   // parsing the arguments
   if(argc < 3)
      error_exit("Syntax error : Incorrect arguments, use : input_file output_file [-v] [-m filename].\r\n\r\n");

   bool use_verbatim = false;
   FILE* matlab_file = NULL;

   FILE* input_file = fopen(argv[1],"r");
   FILE* output_file = fopen(argv[2],"w+");

   if( input_file == NULL || output_file == NULL)
      error_exit("Runtime error : could not open required i/o files.\r\n\r\n");
   
   for(int i=3 ; i < argc; i++){
      if( argv[i][0] != '-' )
         error_exit("Syntax error : Unknown parameter : %s\r\n\r\n",argv[i]);

      switch(argv[i][1]){
         case 'v' :
            use_verbatim = true;
            break;
         case 'm' :
            if(i+1 >= argc)
               error_exit("Syntax error : Filename required with -m option\r\n\r\n");
            
            matlab_file = fopen(argv[i+1], "w+");

            if(matlab_file == NULL)
               error_exit("Runtime error : Cannot open file '%s' for matlab output.\r\n\r\n",argv[i+1]);

            i++;
            break;
      }
   }
   
   // positions and speed at time n-1 (0) and n (1).
   vector p10,p20,v1,v2,p11,p21;
   // masses
   long double m1,m2;
   // discretization parameters
   long double dt, t_final, dt_output;

   fscanf(input_file, "%Lf\r\n%Lf %Lf %Lf\r\n%Lf %Lf %Lf\r\n%Lf\r\n%Lf %Lf %Lf\r\n%Lf %Lf %Lf\r\n%Lf\r\n%Lf\r\n%Lf", &m1, &(p10.x), &(p10.y), &(p10.z), &(v1.x), &(v1.y), &(v1.z), &m2, &(p20.x), &(p20.y), &(p20.z), &(v2.x), &(v2.y), &(v2.z), &dt, &t_final, &dt_output );

   // Initial values determination
   p11 = addv(scalev(v1, dt), p10);
   p21 = addv(scalev(v2, dt), p20); 
   
   write_init(output_file, matlab_file, use_verbatim, m1, p10, v1, m2, p20, v2, dt, t_final, dt_output);

   write_output(output_file, matlab_file, use_verbatim, 0, p10, p20);
   if(dt_output <= dt + DOUBLE_EPSILON) write_output(output_file, matlab_file, use_verbatim, dt, p11, p21);
   
   long double next_out = dt_output;
 
   for(long double t = dt * 2 ; t <= t_final ; t+= dt ){
      vector dp = subv(p21,p11);
      long double norm = normv(dp);
      
      // compute F
      vector f = scalev(dp, - m1 * m2 * CONST_G / (norm * norm * norm)); 

      // compute positions at time t
      vector new_p1 = addv(subv(scalev(f, - dt * dt / m1), p10) , scalev(p11, 2));
      vector new_p2 = addv(subv(scalev(f, dt * dt / m2), p20) , scalev(p21, 2));
      p10 = p11;
      p20 = p21;
      p11 = new_p1;
      p21 = new_p2;
      
      if(t + dt - DOUBLE_EPSILON >= next_out){
         write_output(output_file, matlab_file, use_verbatim, t, p11, p21);
         next_out +=dt_output;
      }
   }
   
   write_end(output_file, matlab_file, use_verbatim);
   fclose(input_file);
   fclose(output_file);
   
   return EXIT_SUCCESS;
}