/////////////////////////////////////////////////////////////// // // // DataGen.cpp - model neural network // // // // version: 1.0 // // Language: Visual C++, ver 5.0 // // Platform: Micron Dual Pentium Pro 200 // // Windows NT 4.0, service pack 3 // // Application: ELE591/791 Project #1 // // Author: Jim Fawcett // // CST 2-187, (315) 443-3948 // // fawcett@neptune.syr.edu // // // /////////////////////////////////////////////////////////////// #include #include #include #include #include #include "vec.h" using namespace std; //----< fill vector with sine values >------------------------- void SineVec(vec &v) { const double PI = 3.1415927; const double MAX_ANGLE = PI/1.5; const double del_angle = MAX_ANGLE/v.size(); double angle = 0; int i; for(i=0; i---------------------- void RandVec(vec &v, double min, double max, bool newSeed) { static int count = 654321; count += 123456; double scaleFactor = (max-min)/RAND_MAX; if(newSeed) srand((unsigned)time(NULL) + count); else srand(123456U); int i; for(i=0; i--------- void main(int argc, char *argv[]) { const int SIZE = 100; vec function(SIZE), noise(SIZE); SineVec(function); RandVec(noise,-0.01,0.01,true); vec noisyFunc(SIZE); noisyFunc = function + noise; ofstream out(argv[argc-1]); if(argc == 1) { cout << "-- please enter name of data file to create\n"; return; } if(!out.good()) { cout << "-- can't open file " << argv[argc-1] << endl; return; } out << noisyFunc; }