Click here to Skip to main content
16,016,157 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Plotting large amount of data points Pin
Ri Qen-Sin23-Oct-07 14:59
Ri Qen-Sin23-Oct-07 14:59 
GeneralA Prayer for Archimedes Pin
Bassam Abdul-Baki10-Oct-07 6:44
professionalBassam Abdul-Baki10-Oct-07 6:44 
GeneralRe: A Prayer for Archimedes Pin
IdUnknown10-Oct-07 7:16
IdUnknown10-Oct-07 7:16 
GeneralRe: A Prayer for Archimedes Pin
Bassam Abdul-Baki10-Oct-07 7:26
professionalBassam Abdul-Baki10-Oct-07 7:26 
Questionfill memory with a pattern Pin
DQNOK10-Oct-07 5:21
professionalDQNOK10-Oct-07 5:21 
AnswerRe: fill memory with a pattern Pin
DQNOK11-Oct-07 7:35
professionalDQNOK11-Oct-07 7:35 
AnswerRe: fill memory with a pattern Pin
Alan Balkany24-Oct-07 4:13
Alan Balkany24-Oct-07 4:13 
GeneralRe: fill memory with a pattern Pin
DQNOK24-Oct-07 10:33
professionalDQNOK24-Oct-07 10:33 
IF (a few critical things...) then I think you're right. I think your algorithm will work really really good. I'm working on other things, and don't really want to write a timing test, but I believe you're probably right about it being the fastest possible algorithm.

Now for the critical things:
IF memcpy copies from the end of the array instead of from the base, this algorithm won't work at all. Depending on how it computes the target (if copying from the end), it'll either copy garbage until it finally hits the first pattern, and then make one good copy of it, or it'll make one good copy first, then cause a GPF by attempting to overwrite memory to the left of the src. Here's a quote from "STANDARD C" by P.J. Plauger and Jim Brodie regarding memcpy: "The elements of the array can be accessed and stored in any order." It could even start in the middle of the array if that favors the target environment.

I suppose one could bracket the code with #if's, assuming one could absolutely determine how memcpy worked; and guarantee that it never changes it's mind depending on any number of things.

The other alternative is to simply write the algorithm myself in C. This way I could guarantee copying from the base of the array instead of from the end. But, as you point out, memcpy is highly tuned for the machine architecture, and my "roll your own" isn't going to work as well.

Thanks a lot anyway. I really appreciate the thoughts. Maybe your idea will come in handy in some of my future projects. It was a really good idea.

David
GeneralRe: fill memory with a pattern Pin
DQNOK25-Oct-07 3:41
professionalDQNOK25-Oct-07 3:41 
QuestionAlgorithm to check how different are two files? Pin
bosfan9-Oct-07 22:01
bosfan9-Oct-07 22:01 
AnswerRe: Algorithm to check how different are two files? Pin
cp98769-Oct-07 22:56
cp98769-Oct-07 22:56 
GeneralRe: Algorithm to check how different are two files? Pin
bosfan9-Oct-07 23:18
bosfan9-Oct-07 23:18 
AnswerRe: Algorithm to check how different are two files? Pin
ScottM111-Oct-07 2:07
ScottM111-Oct-07 2:07 
GeneralRe: Algorithm to check how different are two files? Pin
ChandraRam11-Oct-07 2:25
ChandraRam11-Oct-07 2:25 
GeneralRe: Algorithm to check how different are two files? Pin
ScottM124-Oct-07 3:59
ScottM124-Oct-07 3:59 
AnswerRe: Algorithm to check how different are two files? Pin
chandu00413-Oct-07 0:30
chandu00413-Oct-07 0:30 
AnswerRe: Algorithm to check how different are two files? Pin
Gesown16-Oct-07 6:20
professionalGesown16-Oct-07 6:20 
Questiongenetic algorithms for image generation? Pin
Juraj Borza9-Oct-07 9:56
Juraj Borza9-Oct-07 9:56 
AnswerRe: genetic algorithms for image generation? Pin
Stan F. Form13-Oct-07 3:16
Stan F. Form13-Oct-07 3:16 
AnswerRe: genetic algorithms for image generation? Pin
Marshall15-Oct-07 9:26
Marshall15-Oct-07 9:26 
AnswerRe: genetic algorithms for image generation? Pin
Alan Balkany24-Oct-07 4:24
Alan Balkany24-Oct-07 4:24 
QuestionA simple question Pin
Ennis Ray Lynch, Jr.9-Oct-07 3:53
Ennis Ray Lynch, Jr.9-Oct-07 3:53 
AnswerRe: A simple question Pin
El Corazon9-Oct-07 4:47
El Corazon9-Oct-07 4:47 
GeneralRe: A simple question Pin
Ennis Ray Lynch, Jr.9-Oct-07 5:23
Ennis Ray Lynch, Jr.9-Oct-07 5:23 
GeneralRe: A simple question Pin
El Corazon9-Oct-07 5:25
El Corazon9-Oct-07 5:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.