예제 #1
0
int rx_cmatch(char *rx,char *s,int n) {
  int p=compile(rx);
  if(!errors) {
    char *end=s+n;
    int u;
    SKIP_SPACE: for(;;) {
      if(s==end) return nullable(p);
      s+=u_get(&u,s);
      if(!xmlc_white_space(u)) break;
    }
    for(;;) {
      if(p==notAllowed) return 0;
      if(xmlc_white_space(u)) { u=' ';
	p=drv(p,u);
	if(p==notAllowed) {
	  for(;;) {
	    if(s==end) return 1;
	    s+=u_get(&u,s);
	    if(!xmlc_white_space(u)) return 0;
	  }
	} else goto SKIP_SPACE;
      }
      p=drv(p,u);
      if(s==end) goto SKIP_SPACE;
      s+=u_get(&u,s);
    }
  } else return 0;
}
예제 #2
0
const char *LogitechDevice::close()
{
    if( bw_ ) drv()->setBW( QImage() );
    else drv()->setQVGA( QImage() );
    opened_  = false;
    return NULL;
}
예제 #3
0
const char* LogitechDevice::render_qimage(QImage *p_image)
{
    if( p_image == NULL ) return NULL;
    if( bw_ ) drv()->setBW( *p_image );
    else drv()->setQVGA( *p_image );
    return NULL;
}
예제 #4
0
int JALOUSIE::drvSonne(int JalNr)
{
    SingleLock slock(this, true);
    if(drvstate[JalNr] != STOP)
    {
        pstop(JalNr);
    }
    if(position[JalNr] == AB)
    {
        return drv(JalNr, AUF, SONNENZEIT, false); // schon geschlossen, also nur noch auf Luecke stellen
    }
    else
    {
        return drv(JalNr, AB, FAHRZEIT + offset(), true); // erstmal Schliessen
    }
}
예제 #5
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testMNISTBinaryDigitsDriver()
{
  MNISTDataBinaryDigitsFunction mnistdf;
  LogisticCostFunction mnistcf;
  Config config;
  updateMNISTConfig(config);

  LIBLBFGSOptimizer lbfgs;
  Driver drv(&config, &mnistdf, &mnistcf, &lbfgs);
  drv.drive();
}
예제 #6
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testHousingDriver()
{
  Config config;
  config.setValue("housing.data",
      std::string("/home/sam/School/online/stanford_dl_ex/stanford_dl_ex/ex1/housing.data"));
  HousingDataFunction hdf;
  LinearCostFunction hcf;
  LIBLBFGSOptimizer lbfgs;
  Driver drv(&config, &hdf, &hcf, &lbfgs);
  drv.drive();
}
예제 #7
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testMNISTDriver()
{
  MNISTDataFunction mnistdf;
  SoftmaxCostFunction mnistcf;
  Config config;
  updateMNISTConfig(config);
  LIBLBFGSOptimizer lbfgs;
//  CppNumericalSolversOptimizer lbfgs;
  Driver drv(&config, &mnistdf, &mnistcf, &lbfgs);
  drv.drive();
}
int main(int argc, char* argv[]){
        try{
                driver drv(argc,argv);
                return drv.run();
        } catch( const std::exception& e){
                std::cerr 
                        << "Caught exception: "
                        << boost::diagnostic_information(e)
                        ;
                return EXIT_FAILURE;
        }
}
int main(int argc, char **argv){

  ros::init(argc, argv, "astra_camera");
  ros::NodeHandle n;
  ros::NodeHandle pnh("~");

  astra_wrapper::AstraDriver drv(n, pnh);

  ros::spin();

  return 0;
}
예제 #10
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testIEEEHumanDataFunction()
{
  Config config;

  const bool isSoftmax = false;

  enum Exp
  {
    __L1__, __L2_true__, __L2_negg__, __L3__
  };

  const Exp exp = __L2_negg__;

  config.setValue("IEEEHumanDataFunction.datasetsSetBias", isSoftmax);
  config.setValue("training_accuracy", true);
  config.setValue("testing_accuracy", true);

  switch (exp)
  {
    case 0:
      config.setValue("exp", std::string("__L1__"));
      break;
    case 1:
      config.setValue("exp", std::string("__L2_true__"));
      break;
    case 2:
      config.setValue("exp", std::string("__L2_negg__"));
      break;
    case 3:
      config.setValue("exp", std::string("__L3__"));
  }

  IEEEHumanDataFunction ieeeHumanData;

  CostFunction* cf = nullptr;

  if (isSoftmax)
    cf = new SoftmaxCostFunction(0.1f);
  else
  {
    Vector_t topology(1);
    topology << 6; // 5
    cf = new SupervisedNeuralNetworkCostFunction(topology, 0.1f);
  }

  LIBLBFGSOptimizer lbfgs;
  Driver drv(&config, &ieeeHumanData, cf, &lbfgs);
  drv.drive();

  delete cf;

}
예제 #11
0
int rx_match(char *rx,char *s,int n) {
  int p=compile(rx);
  if(!errors) {
    char *end=s+n;
    int u;
    for(;;) {
      if(p==notAllowed) return 0;
      if(s==end) return nullable(p);
      s+=u_get(&u,s);
      p=drv(p,u);
    }
  } else return 0;
}
예제 #12
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testSoftmaxCostFunctionDriver()
{
  MNISTDataBinaryDigitsFunction mnistdf(true);
  Config config;
  config.setValue("training_accuracy", true);
  config.setValue("testing_accuracy", true);
  updateMNISTConfig(config);
  SoftmaxCostFunction mnistcf(1.0f);
  LIBLBFGSOptimizer lbfgs;
  //config.setValue("debugMode", true);
  config.setValue("numGrd", true);
  //config.setValue("addBiasTerm", false);
  Driver drv(&config, &mnistdf, &mnistcf, &lbfgs);
  drv.drive();
}
예제 #13
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testMNISTSupervisedNeuralNetworkDriver()
{
  Vector_t topology(1);
  topology << 100;

  SupervisedNeuralNetworkCostFunction mnistcf(topology, 0.01f);

  MNISTDataFunction mnistdf;
  Config config;
  updateMNISTConfig(config);
  config.setValue("addBiasTerm", false);
  LIBLBFGSOptimizer lbfgs;
  Driver drv(&config, &mnistdf, &mnistcf, &lbfgs);
  drv.drive();
}
예제 #14
0
int JALOUSIE::pdrvAbwaerts(int JalNr, int imptime)
{
    if(drvstate[JalNr] == AB)
    {
        return 0;
    }
    if(drvstate[JalNr] == AUF)
    {
        pstop(JalNr);
    }
    if(position[JalNr] == AB)
    {
        return 0;
    }
    return drv(JalNr, AB, imptime, false);
}
예제 #15
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testMNISTBinaryDigitsSupervisedNeuralNetworkCostFunctionDriver()
{
  Vector_t topology(1);
  topology << 5;
  SupervisedNeuralNetworkCostFunction mnistcf(topology);
  //SoftmaxCostFunction mnistcf;
  //LogisticCostFunction mnistcf;
  MNISTDataBinaryDigitsFunction mnistdf(true);
  Config config;
  updateMNISTConfig(config);
  config.setValue("addBiasTerm", false);
  config.setValue("training_accuracy", true);
  config.setValue("testing_accuracy", true);

  LIBLBFGSOptimizer lbfgs;
  Driver drv(&config, &mnistdf, &mnistcf, &lbfgs);
  drv.drive();
}
예제 #16
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testSoftICADriver2()
{
  const int numPatches = 20000;
  const int patchWidth = 8;
  NaturalImageDataFunction nidf(numPatches, patchWidth);
  Config config;

  const int numFeatures = 50;
  const double lambda = 0.0005f;
  const double epsilon = 1e-2;

  SoftICACostFunction sfc(numFeatures, lambda, epsilon);

  LIBLBFGSOptimizer lbfgs;
  Driver drv(&config, &nidf, &sfc, &lbfgs);
  drv.drive();

}
int main(int argc, char **argv) {

    openni2_wrapper::CommandLineConfig cl_cfg;
    cl_cfg.verbose = false;
    cl_cfg.use_jpeg = true;
    cl_cfg.use_zlib = 1;
    cl_cfg.jpeg_quality = 94;
    cl_cfg.image_standalone = false;
    cl_cfg.depth_standalone = false;
    cl_cfg.skip_combined = false;
    cl_cfg.msg_channel = "OPENNI_FRAME";
    cl_cfg.data_skip = 1;

    ConciseArgs parser(argc, argv, "openni2-camera-lcm");
    parser.add(cl_cfg.verbose, "v", "verbose", "Verbose printf");
    //parser.add(cl_cfg.use_jpeg, "j", "use_jpeg", "JPEG-compress RGB images"); // now implicit from quality
    parser.add(cl_cfg.use_zlib, "z", "zlib", "depth compression (0-9), 0=no compression)");
    parser.add(cl_cfg.jpeg_quality, "j", "jpeg", "JPEG quality (1-100), 100=compression");
    parser.add(cl_cfg.image_standalone, "si", "image_standalone", "Publish RGB image individually");
    parser.add(cl_cfg.depth_standalone, "sd", "depth_standalone", "Publish Depth image individually");
    parser.add(cl_cfg.skip_combined, "sc", "skip_combined", "Don't publish RGB-D images message");
    parser.add(cl_cfg.msg_channel, "c", "msg_channel", "LCM Channel");
    parser.add(cl_cfg.data_skip, "d", "data_skip", "Period been images (1 = don't skip, 0 skip all), use to select fps");
    parser.parse();

    if (cl_cfg.jpeg_quality == 100) {
        std::cout << "JPEG compression disabled, will not compress\n";
        cl_cfg.use_jpeg = false;
    }

    boost::shared_ptr<lcm::LCM> lcm(new lcm::LCM);
    if(!lcm->good()) {
        std::cerr <<"ERROR: lcm is not good()" <<std::endl;
    }

    openni2_wrapper::OpenNI2Driver drv(lcm, cl_cfg);

    while(1==1) {
        boost::this_thread::sleep(boost::posix_time::milliseconds(30));
    }

    return 0;
}
예제 #18
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testMNISTConvolutionalNeuralNetworkDriver()
{
  MNISTDataFunction mnistdf;
  Config config;
  updateMNISTConfig(config);
  config.setValue("addBiasTerm", false);
  config.setValue("meanStddNormalize", false);
  SGDOptimizer sgd;

  const int imageDim = 28; // height/width of image
  const int filterDim = 9; // dimension of convolutional filter
  const int numFilters = 20; // number of convolutional filters
  const int poolDim = 2; // dimension of pooling area
  const int numClasses = 10; // number of classes to predict

  ConvolutionalNeuralNetworkCostFunction cf(imageDim, filterDim, numFilters, poolDim, numClasses);
  Driver drv(&config, &mnistdf, &cf, &sgd);
  drv.drive();
}
예제 #19
0
파일: LibDevice.cpp 프로젝트: Busti/LCDHost
bool LibDevice::event( QEvent *event )
{
    if( LibObject::event(event) ) return true;
    Q_ASSERT( event->type() >= QEvent::User );
    Q_ASSERT( event->type() <= QEvent::MaxUser );
    Q_ASSERT( id().isValid() );

    if( event->type() == EventDeviceOpen::type() )
    {
        if (const char* retv = open()) {
            qWarning("Failed to open device \"%s\": \"%s\"\n", name(), retv);
            term();
            deleteLater();
        }
        return true;
    }

    if( event->type() == EventDeviceClose::type() )
    {
        close();
        return true;
    }

    if( event->type() == EventRender::type() )
    {
        EventRender *e = static_cast<EventRender*>(event);
        render( e->image );
        return true;
    }

    if( event->type() == EventDeviceDestroy::type() )
    {
        close();
        if(LibDevicePointer *ldp = drv()->findChild<LibDevicePointer *>(objectName()))
            delete ldp;
        deleteLater();
        return true;
    }

    qWarning() << "LibDevice::event() unhandled user event" << EventBase::name(event->type()) << "for" << objectName();
    return false;
}
예제 #20
0
void CPersistenceTests::AllTestsL()
	{
	FileCreationL();

	IccL();
	DuplicatedFieldUidsL();

	BasicCRUDL();
	ViewDefsInclL();
	ViewDefsMaskL();

	TDriveUnit drv(EDriveC);
	CDesCArray* arr = iCntTestImpl.ListDatabasesL(drv);
	delete arr;

	OomTestL();
	AccessCountL();
	TemplateAccessCountL();
	GroupsL();
	iCntTestImpl.CloseDatabase();
	}
예제 #21
0
파일: main.cpp 프로젝트: samindaa/MLLib
void testSoftICADriver()
{
  const int numPatches = 200000; // 200000 10000
  const int patchWidth = 8;
  MNISTSamplePatchesDataFunction mnistdf(numPatches, patchWidth);
  Config config;
  config.setValue("addBiasTerm", false);
  config.setValue("meanStddNormalize", false);
  config.setValue("configurePolicyTesting", false);
  config.setValue("trainingMeanAndStdd", false);
  updateMNISTConfig(config);

  const int numFeatures = 50;
  const double lambda = 0.0005f;
  const double epsilon = 1e-2;

  SoftICACostFunction sfc(numFeatures, lambda, epsilon);

  LIBLBFGSOptimizer lbfgs(1000);
  Driver drv(&config, &mnistdf, &sfc, &lbfgs);
  drv.drive();

}
예제 #22
0
static int drv(int p,int c) {
  int p1,p2,cf,cl,cn,ret,m;
  assert(!P_IS(p,P_ERROR));
  m=new_memo(p,c);
  if(m!=-1) return M_RET(m);
  switch(P_TYP(p)) {
  case P_NOT_ALLOWED: case P_EMPTY: ret=notAllowed; break;
  case P_CHOICE: Choice(p,p1,p2); ret=choice(drv(p1,c),drv(p2,c)); break;
  case P_GROUP: Group(p,p1,p2); {int p11=group(drv(p1,c),p2); ret=nullable(p1)?choice(p11,drv(p2,c)):p11;} break;
  case P_ONE_OR_MORE: OneOrMore(p,p1); ret=group(drv(p1,c),choice(empty,p)); break;
  case P_EXCEPT: Except(p,p1,p2); ret=nullable(drv(p1,c))&&!nullable(drv(p2,c))?empty:notAllowed; break;
  case P_RANGE: Range(p,cf,cl); ret=cf<=c&&c<=cl?empty:notAllowed; break;
  case P_CLASS: Class(p,cn); ret=in_class(c,cn)?empty:notAllowed; break;
  case P_ANY: ret=empty; break;
  case P_CHAR: Char(p,cf); ret=c==cf?empty:notAllowed; break;
  default: ret=0; assert(0);
  }
  new_memo(p,c); M_SET(ret);
  accept_m();
  return ret;
}
예제 #23
0
 inline bool close() { return drv()->close(); }
예제 #24
0
 inline bool open() { return drv()->open(paramsAsProperty().toString()); }
예제 #25
0
 inline bool isValid() const { return drv()->isValid(); }
예제 #26
0
파일: LibDevice.cpp 프로젝트: Busti/LCDHost
lh_device *LibDevice::lockptr()
{
    if(LibDevicePointer *ldp = drv()->findChild<LibDevicePointer *>(objectName()))
        return ldp->lock();
    return 0;
}
예제 #27
0
파일: LibDevice.cpp 프로젝트: Busti/LCDHost
void LibDevice::unlock()
{
    if(LibDevicePointer *ldp = drv()->findChild<LibDevicePointer *>(objectName()))
        ldp->unlock();
    // devmutex_.unlock();
}
예제 #28
0
int main(int argc, char **argv) {
    
    std::string connectionStr("mysql://*****:*****@localhost:13000");
    if (argc > 1) {
        if (argv[1] == strstr(argv[1], "mysql://")) {
            connectionStr.assign(argv[1]);
        }
    }
    std::cout << "Trying to connect to <" << connectionStr << ">\n";

    std::unique_ptr<system::Binary_log_driver> drv(mysql::system::create_transport(connectionStr.c_str()));

    mysql::Binary_log binlog(drv.get());

    /*
      Attach a custom event parser which produces user defined events
    */
    mysql::Basic_transaction_parser transaction_parser;
    Incident_handler incident_handler;
    Replay_binlog replay_handler;

    binlog.content_handler_pipeline()->push_back(&transaction_parser);
    binlog.content_handler_pipeline()->push_back(&incident_handler);
    binlog.content_handler_pipeline()->push_back(&replay_handler);

    int ret = binlog.connect();
    if (0 != ret) {
        std::cerr << "Can't connect to the master.\n";
        return -1;
    }

    if (binlog.set_position(4) != ERR_OK) {
        std::cerr << "Can't reposition the binary log reader.\n";
        return -1;
    }

    Binary_log_event *event;

    bool quit = false;
    while (!quit) {
        /*
         Pull events from the master. This is the heart beat of the event listener.
        */
        if (binlog.wait_for_next_event(&event)) {
            quit = true;
            continue;
        }

        /*
         Print the event
        */
        std::cout << "MainLoop: Event type: [" << mysql::system::get_event_type_str(event->get_event_type())
        << "] length: " << event->header()->event_length
        << " next pos: " << event->header()->next_position
        << std::endl;

        /*
         Perform a special action based on event type
        */

        switch (event->get_event_type()) {
            case mysql::QUERY_EVENT: {
                const mysql::Query_event *qev = static_cast<const mysql::Query_event *>(event);

                std::cout << "query= " << qev->query
                << " db= " << qev->db_name
                << std::endl
                << std::endl;

                if (qev->query.find("DROP TABLE REPLICATION_LISTENER") !=
                    std::string::npos ||
                    qev->query.find("DROP TABLE `REPLICATION_LISTENER`") !=
                    std::string::npos) {
                    quit = true;
                }
            }
                break;

            case mysql::ROTATE_EVENT: {
                mysql::Rotate_event *rot = static_cast<mysql::Rotate_event *>(event);

                std::cout << "filename= " << rot->binlog_file.c_str()
                << " pos= " << rot->binlog_pos
                << std::endl
                << std::endl;
            }
                break;

        }
        delete event;
    }
    return 0;
}