a2nath / a2nath/Linear-Phased-Array

Improve the color_span function to handle zeros and infinite values

Offen
#4 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement good first issue help wanted Visuals
Vorherrschende Sprache
C++
Sterne
1
Forks
1
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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];
}
}
}

```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.