astyle --recursive --indent=spaces=2 --style=kr --indent-col1-comments --break-blocks --convert-tabs --max-code-length=200
This is done for better merging branch/LG_PRE_RELEASE_0.3 into trunk (same process is applied on this branch) git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7073 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
+108
-118
@@ -27,14 +27,14 @@
|
||||
|
||||
*******************************************************************************/
|
||||
/*! \file grid.c
|
||||
* \brief
|
||||
* \brief
|
||||
* \author S. Gashaw, N. Nikaein, J. Harri
|
||||
* \date 2014
|
||||
* \version 0.1
|
||||
* \company Eurecom
|
||||
* \email:
|
||||
* \email:
|
||||
* \note
|
||||
* \warning
|
||||
* \warning
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -50,14 +50,14 @@ int
|
||||
max_vertices_ongrid (omg_global_param omg_param)
|
||||
{
|
||||
return ((int) (omg_param.max_x / xloc_div + 1.0) *
|
||||
(int) (omg_param.max_y / yloc_div + 1.0)) - 1;
|
||||
(int) (omg_param.max_y / yloc_div + 1.0)) - 1;
|
||||
}
|
||||
|
||||
int
|
||||
max_connecteddomains_ongrid (omg_global_param omg_param)
|
||||
{
|
||||
return ((int) (omg_param.max_x / xloc_div) *
|
||||
(int) (omg_param.max_y / yloc_div)) - 1;
|
||||
(int) (omg_param.max_y / yloc_div)) - 1;
|
||||
}
|
||||
|
||||
double
|
||||
@@ -78,15 +78,15 @@ vertice_ypos (int loc_num, omg_global_param omg_param)
|
||||
{
|
||||
//LOG_D(OMG,"y pos %.2f \n\n",omg_param.min_y + (double)yloc_div * (int)( loc_num / (int)(omg_param.max_x/xloc_div + 1.0) ));
|
||||
return omg_param.min_y +
|
||||
(double) yloc_div *(int) (loc_num /
|
||||
(int) (omg_param.max_x / xloc_div + 1.0));
|
||||
(double) yloc_div *(int) (loc_num /
|
||||
(int) (omg_param.max_x / xloc_div + 1.0));
|
||||
}
|
||||
|
||||
double
|
||||
area_minx (int block_num, omg_global_param omg_param)
|
||||
{
|
||||
return omg_param.min_x +
|
||||
xloc_div * (block_num % (int) (omg_param.max_x / xloc_div));
|
||||
xloc_div * (block_num % (int) (omg_param.max_x / xloc_div));
|
||||
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ double
|
||||
area_miny (int block_num, omg_global_param omg_param)
|
||||
{
|
||||
return omg_param.min_y +
|
||||
yloc_div * (int) (block_num / (int) (omg_param.max_x / xloc_div));
|
||||
yloc_div * (int) (block_num / (int) (omg_param.max_x / xloc_div));
|
||||
}
|
||||
|
||||
/*for connected domain that only move to the neighbor domains */
|
||||
@@ -107,108 +107,93 @@ next_block (int current_bn, omg_global_param omg_param)
|
||||
unsigned int blk;
|
||||
int div = (int) (omg_param.max_x / xloc_div);
|
||||
|
||||
/*left border blocks*/
|
||||
if ((current_bn % div) == 0)
|
||||
{
|
||||
/*case 1 for left upper and lower corners(only 2 neighbors) */
|
||||
if ((int) (current_bn / div) == 0)
|
||||
{
|
||||
if (rnd <= 0.5)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
}
|
||||
else if ((int) (current_bn / div) ==
|
||||
(int) (omg_param.max_y / yloc_div) - 1)
|
||||
{
|
||||
if (rnd <= 0.5)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
/*for 3 neighbor blocks */
|
||||
/*left border blocks*/
|
||||
if ((current_bn % div) == 0) {
|
||||
/*case 1 for left upper and lower corners(only 2 neighbors) */
|
||||
if ((int) (current_bn / div) == 0) {
|
||||
if (rnd <= 0.5)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else
|
||||
{
|
||||
if (rnd <= 0.33)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else if (rnd > 0.33 && rnd <= 0.66)
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
|
||||
}
|
||||
/*right boredr blocks*/
|
||||
else if ((current_bn % (int) (omg_param.max_x / xloc_div)) == div - 1)
|
||||
{
|
||||
/*case 1 for right upper and lower corners(only 2 neighbors) */
|
||||
if ((int) (current_bn / div) == 0)
|
||||
{
|
||||
if (rnd <= 0.5)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
}
|
||||
else if ((int) (current_bn / div) ==
|
||||
(int) (omg_param.max_y / yloc_div) - 1)
|
||||
{
|
||||
if (rnd <= 0.5)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
/*for 3 neighbor blocks */
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
} else if ((int) (current_bn / div) ==
|
||||
(int) (omg_param.max_y / yloc_div) - 1) {
|
||||
if (rnd <= 0.5)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else
|
||||
{
|
||||
if (rnd <= 0.33)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else if (rnd > 0.33 && rnd <= 0.66)
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
|
||||
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
/*for 3 neighbor uper and lower borders*/
|
||||
/*for 3 neighbor blocks */
|
||||
else {
|
||||
if (rnd <= 0.33)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else if (rnd > 0.33 && rnd <= 0.66)
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
|
||||
}
|
||||
/*right boredr blocks*/
|
||||
else if ((current_bn % (int) (omg_param.max_x / xloc_div)) == div - 1) {
|
||||
/*case 1 for right upper and lower corners(only 2 neighbors) */
|
||||
if ((int) (current_bn / div) == 0) {
|
||||
if (rnd <= 0.5)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
} else if ((int) (current_bn / div) ==
|
||||
(int) (omg_param.max_y / yloc_div) - 1) {
|
||||
if (rnd <= 0.5)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
/*for 3 neighbor blocks */
|
||||
else {
|
||||
if (rnd <= 0.33)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else if (rnd > 0.33 && rnd <= 0.66)
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*for 3 neighbor uper and lower borders*/
|
||||
else if ((int) (current_bn / div) == 0
|
||||
|| (int) (current_bn / div) ==
|
||||
(int) (omg_param.max_y / yloc_div) - 1)
|
||||
{
|
||||
|
||||
if ((int) (current_bn / div) == 0)
|
||||
{
|
||||
if (rnd <= 0.33)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else if (rnd > 0.33 && rnd <= 0.66)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
}
|
||||
|| (int) (current_bn / div) ==
|
||||
(int) (omg_param.max_y / yloc_div) - 1) {
|
||||
|
||||
if ((int) (current_bn / div) == 0) {
|
||||
if (rnd <= 0.33)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else if (rnd > 0.33 && rnd <= 0.66)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else
|
||||
{
|
||||
if (rnd <= 0.33)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else if (rnd > 0.33 && rnd <= 0.66)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rnd <= 0.25)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else if (rnd > 0.25 && rnd <= 0.50)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else if (rnd > 0.50 && rnd <= 0.75)
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
else {
|
||||
if (rnd <= 0.33)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else if (rnd > 0.33 && rnd <= 0.66)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (rnd <= 0.25)
|
||||
blk = selected_blockn (current_bn, LEFT, div);
|
||||
else if (rnd > 0.25 && rnd <= 0.50)
|
||||
blk = selected_blockn (current_bn, RIGHT, div);
|
||||
else if (rnd > 0.50 && rnd <= 0.75)
|
||||
blk = selected_blockn (current_bn, UPPER, div);
|
||||
else
|
||||
blk = selected_blockn (current_bn, LOWER, div);
|
||||
}
|
||||
|
||||
|
||||
return blk;
|
||||
|
||||
@@ -219,23 +204,28 @@ unsigned int
|
||||
selected_blockn (int block_n, int type, int div)
|
||||
{
|
||||
unsigned int next_blk = 0;
|
||||
switch (type)
|
||||
{
|
||||
case LEFT:
|
||||
next_blk = block_n - 1;
|
||||
break;
|
||||
case RIGHT:
|
||||
next_blk = block_n + 1;
|
||||
break;
|
||||
case UPPER:
|
||||
next_blk = block_n + div;
|
||||
break;
|
||||
case LOWER:
|
||||
next_blk = block_n - div;
|
||||
break;
|
||||
default:
|
||||
LOG_E (OMG, "wrong type input\n");
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case LEFT:
|
||||
next_blk = block_n - 1;
|
||||
break;
|
||||
|
||||
case RIGHT:
|
||||
next_blk = block_n + 1;
|
||||
break;
|
||||
|
||||
case UPPER:
|
||||
next_blk = block_n + div;
|
||||
break;
|
||||
|
||||
case LOWER:
|
||||
next_blk = block_n - div;
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_E (OMG, "wrong type input\n");
|
||||
}
|
||||
|
||||
return next_blk;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user