コード例 #1
6
ファイル: clear_tactic.cpp プロジェクト: bmalehorn/lean
tactic clear_tactic(name const & n) {
    auto fn = [=](environment const &, io_state const &, proof_state const & _s) -> optional<proof_state> {
        if (!_s.get_goals()) {
            throw_no_goal_if_enabled(_s);
            return none_proof_state();
        }
        proof_state s    = apply_substitution(_s);
        goals const & gs = s.get_goals();
        goal  g          = head(gs);
        goals tail_gs    = tail(gs);
        if (auto p = g.find_hyp(n)) {
            expr const & h = p->first;
            unsigned i     = p->second;
            buffer<expr> hyps;
            g.get_hyps(hyps);
            hyps.erase(hyps.size() - i - 1);
            if (depends_on(g.get_type(), h)) {
                throw_tactic_exception_if_enabled(s, sstream() << "invalid 'clear' tactic, conclusion depends on '"
                                                  << n << "'");
                return none_proof_state();
            }
            if (auto h2 = depends_on(i, hyps.end() - i, h)) {
                throw_tactic_exception_if_enabled(s, sstream() << "invalid 'clear' tactic, hypothesis '" << *h2
                                                  << "' depends on '" << n << "'");
                return none_proof_state();
            }
            name_generator ngen = s.get_ngen();
            expr new_type = g.get_type();
            expr new_meta = mk_app(mk_metavar(ngen.next(), Pi(hyps, new_type)), hyps);
            goal new_g(new_meta, new_type);
            substitution new_subst = s.get_subst();
            assign(new_subst, g, new_meta);
            proof_state new_s(s, goals(new_g, tail_gs), new_subst, ngen);
            return some_proof_state(new_s);
        } else {
            throw_tactic_exception_if_enabled(s, sstream() << "invalid 'clear' tactic, goal does not have a hypothesis "
                                              << " named '" << n << "'");
            return none_proof_state();
        }
    };
    return tactic01(fn);
}
コード例 #2
1
bool QPACKHeaderTable::canEvict(uint32_t needed) {
  if (size_ == 0 || !refCount_) {
    return needed <= capacity_;
  }
  uint32_t freeable = 0;
  uint32_t i = tail();
  uint32_t nChecked = 0;
  while (nChecked++ < size() && freeable < needed &&
         ((*refCount_)[i] == 0) && // don't evict referenced or unacked headers
         internalToAbsolute(i) <= ackedInsertCount_) {
    freeable += table_[i].bytes();
    i = next(i);
  }
  if (freeable < needed) {
    VLOG(5) << "header=" << table_[i].name << " blocked eviction, recount="
            << (*refCount_)[i];
    return false;
  }
  return true;
}
コード例 #3
0
 void operator()(ED ed) {
   Tailr tailr = tails(ed, g);
   Ti i = boost::begin(tailr), e = boost::end(tailr);
   if (i == e) {
     terminal_arcs.push_back(ed);
   } else {
     unsigned ntails_uniq = 0;
     do {
       Adj& a = adj[tail(*i, ed, g)];
       if (a.size() && last_added(a) == ed) {
         // last hyperarc with same tail = same hyperarc
       } else {  // new (unique) tail
         add(a, Tail(ed));  // default multiplicity=1
         ++ntails_uniq;
       }
       ++i;
     } while (i != e);
     put(unique_tails_pmap, ed, ntails_uniq);
   }
 }
コード例 #4
0
ファイル: mtail.c プロジェクト: CharlesVaneenoo/TP_L3S5
int main(int argc, char *argv[]) {
    char *pathname = argv[argc-1];
    int ntail = 0;
    int c;

    while ( (c = getopt(argc,argv,"n:")) != -1 ) {
        switch(c) {
        case 'n' :
            ntail = atoi(optarg);
            break;

        default:
            printf("mtail_stupide [-n : number of line from the end] file_pathname\n");
            exit(EXIT_FAILURE);
            break;
        }
    }
    tail(pathname,ntail);
    return 0;
}
コード例 #5
0
string
edit_interface_rep::session_complete_command (tree tt) {
  path p= reverse (obtain_ip (tt));
  tree st= subtree (et, p);
  if ((N(tp) <= N(p)) || (tp[N(p)] != 1)) return "";
  tree t= put_cursor (st[1], tail (tp, N(p)+1));
  // cout << t << LF;

  (void) eval ("(use-modules (utils plugins plugin-cmd))");
  string lan= get_env_string (PROG_LANGUAGE);
  string ses= get_env_string (PROG_SESSION);
  string s  = as_string (call ("verbatim-serialize", lan, tree_to_stree (t)));
  s= s (0, N(s)-1);

  int pos= search_forwards (cursor_symbol, s);
  if (pos == -1) return "";
  s= s (0, pos) * s (pos + N(cursor_symbol), N(s));
  // cout << s << ", " << pos << LF;
  return "(complete " * scm_quote (s) * " " * as_string (pos) * ")";
}
コード例 #6
0
ファイル: whnf_tactic.cpp プロジェクト: codyroux/lean
tactic whnf_tactic(bool relax_main_opaque) {
    return tactic01([=](environment const & env, io_state const & ios, proof_state const & ps) {
            goals const & gs = ps.get_goals();
            if (empty(gs))
                return none_proof_state();
            name_generator ngen = ps.get_ngen();
            auto tc             = mk_type_checker(env, ngen.mk_child(), relax_main_opaque);
            goal  g             = head(gs);
            goals tail_gs       = tail(gs);
            expr  type          = g.get_type();
            auto t_cs           = tc->whnf(type);
            goals new_gs(goal(g.get_meta(), t_cs.first), tail_gs);
            proof_state new_ps(ps, new_gs, ngen);
            if (solve_constraints(env, ios, new_ps, t_cs.second)) {
                return some_proof_state(new_ps);
            } else {
                return none_proof_state();
            }
        });
}
コード例 #7
0
ファイル: boost_compute.hpp プロジェクト: 1ibrium/vexcl
void inclusive_scan(const vex::vector<T> &src, vex::vector<T> &dst) {
    auto queue = src.queue_list();

    // Scan partitions separately.
    for(unsigned d = 0; d < queue.size(); ++d) {
        if (src.part_size(d)) {
            boost::compute::command_queue q( queue[d]() );

            boost::compute::buffer sbuf( src(d)() );
            boost::compute::buffer dbuf( dst(d)() );

            boost::compute::detail::scan(
                    boost::compute::make_buffer_iterator<T>(sbuf, 0),
                    boost::compute::make_buffer_iterator<T>(sbuf, src.part_size(d)),
                    boost::compute::make_buffer_iterator<T>(dbuf, 0),
                    false, q
                    );
        }
    }

    // If there are more than one partition,
    // update all of them except for the first.
    if (queue.size() > 1) {
        std::vector<T> tail(queue.size() - 1, T());

        for(unsigned d = 0; d < tail.size(); ++d) {
            if (src.part_size(d))
                tail[d] = dst[src.part_start(d + 1) - 1];
        }

        std::partial_sum(tail.begin(), tail.end(), tail.begin());

        for(unsigned d = 1; d < queue.size(); ++d) {
            if (src.part_size(d)) {
                // Wrap partition into vector for ease of use:
                vex::vector<T> part(queue[d], dst(d));
                part += tail[d - 1];
            }
        }
    }
}
コード例 #8
0
ファイル: stab.c プロジェクト: bhanug/cdb
/* point_hook - called at each execution point */
static void point_hook(void *cl, Coordinate *cp, Tree *e) {
	Tree t;
	
	/*
	add breakpoint test to *e:
	(_Nub_bpflags[i] != 0 && _Nub_bp(i), *e)
	*/
	t = tree(AND, voidtype,
		(*optree[NEQ])(NE,
			rvalue((*optree['+'])(ADD,
				pointer(idtree(nub_bpflags)),
				cnsttree(inttype, Seq_length(pickle->spoints)))),
			cnsttree(inttype, 0L)),
		vcall(nub_bp, voidtype, cnsttree(inttype, Seq_length(pickle->spoints)), NULL));
	if (*e)
		*e = tree(RIGHT, (*e)->type, t, *e);
	else
		*e = t;
	Seq_addhi(pickle->spoints,
		  sym_spoint(sym_coordinate(cp->file ? cp->file : string(""), cp->x, cp->y), tail()));
}
コード例 #9
0
ファイル: Rehashing.cpp プロジェクト: ziyeqinghan/lintcode
 /**
  * @param hashTable: A list of The first node of linked list
  * @return: A list of The first node of linked list which have twice size
  */    
 vector<ListNode*> rehashing(vector<ListNode*> hashTable) {
     // write your code here
     int n = hashTable.size();
     if(n == 0) return {};
     int m = n*2;
     vector<ListNode*> ans(m, NULL), tail(m, NULL);
     for(ListNode* h:hashTable) {
         while(h) {
             ListNode* t = h->next;
             h->next = NULL;
             int a = (h->val%m+m)%m;
             if(tail[a] == NULL) ans[a] = tail[a] = h;
             else {
                 tail[a]->next = h;
                 tail[a] = h;
             }
             h = t;
         }
     }
     return ans;
 }
コード例 #10
0
ファイル: a.c プロジェクト: zeotrope/j7-src
static DF1(breduce){A z;B b,*u,*v,*x,*xx;I c,cv,d,m;SF f2;VA*p;
 RZ(w); /* AN(w)&&1<IC(w) */
 m=IC(w); RZ(z=tail(w)); c=AN(z); x=BAV(z); v=BAV(w);
 p=vap(self);
 switch(1<c?0:p->bf){
  case V0001: *x=memchr(v,C0,m)?0:1; R z;
  case V0111: *x=memchr(v,C1,m)?1:0; R z;
  case V1110: u=memchr(v,C0,m); d=u?u-v:m; *x=d%2!=d<m-1; R z;
  case V1000: u=memchr(v,C1,m); d=u?u-v:m; *x=d%2==d<m-1; R z;
  case V0010: u=memchr(v,C0,m); *x=(u?u-v:m)%2?1:0; R z;
  case V1011: u=memchr(v,C1,m); *x=(u?u-v:m)%2?0:1; R z;
  case V0100: *x= *(v+m-1)&&!memchr(v,C1,m-1)?1:0; R z;
  case V1101: *x=!*(v+m-1)&&!memchr(v,C0,m-1)?0:1; R z;
  case V0110: b=0; DO(m, b=b!=*v++); *x=b; R z;
  case V1001: b=1; DO(m, b=b==*v++); *x=b; R z;
 }
 switch(p->id){I*x,*xx;
  case CPLUS:
   RZ(z=cvt(INT,z)); x=AV(z);
   if(1==c){d=0; DO(m, if(*v++)d++); *x=d;}
   else{xx=x+=c; v+=c*(m-1); DO(m-1, DO(c, --x; *x=*--v+*x); x=xx);}
コード例 #11
0
// Enqueue an operation
void SolarisAttachListener::enqueue(SolarisAttachOperation* op) {
  // lock list
  int res = os::Solaris::mutex_lock(mutex());
  assert(res == 0, "mutex_lock failed");

  // enqueue at tail
  op->set_next(NULL);
  if (head() == NULL) {
    set_head(op);
  } else {
    tail()->set_next(op);
  }
  set_tail(op);

  // wakeup the attach listener
  RESTARTABLE(::sema_post(wakeup()), res);
  assert(res == 0, "sema_post failed");

  // unlock
  os::Solaris::mutex_unlock(mutex());
}
コード例 #12
0
ファイル: gc.c プロジェクト: mounikamunipalli/hempl
/* Construct a symbol */
any consSym(any val, word w) {
   cell *p;

   if (!(p = Avail)) {
      cell c1;

      if (!val)
         gc(CELLS);
      else {
         Push(c1,val);
         gc(CELLS);
         drop(c1);
      }
      p = Avail;
   }
   Avail = p->car;
   p = symPtr(p);
   val(p) = val ?: p;
   tail(p) = txt(w);
   return p;
}
コード例 #13
0
ファイル: consoleimpl.cpp プロジェクト: Salmista-94/qgit5
bool
ConsoleImpl::start( const QString& cmd, const QString& cmdArgs )
{
    statusBar()->showMessage( "Executing \'" + actionName + "\' action..." );

    // in case of a multi-sequence, line arguments are bounded to first command only
    QString txt = cmd.section( '\n', 0, 0 ).trimmed();
    QString args = cmdArgs.trimmed();
    QString tail( cmd.section( '\n', 1 ).trimmed() );

    if( !args.isEmpty() )
        txt.append( ' ' + args );

    //
    // Any one-line command followed by a newline would fail
    //
    if( !tail.isEmpty() )
        txt.append( '\n' + tail );

    textLabelCmd->setText( txt );
    if( tail.isEmpty() )
    {
        proc = git->runAsync( txt, this );
    }
    else
    {
        //
        // Wrap in a script
        //
        proc = git->runAsScript( txt.append( '\n' ), this );
    }

    if( proc.isNull() )
        deleteLater();
    else
        QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );

    return !proc.isNull();
}
コード例 #14
0
ファイル: u_undo.c プロジェクト: Reborn-s/Experiment
void undo_delete(void)
{
    int		    xmin, ymin, xmax, ymax;
    char	    ctemp[PATH_MAX];

    switch (last_object) {
      case O_POLYLINE:
	list_add_line(&objects.lines, saved_objects.lines);
	redisplay_line(saved_objects.lines);
	break;
      case O_ELLIPSE:
	list_add_ellipse(&objects.ellipses, saved_objects.ellipses);
	redisplay_ellipse(saved_objects.ellipses);
	break;
      case O_TXT:
	list_add_text(&objects.texts, saved_objects.texts);
	redisplay_text(saved_objects.texts);
	break;
      case O_SPLINE:
	list_add_spline(&objects.splines, saved_objects.splines);
	redisplay_spline(saved_objects.splines);
	break;
      case O_ARC:
	list_add_arc(&objects.arcs, saved_objects.arcs);
	redisplay_arc(saved_objects.arcs);
	break;
      case O_COMPOUND:
	list_add_compound(&objects.compounds, saved_objects.compounds);
	redisplay_compound(saved_objects.compounds);
	break;
      case O_ALL_OBJECT:
	saved_objects.next = NULL;
	compound_bound(&saved_objects, &xmin, &ymin, &xmax, &ymax);
	tail(&objects, &object_tails);
	append_objects(&objects, &saved_objects, &object_tails);
	redisplay_zoomed_region(xmin, ymin, xmax, ymax);
    }
    last_action = F_ADD;
}
コード例 #15
0
void
gs_to_ps (url doc, url ps, bool landscape, double paper_h, double paper_w) {
  string cmd= gs_prefix ();
  cmd << "-dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=ps2write ";
  if (landscape)
    cmd << "-dDEVICEWIDTHPOINTS=" << as_string ((int) (28.36*paper_h+ 0.5))
      << " -dDEVICEHEIGHTPOINTS=" << as_string ((int) (28.36*paper_w+ 0.5));
  else
    cmd << "-dDEVICEWIDTHPOINTS=" << as_string ((int) (28.36*paper_w+ 0.5))
      << " -dDEVICEHEIGHTPOINTS=" << as_string ((int) (28.36*paper_h+ 0.5));

  cmd << " -sOutputFile=" << sys_concretize (ps) << " ";
  cmd << sys_concretize (doc);
  cmd << " -c \"[ /Title (" << as_string (tail(ps)) << ") /DOCINFO pdfmark\" ";

  // NOTE: when converting from pdf to ps the title of the document is 
  // incorrectly referring to the name of the temporary file
  // so we add some PS code to override the PS document title with
  // the name of the PS file.

  system (cmd);
}
コード例 #16
0
ファイル: measurement.cpp プロジェクト: CarterWeron/liborcus
length_t to_length(const pstring& str)
{
    length_t ret;
    if (str.empty())
        return ret;

    const char* p = str.get();
    const char* p_start = p;
    const char* p_end = p_start + str.size();
    ret.value = parse_numeric(p, p_end);

    // TODO: See if this part can be optimized.
    pstring tail(p, p_end-p);
    if (tail == "in")
        ret.unit = length_unit_inch;
    else if (tail == "cm")
        ret.unit = length_unit_centimeter;
    else if (tail == "pt")
        ret.unit = length_unit_point;

    return ret;
}
コード例 #17
0
// Append to list
int ListNode::append(VSLNode *list)
{
    // Search end of list
    ListNode *nprev = this;
    VSLNode *node = tail();
    while (node->isListNode())
    {
	nprev = (ListNode *)node; 
	node = nprev->tail();
    }

    // If last element != [], abort (cannot append)
    EmptyListNode empty;
    if (*node != empty)
	return -1;

    // Replace [] by LIST
    delete nprev->tail();
    nprev->tail() = list;

    return 0;
}
コード例 #18
0
// Has to be called whenever a method is compiled
void IdealGraphPrinter::begin_method(Compile* compile) {

  ciMethod *method = compile->method();
  assert(_output, "output stream must exist!");
  assert(method, "null methods are not allowed!");
  assert(!_current_method, "current method must be null!");

  head(GROUP_ELEMENT);

  head(PROPERTIES_ELEMENT);

  // Print properties
  // Add method name
  stringStream strStream;
  method->print_name(&strStream);
  print_prop(METHOD_NAME_PROPERTY, strStream.as_string());

  if (method->flags().is_public()) {
    print_prop(METHOD_IS_PUBLIC_PROPERTY, TRUE_VALUE);
  }

  if (method->flags().is_static()) {
    print_prop(METHOD_IS_STATIC_PROPERTY, TRUE_VALUE);
  }

  tail(PROPERTIES_ELEMENT);

  if (_stream) {
    char answer = 0;
    _xml->flush();
    int result = _stream->read(&answer, 1);
    _should_send_method = (answer == 'y');
  }

  this->_current_method = method;

  _xml->flush();
}
コード例 #19
0
ファイル: ListBox.C プロジェクト: Stabledog/dddbash
// Dump
void ListBox::dump(std::ostream &s) const
{
    if (VSEFlags::include_list_info)
    {
	// Dump formally
	s << "[";
	if (!isEmpty())
	    s << *head() << ":" << *tail();
	s << "]";
    }
    else
    {
	// Use cuter syntax

	s << "(";

	const ListBox *list = this;
	while (list)
	{
	    if (list->isEmpty())
	    {
		if (list->isDummyBox())
		    s << ", " << *list;
		list = 0;
	    }
	    else
	    {
		if (list != this)
		    s << ", ";

		s << *(list->head());
		list = list->tail();
	    }
	}

	 s << ")";
    }
}
コード例 #20
0
ファイル: physic.c プロジェクト: GuillaumePetit/cometbuster
void check_spaceship_collision(celestial_object *spaceship, list *asteroid_list, list *explosion_list, SDL_Surface **surfaces)
{
  list ast_tmp = *asteroid_list;
  celestial_object explosion;
  
  initExplosion(&explosion, surfaces);
  
  while (!is_empty(ast_tmp)) {
    if (collision(spaceship, &ast_tmp->object, surfaces)) {
      explosion.position.x = ast_tmp->object.position.x;
      explosion.position.y = ast_tmp->object.position.y;
      Mix_PlayChannel(2,noiseexplosion, 0);
      explosion.isExplosionOfSpaceship = true;
      *explosion_list = push(explosion, *explosion_list);
      destroy_asteroid(ast_tmp->object, asteroid_list, surfaces);
      delete(ast_tmp, asteroid_list);
      spaceship_state = DESTROY;
      
      return;
    }
    ast_tmp = tail(ast_tmp);
  }
}
int add_end_dl_list(List **list, char *str)
{
  List *newNode;
  newNode = malloc(sizeof(List));
    if (newNode == NULL) {
      return 1;
    }
  newNode->str = strdup(str);
  if (newNode->str == NULL) {
    return 1;
  }

  if (*list == NULL) {
    newNode->prev = NULL;
    *list = newNode;
  }
  else {
  newNode->prev = tail(list);
  newNode->prev->next = newNode;
  }
  newNode->next = NULL;
  return 0;
}
コード例 #22
0
ファイル: loli_output.cpp プロジェクト: ka1han/LoLi
std::string toString(loliObj* obj) {
    switch(obj->type) {
    case INT:
    case FLT:
    case SYM:
        return obj->value;
    case CONS:
        if(nilp(head(obj))) {
            return "NIL";
//			}else if(nilp(tail(obj))){
//				return "(" + toString(head(obj)) + ")";
        } else {
            return "(" + toString(head(obj)) + " . " + toString(tail(obj)) + ")";
        }
    case CHAR:
    case STRING:
        return obj->value;
    case PROC:
        return "<PROCEDURE>";
    case LAMBDA:
        return "<LAMBDA>";
    }
}
コード例 #23
0
ファイル: imi_context.cpp プロジェクト: sunpinyin/sunpinyin
std::vector<CCandidates>
CIMIContext::getBestSentenceTails(int rank, unsigned start, unsigned end)
{
    std::vector<CCandidates> result;
    if (rank < 0) {
        return result;
    }

    CCandidates sentence;
    unsigned word_num = getBestSentence(sentence, rank, start, end);
    unsigned tail_word_num = word_num;

    while (tail_word_num > 1) {
        unsigned dec = tail_word_num / (m_maxTailCandidateNum + 1) + 1;
        tail_word_num -= std::min(dec, tail_word_num);
        if (tail_word_num <= 1) {
            break;
        }
        CCandidates tail(sentence.begin(), sentence.begin() + tail_word_num);
        result.push_back(tail);
    }
    return result;
}
コード例 #24
0
ファイル: example_test.cpp プロジェクト: jiapei100/opennurbs
static const ON_String Internal_ParseOptionTail(
  const char* s
)
{
  for (;;)
  {
    if (nullptr == s || ':' != s[0] || s[1] <= ON_String::Space)
      break;
    ON_String tail(s+1);
    tail.TrimRight();
    int len = tail.Length();
    if (len < 1)
      break;
    if ('"' == tail[0] && '"' == tail[len - 1])
      tail.TrimLeftAndRight("\"");
    else if ('\'' == tail[0] && '\'' == tail[len - 1])
      tail.TrimLeftAndRight("'");
    if (tail.Length() < 1)
      break;
    return tail;
  }
  return ON_String::EmptyString;
}
コード例 #25
0
ファイル: opengl.cpp プロジェクト: shanfl/Particle111
// Emit OpenGL calls to draw the particles. These are drawn with
// whatever primitive type the user specified(GL_POINTS, for
// example). The color and radius are set per primitive, by default.
// For GL_LINES, the other vertex of the line is the velocity vector.
void pDrawGroupp(int primitive, bool const_size, bool const_color)
{
	// Get a pointer to the particles in gp memory
	ParticleGroup *pg = _ps.pgrp;
	if(pg == NULL)
		return; // ERROR
		
	if(pg->p_count < 1)
		return;

	//if(const_color)
	//	glColor4fv((GLfloat *)&pg->list[0].color);
	
	glBegin((GLenum)primitive);
	
	for(int i = 0; i < pg->p_count; i++)
	{
		Particle &m = pg->list[i];
		
		// Warning: this depends on alpha following color in the Particle struct.
		if(!const_color)
			glColor4fv((GLfloat *)&m.color);
		glVertex3fv((GLfloat *)&m.pos);
		
		// For lines, make a tail with the velocity vector's direction and
		// a length of radius.
		if(primitive == GL_LINES) {
			pVector tail(-m.vel.x, -m.vel.y, -m.vel.z);
			tail *= m.size;
			tail += m.pos;
			
			glVertex3fv((GLfloat *)&tail);
		}
	}
	
	glEnd();
}
コード例 #26
0
ファイル: Beak.cpp プロジェクト: RobertLeyland/chirpino
byte Beak::chirp(const char *chirpStr, int16_t nFrames, SynthFrame *frames) {
    static const uint32_t hPhaseStep = pgm_read_dword_near(phaseSteps + 17);
    static const uint32_t jPhaseStep = pgm_read_dword_near(phaseSteps + 19);
    uint32_t phaseStep = jPhaseStep;
    
    // check length and return warning if incorrect
    const char *cs = chirpStr;
    byte count = CHIRP_STRING_LENGTH;
    while(*cs++ && --count) {
    }
    if(count || *cs) {
        return CHIRP_STRING_LENGTH_WARNING;
    }
    
    TheSynth.beginFrameSequence(nFrames, frames);
    
    head(hPhaseStep);
    
    // all chirps start with these two tones
    append(hPhaseStep);
    append(jPhaseStep);

    while(const char code = *chirpStr++) { // assignment, not comparison
        phaseStep = phaseStepForCharCode(code);
        if(phaseStep) {
            append(phaseStep);
        }
        else {
            return BAD_CHIRP_CODE_WARNING;
        }
    }
        
    tail(phaseStep);
    TheSynth.endFrameSequence();
    
    return TheSynth.play();
}
コード例 #27
0
ファイル: test.c プロジェクト: valli22/Peter-Valli
int main(int argc, char *argv[]){
	if (argc==1) {
		fprintf(stderr, "ERROR DE ARGUMENTOS PRINCIPALES");
		return 1;
	}else{
		switch(atoi(argv[1])){
			case 1:
				head(atoi(argv[2]));
				break;
			case 2:
				tail(atoi(argv[2]));
				break;
			case 3: 
				longlines(atoi(argv[2]));
				break;
			default: 
				fprintf(stderr, "ERROR EN CASE");
				return 1;
		}
	}
	return 0;
	

}
コード例 #28
0
ファイル: gc.c プロジェクト: mounikamunipalli/hempl
/* Mark data */
static void mark(any x) {
   while (isCell(x)) {
      if (!(num(cdr(x)) & 1))
         return;
      *(long*)&cdr(x) &= ~1;
      mark(car(x)),  x = cdr(x);
   }
   if (!isNum(x)  &&  num(val(x)) & 1) {
      *(long*)&val(x) &= ~1;
      mark(val(x)),  x = tail(x);
      while (isCell(x)) {
         if (!(num(cdr(x)) & 1))
            return;
         *(long*)&cdr(x) &= ~1;
         mark(cdr(x)),  x = car(x);
      }
      if (!isTxt(x))
         do {
            if (!(num(val(x)) & 1))
               return;
            *(long*)&val(x) &= ~1;
         } while (!isNum(x = val(x)));
   }
}
コード例 #29
0
ファイル: householder.cpp プロジェクト: smarthi/libnd4j
void Householder<T>::evalHHmatrixDataI(const NDArray<T>& x, T& coeff, T& normX) {

	int rows = (int)x.lengthOf()-1;
	int num = 1;
	
	if(rows == 0) {
		rows = 1;
		num = 0;
	}	
	
	NDArray<T> tail(rows, 1, x.ordering(), x.getWorkspace());
	evalHHmatrixData(x, tail, coeff, normX);

	if(x.isRowVector()) {
		NDArray<T>* temp = x.subarray({{}, {num, x.sizeAt(1)}});
		temp->assign(tail);
		delete temp;
	}
	else {		
		NDArray<T>* temp = x.subarray({{num, x.sizeAt(0)}, {}});
		temp->assign(tail);
		delete temp;
	}
}
コード例 #30
0
ファイル: diffuse.cpp プロジェクト: CarVac/filmulator-gui
Func performBlur(Func f, Func coeff, Expr size, Expr sigma) {
    Func blurred;
    blurred(x, y) = undef<float>();

    // Warm up
    blurred(x, 0) = coeff(0) * f(x, 0);
    blurred(x, 1) = (coeff(0) * f(x, 1) +
                     coeff(1) * blurred(x, 0));
    blurred(x, 2) = (coeff(0) * f(x, 2) +
                     coeff(1) * blurred(x, 1) +
                     coeff(2) * blurred(x, 0));

    // Top to bottom
    RDom fwd(3, size - 3);
    blurred(x, fwd) = (coeff(0) * f(x, fwd) +
                       coeff(1) * blurred(x, fwd - 1) +
                       coeff(2) * blurred(x, fwd - 2) +
                       coeff(3) * blurred(x, fwd - 3));

    // Tail end
    Expr padding = cast<int>(ceil(4*sigma) + 3);
    RDom tail(size, padding);
    blurred(x, tail) = (coeff(1) * blurred(x, tail - 1) +
                        coeff(2) * blurred(x, tail - 2) +
                        coeff(3) * blurred(x, tail - 3));

    // Bottom to top
    Expr last = size + padding - 1;
    RDom backwards(0, last - 2);
    Expr b = last - 3 - backwards; // runs from last - 3 down to zero
    blurred(x, b) = (coeff(0) * blurred(x, b) +
                     coeff(1) * blurred(x, b + 1) +
                     coeff(2) * blurred(x, b + 2) +
                     coeff(3) * blurred(x, b + 3));
    return blurred;
}