Пример #1
0
void TChain::get_best(std::vector<double> &x) const {
	unsigned int i_max = get_index_of_best();
	const double *best = get_element(i_max);
	x.clear();
	for(size_t i=0; i<N; i++) {
		x.push_back(best[i]);
	}
}
Пример #2
0
			/**
			 * @brief Get node.
			 *
			 * Returns the pointer of the node at the given
			 * position.
			 * @param index The index of the node.
			 * @return The pointer of the node.
			 */
			inline RStarTreeNodeSharedPtr get_node(
				const Uint32 index) const noexcept
			{
				assert(!get_leaf());

				return boost::dynamic_pointer_cast<
					RStarTreeNode>(get_element(index));
			}
Пример #3
0
Path get_path(const hdf5::node::Node &node)
{
  Path path;
  path.filename(node.link().file().path()); //set the path to the file

  hdf5::node::Node current_node = node.link().file().root();
  path.push_back(get_element(current_node));

  for(auto node_name: node.link().path())
  {
    if(current_node.type() == hdf5::node::Type::GROUP)
      current_node = hdf5::node::Group(current_node).nodes[node_name];

    path.push_back(get_element(current_node));
  }
  return path;
}
Пример #4
0
void _sort_matrix_rows(struct matrix M) {
	int i,j;
	for (i=1; i <= M.rows; i++) {
		for(j=1; j <= M.rows-1; j++) {
			for(int col = 1; col <= M.columns; col++) {
				if ( r_greater(get_element(M,j+1,col), get_element(M,j,col)) ) {
					_switch_rows(M, j+1, j);
					break;
				}
				if ( r_less(get_element(M,j+1,col), get_element(M,j,col)) ) {
					break;
				}
			}
		}
	}
	return;
}
Пример #5
0
struct matrix subtract(struct matrix A, struct matrix B) {
	set_error(NONE);
	struct matrix C;
	int i,j;
	if (A.rows == B.rows && A.columns == B.columns){
		C = new_matrix(A.rows, B.columns);
		for (i=1; i<=C.rows; i++) {
			for (j=1; j<=C.columns; j++) {
				set_element(C, i, j, r_subtract(get_element(A,i,j), get_element(B,i,j)));
			}
		}
	} else {
		C = new_matrix(0,0);
		set_error(INCOMPATIBLE_MATRIX);
	}
	return C;
}
Пример #6
0
 void Parent::textbox_add(int id){
   get_element(tex,gui::Textbox,gui::GUI_TYPE::TEXTBOX,id);
   if (tex.parent_id != -1){
     SHOW_ERROR("BasicGUI: Textbox with ID "+to_string(id)+" already has a parent with ID "+to_string(tex.parent_id)+"! Parenting not done!\n");
   }
   child_elements.push_back(id);
   tex.parent_id = element_id;
 }
Пример #7
0
            /**
             * Remove the given Id from the set.
             *
             * @param id The Id to set.
             */
            void unset(T id) {
                auto& element = get_element(id);

                if ((element & bitmask(id)) != 0) {
                    element &= ~bitmask(id);
                    --m_size;
                }
            }
Пример #8
0
struct rational determinant(struct matrix M){
	set_error(NONE);
	struct rational det = int_to_r(0);
	if (M.rows == M.columns) {
		if(M.rows > 2) {
			for(int i=1; i<= M.rows; i++) {
				//alternate adding and subtracting
				if ((i%2) == 1 ) {
					struct matrix pos_subm = submatrix(M,i,1);
					det = r_add(det, r_multiply(get_element(M,i,1), determinant(pos_subm)));
					free_matrix(pos_subm);
				} else {
					struct matrix neg_subm = submatrix(M,i,1);
					det = r_subtract(det, r_multiply(get_element(M,i,1), determinant(neg_subm)));
					free_matrix(neg_subm);
				}
			}
		}
		if(M.rows == 2) {
			det = r_subtract (	r_multiply(get_element(M,1,1), get_element(M,2,2)),
								r_multiply(get_element(M,1,2), get_element(M,2,1)));
		}
		if(M.rows == 1) {
			det = get_element(M,1,1);
		}
	} else {
		det = int_to_r(-1);
		set_error(INCOMPATIBLE_MATRIX);
	}
	return det;
}
Пример #9
0
void *list_get_top(list_t l)
{
	void *top = NULL;

	if (l.nb_elements > 0)
		top = get_element(&l, l.head);

	return top;
}
Пример #10
0
std::shared_ptr<class attribute_info> attribute::parse(class file& file, class cp& cp)
{
	uint16_t index = file.read<uint16_t>();
	std::string name = cp.get<class CONSTANT_Utf8_info>(index)->value;

	file.read<uint32_t>();

	return get_element(file, cp, name);
}
Пример #11
0
 void Parent::textbox_remove(int id){
   check_element(gui::GUI_TYPE::TEXTBOX,id);
   auto it = find(child_elements.begin(), child_elements.end(), id);
   if (it != child_elements.end()){
     get_element(tex,gui::Textbox,gui::GUI_TYPE::TEXTBOX,id);
     child_elements.erase(it);
     tex.parent_id = -1;
   }
 }
Пример #12
0
 void Parent::label_remove(int id){
   check_element(gui::GUI_TYPE::LABEL,id);
   auto it = find(child_elements.begin(), child_elements.end(), id);
   if (it != child_elements.end()){
     get_element(lab,gui::Label,gui::GUI_TYPE::LABEL,id);
     child_elements.erase(it);
     lab.parent_id = -1;
   }
 }
Пример #13
0
T* safe_queue_t<T>::poll_element()
{
    // 获取并从队列中摘除
    T* element = get_element(true, -1);

    assert(element != NULL);

    return element;
}
Пример #14
0
 void Parent::scrollbar_remove(int id){
   check_element(gui::GUI_TYPE::SCROLLBAR,id);
   auto it = find(child_elements.begin(), child_elements.end(), id);
   if (it != child_elements.end()){
     get_element(scr,gui::Scrollbar,gui::GUI_TYPE::SCROLLBAR,id);
     child_elements.erase(it);
     scr.parent_id = -1;
   }
 }
Пример #15
0
 void Parent::toggle_remove(int id){
   check_element(gui::GUI_TYPE::TOGGLE,id);
   auto it = find(child_elements.begin(), child_elements.end(), id);
   if (it != child_elements.end()){
     get_element(tog,gui::Toggle,gui::GUI_TYPE::TOGGLE,id);
     child_elements.erase(it);
     tog.parent_id = -1;
   }
 }
Пример #16
0
 void Parent::button_remove(int id){
   check_element(gui::GUI_TYPE::BUTTON,id);
   auto it = find(child_elements.begin(), child_elements.end(), id);
   if (it != child_elements.end()){
     get_element(but,gui::Button,gui::GUI_TYPE::BUTTON,id);
     child_elements.erase(it);
     but.parent_id = -1;
   }
 }
Пример #17
0
void trans_grid(void) {
    for (int i = 0; i < size_of_column - 1; ++i)
        for (int j = 0; j < size_of_line - 1; ++j) {
            int a = grid[i][j];
            int b = grid[i][j+1];
            int c = grid[i+1][j];
            grid_transformed[i][j] = get_element(a, b, c);
        }   
}
Пример #18
0
 void Parent::window_remove(int id){
   check_element(gui::GUI_TYPE::WINDOW,id);
   auto it = find(child_elements.begin(), child_elements.end(), id);
   if (it != child_elements.end()){
     get_element(win,gui::Window,gui::GUI_TYPE::WINDOW,id);
     child_elements.erase(it);
     win.parent_id = -1;
   }
 }
Пример #19
0
 void Parent::slider_remove(int id){
   check_element(gui::GUI_TYPE::SLIDER,id);
   auto it = find(child_elements.begin(), child_elements.end(), id);
   if (it != child_elements.end()){
     get_element(sli,gui::Slider,gui::GUI_TYPE::SLIDER,id);
     child_elements.erase(it);
     sli.parent_id = -1;
   }
 }
Пример #20
0
static void apply_one_offset( struct brw_clip_compile *c,
			  struct brw_indirect vert )
{
   struct brw_compile *p = &c->func;
   struct brw_reg pos = deref_4f(vert, c->offset[VERT_RESULT_HPOS]);
   struct brw_reg z = get_element(pos, 2);

   brw_ADD(p, z, z, vec1(c->reg.offset));
}
int main(int argc, char* argv[])
{
  int a[] = {1,2,3,4,5};
  s_node* root = create_linked_list(a,sizeof(a)/sizeof(a[0]));
  s_node* r = get_element(root, 3);
  print_linked_list(r);
  clear_linked_list(root);
  return 0;
}
Пример #22
0
struct matrix transpose(struct matrix M) {
	struct matrix transpose = new_matrix(M.columns, M.rows);
	for (int i=1; i<=M.columns; i++) {
		for (int j=1; j<=M.rows; j++) {
			set_element(transpose,i,j, get_element(M,j,i));
		}
	}
	return transpose;
}
void
ndb_mutex_destoyed(NdbMutex* p)
{
  unsigned no = p->m_mutex_state->m_no;

  /**
   * In order to be able to reuse mutex_no,
   *   we need to clear this no from all mutexes that has it in before map...
   *   this is all mutexes in after map
   */
  for (unsigned i = 0; i<p->m_mutex_state->m_locked_after_list.m_used; i++)
  {
    NdbMutex * m = get_element(&p->m_mutex_state->m_locked_after_list, i);
    assert(check_bit(&p->m_mutex_state->m_locked_after_mask, m->m_mutex_state->m_no));

    /**
     * And we need to lock it while doing this
     */
    NdbMutex_Lock(m);
    assert(check_bit(&m->m_mutex_state->m_locked_before_mask, no));
    clear_bit(&m->m_mutex_state->m_locked_before_mask, no);
    remove_mutex_from_array(&m->m_mutex_state->m_locked_before_list, p);
    NdbMutex_Unlock(m);
  }

  /**
   * And we need to remove ourselfs from after list of mutexes in out before list
   */
  for (unsigned i = 0; i<p->m_mutex_state->m_locked_before_list.m_used; i++)
  {
    NdbMutex * m = get_element(&p->m_mutex_state->m_locked_before_list, i);
    NdbMutex_Lock(m);
    assert(check_bit(&m->m_mutex_state->m_locked_after_mask, no));
    clear_bit(&m->m_mutex_state->m_locked_after_mask, no);
    remove_mutex_from_array(&m->m_mutex_state->m_locked_after_list, p);
    NdbMutex_Unlock(m);
  }

  release(&p->m_mutex_state->m_locked_before_mask);
  release(&p->m_mutex_state->m_locked_before_list);
  release(&p->m_mutex_state->m_locked_after_mask);
  release(&p->m_mutex_state->m_locked_after_list);
  release_mutex_no(no);
}
Пример #24
0
int list_add_element(list_t * l, void *element)
{

	int ret = 1;
	int i = 0, j = 0;

	if (l->nb_elements < l->max_elements) {
		/* Insertion de l'élément dans le tableau de données */
		while (l->link_array[i] != EMPTY_SLOT)
			i++;
		memcpy(get_element(l, i), element, l->elements_size);

		/* Si la liste est vide */
		if (l->nb_elements == 0) {
			l->link_array[i] = END_SLOT;
			l->head = i;
		}
		/* Si l'élément se place en tête */
		else if (l->comparator(element, get_element(l, l->head)) <= 0) {
			l->link_array[i] = l->head;
			l->head = i;
		} else {
			j = l->head;
			/* On cherche la position du nouvel élément */

			while (l->link_array[j] != END_SLOT
			       && l->comparator(element,
						get_element(l,
							    l->link_array[j])) >
			       0) {
				j = l->link_array[j];
			}

			/* Et on fait le lien */
			l->link_array[i] = l->link_array[j];
			l->link_array[j] = i;

		}
		l->nb_elements++;

		ret = 0;
	}
	return ret;
}
Пример #25
0
static void copy_bfc( struct brw_clip_compile *c )
{
   struct brw_compile *p = &c->func;
   GLuint conditional;

   /* Do we have any colors to copy?
    */
   if (!(brw_clip_have_varying(c, VARYING_SLOT_COL0) &&
         brw_clip_have_varying(c, VARYING_SLOT_BFC0)) &&
       !(brw_clip_have_varying(c, VARYING_SLOT_COL1) &&
         brw_clip_have_varying(c, VARYING_SLOT_BFC1)))
      return;

   /* In some wierd degnerate cases we can end up testing the
    * direction twice, once for culling and once for bfc copying.  Oh
    * well, that's what you get for setting wierd GL state.
    */
   if (c->key.copy_bfc_ccw)
      conditional = BRW_CONDITIONAL_GE;
   else
      conditional = BRW_CONDITIONAL_L;

   brw_CMP(p,
	   vec1(brw_null_reg()),
	   conditional,
	   get_element(c->reg.dir, 2),
	   brw_imm_f(0));

   brw_IF(p, BRW_EXECUTE_1);
   {
      GLuint i;

      for (i = 0; i < 3; i++) {
	 if (brw_clip_have_varying(c, VARYING_SLOT_COL0) &&
             brw_clip_have_varying(c, VARYING_SLOT_BFC0))
	    brw_MOV(p,
		    byte_offset(c->reg.vertex[i],
                                brw_varying_to_offset(&c->vue_map,
                                                      VARYING_SLOT_COL0)),
		    byte_offset(c->reg.vertex[i],
                                brw_varying_to_offset(&c->vue_map,
                                                      VARYING_SLOT_BFC0)));

	 if (brw_clip_have_varying(c, VARYING_SLOT_COL1) &&
             brw_clip_have_varying(c, VARYING_SLOT_BFC1))
	    brw_MOV(p,
		    byte_offset(c->reg.vertex[i],
                                brw_varying_to_offset(&c->vue_map,
                                                      VARYING_SLOT_COL1)),
		    byte_offset(c->reg.vertex[i],
                                brw_varying_to_offset(&c->vue_map,
                                                      VARYING_SLOT_BFC1)));
      }
   }
   brw_ENDIF(p);
}
Пример #26
0
Floats CysteineCrossLinkData::get_nonmarginal_elements(double fexp,
                                                       Floats fmods,
                                                       double omega) const {
  Floats probs;

  for (unsigned n = 0; n < fmods.size(); n++) {
    probs.push_back(get_element(fexp, fmods[n], omega));
  }
  return probs;
}
Пример #27
0
void _multiply_row(struct matrix M, struct rational factor, int row){
	set_error(NONE);
	if(row >0 && row<=M.rows){
		int col;
		for(col=1; col<=M.columns; col++){
			set_element(M,row,col,r_multiply(factor,get_element(M,row,col)));
		}
	} else 
		set_error(INCOMPATIBLE_MATRIX);
}
Пример #28
0
void edit_goods_IO(goods_t *l, int page)
{
  printf("\n\tChoose ware to edit: [1-20]  _");
  int index = read_int();  
  int ware = get_element(page, index);
  display_goods(l[ware]);
  printf("\n\n\t[N]ame\n\t[D]escription\n\t[P]rice\n\t[S]helf\n\t[Q]uantity\n\t[c]ancel \n\n\tchoose row or [c]ancel: _");
  edit_propertie(l, ware);
  
}
Пример #29
0
struct matrix scalar_multiply(struct rational a, struct matrix B){ //a * B
	struct matrix C = new_matrix(B.rows, B.columns);
	int i,j;
	for (i=1; i<=C.rows; i++) {
		for (j=1; j<=C.columns; j++) {
			set_element(C, i, j, r_multiply(a, get_element(B,i,j)));
		}
	}
	return C;
}
Пример #30
0
DB_RECORD_NUMBER RecordArray::get(SHORT which)
{
	DB_RECORD_NUMBER far *n;

	if ((n = (DB_RECORD_NUMBER far *)get_element(which)) == NULL)
	{
		return 0;
	}
	return *n;
}