Re: Restrict qualified pointers in C
- From: pa@xxxxxxxxxxxxxxxxxxxxx (Pierre Asselin)
- Date: Sat, 31 Mar 2007 15:40:21 +0000 (UTC)
Your example didn't look like a good candidate for aggressive
optimization. How about this:
/* not tested */
void smear(int n, const float * restrict in, float * restrict out)
{
int i;
out[0]= ( in[0] + 2*in[1] )/3.f;
for(i= 1; i<n-1; i++) {
out[i]= ( in[i-1] + in[i] + in[i + 1] )/3.f;
}
out[n-1]= ( 2*in[n-2] + in[n-1] )/3.f;
}
(I think the "in" pointer doesn't need restrict, but I don't want
to spend time thinking about it.)
--
pa at panix dot com
.
- References:
- Restrict qualified pointers in C
- From: Ken Camann
- Restrict qualified pointers in C
- Prev by Date: Re: Dynamic lists of strings in C
- Next by Date: Re: About Union's question
- Previous by thread: Re: Restrict qualified pointers in C
- Next by thread: Functions in socket
- Index(es):
Relevant Pages
|