Mercurial > hg > Game > Cerium
diff example/Miller_Rabin/spe/Prime.cc @ 1244:cd50c48f45e7 draft real_matrix
fix
author | Daichi Toma <amothic@gmail.com> |
---|---|
date | Thu, 03 Nov 2011 20:40:17 +0900 |
parents | 9d37fa6bc1da |
children | 163207b736c5 |
line wrap: on
line diff
--- a/example/Miller_Rabin/spe/Prime.cc Tue Nov 01 19:23:11 2011 +0900 +++ b/example/Miller_Rabin/spe/Prime.cc Thu Nov 03 20:40:17 2011 +0900 @@ -62,18 +62,19 @@ U64 start = (U64)smanager->get_param(0); /* 素数判定の開始地点 */ U64 end = (U64)smanager->get_param(1); /* 素数判定の終了地点 */ U64 range = end - start; /* 判定する範囲 */ + U64 index_range = range >> 1; /* 判定結果を収める配列を受け取る */ bool *output = (bool*)smanager->get_output(wbuf, 0); /* 初期化 */ - for (U64 i = 0; i < range; i++){ - output[i] = true; + for (U64 i = 0; i < index_range; i++){ + output[i] = false; } - for (U64 i = start + 1,index = 0; index < range; i += 2, index++) { - if (!isPrime(i)) { - output[index] = false; + for (U64 i = start + 1,index = 0; i < end ; i += 2, index++) { + if (isPrime(i)) { + output[index] = true; } } return 0;