Example #1
0
format unification_app_mismatch_exception::pp(formatter const & fmt, options const & opts) const {
    unsigned indent     = get_pp_indent(opts);
    auto const & ctx    = get_context();
    expr const & app    = get_expr();
    auto args_it        = get_args().begin();
    auto args_end       = get_args().end();
    auto types_it       = get_types().begin();
    format app_fmt      = fmt(ctx, app, false, opts);
    format r            = format{format(what()), nest(indent, compose(line(), app_fmt))};
    format fun_type_fmt = fmt(ctx, *types_it, false, opts);
    r += compose(line(), format("Function type:"));
    r += nest(indent, compose(line(), fun_type_fmt));
    ++args_it;
    ++types_it;
    if (get_args().size() > 2)
        r += compose(line(), format("Arguments types:"));
    else
        r += compose(line(), format("Argument type:"));
    for (; args_it != args_end; ++args_it, ++types_it) {
        format arg_fmt    = fmt(ctx, *args_it, false, opts);
        format type_fmt   = fmt(ctx, *types_it, false, opts);
        r += nest(indent, compose(line(), group(format{arg_fmt, space(), colon(), nest(indent, format{line(), type_fmt})})));
    }
    r += pp_elaborator_state(fmt, get_elaborator(), opts);
    return r;
}
Example #2
0
void emit_compound_specifier(struct compound_specifier_s * n) {
    struct subrule_list_s * s;
    struct specifier_list_s * t;

    if (n->list) {
	int count = 0;

	for (s = n->list; s; s = s->subrule_list)
	    count++;
	if (count > 1) {
	    nest();
	    printf("or\n");
	}
	for (s = n->list; s; s = s->subrule_list) {
	    if (s->specifier_list) {
		int count0 = 0;

		for (t = s->specifier_list; t; t = t->list)
		    count0++;
		if (count0 > 1) {
		    nest();
		    printf("and\n");
		}
		for (t = s->specifier_list; t; t = t->list) {
		    if (t->spec)
			emit_negated_specifier(t->spec);
		}
		if (count0 > 1)
		    unnest();
	    }
	}
	if (count > 1)
	    unnest();
    }
}
Example #3
0
format pp(level l, bool unicode, unsigned indent) {
    if (is_explicit(l)) {
        lean_assert(get_depth(l) > 0);
        return format(get_depth(l) - 1);
    } else {
        switch (kind(l)) {
        case level_kind::Zero:
            lean_unreachable(); // LCOV_EXCL_LINE
        case level_kind::Param: case level_kind::Global:
            return format(to_param_core(l).m_id);
        case level_kind::Meta:
            return format("?") + format(meta_id(l));
        case level_kind::Succ: {
            auto p = to_offset(l);
            return pp_child(p.first, unicode, indent) + format("+") + format(p.second);
        }
        case level_kind::Max: case level_kind::IMax: {
            format r = format(is_max(l) ? "max" : "imax");
            r += nest(indent, compose(line(), pp_child(to_max_core(l).m_lhs, unicode, indent)));
            // max and imax are right associative
            while (kind(to_max_core(l).m_rhs) == kind(l)) {
                l = to_max_core(l).m_rhs;
                r += nest(indent, compose(line(), pp_child(to_max_core(l).m_lhs, unicode, indent)));
            }
            r += nest(indent, compose(line(), pp_child(to_max_core(l).m_rhs, unicode, indent)));
            return group(r);
        }}
        lean_unreachable(); // LCOV_EXCL_LINE
    }
}
Example #4
0
format pp(formatter fmt, context const & ctx, std::vector<expr> const & exprs, std::vector<expr> const & types, options const & opts) {
    unsigned indent = get_pp_indent(opts);
    lean_assert(exprs.size() == types.size());
    auto it1 = exprs.begin();
    auto it2 = types.begin();
    format r;
    for (; it1 != exprs.end(); ++it1, ++it2) {
        r += nest(indent, compose(line(), group(format{fmt(ctx, *it1, false, opts), space(), colon(),
                                                       nest(indent, format{line(), fmt(ctx, *it2, false, opts)})})));
    }
    return r;
}
Example #5
0
static void
begin_object(JsonLogger* self)
{
    output(self, "{");
    need_nl(self);
    nest(self);
}
Example #6
0
static void
begin_array(JsonLogger* self)
{
    output(self, "[");
    need_nl(self);
    nest(self);
}
Example #7
0
format pp(options const & o) {
    bool unicode = get_pp_unicode(o);
    format r;
    bool first = true;
    char const * arrow = unicode ? g_arrow : g_assign;
    for_each(o.m_value, [&](sexpr const & p) {
            if (first) { first = false; } else { r += comma(); r += line(); }
            name const & n = to_name(head(p));
            unsigned sz = n.size();
            unsigned indent = unicode ? sz+3 : sz+4;
            r += group(nest(indent, pp(head(p)) + space() + format(arrow) + space() + pp(tail(p))));
        });
    format open  = unicode ? format(g_left_angle_bracket) : lp();
    format close = unicode ? format(g_right_angle_bracket) : rp();
    return group(nest(1, open + r + close));
}
Example #8
0
format elaborator_exception::pp(formatter const & fmt, options const & opts) const {
    unsigned indent  = get_pp_indent(opts);
    format expr_fmt  = fmt(get_context(), get_expr(), false, opts);
    format r;
    r += format{format(what()), space(), format("at term")};
    r += nest(indent, compose(line(), expr_fmt));
    r += pp_elaborator_state(fmt, get_elaborator(), opts);
    return r;
}
Example #9
0
format pp_elaborator_state(formatter fmt, elaborator const & elb, options const & opts) {
    unsigned indent     = get_pp_indent(opts);
    format r;
    if (elb.has_constraints()) {
        format elb_fmt  = elb.pp(fmt, opts);
        r += compose(line(), format("Elaborator state"));
        r += nest(indent, compose(line(), elb_fmt));
    }
    return r;
}
Example #10
0
/* which means that a nested function may have its own label with the
   same name as the outer function */
void j(void)
{
  auto void nest(void);

 l: nest();
  
  void nest(void)
    {
    l: dummy(); /* { dg-warning "defined but not used" "nest label same name" } */
    }
Example #11
0
void emit_negated_specifier(struct negated_specifier_s * n) {
    if (n->spec) {
	if (n->negated) {
	    nest();
	    printf("not\n");
	}
	emit_specifier(n->spec);
	if (n->negated) {
	    unnest();
	}
    }
}
Example #12
0
format unification_type_mismatch_exception::pp(formatter const & fmt, options const & opts) const {
    unsigned indent     = get_pp_indent(opts);
    auto const & ctx    = get_context();
    expr const & e      = get_expr();
    expr const & p      = get_processed_expr();
    expr const & exp    = get_expected_type();
    expr const & given  = get_given_type();
    format r            = format{format(what()), nest(indent, compose(line(), fmt(ctx, e, false, opts)))};
    if (p != e) {
        r += compose(line(), format("Term after elaboration:"));
        r += nest(indent, compose(line(), fmt(ctx, p, false, opts)));
    }
    r += compose(line(), format("Expected type:"));
    r += nest(indent, compose(line(), fmt(ctx, exp, false, opts)));
    if (given) {
        r += compose(line(), format("Got:"));
        r += nest(indent, compose(line(), fmt(ctx, given, false, opts)));
    }
    r += pp_elaborator_state(fmt, get_elaborator(), opts);
    return r;
}
Example #13
0
/* A nested function may not goto a label outside itself  */
void i(void)
{
  auto void nest(void);

 l: nest();
  
  void nest(void)
    {
      goto l;  /* { dg-error "used but not defined" "nest use outer label" } */
    }

  goto l; /* reaches the outer l */
}
Example #14
0
    QString Generator::parse(const std::deque<IFilter::Ptr>& filters)
    {
        FiltersVisitor visitor;
        FilterData filterData;
        QString result;

        for (const IFilter::Ptr& filter: filters)
        {
            FilterData currentfilterData = visitor.visit(filter);

            const bool mergable = canBeMerged(currentfilterData, filterData);

            if (mergable)
            {
                filterData.joins.insert(currentfilterData.joins.cbegin(), currentfilterData.joins.cend());
                filterData.conditions.append(currentfilterData.conditions);
            }
            else   //flush filter to QString query
            {
                //flush current data
                result = nest(result, filterData);

                //apply new one
                filterData = currentfilterData;
            }
        }

        //final flush
        if (filterData.empty() == false || result.isEmpty())   //flush when there is somethign to be flushed or, we have empty queue (no filters case)
        {
            result = nest(result, filterData);
            filterData.clear();
        }

        return result;
    }
Example #15
0
environment check_cmd(parser & p) {
    expr e   = p.parse_expr();
    list<expr> ctx = locals_to_context(e, p);
    level_param_names ls = to_level_param_names(collect_univ_params(e));
    level_param_names new_ls;
    std::tie(e, new_ls) = p.elaborate_relaxed(e, ctx);
    auto tc = mk_type_checker_with_hints(p.env(), p.mk_ngen(), true);
    expr type = tc->check(e, append(ls, new_ls));
    auto reg              = p.regular_stream();
    formatter const & fmt = reg.get_formatter();
    options opts          = p.ios().get_options();
    unsigned indent       = get_pp_indent(opts);
    format r = group(format{fmt(e), space(), colon(), nest(indent, compose(line(), fmt(type)))});
    reg << mk_pair(r, opts) << endl;
    return p.env();
}
Example #16
0
void emit_ast(struct ast_s * n) {
    struct rule_list_s * r;
    if (n->list) {
	int count = 0;

	for (r = n->list; r; r = r->list)
	    count++;
	if (count > 1) {
	    nest();
	    /* semicolons are OR */
	    printf("or\n");
	}
	for (r = n->list; r; r = r->list) {
	    if (r->rule) {
		emit_rule(r->rule);
	    }
	}
	if (count > 1)
	    unnest();
    }
}
Example #17
0
void emit_rule(struct rule_s * n) {
    struct specifier_list_s * s;

    if (n->list) {
	int count = 0;

	for (s = n->list; s; s = s->list)
	    count++;
	if (count > 1) {
	    nest();
	    /* specifiers have implicit AND */
	    printf("and\n");
	}
	
	for (s = n->list; s; s = s->list) {
	    if (s->spec) {
		emit_negated_specifier(s->spec);
	    }
	}
	if (count > 1)
	    unnest();
    }
}
Example #18
0
int main(void){
    while(scanf("%u %u",&bnum,&dim)!=EOF){
        for(i = 0; i < bnum; i++){
            for(j = 0; j < dim; j++) scanf("%u",&bxs[i].d[j]);
            bxs[i].n = i+1;
            std::sort(bxs[i].d,bxs[i].d+dim);
        }
        std::sort(bxs,bxs+bnum,ord);
        for(i = 0; i < bnum; i++){
            max = 0;
            for(j = 0; j < i; j++)
                if(nest(bxs[j],bxs[i]) && q[j] > max)
                    max = q[j], p[i] = j;
            q[i] = max+1;
        }
        for(max = i = 0; i < bnum; i++)
            if(q[i] > max) max = q[i], end = i;        
        printf("%u\n",max);
        trace(end,max-1);
        printf("\n");
    }
    return 0;
}
Example #19
0
void emit_specifier(struct specifier_s * n) {
    if (n->direction) {
	if (n->direction->list) {
	    struct direction_argument_list_s * l;
	    int count = 0;

	    for (l = n->direction->list; l; l = l->list)
		count++;
	    if (count > 1) {
		nest();
		printf("or\n");
	    }
	    for (l = n->direction->list; l; l = l->list) {
		if (l->arg) {
		    nest();
		    printf("direction %s\n", l->arg->direction);
		    unnest();
		}
	    }
	    if (count > 1) 
		unnest();
	}
    } else if (n->target) {
	nest();
	printf("target\n");
	unnest();
    } else if (n->host) {
	if (n->host->list) {
	    struct host_argument_list_s * l;
	    int count = 0;

	    for (l = n->host->list; l; l = l->list)
		count++;
	    if (count > 1) {
		nest();
		printf("or\n");
	    }
	    for (l = n->host->list; l; l = l->list) {
		if (l->arg) {
		    nest();
		    printf("host %s\n", l->arg->host);
		    unnest();
		}
	    }
	    if (count > 1)
		unnest();
	}
    } else if (n->port) {
	nest();
	printf("port\n");
	unnest();
    } else if (n->protocol) {
	nest();
	printf("protocol\n");
	unnest();
    } else if (n->icmptype) {
	nest();
	printf("icmptype\n");
	unnest();
    } else if (n->option) {
	nest();
	printf("option\n");
	unnest();
    } else if (n->chaingroup) {
	nest();
	printf("chaingroup FIXME\n");
	unnest();
    } else if (n->compound) {
	emit_compound_specifier(n->compound);
    }
}
Example #20
0
static void Fpass (void) { nest();  Pelif(); }
Example #21
0
/* first line of group */
static void Fdrop (void) { nest();  Dfalse(); }
Example #22
0
format pp_indent_expr(formatter const & fmt, environment const & env, options const & opts, expr const & e) {
    return nest(get_pp_indent(opts), compose(line(), fmt(env, e, opts)));
}
Example #23
0
bool DataBuilder::onStartList(uint32_t, const CharSequence&, const CharSequence&, const Descriptor*)
{
    return nest(qpid::types::Variant::List());
}
Example #24
0
int main(int argc, const char * argv[]) {
    // insert code here...
    double coeff[13];//array of coefficients for taylor polynomial of cos(x)
    bool neg=false;//if coefficient is supposed  to be negative, then true
    for (int i=0.0; i<13; i++) {//assigns coefficients to array
        if(i%2==0)
        {if(!neg)
        {
            coeff[i]=(double)(1.0/factorial(i));
            neg=true;
        }
            else
            {         coeff[i]=(double)(-1.0/factorial(i));
            neg=false;
            }
        }
        else{
            coeff[i]=0;
        }
        
    }
    
  
    Matrix z=Linspace(-3, 3, 601);//creates matrix with  601 evenly div numbers between -3 and 3
     Matrix p4coeff(1,5,coeff);//matrix with first 4 taylor coefficients
    
    Matrix p4(1,601);//matrix with result for 4th degree polynomial evaluated at z
    for (int i=0;i<601;i++)
    {
        p4(i)=nest(p4coeff,z(i));
    }
    p4.Write("p4.txt");//wriete results to text  file
    
    //same as above for 8th degree polynomial
    Matrix p8coeff(1,9,coeff);
    Matrix p8(1,601);
    for (int i=0;i<601;i++)
    {
        p8(i)=nest(p8coeff,z(i));
    }
    p8.Write("p8.txt");
    
    //same as above for 12th degree polynomial
    Matrix p12coeff(1,13,coeff);
    Matrix p12(1,601);
    for (int i=0;i<601;i++)
    {
        p12(i)=nest(p12coeff,z(i));
    }
    p12.Write("p12.txt");
    
    // all points are evaluated at cos(x)
    Matrix f(1,601);
    for (int i=0;i<601;i++)
    {
        f(i)=cos(z(i));
    }
    f.Write("f.txt");
    
    //calculate relative error for the three taylor polynomials
    Matrix err4(1,601);
    for (int i=0;i<601;i++)
    {
        err4(i)=cos(z(i))-p4(i);
    }
    err4.Abs();
    err4.Write("err4.txt");
    Matrix err8(1,601);
    for (int i=0;i<601;i++)
    {
        err8(i)=cos(z(i))-p8(i);
    }
    err8.Abs();
    err8.Write("err8.txt");
     Matrix err12(1,601);
    for (int i=0;i<601;i++)
    {
        err12(i)=cos(z(i))-p12(i);
    }
    err12.Abs();
    err12.Write("err12.txt");
    z.Write("z.txt");
    }
GeneralizedTransform::GeneralizedTransform(Json::Value const &transform) {
    nest(transform);
}
Example #26
0
V4R_EXPORTS
void computeNormals(const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
                    pcl::PointCloud<pcl::Normal>::Ptr &normals,
                    int method, float radius)
{
    CHECK(normals);

    if(method == 0)
    {
        pcl::NormalEstimation<PointT, pcl::Normal> n3d;
        n3d.setRadiusSearch (radius);
        n3d.setInputCloud (cloud);
        n3d.compute (*normals);
    }
    else if(method == 1)
    {
        pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne;
        ne.setNormalEstimationMethod (ne.AVERAGE_3D_GRADIENT);
        ne.setMaxDepthChangeFactor(0.02f);
        ne.setNormalSmoothingSize(15.f);//20.0f);
        ne.setDepthDependentSmoothing(false);//param.normals_depth_dependent_smoothing);
        ne.setInputCloud(cloud);
        ne.setViewPoint(0,0,0);
        ne.compute(*normals);
    }
    else if(method == 2)
    {
        pcl::NormalEstimationOMP<PointT, pcl::Normal> ne;
        ne.setRadiusSearch ( radius );
        ne.setInputCloud ( cloud );
        ne.compute ( *normals );
    }
    else if(method == 3)
    {
        ZAdaptiveNormals::Parameter n_param;
        n_param.adaptive = true;
        ZAdaptiveNormals nest(n_param);

        DataMatrix2D<Eigen::Vector3f>::Ptr kp_cloud( new DataMatrix2D<Eigen::Vector3f>() );
        DataMatrix2D<Eigen::Vector3f>::Ptr kp_normals_tmp( new DataMatrix2D<Eigen::Vector3f>() );
        convertCloud(*cloud, *kp_cloud);
        nest.compute(*kp_cloud, *kp_normals_tmp);
        convertNormals(*kp_normals_tmp, *normals);
    }
    else if(method==4)
    {
        boost::shared_ptr<PreProcessorAndNormalEstimator<PointT, pcl::Normal> > normal_estimator;
        normal_estimator.reset (new PreProcessorAndNormalEstimator<PointT, pcl::Normal>);
        normal_estimator->setCMR (false);
        normal_estimator->setDoVoxelGrid (false);
        normal_estimator->setRemoveOutliers (false);
        normal_estimator->setValuesForCMRFalse (0.003f, 0.02f);
        normal_estimator->setForceUnorganized(true);

        typename pcl::PointCloud<PointT>::Ptr processed (new pcl::PointCloud<PointT>);
        normal_estimator->estimate (cloud, processed, normals);
    }
    else
    {
        throw std::runtime_error("Chosen normal computation method not implemented!");
    }

    // Normalize normals to unit length
    for ( size_t normal_pt_id = 0; normal_pt_id < normals->points.size(); normal_pt_id++)
    {
        Eigen::Vector3f n1 = normals->points[normal_pt_id].getNormalVector3fMap();
        n1.normalize();
        normals->points[normal_pt_id].normal_x = n1(0);
        normals->points[normal_pt_id].normal_y = n1(1);
        normals->points[normal_pt_id].normal_z = n1(2);
    }
}
Example #27
0
static void Ftrue (void) { nest();  Strue(); }
Example #28
0
static void Ffalse(void) { nest();  Sfalse(); }
Example #29
0
vm_obj format_nest(vm_obj const & i, vm_obj const & fmt) {
    return to_obj(nest(to_unsigned(i), to_format(fmt)));
}
Example #30
0
bool DataBuilder::onStartMap(uint32_t /*count*/, const CharSequence&, const CharSequence&, const Descriptor*)
{
    return nest(qpid::types::Variant::Map());
}