list<MatrixXd> Covariances::access(const node_pair_list_t& node_pair_list) const {
  const SparseSystem& R = (_slam==NULL) ? _R : _slam->_R;
  if (_slam) {
    _slam->update_starts();
  }

  if (R.num_rows()>1) { // skip if _R not calculated yet (eg. before batch step)

    // count how many entries in requested blocks
    int num = 0;
    for (node_pair_list_t::const_iterator it = node_pair_list.begin();
         it != node_pair_list.end(); it++) {
      num += get_dim(it->first) * get_dim(it->second);
    }

    // request individual covariance entries
    vector < pair<int, int> > index_list(num);
    const int* trans = R.a_to_r();
    int n = 0;
    for (node_pair_list_t::const_iterator it = node_pair_list.begin();
         it != node_pair_list.end(); it++) {
      int start_r = get_start(it->first);
      int start_c = get_start(it->second);
      int dim_r = get_dim(it->first);
      int dim_c = get_dim(it->second);
      for (int r=0; r<dim_r; r++) {
        for (int c=0; c<dim_c; c++) {
          index_list[n] = make_pair(trans[start_r + r], trans[start_c + c]);
          n++;
        }
      }
    }
    list<double> covs = cov_marginal(R, _cache, index_list);

    // assemble into block matrices
    list<MatrixXd> result;
    list<double>::iterator it_cov = covs.begin();
    for (node_pair_list_t::const_iterator it = node_pair_list.begin();
         it != node_pair_list.end(); it++) {
      int dim_r = get_dim(it->first);
      int dim_c = get_dim(it->second);
      MatrixXd matrix(dim_r, dim_c);
      for (int r=0; r<dim_r; r++) {
        for (int c=0; c<dim_c; c++) {
          matrix(r,c) = *it_cov;
          it_cov++;
        }
      }
      result.push_back(matrix);
    }
    return result;
  }
  list<MatrixXd> empty_list;
  return empty_list;
}
Exemple #2
0
void tty(void){
	oprintf("try to mount device1:partation:3:%s\n",mount("/mnt/",1,3)?"success":"failed");
	int crt_start;
	__asm__("cli");
	loadbuf=kmalloc(SIZE_LOAD_BUF);
	oprintf("tty running..welcome^.^\n");
	buff=kmalloc(23);
	for(int j=0;j<0;j++){
		oprintf("j=%u,i will do open\n",j);
//		int fd=open("/mnt/home/wws/dimg",0);
		int fd=open("/mnt/short");
		oprintf("fd:%u,inode:%u\n",fd,fd_table[fd].inode);
		int newseek=lseek(fd,-2,2);
		int r_bytes=read(fd,tmp,7);
		oprintf("r_bytes:%u,newseek:%u\n",r_bytes,newseek);
//		while(1);
	}
	while(1){
new_prompt:
		reset_cmd_asciis();
		memsetw((u16*)loadbuf,SIZE_LOAD_BUF/2,0);
		oprintf("#   ");
wait_input:
		while(1){
			unsigned ascii=getchar();
			switch(ascii){
				case 128://ctrl+l
					k_screen_reset();
					goto new_prompt;
				case 129://ctrl+c
					kill(front_pid);
					oprintf("^C\n");
					goto new_prompt;
				case 130://ctrl+u
					crt_start=get_start();
					set_start(crt_start>=80?crt_start-80:crt_start);
					goto wait_input;
				case 131://ctrl+d
					crt_start=get_start();
					set_start(crt_start<(80*24*4-1)?crt_start+80:crt_start);
					goto wait_input;
			}
			oprintf("%c",ascii);//oprintf函数有能力打印控制字符,但更多的ctrl,shift组合还要跟进
			if(ascii=='\n'){//回车符执行命令
				parse_cmd_asciis();
				break;
			}
			//执行到这儿,说明是普通输入,写入cmd_asciis
			write_cmd_asciis(ascii);
		}
	}
}
Exemple #3
0
 int get_end (int rank) {
   /* computer row divisions to each proc */
   int p,per_proc,remainder,end_row;
   MPI_Comm_size(MPI_COMM_WORLD,&p);  
   per_proc = (int)floor(HEIGHT/H)/p;
   remainder = (int)floor(HEIGHT/H)%p;
   if (rank < remainder) {
     end_row = get_start(rank) + per_proc;
   } else {
     end_row = get_start(rank) + per_proc - 1;
   }
   return end_row;
 }
Exemple #4
0
static int	start_end(char *line, t_env *e)
{
	if (!ft_strcmp(line, "start"))
	{
		if (!e->start)
		{
			get_start(e);
			e->start = 1;
			return (1);
		}
		else
			return (ft_putstr_error("Error, multiple start.\n"));
	}
	else if (!ft_strcmp(line, "end"))
	{
		if (!e->end)
		{
			get_end(e);
			e->end = 1;
			return (1);
		}
		else
			return (ft_putstr_error("Error, multiple end.\n"));
	}
	else
		return (ft_putstr_error("Error, bad comment.\n"));
}
 size_t WaveletTreeNoptrs::select(uint symbol, size_t j) const
 {
     symbol = am->map(symbol);
     uint mask = (1<<height)-2;
     uint sum=2;
     uint level = height-1;
     size_t pos=j;
     while(true) {
         size_t start = get_start(symbol,mask);
         size_t end = min((size_t)max_v+1,start+sum);
         start = (start==0)?0:(occ->select1(start)+1);
         end = occ->select1(end+1)-1;
         if(is_set(symbol,level)) {
             uint ones_start = bitstring[level]->rank1(start-1);
             pos = bitstring[level]->select1(ones_start+pos)-start+1;
         }
         else {
             uint ones_start = bitstring[level]->rank1(start-1);
             pos = bitstring[level]->select0(start-ones_start+pos)-start+1;
         }
         mask <<=1;
         sum <<=1;
         if(level==0) break;
         level--;
     }
     return pos-1;
 }
Exemple #6
0
int			ft_atoi(char *s)
{
	int		cnt;
	int		out_int;
	int		is_signed;

	out_int = 0;
	is_signed = 0;
	cnt = get_start(s);
	if (cnt == -1)
		return (0);
	if (s[cnt] == '-')
	{
		if (ft_isdigit(s[cnt + 1]) == 0)
			return (0);
		is_signed = 1;
		cnt++;
	}
	while (ft_isdigit(s[cnt]) == 1)
	{
		out_int = out_int * 10 + (s[cnt] - '0');
		cnt++;
	}
	if (is_signed == 1)
		out_int = -out_int;
	return (out_int);
}
void		iter_for_len(t_item *items, t_args *args, int directory)
{
	t_item *start;

	start = NULL;
	set_sd_props(args);
	if (items)
	{
		start = get_start(items);
		while (items)
		{
			if (directory == 0 && items->child == NULL)
			{
				get_max_len(items, args);
				args->sd->nb_items++;
			}
			else
			{
				get_max_len(items, args);
				args->sd->nb_items++;
			}
			items = items->next;
		}
		items = start;
		start = NULL;
	}
}
list<MatrixXd> Covariances::marginal(const node_lists_t& node_lists) const {
  const SparseSystem& R = (_slam==NULL) ? _R : _slam->_R;
  if (_slam) {
    _slam->update_starts();
  }

  vector < vector<int> > index_lists(node_lists.size());

  if (R.num_rows()>1) { // skip if _R not calculated yet (eg. before batch step)
    int n=0;
    const int* trans = R.a_to_r();
    for (node_lists_t::const_iterator it_list = node_lists.begin();
        it_list != node_lists.end();
        it_list++, n++) {
      // assemble list of indices
      vector<int> indices;
      for (list<Node*>::const_iterator it = it_list->begin(); it!=it_list->end(); it++) {
        Node* node = *it;
        int start = get_start(node);
        int dim = get_dim(node);
        for (int i=0; i<dim; i++) {
          index_lists[n].push_back(trans[start+i]);
        }
      }
    }
    return cov_marginal(R, _cache, index_lists);
  }
  list<MatrixXd> empty_list;
  return empty_list;
}
Exemple #9
0
void AssocContainCanvas::remove(bool from_model) {
  if (!from_model) {
    if (the_canvas()->must_draw_all_relations()) {
      const AssocContainCanvas * a = this;
  
      while (a->begin->type() == UmlArrowPoint) {
	a = (AssocContainCanvas *) ((ArrowPointCanvas *) a->begin)->get_other(a);
	if (a == 0)
	  break;
      }

      if (a && !a->begin->isSelected() && !a->begin->get_bn()->deletedp()) {
	a = this;
  
	while (a->end->type() == UmlArrowPoint) {
	  a = (AssocContainCanvas *) ((ArrowPointCanvas *) a->end)->get_other(a);
	  if (a == 0)
	    break;
	}
  
	if (a && !a->end->isSelected() && !a->end->get_bn()->deletedp()) {
	  msg_warning("Bouml", TR("<i>Draw all relations</i> forced to <i>no</i>"));
	  the_canvas()->dont_draw_all_relations();
	}
      }
    }
    delete_it();
  }
  else
    get_start()->unassociate(get_end());	// line will be deleted
}
Exemple #10
0
// Movimiento de la partida de caza hacia el patch destino
int move_hunters ()
{
	int x = get_x(), y = get_y(), guanacos;

	// Si estoy cazando no me muevo del patch
	if (get_start() == 1)
		return 0;

	// Change the patch
	// Avanzar en x
	if (x != DESTINY[0])
		x = (x>DESTINY[0]) ? x-1:x+1;
	// Avanzar en y
	else if (y != DESTINY[1])
		y = (y>DESTINY[1]) ? y-1:y+1;
	// Llegada al objetivo
	else
		set_arrive(1);
	// Asks guanacos number to the new patch
	add_numGuanacos_message (x,y);
/*	// Recive num of guanacos
	START_INFOGUANACOS_MESSAGE_LOOP
		guanacos = infoGuanacos_message->amount;
	FINISH_INFOGUANACOS_MESSAGE_LOOP
	// si hay guanacos comenzar la caza
	if (guanacos > 0)
		set_start(1);
	// Sino y se ha llegado al destino, acabar la caza
	else if (get_arrive() == 1 )
		set_end(1);*/
	set_x(x);
	set_y(y);
	printf("movido\n");
	return 0;
}
Exemple #11
0
void set_steps(){
	GtkTextBuffer *s = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_step));
	
	char *buf = get_start();
	if(buf != NULL) {
		gtk_text_buffer_set_text(s, buf, -1);
	}
}
Exemple #12
0
int main(int argc, char** argv) {
	get_data(argv[1]);
	get_start();
	plPlotter* plotter = setUp();

	orbitPlot(plotter);
	
	cleanUp(plotter);
	return 0;
}
Exemple #13
0
void Nwindow::print_line(string line, COLOR c){
	int aspace = get_end(line);
        int bspace = get_start(line);

	//assert(bspace >= 0 &&  aspace >= 0);
	int prev_x = pos_x;
	move(pos_y,pos_x + bspace);
	print_color(line.substr(bspace,line.length() - aspace),c);
	move(pos_y +1,prev_x);
}
bool Dfa::match(const string &str) {
    Node* u = get_start();
    auto len = str.length();
    decltype(len) i;
    for(i=0;i<len;++i){
        char c = static_cast<char>(str[i]);
        if(nullptr == u->next(c)) return false;
        u = u->next(c);
    }
    return u->is_end_node();
}
Exemple #15
0
 void init_domain (float ** domain_ptr,int rank) {
   int i,j,start,end,rows;
   start = get_start(rank);
   end = get_end(rank);
   rows = get_num_rows(rank);

   for (j=start;j<end;j++) {
     for (i=0;i<(int)floor(WIDTH/H);i++) {
       domain_ptr[j-start][i] = 0.0;
     }
   }
 }
Exemple #16
0
t_env	*get_env_by_value(char *name, t_env *env)
{
	env = get_start(env);
	while (env)
	{
		if (ft_strcmp(name, env->name) == 0)
		{
			return (env);
		}
		env = env->next;
	}
	return (NULL);
}
void		add_link(t_item **alist, t_item *new_link, int end)
{
	if (*alist && new_link)
	{
		if (end == 0)
		{
			if ((*alist)->prev)
				*alist = get_start(*alist);
			new_link->next = *alist;
			(*alist)->prev = new_link;
			*alist = new_link;
		}
		else
		{
			if ((*alist)->next)
				*alist = get_end(*alist);
			new_link->prev = *alist;
			(*alist)->next = new_link;
			*alist = get_start(new_link);
		}
	}
}
t_env	*find_and_cut(t_env *env, char *name)
{
	while (env)
	{
		if (ft_strcmp(env->name, name) == 0)
		{
			env = cut_list(env);
		}
		if (env->next)
			env = env->next;
		else
			break ;
	}
	return (get_start(env));
}
Exemple #19
0
 float get_convergence_sqd (float ** current_ptr,float ** next_ptr,int rank) {
    int i,j,my_start,my_end,my_num_rows;
    float sum;
    
    my_start = get_start(rank);
    my_end = get_end(rank);
    my_num_rows = get_num_rows(rank);
 
    sum = 0.0;
    for (j=my_start;j<=my_end;j++) {
      for (i=0;i<(int)floor(WIDTH/H);i++) {
        sum += pow(next_ptr[global_to_local(rank,j)][i]-current_ptr[global_to_local(rank,j)][i],2);
      }
    }
    return sum;   
 }
void* precomp_pthread_func(void* args)
{
    precomp_thread_args targs = get_data(precomp_thread_args,args);
    int** mat = targs.mat;
    int** ps = targs.ps;
    int dim = targs.dim;

    for(int j=get_start(args); j<get_end(args); j++)
    {
        ps[0][j] = mat[0][j];
        for (int i=1; i<dim; i++)
        {
            ps[i][j] = ps[i-1][j] + mat[i][j];
        }
    }
}
Exemple #21
0
int	main(int ac, char **av)
{
	t_args	*args;
	int		ret;
	t_item	*items;

	args = NULL;
	ret = 0;
	items = NULL;
	args = ft_get_args(ac, av);
	items = get_start(args->items);
	if (args->options->R == 0)
		args->options->l ? long_display(items, args) : short_display(items, args);
	ret = args->ret;
	clean_program(&args);
	return (ret);
}
Exemple #22
0
unsigned long ContextTrie::get_context_totals() {
	if (vine == -2) {
		vine = get_start();
		last = -1;
		exclusion_pos = 0;
	} else if (vine == -1) {
		return Settings::SYMBOLS + 2;
	}
	max_index = exclusion_pos;
	unsigned long context_totals = 0;   /* the cummulative count */
	for (int i = nodes[vine].down; i != -1; i = nodes[i].right) {
		if (!search_exclusion(nodes[i].symbol, max_index)) {
			context_totals += nodes[i].count;
			exclusion_list[exclusion_pos++] = nodes[i].symbol;
		}
	}
	return context_totals + 1;  /* include teh escape symbol */
}
Exemple #23
0
int     main(int ac, char **av)
{
    t_args      *args;
    t_item      *cursor;

    args = ft_get_args(ac, av);
    cursor = get_start(args->items);
    if (cursor->child)
    {
        cursor = cursor->child;
        while (cursor)
        {
            printf("%s\n", cursor->name);
            cursor = cursor->next;
        }
    }
    clean_program(&args);
    return (0);
}
Exemple #24
0
 float get_val_par (float * above_ptr,float ** domain_ptr,float * below_ptr,int rank,int i,int j) {
   float ret_val;
   int p;
      
   MPI_Comm_size(MPI_COMM_WORLD,&p); 
   /* enforce bc's first */
   if(i == ((int)floor(WIDTH/H/2)-1) && j == 0) {
     /* This is the heat source location */
     ret_val = T_SRC0;
   } else if (i <= 0 || j <= 0 || i >= ((int)floor(WIDTH/H)-1) || j >= ((int)floor(HEIGHT/H)-1)) {
     /* All edges and beyond are set to 0.0 */
     ret_val = 0.0;
   } else {
     /* Else, return value for matrix supplied or ghost rows */
     if (j < get_start(rank)) {
       if (rank == ROOT) {
         /* not interested in above ghost row */
         ret_val = 0.0;
       } else { 
         ret_val = above_ptr[i];
	 /*printf("%d: Used ghost (%d,%d) row from above = %f\n",rank,i,j,above_ptr[i]);
	 fflush(stdout);*/
       }
     } else if (j > get_end(rank)) {
       if (rank == (p-1)) {
         /* not interested in below ghost row */
         ret_val = 0.0;
       } else { 
         ret_val = below_ptr[i];
	 /*printf("%d: Used ghost (%d,%d) row from below = %f\n",rank,i,j,below_ptr[i]);
	 fflush(stdout);*/
       }     
     } else {
       /* else, return the value in the domain asked for */
       ret_val = domain_ptr[global_to_local(rank,j)][i];
       /*printf("%d: Used real (%d,%d) row from self = %f\n",rank,i,global_to_local(rank,j),domain_ptr[global_to_local(rank,j)][i]);
       fflush(stdout);*/
     }
   }
   return ret_val;

 }
t_env		*build_env_list(char **environ)
{
	t_env	*env;

	env = NULL;
	if (ft_str2len(environ) == 0)
	{
		env = manage_empty_environ();
	}
	else
	{
		while (*environ)
		{
			if (ft_strncmp("OLDPWD", *environ, 6) != 0)
				env = create_env_link(env, *environ);
			environ++;
		}
	}
	return (get_start(env));
}
Exemple #26
0
void		replay_directory(t_item *items, t_args *args)
{
	t_item 	*start;
	int		i;
	
	start = NULL;
	start = get_start(items);
	i = 0;
	while (items)
	{
		if (items->child)
		{
			if (i == 1)
				ft_putchar('\n');
			ft_get_items(args, items->name, 1);
			i = 1;
		}
		items = items->next;
	}
	del_list(&start, 0);
}
Exemple #27
0
      // Extract an object x of the Target type from the first Python
      // argument, and invoke get_start(x)/get_finish(x) to produce
      // iterators, which are used to construct a new iterator_range<>
      // object that gets wrapped into a Python iterator.
      static PyObject* create(
          Accessor1 const& get_start, Accessor2 const& get_finish
          , PyObject* args_, PyObject* /*kw*/)
      {
          // Make sure the Python class is instantiated.
          detail::demand_iterator_class("iterator", (Iterator*)0, NextPolicies());

          to_python_value<iterator_range<NextPolicies,Iterator> > cr;

          // Extract x from the first argument
          PyObject* arg0 = PyTuple_GET_ITEM(args_, 0);
          arg_from_python<Target> c0(arg0);
          if (!c0.convertible()) return 0;
          typename arg_from_python<Target>::result_type x = c0(arg0);

          // Build and convert the iterator_range<>.
          return cr(
              iterator_range<NextPolicies,Iterator>(
                  object((python::detail::borrowed_reference)arg0)
                  , get_start(x), get_finish(x)));
      }
Exemple #28
0
inline static int lua_fastsearch_wrap(lua_State *L, int mode) {
    size_t string_len;
    const char *string = luaL_checklstring(L, 1, &string_len);

    size_t token_len;
    const char *token = luaL_checklstring(L, 2, &token_len);
    
    int nargs = lua_gettop(L);
    int start = get_start(L, nargs, string_len);
    int end = get_end(L, nargs, string_len);
    if (start > end){ return -1; }

    string_len = end - start; 
    int val = fastsearch(string + start, string_len,
                            token, token_len, -1, mode);
    if (mode == FAST_COUNT) { return val; }

    if(val == -1) { return val; }
    int r = val + ((start > 0) ? start  : 0);
    return r;
}
Exemple #29
0
bool ContextTrie::add_by_symbol(int s, unsigned long* sym_low, unsigned long* sym_high, unsigned long* context_totals) {
	/* Vine pointer for current addition. -2 means new search with new symbol, -1 means that the
	 * model fell off to the order special order -1 model, i.e. it  has not been found neither in
	 * any context nor as a standalone character. */
	if (vine == -2) {  /* if new search, determine the new value of vine */
		vine = get_start();
		last = -1;
		exclusion_pos = 0;
	} else if (vine == -1) {
		*sym_low = s;
		*sym_high = s + 1;
		*context_totals = Settings::SYMBOLS + 2;  /* including eof marker and flush marker */
		assert(last != -1);
		nodes[last].vine = 0;
		vine = -2;
		return true;
	}
	long n = search_by_symbol(vine, s, sym_low, sym_high, context_totals);
	if (n == -1) {
		nodes[insert_node].set(s, 1, -1, nodes[vine].down, -1);
		nodes[vine].down = insert_node;
		if (last == -1)
			base = insert_node;
		else
			nodes[last].vine = insert_node;
		last = insert_node;
		vine = nodes[vine].vine;
		insert_node++;
		return false;
	} else {
		nodes[n].count++;
		if (last == -1)
			base = n;
		else
			nodes[last].vine = n;
		vine = -2;
		return true;
	}
}
Exemple #30
0
void CodLinkCanvas::menu(const QPoint&) {
  bool new_dirs;
  CodDirsCanvas * d = find_dirs();
  CodObjCanvas * from;
  CodObjCanvas * to;

  get_start_end(from, to);
  
  if (d == 0) {
    new_dirs = TRUE;
    (d = dirs = new CodDirsCanvas(the_canvas(), this, 0))->show();
  }
  else
    new_dirs = FALSE;
  
  Q3PopupMenu m;
  Q3PopupMenu geo;
  
  m.insertItem(new MenuTitle(TR("Link"), m.font()), -1);
  m.insertSeparator();
  m.insertItem(TR("add messages to ") + from->get_full_name(), 1);
  m.insertItem(TR("add messages to ") + to->get_full_name(), 2);
  m.insertSeparator();
  m.insertItem(TR("Edit its messages"), 3);
  m.insertItem(TR("Edit all the messages"), 4);
  m.insertSeparator();
  m.insertItem(TR("Select linked items"), 7);
  m.insertSeparator();
  if (!new_dirs) {
    m.insertItem(TR("Edit drawing settings"), 5);
    m.insertSeparator();
  }
  if (get_start() != get_end()) {
    init_geometry_menu(geo, 10);
    m.insertItem(TR("Geometry (Ctrl+l)"), &geo);
    m.insertSeparator();
  }
  m.insertItem(TR("Remove from diagram"), 6);
  
  int rank = m.exec(QCursor::pos());
  
  switch (rank) {
  case 1:
    {
      CodAddMsgDialog dialog(to, from, d,
			     (ColDiagramView *) the_canvas()->get_view(),
			     FALSE);
      
      dialog.raise();
      if (dialog.exec() != QDialog::Accepted)
	return;
    }
    break;
  case 2:
    {
      CodAddMsgDialog dialog(from, to, d,
			     (ColDiagramView *) the_canvas()->get_view(),
			     TRUE);
      
      dialog.raise();
      if (dialog.exec() != QDialog::Accepted)
	return;
    }
    break;
  case 3:
    CodEditMsgDialog::exec((ColDiagramView *) the_canvas()->get_view(), d->get_msgs());
    return;
  case 4:
    CodEditMsgDialog::exec((ColDiagramView *) the_canvas()->get_view(),
			   ((ColDiagramView *) the_canvas()->get_view())->get_msgs());
    return;
  case 5:
    if (d->edit_drawing_settings())
      modified();
    return;
  case 6:
    delete_it();
    ((ColDiagramView *) the_canvas()->get_view())->update_msgs();
    break;
  case 7:
    select_associated();
    return;
  default:
    if (rank >= 10) {
      rank -= 10;
      if (rank == RecenterBegin)
	set_decenter(-1.0, decenter_end);
      else if (rank == RecenterEnd)
	set_decenter(decenter_begin, -1.0);
      else if (rank != (int) geometry)
	set_geometry((LineGeometry) rank, TRUE);
      else
	return;
    }
    else
      return;
  }
  
  package_modified();
  
  if (new_dirs && (dirs != 0)) {
    if (dirs->get_msgs().count() == 0) {
      dirs->delete_it();
      dirs = 0;
    }
    else
      dirs->update_pos(beginp, endp);
  }
}