comparison example/Miller_Rabin/spe/PrintTask.cc @ 1242:9d37fa6bc1da draft

add Miller_Rabin
author Daichi Toma <amothic@gmail.com>
date Tue, 01 Nov 2011 19:01:13 +0900
parents
children cd50c48f45e7
comparison
equal deleted inserted replaced
1241:b96b1604ab85 1242:9d37fa6bc1da
1 #include <stdio.h>
2 #include "SchedTask.h"
3 #include "PrintTask.h"
4 #include "Func.h"
5
6 typedef unsigned long long U64;
7
8 SchedDefineTask1(PrintTask, print);
9
10 static int
11 print(SchedTask *smanager, void *rbuf, void *wbuf)
12 {
13 bool print_flag = (bool)smanager->get_param(1); //プリントするかどうか
14
15 if (print_flag == false) {
16 return 0;
17 }
18
19 U64 size = ((U64)smanager->get_param(0)) >> 1; /* 出力する範囲 */
20 bool *input = (bool*)smanager->get_input(rbuf, 0); /* 出力する配列 */
21
22 printf("%d ",(int)2);
23
24 /* 素数の判定結果が1ならば出力する */
25 for (U64 i = 1; i < size; i++) {
26 if ( input[i] == true ) {
27 printf("%llu ",i*2+1);
28 }
29 }
30 printf("\n");
31 return 0;
32 }