Beispiel #1
0
/**
 * Description not yet available.
 * \param
 */
 dvar_matrix operator*(const dvar_matrix& m1, const dvar_matrix& m2)
 {
   if (m1.colmin() != m2.rowmin() || m1.colmax() != m2.rowmax())
   {
     cerr << " Incompatible array bounds in "
     "dmatrix operator*(const dmatrix& x, const dmatrix& m)\n";
     ad_exit(21);
   }
   //dmatrix cm1=value(m1);
   //dmatrix cm2=value(m2);
   dmatrix tmp(m1.rowmin(),m1.rowmax(), m2.colmin(), m2.colmax());
   double sum;


   for (int j=m2.colmin(); j<=m2.colmax(); j++)
   {
     dvector m2col=column_value(m2,j);

     for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
     {
       sum=value(m1(i))*m2col;
       tmp(i,j)=sum;
     }
   }

   dvar_matrix vtmp=nograd_assign(tmp);
   save_identifier_string("TEST1");
   m1.save_dvar_matrix_value();
   m1.save_dvar_matrix_position();
   m2.save_dvar_matrix_value();
   m2.save_dvar_matrix_position();
   vtmp.save_dvar_matrix_position();
   save_identifier_string("TEST6");
   gradient_structure::GRAD_STACK1->
            set_gradient_stack(dmdm_prod);
   return vtmp;
 }
	T get(int column) const
	{
		typename converter<T>::base_type t;
		column_value(column, t);
		return converter<T>::to(t);
	}
Beispiel #3
0
int detect_char (IplImage *img,int *lines_number,int line_numbers_size,
        struct  rect_char *chars,struct rect_char **ptr)
{

    // detection space 
    int white = 0;
    int first_char = 0;

    int i,x,x1,x2,x3,mem_x1,mem_x2,c=0,white_ref;

    for (i=0;i< line_numbers_size;i= i+2)
    {
        mem_x1 = -1;
        mem_x2 = -1;
        white = 0;
        first_char = 0;
        white_ref = 0.18 * (lines_number[i+1]-lines_number[i]);
        if (white_ref >10)
            white_ref = 10;

        for(x=1 ; x < img->width-1; x++)
        {

            x1 = column_value(lines_number[i],lines_number[i+1],x-1,img);
            x2 = column_value(lines_number[i],lines_number[i+1],x,img);
            x3 = column_value(lines_number[i],lines_number[i+1],x+1,img);


            if (x2 == 0 && x1 == 1)
            {
                mem_x2=x;
            }

            if(mem_x2 != -1 && mem_x1 != -1)
            {
                if (c != 0)
                    chars = realloc_r(ptr,(c+1)*sizeof(struct rect_char));


                chars[c].y = lines_number[i];
                chars[c].x = mem_x1;
                chars[c].width = mem_x2 - mem_x1;
                chars[c].height = lines_number[i+1] - lines_number[i];
                c++;


                if (white > white_ref && c>0 && first_char == 1 )
                {
                    chars = realloc_r(ptr,(c+1)*sizeof(struct rect_char));

                    chars[c].y = lines_number[i];
                    chars[c].x = chars[c-2].x +chars[c - 2].width +2;
                    chars[c].width = white -3;
                    chars[c].height = lines_number[i+1]-lines_number[i];
                    c++;
                }
                white =0;
                first_char = 1;



                mem_x2 = -1;
                mem_x1 = -1;
            }


            if( x1 == 0 && x2 ==0 && x3 ==0)
            {
                white ++;
            }

            if (x2 == 0 && x3 == 1 )
            {
                mem_x1 = x;
            }


        }
    }

    return c;
}
static void
end2_tag (void *data, const char *el)
{
/* GML element ending [Pass II] */
    struct gml_params *params = (struct gml_params *) data;
    if (strcmp (el, "gml:featureMember") == 0)
      {
	  params->is_feature = 0;
	  return;
      }
    if (strcmp (el, "gml:featureMembers") == 0)
      {
	  params->is_feature = 0;
	  return;
      }
    if (strcasecmp (el, "gml:Point") == 0)
      {
	  params->is_point = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:MultiPoint") == 0)
      {
	  params->is_multi_point = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:LineString") == 0)
      {
	  params->is_linestring = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:MultiLineString") == 0)
      {
	  params->is_multi_linestring = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:Polygon") == 0)
      {
	  polygon_set_up (params);
	  clean_polygon (params);
	  params->is_polygon = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:MultiPolygon") == 0)
      {
	  params->is_multi_polygon = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:MultiSurface") == 0)
      {
	  params->is_multi_polygon = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:outerBoundaryIs") == 0)
      {
	  params->is_outer_boundary = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:exterior") == 0)
      {
	  params->is_outer_boundary = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:innerBoundaryIs") == 0)
      {
	  params->is_inner_boundary = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (strcasecmp (el, "gml:interior") == 0)
      {
	  params->is_inner_boundary = 0;
	  *(params->CharData) = '\0';
	  params->CharDataLen = 0;
	  return;
      }
    if (params->is_feature)
	check_end2_fid (params, el);
    if (params->is_fid)
      {
	  *(params->CharData + params->CharDataLen) = '\0';
	  column_value (params, el);
      }
    if (strcasecmp (el, "gml:coordinates") == 0)
	parse_coords_1 (params);
    if (strcasecmp (el, "gml:posList") == 0 || strcasecmp (el, "gml:pos") == 0)
	parse_coords_2 (params);
}