• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Tape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Tape的典型用法代码示例。如果您正苦于以下问题:C++ Tape类的具体用法?C++ Tape怎么用?C++ Tape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Tape类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Tape

Tape* TapeManager::findTape( const QString & id )
{
  /* 2002-01-26 LEW */
  //  printf("Contents of _tapeIDs: %d entries\n", _tapes.count());  
  //  for ( QStringList::Iterator it = _tapeIDs.begin(); it != _tapeIDs.end(); ++it ) {
  //    printf("%s\n", (*it).latin1());
  //  }
  //  printf("\n");

  //  QDictIterator<Tape> it( _tapes );
  //  printf("Contents of _tapes: %d entries\n", _tapes.count());
  //  for( ; it.current(); ++it )
  //    printf("index ?: %s (%d)\n", it.current()->getName().latin1(), 
  //                            it.current()->getCTime());
  //  printf("\n");
  /* 2002-01-26 LEW */

    Tape* tape = _tapes[ id ];

    if ( !tape ) {
        tape = new Tape( id.ascii() );
        _tapes.insert( tape->getID(), tape );
    }

    return tape;
}
开发者ID:iegor,项目名称:kdesktop,代码行数:26,代码来源:TapeManager.cpp


示例2: measure

double measure(Tape& tape) {
  uint64_t result(0);
  timer t;
  t.start();
  std::accumulate(tape.begin(), tape.end(), result);
  return t.stop();
}
开发者ID:FelixPetriconi,项目名称:stepanov-conversations-course,代码行数:7,代码来源:test_tape.cpp


示例3: Tape

Tape* TapeManager::findTape( const char* id )
{
    Tape* tape = _tapes[ id ];

    if ( !tape ) {
        tape = new Tape( id );
        _tapes.insert( tape->getID(), tape );
    }

    return tape;
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:11,代码来源:TapeManager.cpp


示例4: run

 void run() {
   Tape tape;
   for (int pc = 0; pc < code.length(); pc++) {
     switch (code[pc]) {
       case '+':
         tape.inc();
         break;
       case '-':
         tape.dec();
         break;
       case '>':
         tape.advance();
         break;
       case '<':
         tape.devance();
         break;
       case '[':
         if (tape.get() == 0) pc = bracket_map[pc];
         break;
       case ']':
         if (tape.get() != 0) pc = bracket_map[pc];
         break;
       case '.':
         printf("%c", tape.get());
         fflush(stdout);
         break;
     }
   }
 }
开发者ID:343829084,项目名称:benchmarks,代码行数:29,代码来源:brainfuck.cpp


示例5: emplace_back

namespace graph {
    thread_local bool _backprop_enabled = true;
    thread_local Tape tape;

    void emplace_back(std::function<void()>&& f) {
        tape.backprop.emplace_back(f);
    }

    void backward() {
        tape.backward();
    }

    void clear() {
        tape.backprop.clear();
    }

    bool backprop_enabled() {
        return _backprop_enabled;
    }

    void _set_backprop_enabled(bool value) {
        _backprop_enabled = value;
    }

    size_t size() {
        return tape.backprop.size();
    }


    /* Tape */

    void Tape::backward () {
        for (auto it = backprop.rbegin(); it != backprop.rend(); ++it)
            (*it)();
        backprop.clear();
    }

    /* NoBackprop */
    NoBackprop::NoBackprop() : NoBackprop(true) {
    }

    NoBackprop::NoBackprop(bool condition) : old_value(_backprop_enabled), enabled(condition) {
        if(enabled)
            _backprop_enabled = false;
    }

    NoBackprop::~NoBackprop() {
        if (enabled)
            _backprop_enabled = old_value;
    }

}
开发者ID:bhack,项目名称:Dali,代码行数:52,代码来源:Tape.cpp


示例6: main

int main()
{
	const int success(0);
	Tape tape;
	tape.Initialize("AABB");
	try{
		tape.Update('B','L');
	}
	catch(Crash &error)
	{
		cout << error.what() << ".\n";
	}
	catch (bad_alloc& error)
	{
		cout << "allocation error!\n";
	}
	catch(...)
	{
		cout << "Something went wrong!\n";
	}
	tape.View();
	return success;
}
开发者ID:Gyathair,项目名称:CptS322TuringMachine,代码行数:23,代码来源:Main_TapeTest.cpp


示例7: Run

    void Run(Tape &tape, bool print_each_step = false)
    {
        if (print_each_step)
            tape.PrintLine();

        m_state = 0;
        while (!m_state_final[m_state])
        {
            Rule23::iterator i = m_rules.find(m_state);
            if (i == m_rules.end())
            {
                std::cerr << 'S' << m_state << " undefined.\n";
                break;
            }

            char symbol_read = tape.Read();
            Rule13 &rule13 = i->second;
            Rule13::iterator j = rule13.find(symbol_read);
            if (j == rule13.end())
            {
                std::cerr << "No rule for S" << m_state << " and '" << symbol_read << "'.\n";
                break;
            }

            Rule03 &rule03 = j->second;
            m_state = std::get<0>(rule03);

            char symbol_write = std::get<1>(rule03);
            tape.Write(symbol_write);

            char direction = std::get<2>(rule03);
            if (direction == 'L')
                tape.MoveLeft();
            else if (direction == 'R')
                tape.MoveRight();

            if (print_each_step)
                tape.PrintLine();
        }
    }
开发者ID:lewischeng-ms,项目名称:misc,代码行数:40,代码来源:turing.cpp


示例8: gradient

 /**
  * @brief Get a reference to the actual gradient value of this instance.
  * @return Reference to the gradient value.
  */
 inline Real& gradient() {
   return globalTape.gradient(gradientData);
 }
开发者ID:psesh,项目名称:CoDiPack,代码行数:7,代码来源:activeReal.hpp


示例9: calcGradient

 inline void calcGradient(Data& data, const Real& jacobi) const {
   globalTape.pushJacobi(data, jacobi, primalValue, gradientData);
 }
开发者ID:psesh,项目名称:CoDiPack,代码行数:3,代码来源:activeReal.hpp


示例10:

 /**
  * @brief Call the tape to destroy the gradient data.
  */
 inline ~ActiveReal() {
   globalTape.destroyGradientData(primalValue, gradientData);
 }
开发者ID:psesh,项目名称:CoDiPack,代码行数:6,代码来源:activeReal.hpp


示例11: ActiveReal

 /**
  * @brief Copy Constructor. The logic is handled by the tape.
  *
  * The tape is required to set the primal value of v to the primal value
  * of this type.
  *
  * @param[in] v The value to copy.
  */
 inline ActiveReal(const ActiveReal<Real, Tape>& v) {
   globalTape.initGradientData(this->primalValue, gradientData);
   globalTape.store(primalValue, gradientData, v);
 }
开发者ID:psesh,项目名称:CoDiPack,代码行数:12,代码来源:activeReal.hpp


示例12: getGradient

 /**
  * @brief Get the value of the gradient of this instance.
  * @return The gradient value.
  */
 inline Real getGradient() const {
   return globalTape.getGradient(gradientData);
 }
开发者ID:psesh,项目名称:CoDiPack,代码行数:7,代码来源:activeReal.hpp


示例13: setGradient

 /**
  * @brief Set the value of the gradient of this instance.
  * @param gradient  The new gradient value.
  */
 inline void setGradient(const Real& gradient) {
   globalTape.setGradient(gradientData, gradient);
 }
开发者ID:psesh,项目名称:CoDiPack,代码行数:7,代码来源:activeReal.hpp


示例14: print_tape

 inline void print_tape() {
     if (tape_changed) {
         for (int i=0; i<tape.size(); i++)
             cout << tape[i];
         cout << endl;
     }
 }
开发者ID:pkrumins,项目名称:busy-beaver,代码行数:7,代码来源:busy-beaver.cpp


示例15: move_head

    inline void move_head(char move) {
        if (move == 'l')
            pos -= 1;
        else if (move == 'r')
            pos += 1;
        else
            throw string("unknown state");

        if (pos < 0) {
            tape.insert(tape.begin(), init);
            pos = 0;
        }
        if (pos >= tape.size()) {
            tape.push_back(init);
        }
        moves++;
    }
开发者ID:pkrumins,项目名称:busy-beaver,代码行数:17,代码来源:busy-beaver.cpp


示例16: backward

 void backward() {
     tape.backward();
 }
开发者ID:bhack,项目名称:Dali,代码行数:3,代码来源:Tape.cpp



注:本文中的Tape类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Target类代码示例发布时间:2022-05-31
下一篇:
C++ TaoMessage类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap