2010-09-01から1ヶ月間の記事一覧

離散フーリエ変換時の補完とか

dsp

頭こんがらがります。 時間領域 周波数領域 ブロック全体の最後に0詰め 周波数補完 サンプル補完 ナイキスト周波数の辺りに0詰め サンプルごとに0詰め サンプリングレート変換(折り返しあり) ブロック繰り返し 周波数ごとに0詰め

コンパイラ屋さんが頑張っています。boost屋さんも頑張っています

#include <iostream> #include <boost/preprocessor/repetition/repeat.hpp> #include <boost/preprocessor/arithmetic/add.hpp> #include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/stringize.hpp> #define TEST_MAX 229 #define MAX_CLASS BOOST_PP_CAT(A, TEST_MAX) struct MAX_CLASS; struct A0 { st…</boost/preprocessor/stringize.hpp></boost/preprocessor/cat.hpp></boost/preprocessor/arithmetic/add.hpp></boost/preprocessor/repetition/repeat.hpp></iostream>

removedアダプタ

Boost.Filesystem v3調べ物メモ - Faith and Brave - C++で遊ぼう removedアダプタは僕も欲しいかも・・・! #ifndef HWM_REMOVED_HPP_ #define HWM_REMOVED_HPP_ #include <pstade/oven/detail/base_to_adaptor.hpp> #include <pstade/oven/detail/filter_iterator.hpp> #include <pstade/result_of.hpp> #include <pstade/oven/range_value.hpp> #i…</pstade/oven/range_value.hpp></pstade/result_of.hpp></pstade/oven/detail/filter_iterator.hpp></pstade/oven/detail/base_to_adaptor.hpp>

enumerate Rangeアダプタがすっきりした

前々回、こんなのを作ったけど、any_rangeを使ったりしてなんだか汚い感じでしたし、 counting rangeのDifferenceかなんかの型がmsvcでwarning:4244を出したりして微妙だったので改良を。 #ifndef HWM_ENUMERATE_HPP_ #define HWM_ENUMERATE_HPP_ #include <pstade/result_of.hpp> </pstade/result_of.hpp>…

演算子の優先順位、Range

オウフ・・・ using namespace pstade::oven; int v[] = { 1, 2, 3, 4, 5, 6, 7 }; int a = 4; BOOST_AUTO(it, find(v, a)); return (it == v|end) ? *it : -1; なんか通らない通らない、何がおかしいのやらってよくわかんないけどどうしたもんだって思っていたら…

OvenでPythonで言うところのenumerate関数を作る。(何番煎じ?)

enumerate.hpp #ifndef HWM_ENUMERATE_HPP_ #define HWM_ENUMERATE_HPP_ #include <boost/tuple/tuple.hpp> #include <pstade/pass_by.hpp> #include <pstade/result_of.hpp> #include <pstade/oven/any_range.hpp> #include <pstade/oven/counting.hpp> #include <pstade/oven/distance.hpp> #include </pstade/oven/distance.hpp></pstade/oven/counting.hpp></pstade/oven/any_range.hpp></pstade/result_of.hpp></pstade/pass_by.hpp></boost/tuple/tuple.hpp>

円周率

ぼーーーー( ゚ ρ ゚ ) #include <pstade/oven/generation.hpp> #include <pstade/oven/algorithm.hpp> #include <pstade/oven/regular.hpp> #include <cmath> #include <cstdio> struct generator { typedef double result_type; result_type operator()() const { a_ += 1.0; return a_; } generator() : a_(0.) {} private: mut…</cstdio></cmath></pstade/oven/regular.hpp></pstade/oven/algorithm.hpp></pstade/oven/generation.hpp>

0と1を次々と返すC++のコード

C++

0と1を次々返す方法 - When it’s ready. C++らしく書けばこうかな #include <iostream> struct switcher { switcher(bool p = true) : p_(!p) {} operator bool() { return p_ = !p_; } private: bool p_; }; int main() { switcher sw; std::cout << sw << std::endl;</iostream>…

Perl練習、再帰とファイルシステムの扱い

カレントディレクトリ以下からC++のソース、ヘッダを見つけて列挙 use strict; sub FindFile { my ($dir, $pred, $operator) = @_; my @list = (); opendir(DIR, $dir) or die("Can not open directory : $dir ($!)"); @list = readdir(DIR); closedir(DIR);…

Perlのクラスメンバの配列変数

メモ。 Perlでクラスを作ったときに配列のメンバ変数を持ちたい時。 my $self = { arr_ => [@list] }; でハッシュに入れて foreach (@{ $self->{arr_} }) { print $_ . "\n"; } みたいにして使う。[]で配列の無名リファレンスを作ってスカラに代入、 @{}で配…