Any better replacement for these functions
-
Hello, I am trying to improve the speed of a function which heavily using these functions.
template<class T> T min(const valarray<T>& x);
andINT abs( int n );
in math.h andint memcmp( const void *buf1, const void *buf2, size_t count );
Any better functions to be used other than these. Thank you. Sonork 100.41263:Anthony_Yio -
Hello, I am trying to improve the speed of a function which heavily using these functions.
template<class T> T min(const valarray<T>& x);
andINT abs( int n );
in math.h andint memcmp( const void *buf1, const void *buf2, size_t count );
Any better functions to be used other than these. Thank you. Sonork 100.41263:Anthony_YioTry using memmove instead of memcpy. As for abs(), try replacing it with this inline function: inline int myAbs(int n) { if (n < 0) return -n; else return n; } That would be a lot quicker than a function call. There maybe more to the abs function than that, but I don't know the details. As for min(), I've never seen that particular version of it before. If you are doing something thats computationally heavy on prepared data, you could sort the data ahead of time and then just pull out the first element, that'd be your min.