static void connect(Net *net, Connector* conn){ Data *data = conn->data; double epsilon = data->epsilon; net_size_t size = net_size(net); net_size_t edge = sqrt(size); if((edge * edge) != size){ printf("lattice_guassi_connector.c::lattice net requires the net's size must be n*n\n"); exit(0); } net_size_t i, j; srand(data->seed); for(i = 0; i < edge; i++){ for(j = 0; j < edge; j++){ net_size_t cur = edge * i + j; if(j != (edge - 1)){ weight_t edge_weight = get_gaussi(epsilon); net_connect(cur, cur + 1, edge_weight, net); net_connect(cur+1, cur, edge_weight, net); } if(i != (edge - 1)){ weight_t edge_weight = get_gaussi(epsilon); net_connect(cur, cur + edge, edge_weight, net); net_connect(cur + edge , cur, edge_weight, net); } }//for j }//for i }
/** * the distance between <i, j> will return the node[j]'s distance to the center of the net. */ double fake_distance(net_size_t i, net_size_t j, Net *net, void *ctx){ net_size_t edge = sqrt(net_size(net)); net_size_t x = j / edge; net_size_t y = j - x * edge; double xx = (double)x - (double)(edge - 1) / 2.0; xx *= xx; double yy = (double)y - (double)(edge - 1) / 2.0; yy *= yy; return sqrt(xx + yy); }
static grub_size_t grub_multiboot_get_mbi_size (void) { #ifdef GRUB_MACHINE_EFI if (!efi_mmap_size) find_efi_mmap_size (); #endif return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag) + sizeof (struct multiboot_tag) + (sizeof (struct multiboot_tag_string) + ALIGN_UP (cmdline_size, MULTIBOOT_TAG_ALIGN)) + (sizeof (struct multiboot_tag_string) + ALIGN_UP (sizeof (PACKAGE_STRING), MULTIBOOT_TAG_ALIGN)) + (modcnt * sizeof (struct multiboot_tag_module) + total_modcmd) + ALIGN_UP (sizeof (struct multiboot_tag_basic_meminfo), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_bootdev), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_elf_sections), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (elf_sec_entsize * elf_sec_num, MULTIBOOT_TAG_ALIGN) + ALIGN_UP ((sizeof (struct multiboot_tag_mmap) + grub_get_multiboot_mmap_count () * sizeof (struct multiboot_mmap_entry)), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_framebuffer), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_efi32), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_efi64), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_old_acpi) + sizeof (struct grub_acpi_rsdp_v10), MULTIBOOT_TAG_ALIGN) + acpiv2_size () + net_size () #ifdef GRUB_MACHINE_EFI + ALIGN_UP (sizeof (struct multiboot_tag_efi_mmap) + efi_mmap_size, MULTIBOOT_TAG_ALIGN) #endif + sizeof (struct multiboot_tag_vbe) + MULTIBOOT_TAG_ALIGN - 1 + sizeof (struct multiboot_tag_apm) + MULTIBOOT_TAG_ALIGN - 1; }