a2nath / a2nath/Linear-Phased-Array

Improve the color_span function to handle zeros and infinite values

Aperta
#4 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement good first issue help wanted Visuals
Lingua principale
C++
Stelle
1
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

It is good that we're ignoring heavy calculations in Update() and Init() functions that are at "holes" or at divided by zero errors or Infinite values, otherwise.

But we're also interpolating the closet value into these holes so that it doesn't throw off the color_span recalculate function. Now re-design the function so that it is not thrown off by zero and inf. That way we don't have to interpolate in the Update() and Init() which are very expensive subroutines.

```
indices_with_inf
indices_with_z
```

:(

```c
/*update the antenna array from updated power and scan angle */
void AAntenna::update(
const size_t& malloc_size,
double* phee_minus_alpha_list,
double* gain_RX_grid,
double* pathloss_list,
double* dummy,
double* host_hmatrix)
{
/* update the antenna gain Gtx */
indices_with_inf.clear();
indices_with_z.clear();

for (long long idx = 0; idx < malloc_size; ++idx)
{
if (pathloss_list[idx] == 0)
{ // this is going to be a inf
indices_with_inf.emplace_back(idx);
continue;
}
else if (gain_RX_grid[idx] == 0)
{ // this is going to be a zero
indices_with_z.emplace_back(idx);
continue;
}

double phee = (phee_minus_alpha_list[idx] + current.alpha) / 2;

double sin_term = current.panel_count * sin(phee);
double gain_factor_antenna_system = gain_RX_grid[idx]; // xN antennas already

if (sin_term != 0)
{
gain_factor_antenna_system *= cached::pow_2(cached::sin(current.panel_count * phee) / sin_term);
}

/* update the channel matrix */
host_hmatrix[idx] = gain_factor_antenna_system / pathloss_list[idx];
}

for (long i = 0; i < indices_with_inf.size(); ++i)
{
auto& problem_index = indices_with_inf[i];

if (0 <= problem_index - 1)
{
host_hmatrix[problem_index] = host_hmatrix[problem_index - 1];
}
else if (problem_index + 1 < malloc_size)
{
host_hmatrix[problem_index] = host_hmatrix[problem_index + 1];
}
// else all of them are infinity
}

for (long i = 0; i < indices_with_z.size(); ++i)
{
auto& problem_index = indices_with_z[i];

if (0 <= problem_index - 1)
{
host_hmatrix[problem_index] = host_hmatrix[problem_index - 1];
}
else if (problem_index + 1 < malloc_size)
{
host_hmatrix[problem_index] = host_hmatrix[problem_index + 1];
}
}
}

```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.