Ejemplo n.º 1
0
void TilingPatternImpl::on_write(ObjFmt& fmt)
{
    fmt
        .dict_key("Type").output("Pattern")
        .dict_key("PatternType").space().output(1)
        .dict_key("PaintType").space().output(is_colored() ? 1 : 2)
        .dict_key("TilingType").space().output(m_tiling_type)
        .dict_key("XStep").space().output(m_step[0])
        .dict_key("YStep").space().output(m_step[1])
    ;

    output_array("BBox", fmt, m_bbox, m_bbox+4);
    output_array("Matrix", fmt, m_matrix.begin(), m_matrix.end());
    output_resource_dictionary_ref(m_res_dict, fmt);
}
Ejemplo n.º 2
0
int main (int argc, char *argv[])
{
   double **phi, **oldphi;
   int    **mask;
   int    i, j, k;
   int    nptsx = 200, nptsy = 200;
   int    nsteps  = 500;

   phi = (double **)malloc(sizeof(double*)*nptsy);
   oldphi = (double **)malloc(sizeof(double*)*nptsy);
   mask = (int **)malloc(sizeof(int*)*nptsy);
   for (k=0;k<nptsy;k++){
        phi[k] = (double *)malloc(sizeof(double)*nptsx);
        oldphi[k] = (double *)malloc(sizeof(double)*nptsx);
        mask[k] = (int *)malloc(sizeof(int)*nptsx);
   }

   setup_grid (phi, nptsx, nptsy, mask);
 
/* Iterate to find solution */
   for(k=1;k<=nsteps;k++){
         for(j=0;j<nptsy;j++)
            for(i=0;i<nptsx;i++)
               oldphi[j][i] = phi[j][i];
         for(j=0;j<nptsy;j++)
            for(i=0;i<nptsx;i++)
               if (mask[j][i]) phi[j][i] = 0.25*(oldphi[j][i-1] +
                  oldphi[j][i+1] + oldphi[j-1][i] + oldphi[j+1][i]);
   }
   output_array (phi, nptsx, nptsy);
 
   return 0;
}
Ejemplo n.º 3
0
//
// Writes the shading pattern dictionary
//
void ShadingPatternImpl::on_output_definition()
{
    ObjFmt& fmt(object_writer());
    fmt
        .dict_start()
        .dict_key("Type").output("Pattern")
        .dict_key("PatternType").space().output(2)
        .dict_key("Shading").space().ref(m_shading_ref);
    output_array("Matrix", fmt, m_matrix.begin(), m_matrix.end());
    fmt.dict_end();
}
Ejemplo n.º 4
0
int main(int argc, const char *argv[])
{
	int V[N] = {2, 8, 32, 8, 64};
	int C[N] = {64, 64, 128, 128, 128};
	int H[N] = {1, 2, 4, 3, 5};
	int B[N] = {0, 0, 0, 0, 0};
	int totalV = 256;

	// int satisfaction = best_satisfaction_solution(V, C, H, B, N, totalV);
	int satisfaction = best_satisfaction_solution_use_recursion(
		V, C, H, B, N, totalV);
	printf("The best satisfaction solution is: ");
	output_array(B, N);
	printf("And its satisfaction = %d\n", satisfaction);

	return 0;
}
Ejemplo n.º 5
0
int main (int argc, char *argv[])
{
   float *h_phi;
   float *h_oldphi;
   int *h_mask;
   int nsize1=sizeof(float)*NPTSX*NPTSY;
   int nsize2=sizeof(int)*NPTSX*NPTSY;

   h_phi = (float *)malloc(nsize1);
   h_oldphi = (float *)malloc(nsize1);
   h_mask = (int *)malloc(nsize2);
   setup_grid (h_oldphi, NPTSX, NPTSY, h_mask);
   performUpdates(h_phi,h_oldphi,h_mask,NPTSX,NPTSY,NSTEPS);
 
   output_array (h_phi, NPTSX, NPTSY);
 
   return 0;
}
Ejemplo n.º 6
0
//
// Writes the shading pattern dictionary
//
void ShadingImpl::on_output_definition()
{
    ObjFmt& fmt(object_writer());
    // shading subdictionary
    fmt
        .dict_start()
        .dict_key("ShadingType").space().output(m_shading_type)
        .dict_key("ColorSpace");

    if (is_valid(m_cs_ref))
    {
        fmt.space().ref(m_cs_ref);
    }
    else
    {
        JAG_ASSERT(is_trivial_color_space(m_cs));
        output_trivial_color_space_name(m_cs, fmt.fmt_basic());
    }

    output_array("BBox", fmt, m_bbox.begin(), m_bbox.end());
    output_array("Background", fmt, m_background.begin(), m_background.end());

    switch(m_shading_type)
    {
    case SHV_AXIAL:
    case SHV_RADIAL:
        output_array("Coords", fmt, m_coords.begin(), m_coords.end());
        output_functions();
        if (m_keys.test(BIT_EXTEND))
        {
            fmt
                .dict_key("Extend")
                .array_start()
                .output_bool(m_extend[0])
                .output_bool(m_extend[1])
                .array_end();
        }
        output_array("Domain", fmt, m_domain.begin(), m_domain.end());

        break;

    case SHV_FUNCTION:
        output_functions();
        output_array("Domain", fmt, m_domain.begin(), m_domain.end());
        output_array("Matrix", fmt, m_matrix_fun.begin(), m_matrix_fun.end());
        break;

    default:
        JAG_INTERNAL_ERROR;
    }
    fmt.dict_end(); // shading
}
static bool output_value(uint8_t *source, uint8_t *sourcelimit, uint8_t typecode, dynbuffer_t *dest)
{
	uint8_t subtype;

	/* switch on type */
	switch (typecode) {
	case JSONBINARY_TYPE_OBJECT:
		return output_object(source, sourcelimit, dest);
	case JSONBINARY_TYPE_ARRAY:
		return output_array(source, sourcelimit, dest);
	case JSONBINARY_TYPE_STRING:
		dynbuffer_append_byte(dest, '"');
		json_escape_string(dest, source, sourcelimit-source, true, '"');
		dynbuffer_append_byte(dest, '"');
		break;
	case JSONBINARY_TYPE_NUMBER:
		dynbuffer_append(dest, source, sourcelimit-source);
		break;
	case JSONBINARY_TYPE_SS:
		if (source>=sourcelimit) return false;
		subtype=*source;
		switch (subtype) {
		case JSONBINARY_SS_DATA_FALSE:
			dynbuffer_append(dest, "false", 5);
			break;
		case JSONBINARY_SS_DATA_TRUE:
			dynbuffer_append(dest, "true", 4);
			break;
		case JSONBINARY_SS_DATA_NULL:
			dynbuffer_append(dest, "null", 4);
			break;
		case JSONBINARY_SS_DATA_UNDEFINED:
			dynbuffer_append(dest, "undefined", 9);
			break;
		default:
			return false;
		}
		break;
	}

	return true;
}
Ejemplo n.º 8
0
int main(void)
{
	int num;

	// 注意:为了便于计算左右孩子的下标序号,数组编号从1开始(牺牲元素pbt[0])
	int pbt[] = {0, 49, 38, 65, 97, 76, 13, 27, 50};

	num = sizeof(pbt)/sizeof(pbt[0]) - 1; 

	// 从无序序列创建小顶堆
	build_heap(pbt, num);

	// 执行堆排序
	heap_sort(pbt, num);

	// 输出排序结果
	output_array(pbt, num);

	system("pause");
	return 0;
} 
Ejemplo n.º 9
0
void begin()
{
  int i;
  float *A, *W_re, *W_im; 

  A = (float*)malloc(sizeof(float)*2*n);
  W_re = (float*)malloc(sizeof(float)*n/2); 
  W_im = (float*)malloc(sizeof(float)*n/2); 
  /* assert(A_re != NULL && A_im != NULL && W_re != NULL && W_im != NULL);  */
  compute_W(W_re, W_im); 
  
  while (numiters == -1 || numiters-- > 0) {
    init_array(A); 
    fft(A, W_re, W_im);
#ifdef FFT2
    permute_bitrev(A);
#endif
    output_array(A);
  }

  free(A);
  free(W_re); 
  free(W_im); 
}