Disruptive
Programmer
Hi
I am repeatedly copying the array elements from old array to new array, performing operations on the new array (changing) in the process and then determining whether or not use the new array values or the old ones. To speed things up what I do is create a new array and using pointers reassign the pointer such that the updated pointer points at the right place to which ever array is the desired one.
Now the question I have relates to speed. How can I speed up the process of copying this array. Currently the code I am using is listed below:
for(i=0;i<BeadTotal;i++)
{
// Take a copy of all original positions...
ptrBeadArrayOld[0]=(*ptrBeadArray)[0];
ptrBeadArrayOld[1]=(*ptrBeadArray)[1];
ptrBeadArrayOld[2]=(*ptrBeadArray)[2];
}
memcpy(ptrBeadArrayOld,ptrBeadArray,3*BeadTotal*sizeof(double));
I have tried using memcpy but I keep getting a segmentation fault. Can you please advise of the fastest way of performing this operation.
Thanks
I am repeatedly copying the array elements from old array to new array, performing operations on the new array (changing) in the process and then determining whether or not use the new array values or the old ones. To speed things up what I do is create a new array and using pointers reassign the pointer such that the updated pointer points at the right place to which ever array is the desired one.
Now the question I have relates to speed. How can I speed up the process of copying this array. Currently the code I am using is listed below:
for(i=0;i<BeadTotal;i++)
{
// Take a copy of all original positions...
ptrBeadArrayOld[0]=(*ptrBeadArray)[0];
ptrBeadArrayOld[1]=(*ptrBeadArray)[1];
ptrBeadArrayOld[2]=(*ptrBeadArray)[2];
}
memcpy(ptrBeadArrayOld,ptrBeadArray,3*BeadTotal*sizeof(double));
I have tried using memcpy but I keep getting a segmentation fault. Can you please advise of the fastest way of performing this operation.
Thanks