a2nath / a2nath/Linear-Phased-Array

Improve the color_span function to handle zeros and infinite values

オープン
#4 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement good first issue help wanted Visuals
主要言語
C++
スター
1
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

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

```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。