今週になって突然、うちの部署で無線技術の勉強をすることに。
2人を除いて全員無線なんて全然知らないんで、取り敢えず簡単な状況から連日に渡り勉強会。
んで今日はねこさんが担当で802.11nの解説。信号の変復調から送信方式まで知識ゼロの状態から2~3日の突貫でなんとか付け刃を準備…はっきり言って無謀でした orz
*お世話になった資料
ほんとにお世話になりました m( _ _ )m
火曜日, 4月 10, 2007
月曜日, 4月 02, 2007
[C++] (ファイルから)数値データを読み込む
老化の進んだねこさんの備忘録シリーズ…しばらくすると覚えてられない orz
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
struct Spectrum {
   double freq, power;
};
int main(int argc, char* argv[]) {
   std::istream& is = std::cin;
   std::string line;
   boost::regex reg("^\\s*(\\S+)\\s*(\\S+)\\s*");
   boost::smatch results;
   std::vector<Spectrum> spec;
   while (!is.eof()) {
       std::getline(is,line);
       Spectrum sp;
       if (boost::regex_search(line,results,reg)) {
           try {
               sp.freq  = boost::lexical_cast<double>(results.str(1));
               sp.power = boost::lexical_cast<double>(results.str(2));
           }
           catch (boost::bad_lexical_cast &) {
               // do anything....
           }
           spec.push_back(sp);
       }
   }
   std::vector<Spectrum>::iterator it;
   for (it=spec.begin();it!=spec.end();++it) {
       std::cout << it->freq << " " << it->power << std::endl;
   }
   return EXIT_SUCCESS;
}コンパイルはこんな感じ
g++ -O3 -o spec spec.cc -lboost_regex-gcc-mt-1_32(参考)
登録:
コメント (Atom)
 
