I am trying to use valarray since it is much like MATLAB while operating vector and matrices. I first did some performance check and found that valarray cannot achieve the p
Hmm..I tested Blitz++ and it's same as valarray... And moreover, the Blitz++ [] operator is very slow.
#include
#include
#ifdef WIN32
#include "windows.h"
LARGE_INTEGER sys_freq;
#endif
#ifdef LINUX
#endif
using namespace std;
SYSTEMTIME stime;
__forceinline double gettime_hp();
double gettime_hp()
{
#ifdef WIN32
LARGE_INTEGER tick;
extern LARGE_INTEGER sys_freq;
QueryPerformanceCounter(&tick);
return (double)tick.QuadPart * 1000.0 / sys_freq.QuadPart;
#endif
#ifdef LINUX
struct timespec timestamp;
clock_gettime(CLOCK_REALTIME, ×tamp);
return timestamp.tv_sec * 1000.0 + timestamp.tv_nsec * 1.0e-6;
#endif
}
BZ_USING_NAMESPACE(blitz)
int main()
{
int N = 5*1024*1024;
// Create three-dimensional arrays of double
Array a(N), b(N), c(N);
int i, j;
#ifdef WIN32
QueryPerformanceFrequency(&sys_freq);
#endif
for (j=0 ; j<8 ; ++j)
{
for (i=0 ; i