Esempio n. 1
0
int kd_tree::kernel_srch(array_1d<double> &pt, array_1d<double> &kern, array_1d<int> &kdex){
   /*
   pt is the center of your kernel
  
   kern will specify the the half-width in each dimension you are looking for
  
   kdex is where the routine will store the indices of the allowed points
  
   the routine will return the number of allowed points found
   
   THIS IS NOT WELL-TESTED
  */
  int node,i,k;
  
  nkernel=0;
  ktests=1;
  node=find_node(pt);
  
  k=1;
  for(i=0;i<data.get_cols() && k==1;i++){
    if(data.get_data(node,i)<pt.get_data(i)-kern.get_data(i) || data.get_data(node,i)>pt.get_data(i)+kern.get_data(i))k=0;
  }
  
  if(k==1){
    kdex.set(nkernel,node);
    nkernel++;
  }
  
  if(tree.get_data(node,3)>=0){
    kernel_check(pt,kern,kdex,tree.get_data(node,3),node);
  }
  if(tree.get_data(node,2)>=0){
    kernel_check(pt,kern,kdex,tree.get_data(node,2),node);
  }
  if(tree.get_data(node,1)>=0){
    kernel_check(pt,kern,kdex,tree.get_data(node,1),node);
  }
  
  return nkernel;
}
Esempio n. 2
0
File: main.c Progetto: 8l/Hydrogen
void main_bsp(void)
{
    // Print header
    screen_write("Hydrogen v0.2b - http://github.com/farok/H2", 0, 0);
    screen_write("Copyright (c) 2012 by Lukas Heidemann", 0, 1);
    screen_write("-------------------------------------------------", 0, 2);

    // Load the IDT
    idt_load(idt_address, IDT_LENGTH);
    idt_setup_loader();

    // Initialize Hydrogen info tables and parse the multiboot tables
    info_init();
    multiboot_parse();

    // Setup the heap
    heap_init();

    // Now parse the ACPI tables and analyze the IO APICs
    acpi_parse();
    ioapic_analyze();

    // Find, check and load the kernel binary
    kernel_find();
    kernel_check();
    elf64_load(kernel_binary);
    kernel_analyze();

    // Initialize interrupt controllers
    lapic_detect();
    lapic_setup();
    ioapic_setup_loader();
    pic_setup();

    // Calibrate the LAPIC timer
    lapic_timer_calibrate();

    // Boot APs
    info_cpu[lapic_id()].flags |= HY_INFO_CPU_FLAG_BSP;
    smp_setup();

    // Setup IDT and IOAPIC according to kernel header
    idt_setup_kernel();
    ioapic_setup_kernel();

    // Setup fast syscall support
    syscall_init();

    // Setup mapping
    kernel_map_info();
    kernel_map_stack();
    kernel_map_idt();
    kernel_map_gdt();

    // Set free address
    info_root->free_paddr = (heap_top + 0xFFF) & ~0xFFF;

    // Lower main entry barrier and jump to the kernel entry point
    main_entry_barrier = 0;
    kernel_enter_bsp();
}
Esempio n. 3
0
void kd_tree::kernel_check(array_1d<double> &pt, array_1d<double> &kern, array_1d<int> &kdex,\
int consider, int wherefrom){
  //consider is the point you are currently looking at
  //wherefrom is where you came from
  
  int i,j,k,l,otherbranch;
  
  
  ktests++;
  k=1;
  for(i=0;i<data.get_cols() && k==1;i++){
    if(data.get_data(consider,i)>pt.get_data(i)+kern.get_data(i) ||  
       data.get_data(consider,i)<pt.get_data(i)-kern.get_data(i)){
      k=0;
    }
  }
  
  if(k==1){
    kdex.set(nkernel,consider);
    nkernel++;
  }
  
  if(tree.get_data(consider,1)==wherefrom)otherbranch=2;
  else if(tree.get_data(consider,2)==wherefrom)otherbranch=1;
  else otherbranch=3;
  
  if(otherbranch==3){
    //you descended here from the parent
    i=tree.get_data(consider,0);
    
    if(tree.get_data(consider,1)>=0){
      
      if(data.get_data(consider,i)>=pt.get_data(i)-kern.get_data(i)){
        kernel_check(pt,kern,kdex,tree.get_data(consider,1),consider);
      }
    }
    if(tree.get_data(consider,2)>=0){
      if(data.get_data(consider,i)<=pt.get_data(i)+kern.get_data(i)){
        kernel_check(pt,kern,kdex,tree.get_data(consider,2),consider);
      }
    }
    
  }
  else if(otherbranch==1 || otherbranch==2){
   if(tree.get_data(consider,3)>=0){
     kernel_check(pt,kern,kdex,tree.get_data(consider,3),consider);
   }
   
   if(tree.get_data(consider,otherbranch)>=0){
     i=tree.get_data(consider,otherbranch);
     j=tree.get_data(consider,0);
     
     if(otherbranch==1){
       if(data.get_data(consider,j)>=pt.get_data(j)-kern.get_data(j)){
         kernel_check(pt,kern,kdex,i,consider);
       }
     }
     else if(otherbranch==2){
       if(data.get_data(consider,j)<=pt.get_data(j)+kern.get_data(j)){
         kernel_check(pt,kern,kdex,i,consider);
       }
     }
     
   }
   
   
  }
  
  
}