#include <gosignal3d.h>
#include <gofiltermacros.h>
#include <gosignalmacros.h>
#include <time.h>
#include <iostream.h>
#define SIGNAL_TYPE goFloat
#define MASK_TYPE goFloat
int main (int argc, char* argv[])
{
if (argc < 4)
{
cout << "libGo 3D filter example." << endl;
cout << "Usage:" << endl;
cout << argv[0] << " <x size> <y size> <z size>" << endl << endl;
exit(1);
}
clock_t t1,t2;
t1 = clock();
signal.
make (atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
t2 = clock();
cout << "Signal memory allocated in " << (t2 - t1) / (float)CLOCKS_PER_SEC << "s" << endl;
cout << "t1 = " << t1 << endl << "t2 = " << t2 << endl;
cout << "Filter macro test" << endl;
cout << "-----------------" << endl;
MASK_TYPE mask[4] = {1,2,1,2};
goFloat r = 0;
MASK_TYPE *maskPtr = &mask[0];
SIGNAL_TYPE *signalPtr = signal.
getPtr();
*(signalPtr++) = 1;
*(signalPtr++) = 2;
*(signalPtr++) = 3;
*(signalPtr++) = 4;
signalPtr = signal.getPtr();
SIGNAL_TYPE *tempF = signalPtr;
MASK_TYPE *tempF2 = mask;
t1 = clock();
int i;
int sz = (atoi(argv[1]) * atoi(argv[2]) * atoi(argv[3]));
for (i = 0; i < sz; i++)
{
GO_FILTER_MULT4(r, signalPtr, maskPtr);
}
t2 = clock();
cout << "Time for " << i << " filter operations on the same memory: " << (t2 - t1) / (float)CLOCKS_PER_SEC << "s" << endl;
cout << "r = " << r << endl;
cout << endl << "Filter macro test with signal macros" << endl;
cout << "------------------------------------" << endl;
signal2.
make (atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
t1 = clock();
signal, \
signal2, \
SIGNAL_TYPE, SIGNAL_TYPE);
t2 = clock();
cout << "Time to filter the signal in x direction: " << (t2 - t1) / (float)CLOCKS_PER_SEC << "s" << endl;
t1 = clock();
signal2, \
signal, \
SIGNAL_TYPE, SIGNAL_TYPE);
t2 = clock();
cout << "Time to filter the signal in z direction: " << (t2 - t1) / (float)CLOCKS_PER_SEC << "s" << endl;
t1 = clock();
signal, \
signal2, \
SIGNAL_TYPE, SIGNAL_TYPE);
t2 = clock();
cout << "Time to filter the signal in y direction: " << (t2 - t1) / (float)CLOCKS_PER_SEC << "s" << endl;
exit(1);
}