コード例 #1
0
ファイル: stack.c プロジェクト: CriminalGin/cuhk-csci3150
int fun2(int x, int y) {
    int c = 10;
    PRINT_INT(x, __FUNCTION__);
    PRINT_INT(y, __FUNCTION__);
    PRINT_INT(c, __FUNCTION__);
    return (x + y + c);
}
コード例 #2
0
ファイル: stack.c プロジェクト: CriminalGin/cuhk-csci3150
int main(void) {
    int a = 1, b = 2;
    PRINT_INT(a, __FUNCTION__);
    PRINT_INT(b, __FUNCTION__);
    b = fun1(a, b);
    return -1;
}
コード例 #3
0
ファイル: add-two-vars.c プロジェクト: mbway/Simulizer
int main() {

    C("assigning to a new local variable");
    int c = a + b;
    // %0 is replaced with the appropriate register by the compiler
    A_READ(c, "print('c = ' + %0.get());");


    C("assigning to a global variable");
    res = a - b;
    A_READ(res, "print('res = ' + %0.get());");


    C("print using assembly IO rather than Javascript annotations");
    PRINT_INT(res);


    C("more than 2 operands");
    int large = a + b + 33 + res;
    A_READ(large, "var l = %0.get();");
    A("print('large = ' + l + ' = ' + binString(l) + ' = ' + hexString(l));");


    EXIT();
}
コード例 #4
0
void panoDumpPTRect(PTRect *rect, char *label, int indent)
{
    char ind[MAX_INDENT+1];
    panoDumpSetIndent(ind, indent);

    if (label != NULL) {
        fprintf(stderr, "%s%s\n", ind, label);
    }

    fprintf(stderr, "%sRectangle\n", ind);

#define PRINT_INT(a) PRINT_GENERIC(a, "%d", (int)rect)
    PRINT_INT(top);
    PRINT_INT(bottom);
    PRINT_INT(left);
    PRINT_INT(right);
#undef PRINT_INT
}
コード例 #5
0
ファイル: macro_arguments.c プロジェクト: b3h3moth/L-C
int main(void) {
    int n1 = 32;
    int n2 = 28;

   /* Il comportamento del preprocessore è controllato dalle direttive di
    preprocessamento; riguarda i comandi che iniziano con #
    
    E' utile pensare al preprocessore come un componente separato rispetto
    alla compilazione
    
    Per verificare in output le direttive si può immettere l'opzione
    gcc -E al compilatore */

   printf("MAX %d\n", MAX(n1,n2));
   PRINT_INT(n1);
   PRINT_INT(n2);

   return(EXIT_SUCCESS);
}
コード例 #6
0
void panoDumpImage(Image *im, char *label, int indent)
{
    char ind[MAX_INDENT+1];
    int i;

    if (im == NULL) return;
    // prepare indent

    panoDumpSetIndent(ind, indent);

    if (label != NULL) {
        fprintf(stderr, "%s%s\n", ind, label);
    }
    
#define PRINT_INT(a) PRINT_GENERIC(a,"%d", (int)im)
#define PRINT_F(a) PRINT_GENERIC(a,"%f", im)
#define PRINT_S(a)   PRINT_GENERIC(a,"\"%s\"", im)

    fprintf(stderr, "%sImage Data\n", ind);
    PRINT_INT(width);
    PRINT_INT(height);
    PRINT_INT(bytesPerLine);
    PRINT_INT(bitsPerPixel);
    PRINT_INT(dataSize);
    PRINT_INT(dataformat);
    PRINT_INT(format);
    PRINT_INT(formatParamCount);

    for (i=0;i< im->formatParamCount; i++) {
        fprintf(stderr, "%s\t\tformat Param[%d] %f\n", ind, i, im->formatParam[i]);
    }
    PRINT_F(hfov);
    PRINT_F(yaw);
    PRINT_F(roll);
    PRINT_F(pitch);

    PRINT_S(name);
    
    panoDumpCorrectPrefs(&im->cP, NULL, indent+1);
    panoDumpPTRect(&im->selection, NULL,indent+1);
    panoDumpCropInfo(&im->cropInformation, NULL, indent+1);

#undef PRINT_INT
#undef PRINT_F
#undef PRINT_S

}
コード例 #7
0
void panoDumpAdjustData(aPrefs* aP, char *label, int indent)
{

    char ind[MAX_INDENT+1];

    assert (aP != NULL);

    panoDumpSetIndent(ind, indent);

    if (label != NULL) {
        fprintf(stderr, "%s%s\n", ind, label);
    }

    fprintf(stderr, "%s\tAdjust Data\n", ind);

#define PRINT_INT(a) PRINT_GENERIC(a,"%d", (int)aP)
#define PRINT_F(a) PRINT_GENERIC(a,"%f", aP)
#define PRINT_S(a)   PRINT_GENERIC(a,"\"%s\"", aP)


    PRINT_INT(mode);
    PRINT_S(scriptFile.name);
    PRINT_INT(nt);
    PRINT_INT(interpolator);
    PRINT_F(gamma);
    PRINT_INT(fastStep);

#undef PRINT_INT
#undef PRINT_F
#undef PRINT_S


    panoDumpImage(&aP->im, "Input Image", indent + 1);
    panoDumpImage(&aP->pano, "Panorama",  indent + 1);

}
コード例 #8
0
void panoDumpCropInfo(CropInfo *crop, char *label, int indent)
{
    char ind[MAX_INDENT+1];
    panoDumpSetIndent(ind, indent);

#define PRINT_INT(a) PRINT_GENERIC(a, "%d", (int)crop)

    fprintf(stderr, "%sCrop Info\n", ind);
    PRINT_INT(full_width);
    PRINT_INT(full_height);
    PRINT_INT(cropped_width);
    PRINT_INT(cropped_height);
    PRINT_INT(x_offset);
    PRINT_INT(y_offset);

#undef PRINT_INT
}
コード例 #9
0
ファイル: motor_rtctl.c プロジェクト: fangzhuang2004/px4esc
void motor_rtctl_print_debug_info(void)
{
    static const int ALIGNMENT = 25;

#define PRINT_INT(name, value) lowsyslog("  %-*s %li\n", ALIGNMENT, (name), (long)(value))
#define PRINT_FLT(name, value) lowsyslog("  %-*s %f\n", ALIGNMENT, (name), (float)(value))

    /*
     * Instant state
     */
    irq_primask_disable();
    const struct control_state state_copy = _state;
    irq_primask_enable();

    lowsyslog("Motor RTCTL state\n");
    PRINT_INT("comm period",     state_copy.comm_period / HNSEC_PER_USEC);
    PRINT_INT("flags",           state_copy.flags);
    PRINT_INT("neutral voltage", state_copy.neutral_voltage);
    PRINT_INT("input voltage",   state_copy.input_voltage_raw);
    PRINT_INT("input current",   state_copy.input_current);
    PRINT_INT("pwm val",         state_copy.pwm_val);

    /*
     * Diagnostics
     */
    irq_primask_disable();
    const struct diag_info diag_copy = _diag;
    irq_primask_enable();

    lowsyslog("Motor RTCTL diag\n");
    PRINT_INT("zc failures",       diag_copy.zc_failures_since_start);
    PRINT_INT("desaturations",     diag_copy.desaturations);
    PRINT_INT("bemf out of range", diag_copy.bemf_samples_out_of_range);
    PRINT_INT("bemf premature zc", diag_copy.bemf_samples_premature_zc);
    PRINT_INT("zc sol failures",   diag_copy.zc_solution_failures);
    PRINT_INT("zc sol num samples",diag_copy.zc_solution_num_samples);
    PRINT_FLT("zc sol slope",      diag_copy.zc_solution_slope / (float)LEAST_SQUARES_MULT);
    PRINT_FLT("zc sol yintercept", diag_copy.zc_solution_yintercept / (float)LEAST_SQUARES_MULT);

    /*
     * ZC fitting
     */
#if DEBUG_BUILD
    if (_diag.zc_solution_num_samples > 0) {
        lowsyslog("Motor ZC solution data\n");

        lowsyslog("  zc samples   ");
        for (int i = 0; i < _diag.zc_solution_num_samples; i++) {
            lowsyslog("%-5i ", diag_copy.zc_solution_samples[i]);
        }
        lowsyslog("\n");

        lowsyslog("  zc fitted    ");
        for (int i = 0; i < _diag.zc_solution_num_samples; i++) {
            const int x = _params.adc_sampling_period * i;
            const int y = (diag_copy.zc_solution_slope * x + diag_copy.zc_solution_yintercept) /
                          LEAST_SQUARES_MULT;
            lowsyslog("%-5i ", y);
        }
        lowsyslog("\n");
    }
#endif

#undef PRINT_INT
#undef PRINT_FLT
}
コード例 #10
0
static void
test_curved_interface
(
 curved_element_data_t** e_m,
 int faces_m,
 int f_m,
 curved_element_data_t** e_p,
 int faces_p,
 int f_p,
 int* e_m_is_ghost,
 int orientation,
 dgmath_jit_dbase_t* dgmath_jit_dbase,
 void* params
)
{
  test_curved_data_t* test_curved_data = (test_curved_data_t*)params;
  
  int stride;
  int deg_p [(P4EST_HALF)];
  int max_deg_p = -1;
  int face_nodes_p [(P4EST_HALF)];
  int deg_m [(P4EST_HALF)];
  int face_nodes_m [(P4EST_HALF)];
  int max_deg_m = -1;
  int deg_mortar [(P4EST_HALF)];
  int nodes_mortar [(P4EST_HALF)];
  int faces_mortar = (faces_m > faces_p) ? faces_m : faces_p;
  
  int i,j;
  
  /* calculate degs and nodes of each face of (-) side */
  int total_side_nodes_m = 0;
  for (i = 0; i < faces_m; i++){
    if(test_curved_data->print_data)
      printf("e_m[%d]: id = %d, deg = %d, tree = %d, hanging = %d\n", i, e_m[i]->id, e_m[i]->deg, e_m[i]->tree, (faces_m == (P4EST_HALF)));
    deg_m[i] = e_m[i]->deg;
    /* if (sum_ghost_array != 0) */
      /* printf(" sum_ghost_array = %d, deg_m[i] = %d\n" , sum_ghost_array, deg_m[i]); */
    if (e_m[i]->deg > max_deg_m) max_deg_m = e_m[i]->deg;
    face_nodes_m[i] = dgmath_get_nodes( (P4EST_DIM) - 1, e_m[i]->deg );
    total_side_nodes_m += face_nodes_m[i];
  }
  
  /* calculate degs and nodes of each face of (+) side  */
  int total_side_nodes_p = 0;
  for (i = 0; i < faces_p; i++){
    if(test_curved_data->print_data)
      printf("e_p[%d]: id = %d, deg = %d, tree = %d, hanging = %d\n", i, e_p[i]->id, e_p[i]->deg, e_p[i]->tree, (faces_p == (P4EST_HALF)));
    deg_p[i] = e_p[i]->deg;
    if (e_p[i]->deg > max_deg_p) max_deg_p = e_p[i]->deg;
    face_nodes_p[i] = dgmath_get_nodes( (P4EST_DIM) - 1, e_p[i]->deg );
    total_side_nodes_p += face_nodes_p[i];
  }    

  /* calculate degs and nodes of the mortar faces */
  int total_nodes_mortar = 0;
  for (i = 0; i < faces_m; i++)
    for (j = 0; j < faces_p; j++){
      /* find max degree for each face pair of the two sides*/
      deg_mortar[i+j] = util_max_int( e_m[i]->deg, e_p[j]->deg );
      nodes_mortar[i+j] = dgmath_get_nodes ( (P4EST_DIM) - 1, deg_mortar[i+j] );
      total_nodes_mortar += dgmath_get_nodes( (P4EST_DIM) - 1, deg_mortar[i+j] );
    }

  int face_corners = P4EST_HALF;
  p4est_qcoord_t f_m_corners [P4EST_HALF][P4EST_HALF][3];
  p4est_qcoord_t f_p_corners [P4EST_HALF][P4EST_HALF][3];

  double face_corners_mortar_m [P4EST_HALF][P4EST_HALF][3];
  double face_corners_mortar_p [P4EST_HALF][P4EST_HALF][3];

  double face_corners_m [P4EST_HALF][P4EST_HALF][3];
  double face_corners_p [P4EST_HALF][P4EST_HALF][3];

  
  printf("\n*********SIDE**********\n");
  PRINT_INT(faces_m);
  if (e_m[0]->tree != e_p[0]->tree)
    printf("TREE BOUNDARY\n");
  
  for (int i = 0; i < faces_m; i++){    
    /* PRINT_INT(i); */
    /* PRINT_INT(e_m[i]->deg); */
    /* PRINT_INT(e_m[i]->qx); */
    /* PRINT_INT(e_m[i]->qy); */
    /* PRINT_INT(e_m[i]->qz); */
    /* PRINT_INT(e_m[i]->dq); */
    /* PRINT_INT(e_m[i]->tree); */

    for (int j = 0; j < face_corners; j++){
      double xyz [] = {0.,0.,0.};
      double abc [] = {0.,0.,0.};
      int c = p4est_face_corners[f_m][j];
      int cx = dgmath_is_child_left_or_right(c, 0);
      int cy = dgmath_is_child_left_or_right(c, 1);
      f_m_corners[i][j][0] = e_m[i]->qx + cx*e_m[i]->dq;
      f_m_corners[i][j][1] = e_m[i]->qy + cy*e_m[i]->dq;
      abc[0] = (double)(e_m[i]->qx + cx*e_m[i]->dq)/(double)P4EST_ROOT_LEN;
      abc[1] = (double)(e_m[i]->qy + cy*e_m[i]->dq)/(double)P4EST_ROOT_LEN;
#if (P4EST_DIM)==3
      int cz = dgmath_is_child_left_or_right(c, 2);
      f_m_corners[i][j][2] = e_m[i]->qz + cz*e_m[i]->dq;
      abc[2] = (double)(e_m[i]->qz + cz*e_m[i]->dq)/(double)P4EST_ROOT_LEN;
      test_curved_data->geom->X(test_curved_data->geom, which_tree, abc, xyz);
      if (faces_m == (P4EST_HALF)){
        face_corners_mortar_m[i][j][0] = xyz[0];
        face_corners_mortar_m[i][j][1] = xyz[1];
        face_corners_mortar_m[i][j][2] = xyz[2];
      }
      face_corners_m[i][j][0] = xyz[0];
      face_corners_m[i][j][1] = xyz[1];
      face_corners_m[i][j][2] = xyz[2];
      
      printf("c = %d, x,y,z = %.15f,%.15f,%.15f\n", j, xyz[0], xyz[1], xyz[2]);
#elif (P4EST_DIM)==2
      test_curved_data->geom->X(test_curved_data->geom, e_m[i]->tree, abc, xyz);
      if (faces_m == (P4EST_HALF)){
        face_corners_mortar_m[i][j][0] = xyz[0];
        face_corners_mortar_m[i][j][1] = xyz[1];
      }
      face_corners_m[i][j][0] = xyz[0];
      face_corners_m[i][j][1] = xyz[1];      
      printf("c = %d, x,y = %.15f,%.15f\n", j, xyz[0], xyz[1]);
#else
      mpi_abort("dim = 2 or 3 only");
#endif
    }
  }


  if (faces_m == 1 && faces_p == (P4EST_HALF)){
    printf("******************\n");
    printf("Side m projected\n");

#if (P4EST_DIM)==3
    p4est_qcoord_t dqa [3];
    dqa[0] = f_m_corners[0][1][0] - f_m_corners[0][0][0];
    dqa[1] = f_m_corners[0][1][1] - f_m_corners[0][0][1];
    dqa[2] = f_m_corners[0][1][2] - f_m_corners[0][0][2];

    p4est_qcoord_t dqb [3];
    dqb[0] = f_m_corners[0][2][0] - f_m_corners[0][0][0];
    dqb[1] = f_m_corners[0][2][1] - f_m_corners[0][0][1];
    dqb[2] = f_m_corners[0][2][2] - f_m_corners[0][0][2];    

    dqa[0] /= 2;
    dqa[1] /= 2;
    dqa[2] /= 2;
    dqb[0] /= 2;
    dqb[1] /= 2;
    dqb[2] /= 2;
    
    for (int f = 0; f < faces_p; f++){
      for (int c = 0; c < (P4EST_HALF); c++){
        int fa = dgmath_is_child_left_or_right(f, 0);
        int fb = dgmath_is_child_left_or_right(f, 1);
        int ca = dgmath_is_child_left_or_right(c, 0);
        int cb = dgmath_is_child_left_or_right(c, 1);

        p4est_qcoord_t qcx = f_m_corners[0][0][0] + fa*dqa[0] + fb*dqb[0] + ca*dqa[0] + cb*dqb[0];
        p4est_qcoord_t qcy = f_m_corners[0][0][1] + fa*dqa[1] + fb*dqb[1] + ca*dqa[1] + cb*dqb[1];
        p4est_qcoord_t qcz = f_m_corners[0][0][2] + fa*dqa[2] + fb*dqb[2] + ca*dqa[2] + cb*dqb[2];
        double abc [] = {0,0,0};
        double xyz [] = {0,0,0};
        
        abc[0] = (double)(qcx)/(double)P4EST_ROOT_LEN;
        abc[1] = (double)(qcy)/(double)P4EST_ROOT_LEN;
        abc[2] = (double)(qcz)/(double)P4EST_ROOT_LEN;
        test_curved_data->geom->X(test_curved_data->geom, e_m[0]->tree, abc, xyz);
        face_corners_mortar_m[f][c][0] = xyz[0];
        face_corners_mortar_m[f][c][1] = xyz[1];
        face_corners_mortar_m[f][c][2] = xyz[2];
        printf("c = %d, x,y,z = %.15f,%.15f,%.15f\n", c, xyz[0], xyz[1], xyz[2]);
      }
    }
#elif (P4EST_DIM)==2
    p4est_qcoord_t dqa [3];
    dqa[0] = f_m_corners[0][1][0] - f_m_corners[0][0][0];
    dqa[1] = f_m_corners[0][1][1] - f_m_corners[0][0][1];

    dqa[0] /= 2;
    dqa[1] /= 2;

    printf("dqa[0] = %d, dqa[1] =%d\n", dqa[0], dqa[1]);
    
    for (int f = 0; f < faces_p; f++){
      for (int c = 0; c < (P4EST_HALF); c++){
        int fa = dgmath_is_child_left_or_right(f, 0);
        int ca = dgmath_is_child_left_or_right(c, 0);
        p4est_qcoord_t qcx = f_m_corners[0][0][0] + fa*dqa[0] + ca*dqa[0];
        p4est_qcoord_t qcy = f_m_corners[0][0][1] + fa*dqa[1] + ca*dqa[1];
        double abc [] = {0,0,0};
        double xyz [] = {0,0,0};        
        abc[0] = (double)(qcx)/(double)P4EST_ROOT_LEN;
        abc[1] = (double)(qcy)/(double)P4EST_ROOT_LEN;
        test_curved_data->geom->X(test_curved_data->geom, e_m[0]->tree, abc, xyz);
        face_corners_mortar_m[f][c][0] = xyz[0];
        face_corners_mortar_m[f][c][1] = xyz[1];
        printf("c = %d, x,y,z = %.15f,%.15f\n", c, xyz[0], xyz[1]);
      }
    }
#else
    mpi_abort("dim = 2 or 3 only");
#endif
    
    
  }

   
  printf("******************\n");  
  PRINT_INT(faces_p);
  for (int i = 0; i < faces_p; i++){    
    /* PRINT_INT(i); */
    /* PRINT_INT(e_p[i]->deg); */
    /* PRINT_INT(e_p[i]->qx); */
    /* PRINT_INT(e_p[i]->qy); */
    /* PRINT_INT(e_p[i]->qz); */
    /* PRINT_INT(e_p[i]->dq); */
    /* PRINT_INT(e_p[i]->tree); */

    for (int j = 0; j < face_corners; j++){
      double xyz [] = {0.,0.,0.};
      double abc [] = {0.,0.,0.};
      int c = p4est_face_corners[f_p][j];
      int cx = dgmath_is_child_left_or_right(c, 0);
      int cy = dgmath_is_child_left_or_right(c, 1);
      abc[0] = (double)(e_p[i]->qx + cx*e_p[i]->dq)/(double)P4EST_ROOT_LEN;
      abc[1] = (double)(e_p[i]->qy + cy*e_p[i]->dq)/(double)P4EST_ROOT_LEN;
#if (P4EST_DIM)==3
      int cz = dgmath_is_child_left_or_right(c, 2);
      abc[2] = (double)(e_p[i]->qz + cz*e_p[i]->dq)/(double)P4EST_ROOT_LEN;
      test_curved_data->geom->X(test_curved_data->geom, which_tree, abc, xyz);
      printf("c = %d, x,y,z = %.15f,%.15f,%.15f\n", j, xyz[0], xyz[1], xyz[2]);
#elif (P4EST_DIM)==2
      test_curved_data->geom->X(test_curved_data->geom, e_p[i]->tree, abc, xyz);


      printf("c = %d, x,y = %.15f,%.15f\n", j, xyz[0], xyz[1]);
#else
      mpi_abort("dim = 2 or 3 only");
#endif
    }

  }
    printf("******************\n");
    printf("Side p reoriented\n");
    
    PRINT_INT(faces_p);
    for (int i = 0; i < faces_p; i++){
      int i_new = i;
      if(faces_p == P4EST_HALF)
        i_new = dgmath_reorient_face_order((P4EST_DIM)-1, f_m, f_p, orientation, i);
      for (int j = 0; j < face_corners; j++){
        /* PRINT_INT(j); */
        int j_new = dgmath_reorient_face_order((P4EST_DIM)-1, f_m, f_p, orientation, j); 
        /* PRINT_INT(j_new); */
        double xyz [] = {0.,0.,0.};
        double abc [] = {0.,0.,0.};
        int c = p4est_face_corners[f_p][j_new];
        int cx = dgmath_is_child_left_or_right(c, 0);
        int cy = dgmath_is_child_left_or_right(c, 1);
        f_p_corners[i][j][0] = e_p[i_new]->qx + cx*e_p[i_new]->dq;
        f_p_corners[i][j][1] = e_p[i_new]->qy + cy*e_p[i_new]->dq;        
        abc[0] = (double)(e_p[i_new]->qx + cx*e_p[i_new]->dq)/(double)P4EST_ROOT_LEN;
        abc[1] = (double)(e_p[i_new]->qy + cy*e_p[i_new]->dq)/(double)P4EST_ROOT_LEN;
#if (P4EST_DIM)==3
        int cz = dgmath_is_child_left_or_right(c, 2);
        abc[2] = (double)(e_p[i_new]->qz + cz*e_p[i_new]->dq)/(double)P4EST_ROOT_LEN;
        test_curved_data->geom->X(test_curved_data->geom, which_tree, abc, xyz);
        if(faces_p == (P4EST_HALF)){
          face_corners_mortar_p[i][j][0] = xyz[0];
          face_corners_mortar_p[i][j][1] = xyz[1];
          face_corners_mortar_p[i][j][2] = xyz[2];
        }
        face_corners_p[i][j][0] = xyz[0];
        face_corners_p[i][j][1] = xyz[1];      
        face_corners_p[i][j][2] = xyz[2];      
        printf("c = %d, x,y,z = %.15f,%.15f,%.15f\n", j, xyz[0], xyz[1], xyz[2]);
#elif (P4EST_DIM)==2
        test_curved_data->geom->X(test_curved_data->geom, e_p[i_new]->tree, abc, xyz);
        if(faces_p == (P4EST_HALF)){
          face_corners_mortar_p[i][j][0] = xyz[0];
          face_corners_mortar_p[i][j][1] = xyz[1];
        }
        face_corners_p[i][j][0] = xyz[0];
        face_corners_p[i][j][1] = xyz[1];      
        
        printf("c = %d, x,y = %.15f,%.15f\n", j, xyz[0], xyz[1]);
#else
        mpi_abort("dim = 2 or 3 only");
#endif
      }
  }

  if (faces_p == 1 && faces_m == (P4EST_HALF)){
    printf("******************\n");
    printf("Side p projected\n");

#if (P4EST_DIM)==3
    p4est_qcoord_t dqa [3];
    dqa[0] = f_p_corners[0][1][0] - f_p_corners[0][0][0];
    dqa[1] = f_p_corners[0][1][1] - f_p_corners[0][0][1];
    dqa[2] = f_p_corners[0][1][2] - f_p_corners[0][0][2];

    p4est_qcoord_t dqb [3];
    dqb[0] = f_p_corners[0][2][0] - f_p_corners[0][0][0];
    dqb[1] = f_p_corners[0][2][1] - f_p_corners[0][0][1];
    dqb[2] = f_p_corners[0][2][2] - f_p_corners[0][0][2];    

    dqa[0] /= 2;
    dqa[1] /= 2;
    dqa[2] /= 2;
    dqb[0] /= 2;
    dqb[1] /= 2;
    dqb[2] /= 2;
    
    for (int f = 0; f < faces_m; f++){
      for (int c = 0; c < (P4EST_HALF); c++){
        int fa = dgmath_is_child_left_or_right(f, 0);
        int fb = dgmath_is_child_left_or_right(f, 1);
        int ca = dgmath_is_child_left_or_right(c, 0);
        int cb = dgmath_is_child_left_or_right(c, 1);
        p4est_qcoord_t qcx = f_p_corners[0][0][0] + fa*dqa[0] + fb*dqb[0] + ca*dqa[0] + cb*dqb[0];
        p4est_qcoord_t qcy = f_p_corners[0][0][1] + fa*dqa[1] + fb*dqb[1] + ca*dqa[1] + cb*dqb[1];
        p4est_qcoord_t qcz = f_p_corners[0][0][2] + fa*dqa[2] + fb*dqb[2] + ca*dqa[2] + cb*dqb[2];
        double abc [] = {0,0,0};
        double xyz [] = {0,0,0};
        
        abc[0] = (double)(qcx)/(double)P4EST_ROOT_LEN;
        abc[1] = (double)(qcy)/(double)P4EST_ROOT_LEN;
        abc[2] = (double)(qcz)/(double)P4EST_ROOT_LEN;
        test_curved_data->geom->X(test_curved_data->geom, e_p[0]->tree, abc, xyz);


        face_corners_mortar_p[f][c][0] = xyz[0];
        face_corners_mortar_p[f][c][1] = xyz[1];
        face_corners_mortar_p[f][c][2] = xyz[2];
        
        printf("c = %d, x,y,z = %.15f,%.15f,%.15f\n", c, xyz[0], xyz[1], xyz[2]);
      }
    }
#elif (P4EST_DIM)==2
    p4est_qcoord_t dqa [3];
    dqa[0] = f_p_corners[0][1][0] - f_p_corners[0][0][0];
    dqa[1] = f_p_corners[0][1][1] - f_p_corners[0][0][1];

    dqa[0] /= 2;
    dqa[1] /= 2;

    /* printf("dqa[0] = %d, dqa[1] =%d\n", dqa[0], dqa[1]); */
    
    for (int f = 0; f < faces_m; f++){
      for (int c = 0; c < (P4EST_HALF); c++){
        int fa = dgmath_is_child_left_or_right(f, 0);
        int ca = dgmath_is_child_left_or_right(c, 0);
        p4est_qcoord_t qcx = f_p_corners[0][0][0] + fa*dqa[0] + ca*dqa[0];
        p4est_qcoord_t qcy = f_p_corners[0][0][1] + fa*dqa[1] + ca*dqa[1];
        double abc [] = {0,0,0};
        double xyz [] = {0,0,0};        
        abc[0] = (double)(qcx)/(double)P4EST_ROOT_LEN;
        abc[1] = (double)(qcy)/(double)P4EST_ROOT_LEN;
        test_curved_data->geom->X(test_curved_data->geom, e_p[0]->tree, abc, xyz);

        face_corners_mortar_p[f][c][0] = xyz[0];
        face_corners_mortar_p[f][c][1] = xyz[1];
        
        printf("c = %d, x,y,z = %.15f,%.15f\n", c, xyz[0], xyz[1]);
      }
    }
#else
    mpi_abort("dim = 2 or 3 only");
#endif
    
    
  }

  printf("*********SIDE**********\n");

  double mortar_err = 0.;
  if (faces_m == 1 && faces_p == 1){
    for (int i = 0; i < 1; i++){
      for (int j = 0; j < (P4EST_HALF); j++){
        for (int k = 0; k < (P4EST_DIM); k++){
          test_curved_data->mortar_err += fabs( face_corners_m[i][j][k] - face_corners_p[i][j][k]);
        }
      }
    }
  }
  else{
    for (int i = 0; i < (P4EST_HALF); i++){
      for (int j = 0; j < (P4EST_HALF); j++){
        for (int k = 0; k < (P4EST_DIM); k++){
          test_curved_data->mortar_err += fabs( face_corners_mortar_m[i][j][k] - face_corners_mortar_p[i][j][k]);
        }
      }
    }
  }
}
コード例 #11
0
ファイル: stack.c プロジェクト: CriminalGin/cuhk-csci3150
int fun1(int u, int v) {
    PRINT_INT(u, __FUNCTION__);
    PRINT_INT(v, __FUNCTION__);
    return fun2(v, u);
}
コード例 #12
0
ファイル: main.c プロジェクト: johndgiese/knking-c
int main() {

    int i, j, k;

    PROBLEM(5, 1);
    i = 2; j = 3;
    k = i*j == 6;
    printf("%d\n", k); // 1

    i = 5; j = 10; k = 1;
    printf("%d\n", k > i < j); // 1

    i = 3; j = 2; k = 1;
    printf("%d\n", i < j == j < k); // 1

    i = 3; j = 4; k = 5;
    printf("%d\n", i % j + i < k); // 0


    PROBLEM(5, 3);
    i = 3; j = 4; k = 5;
    printf("%d ", i < j || ++j < k);  // ((i < j) || ((++j) < k))
    printf("%d %d %d\n", i, j, k); // 1 3 4 5

    i = 7; j = 8; k = 9;
    printf("%d ", i - 7 && j++ < k);
    printf("%d %d %d\n", i, j, k); // 0 7 8 9

    i = 7; j = 8; k = 9;
    printf("%d ", (i = j) || (j = k));
    printf("%d %d %d\n", i, j, k); // 1 8 8 9

    i = 1; j = 1; k = 1;
    printf("%d ", ++i || ++j && ++k);
    printf("%d %d %d\n", i, j, k); // 1 2 1 1

    PROBLEM(5, 4);
    #define LT_E_GT(num) -(num < 0) + (num > 0)
    PRINT_INT(LT_E_GT(-4));
    PRINT_INT(LT_E_GT(0));
    PRINT_INT(LT_E_GT(4));

    PROBLEM(5, 10);
    i = 1;
    switch (i % 3) {
        case 0: printf("zero\n");
        case 1: printf("one\n");
        case 2: printf("two\n");
    }

    PROBLEM(5, 11);

    int area_code = 229;
    char *major_city;

    just_before_switch:
    switch(area_code) {
        case 229:
            major_city = "Albany";
            break;
        case 404:
            major_city = "Atlanta";
            break;
        case 470:
            major_city = "Atlanta";
            break;
        default:
            major_city = "";
    }
    if ( strlen(major_city) == 0) {
        printf("Area code not recognized\n");
    } else {
        printf("%s\n", major_city);
    }

    // goto's are bad pratice--this is just for fun :)
    if (area_code == 229) {
        area_code = 404;
        goto just_before_switch;
    } else if (area_code == 404) {
        area_code = 10;
        goto just_before_switch;
    }



    return 0;
}