⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 此代码经过大量使用
💻 CPP
字号:
/***************************************************************************                          main.cpp  -  description                             -------------------    begin                : Mon Feb 25 2002    copyright            : (C) 2002 by Matt Grover    email                : mpgrover@sourceforge.net ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <iostream.h>#include <stdlib.h>#include <string.h>#include <amygdala/types.h>#include "spikeloop.h"void Usage();int ParseCommandLine(int argc, char *argv[]);unsigned int runTime = 1000;unsigned int layerSize = 6;unsigned int numLayers = 5;float sigma = 0.01;bool gnuplot = false;int main(int argc, char *argv[]){    // Watch for help request    if ((argc == 2) && !strcmp(argv[1], "--help")) {        Usage();        return 2;    }    int rc = ParseCommandLine(argc, argv);    if (rc) {        return rc;    }    SpikeLoop* loop = new SpikeLoop(layerSize, numLayers);    loop->SetSigma(sigma);    loop->SetGnuplot(gnuplot);    loop->Run(runTime);    delete loop;}int ParseCommandLine(int argc, char *argv[]){    int index;    for (index = 1; index < argc; index++)    {        // Break out on first parm not starting with a dash        if (argv[index][0] != '-')            break;        if (!strncmp(argv[index], "-t=", 3)) {            const char* const parm = &argv[index][3];            // test to make sure parm is numeric            if (!(runTime = atoi(parm))) {                cerr << parm << " is not a number.\n";                return 2;            }        }        else if (!strncmp(argv[index], "-l=", 3)) {            const char* const parm = &argv[index][3];            // test to make sure parm is numeric            if (!(numLayers = atoi(parm))) {                cerr << parm << " is not a number.\n";                return 2;            }        }        else if (!strncmp(argv[index], "-s=", 3)) {            const char* const parm = &argv[index][3];            // test to make sure parm is numeric            if (!(layerSize = atoi(parm))) {                cerr << parm << " is not a number.\n";                return 2;            }        }        else if (!strncmp(argv[index], "-S=", 3)) {            const char* parm = &argv[index][3];            if (!(sigma = atof(parm))) {                cerr << parm << " is not a valid number.\n";                return 2;            }        }        else if (!strncmp(argv[index], "-g", 2)) {            gnuplot = true;        }        else {            cerr << "Unknown option '" << argv[index]                 << "', ignoring it\n" << endl;        }    }    return 0;}void Usage(){    cout <<  "\nUsage: spikeloop [options]\n\n"             "Options:\n"             "    -l=n        Number of layers in loop [5]\n"             "    -s=n        Layer size [6]\n"             "    -t=n        Simulation run time (ms) [1000]\n"             "    -g          Set output mode to gnuplot logging\n"             "    -S=n        Standard deviation for initial weight distribution [0.01]\n"             "    --help      Show this help\n\n"         <<  endl;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -