sin の検索結果:

点線で楕円を描く・まとめ

…(a * math.sin(phi))**2 + (b * math.cos(phi))**2) def coordinate(du, a, b): for angle in angles(du, a, b): yield (a * math.cos(angle), b * math.sin(angle)) def circumference(a, b): """Return a length of a circumference of an ellipse. @param …

点線で楕円を描く・その2

…k2 * math.sin(phi)**2) def draw(argv=None): if not argv: argv = sys.argv filename = argv[1] a = float(argv[2]) b = float(argv[3]) du = float(argv[4]) k2 = 1 - (b/a)**2 phi = 0 with open(filename, 'w') as out_file: print >> out_file, '#x\ty'…

点線で楕円を描く

[追記] この記事には誤りが含まれています。訂正した記事はこちらです。 今日は 1 つネタをもらったので, ガチな数学をやろうと思います. お題は「点線で楕円を描く」です.円の場合は, 等角度ごとに区切って点線を書いていけば良いので簡単です. たいていの場合, 三角関数は標準ライブラリにあるのであまり苦労しません.しかし楕円の場合となると, 円がつぶれた形をしているので一筋縄ではいきません. 話の流れを追いつつ, どう解決していったか見ていきましょう. 発端 募集:PIL で…

高木貞治プロジェクト・代数的整数論

高木貞治プロジェクトとは 2011年1月1日をもって高木貞治先生の著作権が切れ, 著作物の内容を様々な形で利用できるようになりました. そこで著作物の内容を Web 上で公開していくプロジェクトが開始されました.ここがプロジェクト・ホームになると思います. http://oku.edu.mie-u.ac.jp/~okumura/blog/node/2574事の起こりの流れは Togetter にまとめられています. http://togetter.com/li/86256 公…

Dijkstra 法がなぜ並列処理に向かないか?

…しかないリソース (Singleton!) に対して各選手が処理を行っているため依存関係が生じ, どうしてもそれぞれの処理を並列で動かすことができません. これを小難しく数式で書くとアムダールの法則とグスタフソンの法則になります. とは言ってもこの式は算数レベルの話なので, 覚えるほどの価値はありません. 式の字面を覚えるのではなく「並列処理基盤に載せても, 並列に処理できるとこしか処理時間の圧縮はできないよ」という式の意味の方を, 自分の言葉で噛み砕いて脳みそに染み込ませて…

python の内包表記で list の flatten を書く

…Returns a single, flat list which contains all elements retrieved from the sequence and all recursively contained sub-sequences (iterables). Examples: >>> [1, 2, [3,4], (5,6)] [1, 2, [3, 4], (5, 6)] >>> flatten([[[1,2,3], (42,None)], [4,5],…

19問目

…t firstDaysInLeapYear[N_DAYS_IN_WEEK] = {3, 1, 1, 2, 2, 1, 2}; const int FIRST_YEAR_IN_19TH_CENTURY = 1901; const int FIRST_YEAR_IN_20TH_CENTURY = 2001; int solveVer00(); int isLeapYear(int); enum day nextNewYearsDay(int, enum day); int num…

問題2改

…ual/libc/Using-Getopt.html#Using-Getopt #include <stdio.h> #include <stdlib.h> #include <math.h> long solveVer00(long); long solveVer01(long); int main(int argc, char **argv) { int version; long upperBound; upperBound = 4000000; if (argc ==…

Tomcat のインストールの作業メモ

…artup.sh Using CATALINA_BASE: /usr/local/tomcat/current Using CATALINA_HOME: /usr/local/tomcat/current Using CATALINA_TMPDIR: /usr/local/tomcat/current/temp Using JRE_HOME: /Library/Java/Homehttp://localhost:8080/ をブラウザで開いて無事 Tomcat のページが表示…

gcc でアセンブリコードを出力する

…gdb) step Single stepping until exit from function main, which has no line number information. 0x00001f82 in _start () (gdb) info register eax 0x0 0 ecx 0x1 1 edx 0x0 0 ebx 0xbffff8f4 -1073743628 esp 0xbffff890 0xbffff890 ebp 0xbffff8c8 0xb…

readlineの使い方 追記

…ad_history _readline _using_history _write_history collect2: ld returned 1 exit statusA. あぁ、ごめんごめん。readlineを使うときは、readlineとcursesをリンクしなきゃいけないんだ。 -l オプションでreadlineとcursesのライブラリを指定してくれ。 [hogehoge]$ gcc prompto.c -o prompto -lreadline -lcurses

readlineの使い方

…story機能は、using_historyで初期化して、add_historyでhistoryに登録するんだ。 Q. うぇえん、この前のhistoryが見付からないよぉ。 A. 落ち着け、No.5。必ずその機能があるはずだ。 それはさておき、なんかしらのファイルに保存したり、そこから読み出したりする操作をしないと、記録されるわけはないわな。そのための関数が、write_historyとread_historyだ。 使い方は、historyファイルの名前を".my_histo…