ときどきの雑記帖 RE* (新南口)
Albedo 0.39
今週のしずえさん
かなづちの使い方。
Firefox
- Firefoxのユーザー、約3年で4600万人減……その理由を考察したレポートが海外で話題に【やじうまWatch】 - INTERNET Watch
- Firefox Lost Almost 50 million Users: Here’s Why It is Concerning - It’s FOSS News
そう言えば某自治体の某予約サイトがですね、 何回めかのバージョンアップ(システム入れ替え?)のときに いきなり予告もなしにFirefoxお断りにしてくれたので、 余計な苦労(謎)をする羽目になりマイナーの悲哀を感じたり。
まあ最初の時点で「推奨」に入っていたかどうかは覚えてないのだけど (使えてはいたのが途中から蹴られるようになった)。
2010
2001年宇宙の旅と比べちゃうとアレだけど、 実は結構好きだったりする>(映画の)2010年
CDC6000
続き。
プログラム的にしらみつぶしに探したにしても、(おそらくは)60bit整数の範囲の検索では それほど大きな数まではできないだろう ((expt(expt 2 60) 0.2) → 4096.0)から、 「見つからなかった」場合はあまり意味がないような気がするので なにか実行するのに特別な理由があったんじゃないか と思い検索したが、求めるものは見つからなかった。
- ランダー・パーキン・セルフリッジ予想 - Wikipedia
- オイラー予想 - Wikipedia
- How Two Sentences (and a CDC 6600 program) Overturned 200 Years Of Mathematical Precedent : programming
- How Two Sentences Overturned 200 Years Of Mathematical Precedent
Euler’s sum of powers conjecture - Wikipedia
Euler’s conjecture was disproven by L. J. Lander and T. R. Parkin in 1966 when, through a direct computer search on a CDC 6600, they found a counterexample for k = 5.[3] This was published in a paper comprising just two sentences.[3] A total of three primitive (that is, in which the summands do not all have a common factor) counterexamples are known:
27^5 + 84^5 + 110^5 + 133^5 = 144^5 (Lander & Parkin, 1966),
(-220)^5 + 5027^5 + 6237^5 + 14068^5 = 14132^5 (Scher & Seidl, 1996), and
55^5 + 3183^5 + 28969^5 + 85282^5 = 85359^5 (Frye, 2004).
(log (expt 85359 5) 2)
81.90628
ただこの過程で2014年の10月や2015年の4月にもTwitterで話題になっていたのを (英語でだけど) 発見した。
Shortest-known paper in a serious math journal. Two sentences. pic.twitter.com/TW2wHn3JPS
— Cliff Pickover (@pickover) October 26, 2014
Shortest-known paper in a serious math journal. Two sentences. pic.twitter.com/TW2wHn3JPS
— Cliff Pickover (@pickover) April 7, 2015
一連のスレッドを追いかけてみるとプログラムを書いたという人もいて
@pickover And reproduced on a modern computer in less than 1 second of runtime: http://t.co/wHZWKomNlF 27^5 + 84^5 + 110^5 + 133^5 = 144^5
— Bert Hubert 🇺🇦 (@bert_hu_bert) October 26, 2014
@pickover @andreasdotorg I wonder how long that search took on the CDC 6600? It takes 0.018 seconds on my home PC! http://t.co/i55sLmBLUt
— Bruce Hoult (@BruceHoult) April 7, 2015
そのプログラムがこれ↓
Euler conjecture - Pastebin.com
/*
https://twitter.com/pickover/status/585271919991095296
$ gcc -O3 n_nth_powers.cpp -o n_nth_powers
$ time ./n_nth_powers
27^5 + 84^5 + 110^5 + 133^5 = 144^5
real 0m0.018s
user 0m0.018s
sys 0m0.000s
*/
#include <stdio.h>
#include <stdint.h>
typedef uint64_t num;
const int MAX=7131; // 5th root of 2^64
int main()
{
num power5[MAX+1];
for (num i=0; i<=MAX; ++i) power5[i] = i*i*i*i*i;
for (int n4=1; n4<=MAX; ++n4){
num tot4 = power5[n4];
int guess = n4;
num guessp5 = power5[guess];
for (int n3=1; n3<=n4; ++n3){
num tot3 = tot4 + power5[n3];
for (int n2=1; n2<=n3; ++n2){
num tot2 = tot3 + power5[n2];
for (int n1=1; n1<=n2; ++n1){
num tot = tot2 + power5[n1];
if (guessp5 < tot){
do {
guessp5 = power5[++guess];
} while (guessp5 < tot);
} else if (guessp5 > tot){
do {
guessp5 = power5[--guess];
} while (guessp5 > tot);
}
if (guessp5 == tot){
printf("%d^5 + %d^5 + %d^5 + %d^5 = %d^5\n", n1, n2, n3, n4, guess);
return 0;
}
}
}
}
}
return 0;
}
なんか面白いことやっている? 右辺の5乗の計算で工夫しているようだけど どのくらい効果があるんだろう。
O2 O3
上記のプログラムでは-O3を指定することを想定しているっぽく、 そういた前回自分は「手癖」で-O2を指定したけど -O2と-O3ではどのくらい変わるのか気になった。
gcc最適化(O2/O3)アセンブラ比較(その3) | コマンドの達人 という記事もあったけどまずはマニュアルだよね。 ということで
Optimize Options (Using the GNU Compiler Collection (GCC)) を見ると、O1、O2、O3 で以下のような最適化が有効になっていく模様。
-O1
-fauto-inc-dec
-fbranch-count-reg
-fcombine-stack-adjustments
-fcompare-elim
-fcprop-registers
-fdce
-fdefer-pop
-fdelayed-branch
-fdse
-fforward-propagate
-fguess-branch-probability
-fif-conversion
-fif-conversion2
-finline-functions-called-once
-fipa-modref
-fipa-profile
-fipa-pure-const
-fipa-reference
-fipa-reference-addressable
-fmerge-constants
-fmove-loop-invariants
-fomit-frame-pointer
-freorder-blocks
-fshrink-wrap
-fshrink-wrap-separate
-fsplit-wide-types
-fssa-backprop
-fssa-phiopt
-ftree-bit-ccp
-ftree-ccp
-ftree-ch
-ftree-coalesce-vars
-ftree-copy-prop
-ftree-dce
-ftree-dominator-opts
-ftree-dse
-ftree-forwprop
-ftree-fre
-ftree-phiprop
-ftree-pta
-ftree-scev-cprop
-ftree-sink
-ftree-slsr
-ftree-sra
-ftree-ter
-funit-at-a-time
-O2
-falign-functions -falign-jumps
-falign-labels -falign-loops
-fcaller-saves
-fcode-hoisting
-fcrossjumping
-fcse-follow-jumps -fcse-skip-blocks
-fdelete-null-pointer-checks
-fdevirtualize -fdevirtualize-speculatively
-fexpensive-optimizations
-ffinite-loops
-fgcse -fgcse-lm
-fhoist-adjacent-loads
-finline-functions
-finline-small-functions
-findirect-inlining
-fipa-bit-cp -fipa-cp -fipa-icf
-fipa-ra -fipa-sra -fipa-vrp
-fisolate-erroneous-paths-dereference
-flra-remat
-foptimize-sibling-calls
-foptimize-strlen
-fpartial-inlining
-fpeephole2
-freorder-blocks-algorithm=stc
-freorder-blocks-and-partition -freorder-functions
-frerun-cse-after-loop
-fschedule-insns -fschedule-insns2
-fsched-interblock -fsched-spec
-fstore-merging
-fstrict-aliasing
-fthread-jumps
-ftree-builtin-call-dce
-ftree-pre
-ftree-switch-conversion -ftree-tail-merge
-ftree-vrp
-fgcse-after-reload
-fipa-cp-clone
-floop-interchange
-floop-unroll-and-jam
-fpeel-loops
-fpredictive-commoning
-fsplit-loops
-fsplit-paths
-ftree-loop-distribution
-ftree-loop-vectorize
-ftree-partial-pre
-ftree-slp-vectorize
-funswitch-loops
-fvect-cost-model
-fvect-cost-model=dynamic
-fversion-loops-for-strides
O2からO3ではそれほど増えてはいないけど、なんかループ絡みのものが目立つような?
追記
e以外の5乗の計算を最内のループから追い出した最適化は
-O1で有効になる
-fmove-loop-invariants
ですな多分。
match
正規表現で末尾が一致するのにif文でfalseが返ってくる。 - Qiita
この種の混乱(勘違い)はPythonでも見たような。 re — 正規表現操作 — Python 3.9.4 ドキュメント
あと、(コメントにもあるように)endWith使うところだろうという話は脇によけといて
matches
public boolean matches()
領域全体をこのパターンとマッチします。
マッチが成功した場合は、start、end、およびgroupメソッドを使用して詳細情報を取得できます。
戻り値:
領域シーケンスの全体がこの正規表現エンジンのパターンとマッチした場合にのみtrue
ん-、わかりづらいっちゃわかりづらい?>動作の説明
でも「領域全体を」ってあるしなあ。
xargs
POSIX的にはどうなの? ということでいつものように。
-I replstr
[XSI] [Option Start] Insert mode: utility is executed for each logical line from standard input. Arguments in the standard input shall be separated only by unescaped <newline> characters, not by <blank> characters. Any unquoted unescaped <blank> characters at the beginning of each line shall be ignored. The resulting argument shall be inserted in arguments in place of each occurrence of replstr. At least five arguments in arguments can each contain one or more instances of replstr. Each of these constructed arguments cannot grow larger than an implementation-defined limit greater than or equal to 255 bytes. Option -x shall be forced on.
-x
Terminate if a constructed command line will not fit in the implied or specified size (see the -s option above).
なるほど。
banner
ちょっと笑ってしまった。
そういや昔の(っていつですか)コマンドには使い方のサマリを出してくれるのそんなになかったよねえ。 で、manを読む。と。