C - De-interleave Data?

You might take a look at the qsort() library function There are two possiblities: 1 The float could be seen as a pointer to an array of float An array of float in fact is a pointer to a the first float in this array. That's where the pointer to pointer comes from 2 The float is an array of float will say an array pointers to float Referring case 1: Assuming your source data is held by an array referenced by source and you know how many entries this array has you could use qsort() to "de-interleave", say "sort", the data To do so you need to declare a function which could be used by qsort() to access and compare the data to sort The signature of this function expected by qsort is: int(*compar)(const void *, const void *) So you implementation of it might look like this: int compare_floats(const void * pvFloat1, const void * pvFloat2) { if ((!pvFloat1) && (!pvFloat2)) return 0; if (!pvFloat1) return -1; if (!pvFloat2) return 1; if (*((float*) pvFloat1) *((float*) pvFloat2)) return 1; /* The floats are equal here. */ return 0; } (the code above sorts NULL-entries to the beginning of the destination array) In your code make sure you have enough memory assigned to dest and call qsort() this way (assuming your source arrary holds eight entries): qsort(*source, *dest, 8, compare_floats) Referring case 2: (Later when I find some time ;-).

You might take a look at the qsort() library function. There are two possiblities: 1 The float ** could be seen as a pointer to an array of float. An array of float in fact is a pointer to a the first float in this array.

That's where the pointer to pointer comes from. 2 The float ** is an array of float *, will say an array pointers to float. Referring case 1: Assuming your source data is held by an array referenced by ** source and you know how many entries this array has you could use qsort() to "de-interleave", say "sort", the data.To do so you need to declare a function which could be used by qsort() to access and compare the data to sort.

The signature of this function expected by qsort is: int(*compar)(const void *, const void *) So you implementation of it might look like this: int compare_floats(const void * pvFloat1, const void * pvFloat2) { if ((!pvFloat1) && (!pvFloat2)) return 0; if (!pvFloat1) return -1; if (!pvFloat2) return 1; if (*((float*) pvFloat1) *((float*) pvFloat2)) return 1; /* The floats are equal here. */ return 0; } (the code above sorts NULL-entries to the beginning of the destination array) In your code make sure you have enough memory assigned to dest and call qsort() this way (assuming your source arrary holds eight entries): qsort(*source, *dest, 8, compare_floats); Referring case 2: (Later when I find some time ;-).

Obviously the unsafe code is the fastest, but I was surprised to see that the CLS couldn't figure out that that it can drop the index checks when dealing with jagged array. Maybe someone can think of more ways to optimize my tests. I tried loop unrolling with the unsafe code and it didn't have an effect.

The results are also a hit-miss compared test#4 with 1% difference. Test #4 is my best way to go, so far. As I told jerryjvl, the problem is getting the CLS to not index check the input buffer, since adding a second check (&& offset Looks like loop unrolling is not favorable.

My optimized code is still my best way to go and with only 10% difference compared to the unsafe code. If only I could tell the compiler that (i Length) implies that (offset.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions