necpp
necpp copied to clipboard
Get rid of two loops.
Hello Tim, excellent work !
I found a possible way of getting rid of 2 loops in 'void solves'. At line 705 and 755, this piece of exact equal code:
for (int64_t k = 0; k < nop; k++ ) {
int64_t ia= i+ k* npeq;
scm[k]= b[ia+column_offset];
}
nec_complex sum_normal(scm[0]);
for (int64_t k = 1; k < nop; k++ )
sum_normal += scm[k];
/* test added */
nec_complex tester = solves_sum_cpl(b, scm, nop, npeq, i, column_offset);
ASSERT(tester == sum_normal);
// ...... more code
}
I ASSERT tested the following function, but could not find a case where it is triggered. So, I commented out 'if ( nop == 1) return;' a few lines above.
/* I: Test to see if we can snip out a loop scm = referenced */
nec_complex solves_sum_cpl(complex_array b, complex_array& scm, int64_t nop, int64_t npeq, int64_t i, int64_t column_offset)
{
nec_complex sum_normal;
for (int64_t k = 0; k < nop; k++)
{
scm[k] = b[(i + k * npeq) + column_offset];
sum_normal += scm[k];
}
return sum_normal;
}
It integrates summing into its parent loop.
Imre Biacsics
Hi Imre,
This looks excellent. I'll double check, but otherwise will incorporate.
Oops, reacted by email. Removed it from github. ((to bulky) The content in shorter terms: "I want to exchange some ideas about the nec2 input and output." Imre