Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of two loops. #50

Open
livep2000 opened this issue Nov 1, 2017 · 2 comments
Open

Get rid of two loops. #50

livep2000 opened this issue Nov 1, 2017 · 2 comments

Comments

@livep2000
Copy link

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

@tmolteno
Copy link
Owner

tmolteno commented Nov 2, 2017

Hi Imre,

This looks excellent. I'll double check, but otherwise will incorporate.

@livep2000
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants