¥Ý¥±¥â¥óGO ¸ÄÂÎÃÍ·×»»

¥Ý¥±¥â¥óGO¤Ç¤Ï¡¢Â¿¤¯¤Î¥È¥ì¡¼¥Ê¡¼¤¬ºÇ¶¯¤Î¥Ý¥±¥â¥ó¤òõ¤·¤Æ¤¤¤Þ¤¹¡£
¤·¤«¤·¡¢100%¸ÄÂÎÃͤȸƤФì¤ëºÇ¶¯¥Ý¥±¥â¥ó¤¬¼ê¤ËÆþ¤ë¤³¤È¤Ï¡¢¤á¤Ã¤¿¤Ë¤¢¤ê¤Þ¤»¤ó¡£
¤Ê¤Î¤Ç¡¢90%¤ä80%¤Ç²æËý¤¹¤ë¤ï¤±¤Ç¤¹¤¬¡¢¤³¤Î¡ó¤Çɽ¤»¤é¤ì¤ë¸ÄÂÎÃͤȤϲ¿¤À¤í¤¦¤È»×¤¤¡¢Ä´¤Ù¤Æ¤ß¤Þ¤·¤¿¡£

³Æ¥Ý¥±¥â¥ó¤Ë¤Ï¡¢´ðËܤȤʤë¼ï²Ã͡ʹ¶·âÎÏ¡¦ËɸæÎÏ¡¦ÂÎÎϡˤ¬ÀßÄꤵ¤ì¤Æ¤¤¤Æ¡¢
¤½¤ì¤¾¤ì¤Î¸ÄÂΤˤϡ¢¡Ü¦Á¤È¤Ê¤ë¡¢¹¶·âÎÏ¡¦ËɸæÎÏ¡¦ÂÎÎϤ¬Í¿¤¨¤é¤ì¤ë¡£
¥²¡¼¥à²èÌ̾å¤Çɽ¼¨¤µ¤ì¤ëÃͤϡ¢¶¯¤µ¤òɽ¤¹CP¤ÈÂÎÎϤòɽ¤¹HP¤À¤±¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£





¸ÄÂÎÆÃÍ­ÃÍ(Individual)¤Ï¡¢¹¶·âÎÏ¡¦ËɸæÎÏ¡¦ÂÎÎϤ½¤ì¤¾¤ì¤Ë¡¢0¡Á15¤ÎÈϰϤǷèÄꤵ¤ì¤ë¡£

¥Ý¥±¥â¥ó¤Ë¤Ï¡¢1¡Á40¤Î¥ì¥Ù¥ë¤¬¤¢¤ê¡¢0.5¥­¥¶¥ß¤Ç»ØÄꤵ¤ì¤ë¡£
¤³¤Î¥ì¥Ù¥ë¤Ï¡¢¶¯²½¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢0.5¾å¤²¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
¥Ý¥±¥â¥ó¥ì¥Ù¥ë¤Ë¤è¤ê¡¢CPÊäÀµÃͤ¬°ì°Õ¤ËÄê¤Þ¤ë¡£

¥Ý¥±¥â¥óËè¤Î¼ï²Ãͤ䡢CPÊäÀµÃͤˤĤ¤¤Æ¤Ï¡¢¥Í¥Ã¥È¾å¤ËÂô»³¤Î¾ðÊ󤬽ФƤ¤¤ë¡£

CP¤äHP¤Î·×»»ÊýË¡¤¬¤ï¤«¤Ã¤¿¤È¤³¤í¤Ç¡¢
¤Ç¤Ï¡¢¼«Ê¬¤Î»ý¤Ã¤Æ¤¤¤ë¥Ý¥±¥â¥ó¤Î¸ÄÂÎÃͤϡ¢¤É¤¦¤·¤¿¤é¤ï¤«¤ë¤Î¤À¤í¤¦¡£
¥Í¥Ã¥È¾å¤Ë¤Ï¡¢¸ÄÂÎÃÍ·×»»µ¡¤Ê¤ë¤â¤Î¤¬¤¢¤ë¤¬¡¢¤É¤¦¤ä¤Ã¤Æ·×»»¤·¤Æ¤¤¤ë¤Î¤À¤í¤¦¡£

HP¤«¤é¹Í¤¨¤Æ¤ß¤ë¡£
¥Ý¥±¥â¥ó¤Î̾Á°¤«¤é¼ï²ÃͤϤ狼¤ë¡£¡Ö¶¯²½¤ËɬÍפʺ½¡×¤«¤é¤ª¤ª¤è¤½¤Î¥Ý¥±¥â¥ó¥ì¥Ù¥ë¤¬¤ï¤«¤ë¡£
¤Ê¤é¤Ð¡¢¥ì¥Ù¥ë¤Î³ºÅöÈÏ°ÏÆâ¤ÇÊÒ¤Ãü¤«¤éHP·×»»¤ò¹Ô¤¤¡¢¥²¡¼¥à²èÌ̤˽ФƤ¤¤ëHP¤È¹çÃפ¹¤ì¤Ð¡¢¤½¤ì¤¬Àµ²ò¤È¤Ê¤ë¡£
¤·¤«¤·¡¢Ê£¿ô¤ÎÀµ²ò¤¬½Ð¤ë¤³¤È¤â¹Í¤¨¤é¤ì¤ë¤Î¤Ç¡¢¤³¤ì¤é¤ÏÀµ²ò¸õÊä¤È¤Ê¤ë¡£

CP¤âƱ¤¸¤è¤¦¤Ë·×»»¤ò¹Ô¤¦¤¬¡¢´û¤ËHP·×»»¤Ç¥ì¥Ù¥ë¸õÊ䤬¹Ê¤é¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢¤½¤Îʬ¤À¤±¤ÇºÑ¤à¡£
¥²¡¼¥à²èÌ̤˽ФƤ¤¤ëCP¤È¹çÃפ¹¤ì¤Ð¡¢¤ä¤Ï¤ê¤³¤ì¤â¡¢Àµ²ò¸õÊä¤È¤Ê¤ë¡£

Àµ²ò¸õÊä¤ò¥Æ¡¼¥Ö¥ë¤Ë¤·¤Æɽ¼¨¤¹¤ì¤Ð¡¢Êá¤Þ¤¨¤¿¥Ý¥±¥â¥ó¤Î¸ÄÂÎÃͤÎÌܰ¤Ȥʤ롣
¥Á¡¼¥à¥ê¡¼¥À¡¼¤Ë¤è¤ëɾ²Á¤¬¤ï¤«¤ì¤Ð¡¢¹¹¤ËÀµ²ò¸õÊä¤ò¹Ê¤ê¹þ¤à¤³¤È¤¬¤Ç¤­¤ë¡£

¤³¤³¤Þ¤ÇÍè¤ì¤Ð¡¢¸å¤Ï¥×¥í¥°¥é¥à¤ËÍî¤È¤·¹þ¤à¤À¤±¤Ç¤¹¡£

¤ª¤½¤é¤¯¡¢¤³¤Î¥×¥í¥°¥é¥à¤ÎÆñ¤·¤µ¤Ï¡¢¼ï²Ãͥơ¼¥Ö¥ë¤Î¹¹¿·¤À¤È»×¤¤¤Þ¤¹¡£
Niantic¼Ò¤ÎÊѹ¹¤ò¿ï»þ¡¢ÄÉÀפ·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤³¤È¤Ç¤¹¡£

¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é

Chrome, FF ¤ÇÆ°ºî³Îǧ¤·¤Æ¤¤¤Þ¤¹¡£
°Ê²¼¤Ï¥½¡¼¥¹¥³¡¼¥É¤Ç¤¹¡£index.html¤Î£±ËܤǤ¹¡£


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>poke5 ¸ÄÂÎÃÍ·×»»¥Ä¡¼¥ë</title>
<style>
* {
	margin:0;
	padding: 0;
}
body {
	padding:5px;
	background:#ace url(kinkoi.jpg);
}
#namediv input {
	width:70px;
	height:25px;
	font-size:12px;
}
input.pk_inp {
	display:block;
	margin:2px 10px 2px 0;
	padding: 2px;
}
form.hyouka input {
	margin:2px 2px 2px 20px;
	padding: 2px;
}
span.inp_lavel {
	display:block;
	width:60px;
	float:left;
	clear:both;
}
select {
	margin:5px;
	padding: 2px;
}
table {
	margin:5px;
	padding: 2px;
}
td {
	width:100px;
	text-align:center;
}
</style>

<script type="text/javascript">

var mltbl = [
// ¥Ý¥±¥â¥ó¥ì¥Ù¥ë¤Ë´Ø¤¹¤ë¥Æ¡¼¥Ö¥ë
//  ml:    ¥Ý¥±¥â¥ó¥ì¥Ù¥ë
//  perc:  ¥ì¥Ù¥ë40¤ËÂФ¹¤ë³ä¹ç
//  c:     CPÊäÀµÃÍ
//  sand:  ¶¯²½¤ËɬÍפʺ½
//  candy: ¶¯²½¤ËɬÍפʰ»
{ml:1,perc:1.414724036,c:0.094,sand:0,candy:0},
{ml:1.5,perc:2.923932542,c:0.1351374,sand:200,candy:1},
{ml:2,perc:4.433141061,c:0.1663979,sand:200,candy:1},
{ml:2.5,perc:5.942349554,c:0.1926509,sand:200,candy:1},
{ml:3,perc:7.451557498,c:0.2157325,sand:200,candy:1},
{ml:3.5,perc:8.960765971,c:0.2365727,sand:400,candy:1},
{ml:4,perc:10.4699736,c:0.2557201,sand:400,candy:1},
{ml:4.5,perc:11.97918208,c:0.2735304,sand:400,candy:1},
{ml:5,perc:13.48839026,c:0.2902499,sand:400,candy:1},
{ml:5.5,perc:14.99759871,c:0.3060574,sand:600,candy:1},
{ml:6,perc:16.50680775,c:0.3210876,sand:600,candy:1},
{ml:6.5,perc:18.01601622,c:0.335445,sand:600,candy:1},
{ml:7,perc:19.52522443,c:0.3492127,sand:600,candy:1},
{ml:7.5,perc:21.03443291,c:0.3624578,sand:800,candy:1},
{ml:8,perc:22.54364161,c:0.3752356,sand:800,candy:1},
{ml:8.5,perc:24.05285006,c:0.3875924,sand:800,candy:1},
{ml:9,perc:25.56206057,c:0.3995673,sand:800,candy:1},
{ml:9.5,perc:27.07126902,c:0.4111936,sand:1000,candy:1},
{ml:10,perc:28.58047697,c:0.4225,sand:1000,candy:1},
{ml:10.5,perc:30.00849419,c:0.4335117,sand:1000,candy:1},
{ml:11,perc:31.43650994,c:0.4431076,sand:1000,candy:1},
{ml:11.5,perc:32.86452696,c:0.45306,sand:1300,candy:2},
{ml:12,perc:34.29254396,c:0.4627984,sand:1300,candy:2},
{ml:12.5,perc:35.72056114,c:0.4723361,sand:1300,candy:2},
{ml:13,perc:37.14857675,c:0.481685,sand:1300,candy:2},
{ml:13.5,perc:38.5765939,c:0.4908558,sand:1600,candy:2},
{ml:14,perc:40.00461398,c:0.4998584,sand:1600,candy:2},
{ml:14.5,perc:41.43263118,c:0.5087018,sand:1600,candy:2},
{ml:15,perc:42.86064648,c:0.517394,sand:1600,candy:2},
{ml:15.5,perc:44.28866364,c:0.5259425,sand:1900,candy:2},
{ml:16,perc:45.71668075,c:0.5343543,sand:1900,candy:2},
{ml:16.5,perc:47.14469795,c:0.5426358,sand:1900,candy:2},
{ml:17,perc:48.57271292,c:0.5507927,sand:1900,candy:2},
{ml:17.5,perc:50.00073006,c:0.5588306,sand:2200,candy:2},
{ml:18,perc:51.42875488,c:0.5667545,sand:2200,candy:2},
{ml:18.5,perc:52.85677208,c:0.5745692,sand:2200,candy:2},
{ml:19,perc:54.28478797,c:0.5822789,sand:2200,candy:2},
{ml:19.5,perc:55.71280516,c:0.5898879,sand:2500,candy:2},
{ml:20,perc:57.14082102,c:0.5974,sand:2500,candy:2},
{ml:20.5,perc:58.56883825,c:0.6048188,sand:2500,candy:2},
{ml:21,perc:59.99873261,c:0.6121573,sand:2500,candy:2},
{ml:21.5,perc:61.42674981,c:0.6194041,sand:3000,candy:3},
{ml:22,perc:62.8566514,c:0.6265671,sand:3000,candy:3},
{ml:22.5,perc:64.28466862,c:0.6336492,sand:3000,candy:3},
{ml:23,perc:65.7145723,c:0.640653,sand:3000,candy:3},
{ml:23.5,perc:67.14258943,c:0.647581,sand:3500,candy:3},
{ml:24,perc:68.57248641,c:0.6544356,sand:3500,candy:3},
{ml:24.5,perc:70.00050364,c:0.6612193,sand:3500,candy:3},
{ml:25,perc:71.43040741,c:0.667934,sand:3500,candy:3},
{ml:25.5,perc:72.85842452,c:0.6745819,sand:4000,candy:4},
{ml:26,perc:74.28832607,c:0.6811649,sand:4000,candy:4},
{ml:26.5,perc:75.71634322,c:0.6876849,sand:4000,candy:4},
{ml:27,perc:77.14623491,c:0.6941437,sand:4000,candy:4},
{ml:27.5,perc:78.57425209,c:0.7005429,sand:4500,candy:4},
{ml:28,perc:80.00416311,c:0.7068842,sand:4500,candy:4},
{ml:28.5,perc:81.43218023,c:0.7131691,sand:4500,candy:4},
{ml:29,perc:82.86207287,c:0.7193991,sand:4500,candy:4},
{ml:29.5,perc:84.29009019,c:0.7255756,sand:5000,candy:4},
{ml:30,perc:85.71999464,c:0.7317,sand:5000,candy:4},
{ml:30.5,perc:86.43399483,c:0.734741,sand:5000,candy:4},
{ml:31,perc:87.14799422,c:0.7377695,sand:5000,candy:4},
{ml:31.5,perc:87.86199453,c:0.7407856,sand:6000,candy:6},
{ml:32,perc:88.57599299,c:0.7437894,sand:6000,candy:6},
{ml:32.5,perc:89.28999328,c:0.7467812,sand:6000,candy:6},
{ml:33,perc:90.00399022,c:0.749761,sand:6000,candy:6},
{ml:33.5,perc:90.71799057,c:0.7527291,sand:7000,candy:8},
{ml:34,perc:91.43199898,c:0.7556855,sand:7000,candy:8},
{ml:34.5,perc:92.14599918,c:0.7586304,sand:7000,candy:8},
{ml:35,perc:92.85999484,c:0.7615638,sand:7000,candy:8},
{ml:35.5,perc:93.57399517,c:0.7644861,sand:8000,candy:10},
{ml:36,perc:94.28799738,c:0.7673972,sand:8000,candy:10},
{ml:36.5,perc:95.00199776,c:0.7702973,sand:8000,candy:10},
{ml:37,perc:95.71600203,c:0.7731865,sand:8000,candy:10},
{ml:37.5,perc:96.43000241,c:0.776065,sand:9000,candy:12},
{ml:38,perc:97.14399355,c:0.7789328,sand:9000,candy:12},
{ml:38.5,perc:97.85799386,c:0.7817901,sand:9000,candy:12},
{ml:39,perc:98.57199794,c:0.784637,sand:9000,candy:12},
{ml:39.5,perc:99.2859983,c:0.7874736,sand:10000,candy:15},
{ml:40,perc:100,c:0.7903,sand:10000,candy:15}
];

var pktbl = [
// ¼ï²Ãͥơ¼¥Ö¥ë
//  no:    ¥Ý¥±¥â¥óÈÖ¹æ
//  name:  ̾Á°
//  maxcp: ºÇÂç£Ã£Ð(Lv=40)
//  atk:   ¼ï²ÃÍ ¹¶·â
//  def:   ¼ï²ÃÍ Ëɸæ
//  hp:    ¼ï²ÃÍ ÂÎÎÏ
{no:1,name:"¥Õ¥·¥®¥À¥Í",maxcp:981,atk:118,def:118,hp:90},
{no:2,name:"¥Õ¥·¥®¥½¥¦",maxcp:1552,atk:151,def:151,hp:120},
{no:3,name:"¥Õ¥·¥®¥Ð¥Ê",maxcp:2568,atk:198,def:198,hp:160},
{no:4,name:"¥Ò¥È¥«¥²",maxcp:831,atk:116,def:96,hp:78},
{no:5,name:"¥ê¥¶¡¼¥É",maxcp:1484,atk:158,def:129,hp:116},
{no:6,name:"¥ê¥¶¡¼¥É¥ó",maxcp:2686,atk:223,def:176,hp:156},
{no:7,name:"¥¼¥Ë¥¬¥á",maxcp:808,atk:94,def:122,hp:88},
{no:8,name:"¥«¥á¡¼¥ë",maxcp:1324,atk:126,def:155,hp:118},
{no:9,name:"¥«¥á¥Ã¥¯¥¹",maxcp:2291,atk:171,def:210,hp:158},
{no:10,name:"¥­¥ã¥¿¥Ô¡¼",maxcp:393,atk:55,def:62,hp:90},
{no:11,name:"¥È¥é¥ó¥»¥ë",maxcp:419,atk:45,def:94,hp:100},
{no:12,name:"¥Ð¥¿¥Õ¥ê¡¼",maxcp:1701,atk:167,def:151,hp:120},
{no:13,name:"¥Ó¡¼¥É¥ë",maxcp:397,atk:63,def:55,hp:80},
{no:14,name:"¥³¥¯¡¼¥ó",maxcp:392,atk:46,def:86,hp:90},
{no:15,name:"¥¹¥Ô¥¢¡¼",maxcp:1777,atk:169,def:150,hp:130},
{no:16,name:"¥Ý¥Ã¥Ý",maxcp:580,atk:85,def:76,hp:80},
{no:17,name:"¥Ô¥¸¥ç¥ó",maxcp:1085,atk:117,def:108,hp:126},
{no:18,name:"¥Ô¥¸¥ç¥Ã¥È",maxcp:1994,atk:166,def:157,hp:166},
{no:19,name:"¥³¥é¥Ã¥¿",maxcp:588,atk:103,def:70,hp:60},
{no:20,name:"¥é¥Ã¥¿",maxcp:1549,atk:161,def:144,hp:110},
{no:21,name:"¥ª¥Ë¥¹¥º¥á",maxcp:673,atk:112,def:61,hp:80},
{no:22,name:"¥ª¥Ë¥É¥ê¥ë",maxcp:1814,atk:182,def:135,hp:130},
{no:23,name:"¥¢¡¼¥Ü",maxcp:778,atk:110,def:102,hp:70},
{no:24,name:"¥¢¡¼¥Ü¥Ã¥¯",maxcp:1737,atk:167,def:158,hp:120},
{no:25,name:"¥Ô¥«¥Á¥å¥¦",maxcp:787,atk:112,def:101,hp:70},
{no:26,name:"¥é¥¤¥Á¥å¥¦",maxcp:2025,atk:193,def:165,hp:120},
{no:27,name:"¥µ¥ó¥É",maxcp:1194,atk:126,def:145,hp:100},
{no:28,name:"¥µ¥ó¥É¥Ñ¥ó",maxcp:2328,atk:182,def:202,hp:150},
{no:29,name:"¥Ë¥É¥é¥ó¡ê",maxcp:736,atk:86,def:94,hp:110},
{no:30,name:"¥Ë¥É¥ê¡¼¥Ê",maxcp:1218,atk:117,def:126,hp:140},
{no:31,name:"¥Ë¥É¥¯¥¤¥ó",maxcp:2338,atk:180,def:174,hp:180},
{no:32,name:"¥Ë¥É¥é¥ó¡é",maxcp:739,atk:105,def:76,hp:92},
{no:33,name:"¥Ë¥É¥ê¡¼¥Î",maxcp:1252,atk:137,def:112,hp:122},
{no:34,name:"¥Ë¥É¥­¥ó¥°",maxcp:2386,atk:204,def:157,hp:162},
{no:35,name:"¥Ô¥Ã¥Ô",maxcp:1085,atk:107,def:116,hp:140},
{no:36,name:"¥Ô¥¯¥·¡¼",maxcp:2353,atk:178,def:171,hp:190},
{no:37,name:"¥í¥³¥ó",maxcp:774,atk:96,def:122,hp:76},
{no:38,name:"¥­¥å¥¦¥³¥ó",maxcp:2157,atk:169,def:204,hp:146},
{no:39,name:"¥×¥ê¥ó",maxcp:713,atk:80,def:44,hp:230},
{no:40,name:"¥×¥¯¥ê¥ó",maxcp:1906,atk:156,def:93,hp:280},
{no:41,name:"¥º¥Ð¥Ã¥È",maxcp:569,atk:83,def:76,hp:80},
{no:42,name:"¥´¥ë¥Ð¥Ã¥È",maxcp:1830,atk:161,def:153,hp:150},
{no:43,name:"¥Ê¥¾¥Î¥¯¥µ",maxcp:1069,atk:131,def:116,hp:90},
{no:44,name:"¥¯¥µ¥¤¥Ï¥Ê",maxcp:1512,atk:153,def:139,hp:120},
{no:45,name:"¥é¥Õ¥ì¥·¥¢",maxcp:2367,atk:202,def:170,hp:150},
{no:46,name:"¥Ñ¥é¥¹",maxcp:836,atk:121,def:99,hp:70},
{no:47,name:"¥Ñ¥é¥»¥¯¥È",maxcp:1657,atk:165,def:146,hp:120},
{no:48,name:"¥³¥ó¥Ñ¥ó",maxcp:902,atk:100,def:102,hp:120},
{no:49,name:"¥â¥ë¥Õ¥©¥ó",maxcp:1937,atk:179,def:150,hp:140},
{no:50,name:"¥Ç¥£¥°¥À",maxcp:465,atk:109,def:88,hp:20},
{no:51,name:"¥À¥°¥È¥ê¥ª",maxcp:1333,atk:167,def:147,hp:70},
{no:52,name:"¥Ë¥ã¡¼¥¹",maxcp:638,atk:92,def:81,hp:80},
{no:53,name:"¥Ú¥ë¥·¥¢¥ó",maxcp:1539,atk:150,def:139,hp:130},
{no:54,name:"¥³¥À¥Ã¥¯",maxcp:966,atk:122,def:96,hp:100},
{no:55,name:"¥´¥ë¥À¥Ã¥¯",maxcp:2270,atk:191,def:163,hp:160},
{no:56,name:"¥Þ¥ó¥­¡¼",maxcp:1002,atk:148,def:87,hp:80},
{no:57,name:"¥ª¥³¥ê¥¶¥ë",maxcp:2105,atk:207,def:144,hp:130},
{no:58,name:"¥¬¡¼¥Ç¥£",maxcp:1110,atk:136,def:96,hp:110},
{no:59,name:"¥¦¥¤¥ó¥Ç¥£",maxcp:2839,atk:227,def:166,hp:180},
{no:60,name:"¥Ë¥ç¥í¥â",maxcp:695,atk:101,def:82,hp:80},
{no:61,name:"¥Ë¥ç¥í¥¾",maxcp:1313,atk:130,def:130,hp:130},
{no:62,name:"¥Ë¥ç¥í¥Ü¥ó",maxcp:2441,atk:182,def:187,hp:180},
{no:63,name:"¥±¡¼¥·¥£",maxcp:1148,atk:195,def:103,hp:50},
{no:64,name:"¥æ¥ó¥²¥é¡¼",maxcp:1859,atk:232,def:138,hp:80},
{no:65,name:"¥Õ¡¼¥Ç¥£¥ó",maxcp:2887,atk:271,def:194,hp:110},
{no:66,name:"¥ï¥ó¥ê¥­¡¼",maxcp:1199,atk:137,def:88,hp:140},
{no:67,name:"¥´¡¼¥ê¥­¡¼",maxcp:1910,atk:177,def:130,hp:160},
{no:68,name:"¥«¥¤¥ê¥­¡¼",maxcp:2889,atk:234,def:162,hp:180},
{no:69,name:"¥Þ¥À¥Ä¥Ü¥ß",maxcp:916,atk:139,def:64,hp:100},
{no:70,name:"¥¦¥Ä¥É¥ó",maxcp:1475,atk:172,def:95,hp:130},
{no:71,name:"¥¦¥Ä¥Ü¥Ã¥È",maxcp:2268,atk:207,def:138,hp:160},
{no:72,name:"¥á¥Î¥¯¥é¥²",maxcp:956,atk:97,def:182,hp:80},
{no:73,name:"¥É¥¯¥¯¥é¥²",maxcp:2374,atk:166,def:237,hp:160},
{no:74,name:"¥¤¥·¥Ä¥Ö¥Æ",maxcp:1193,atk:132,def:163,hp:80},
{no:75,name:"¥´¥í¡¼¥ó",maxcp:1815,atk:164,def:196,hp:110},
{no:76,name:"¥´¥í¡¼¥Ë¥ã",maxcp:2916,atk:211,def:229,hp:160},
{no:77,name:"¥Ý¥Ë¡¼¥¿",maxcp:1502,atk:170,def:132,hp:100},
{no:78,name:"¥®¥ã¥í¥Ã¥×",maxcp:2252,atk:207,def:167,hp:130},
{no:79,name:"¥ä¥É¥ó",maxcp:1204,atk:109,def:109,hp:180},
{no:80,name:"¥ä¥É¥é¥ó",maxcp:2482,atk:177,def:194,hp:190},
{no:81,name:"¥³¥¤¥ë",maxcp:1083,atk:165,def:128,hp:50},
{no:82,name:"¥ì¥¢¥³¥¤¥ë",maxcp:2237,atk:223,def:182,hp:100},
{no:83,name:"¥«¥â¥Í¥®",maxcp:1092,atk:124,def:118,hp:104},
{no:84,name:"¥É¡¼¥É¡¼",maxcp:1011,atk:158,def:88,hp:70},
{no:85,name:"¥É¡¼¥É¥ê¥ª",maxcp:2138,atk:218,def:145,hp:120},
{no:86,name:"¥Ñ¥¦¥ï¥¦",maxcp:899,atk:85,def:128,hp:130},
{no:87,name:"¥¸¥å¥´¥ó",maxcp:1894,atk:139,def:184,hp:180},
{no:88,name:"¥Ù¥È¥Ù¥¿¡¼",maxcp:1269,atk:135,def:90,hp:160},
{no:89,name:"¥Ù¥È¥Ù¥È¥ó",maxcp:2709,atk:190,def:184,hp:210},
{no:90,name:"¥·¥§¥ë¥À¡¼",maxcp:958,atk:116,def:168,hp:60},
{no:91,name:"¥Ñ¥ë¥·¥§¥ó",maxcp:2475,atk:186,def:323,hp:100},
{no:92,name:"¥´¡¼¥¹",maxcp:1002,atk:186,def:70,hp:60},
{no:93,name:"¥´¡¼¥¹¥È",maxcp:1716,atk:223,def:112,hp:90},
{no:94,name:"¥²¥ó¥¬¡¼",maxcp:2619,atk:261,def:156,hp:120},
{no:95,name:"¥¤¥ï¡¼¥¯",maxcp:1002,atk:85,def:288,hp:70},
{no:96,name:"¥¹¥ê¡¼¥×",maxcp:992,atk:89,def:158,hp:120},
{no:97,name:"¥¹¥ê¡¼¥Ñ¡¼",maxcp:2048,atk:144,def:215,hp:170},
{no:98,name:"¥¯¥é¥Ö",maxcp:1386,atk:181,def:156,hp:60},
{no:99,name:"¥­¥ó¥°¥é¡¼",maxcp:2694,atk:240,def:214,hp:110},
{no:100,name:"¥Ó¥ê¥ê¥À¥Þ",maxcp:857,atk:109,def:114,hp:80},
{no:101,name:"¥Þ¥ë¥Þ¥¤¥ó",maxcp:1900,atk:173,def:179,hp:120},
{no:102,name:"¥¿¥Þ¥¿¥Þ",maxcp:1102,atk:107,def:140,hp:120},
{no:103,name:"¥Ê¥Ã¥·¡¼",maxcp:2916,atk:233,def:158,hp:190},
{no:104,name:"¥«¥é¥«¥é",maxcp:943,atk:90,def:165,hp:100},
{no:105,name:"¥¬¥é¥¬¥é",maxcp:1691,atk:144,def:200,hp:120},
{no:106,name:"¥µ¥ï¥à¥é¡¼",maxcp:2406,atk:224,def:211,hp:100},
{no:107,name:"¥¨¥Ó¥ï¥é¡¼",maxcp:2098,atk:193,def:212,hp:100},
{no:108,name:"¥Ù¥í¥ê¥ó¥¬",maxcp:1322,atk:108,def:137,hp:180},
{no:109,name:"¥É¥¬¡¼¥¹",maxcp:1091,atk:119,def:164,hp:80},
{no:110,name:"¥Þ¥¿¥É¥¬¥¹",maxcp:2183,atk:174,def:221,hp:130},
{no:111,name:"¥µ¥¤¥Û¡¼¥ó",maxcp:1679,atk:140,def:157,hp:160},
{no:112,name:"¥µ¥¤¥É¥ó",maxcp:3300,atk:222,def:206,hp:210},
{no:113,name:"¥é¥Ã¥­¡¼",maxcp:1469,atk:60,def:176,hp:500},
{no:114,name:"¥â¥ó¥¸¥ã¥é",maxcp:2208,atk:183,def:205,hp:130},
{no:115,name:"¥¬¥ë¡¼¥é",maxcp:2463,atk:181,def:165,hp:210},
{no:116,name:"¥¿¥Ã¥Ä¡¼",maxcp:921,atk:129,def:125,hp:60},
{no:117,name:"¥·¡¼¥É¥é",maxcp:1979,atk:187,def:182,hp:110},
{no:118,name:"¥È¥µ¥­¥ó¥È",maxcp:1006,atk:123,def:115,hp:90},
{no:119,name:"¥¢¥º¥Þ¥ª¥¦",maxcp:2040,atk:175,def:154,hp:160},
{no:120,name:"¥Ò¥È¥Ç¥Þ¥ó",maxcp:926,atk:137,def:112,hp:60},
{no:121,name:"¥¹¥¿¡¼¥ß¡¼",maxcp:2303,atk:210,def:184,hp:120},
{no:122,name:"¥Ð¥ê¥ä¡¼¥É",maxcp:1984,atk:192,def:233,hp:80},
{no:123,name:"¥¹¥È¥é¥¤¥¯",maxcp:2464,atk:218,def:170,hp:140},
{no:124,name:"¥ë¡¼¥¸¥å¥é",maxcp:2512,atk:223,def:182,hp:130},
{no:125,name:"¥¨¥ì¥Ö¡¼",maxcp:2196,atk:198,def:173,hp:130},
{no:126,name:"¥Ö¡¼¥Ð¡¼",maxcp:2254,atk:206,def:169,hp:130},
{no:127,name:"¥«¥¤¥í¥¹",maxcp:2770,atk:238,def:197,hp:130},
{no:128,name:"¥±¥ó¥¿¥í¥¹",maxcp:2488,atk:198,def:197,hp:150},
{no:129,name:"¥³¥¤¥­¥ó¥°",maxcp:220,atk:29,def:102,hp:40},
{no:130,name:"¥®¥ã¥é¥É¥¹",maxcp:3281,atk:237,def:197,hp:190},
{no:131,name:"¥é¥×¥é¥¹",maxcp:2603,atk:165,def:180,hp:260},
{no:132,name:"¥á¥¿¥â¥ó",maxcp:718,atk:91,def:91,hp:96},
{no:133,name:"¥¤¡¼¥Ö¥¤",maxcp:969,atk:104,def:121,hp:110},
{no:134,name:"¥·¥ã¥ï¡¼¥º",maxcp:3157,atk:205,def:177,hp:260},
{no:135,name:"¥µ¥ó¥À¡¼¥¹",maxcp:2730,atk:232,def:201,hp:130},
{no:136,name:"¥Ö¡¼¥¹¥¿¡¼",maxcp:2904,atk:246,def:204,hp:130},
{no:137,name:"¥Ý¥ê¥´¥ó",maxcp:1567,atk:153,def:139,hp:130},
{no:138,name:"¥ª¥à¥Ê¥¤¥È",maxcp:1345,atk:155,def:174,hp:70},
{no:139,name:"¥ª¥à¥¹¥¿¡¼",maxcp:2685,atk:207,def:227,hp:140},
{no:140,name:"¥«¥Ö¥È",maxcp:1172,atk:148,def:162,hp:60},
{no:141,name:"¥«¥Ö¥È¥×¥¹",maxcp:2517,atk:220,def:203,hp:120},
{no:142,name:"¥×¥Æ¥é",maxcp:2608,atk:221,def:164,hp:160},
{no:143,name:"¥«¥Ó¥´¥ó",maxcp:3355,atk:190,def:190,hp:320},
{no:144,name:"¥Õ¥ê¡¼¥¶¡¼",maxcp:2933,atk:192,def:249,hp:180},
{no:145,name:"¥µ¥ó¥À¡¼",maxcp:3330,atk:253,def:188,hp:180},
{no:146,name:"¥Õ¥¡¥¤¥ä¡¼",maxcp:3272,atk:251,def:184,hp:180},
{no:147,name:"¥ß¥Ë¥ê¥å¥¦",maxcp:860,atk:119,def:94,hp:82},
{no:148,name:"¥Ï¥¯¥ê¥å¡¼",maxcp:1609,atk:163,def:138,hp:122},
{no:149,name:"¥«¥¤¥ê¥å¡¼",maxcp:3581,atk:263,def:201,hp:182},
{no:150,name:"¥ß¥å¥¦¥Ä¡¼",maxcp:4760,atk:330,def:200,hp:212},
{no:151,name:"¥ß¥å¥¦",maxcp:3090,atk:210,def:209,hp:200},
{no:152,name:"¥Á¥³¥ê¡¼¥¿",maxcp:801,atk:92,def:122,hp:90},
{no:153,name:"¥Ù¥¤¥ê¡¼¥Õ",maxcp:1296,atk:122,def:155,hp:120},
{no:154,name:"¥á¥¬¥Ë¥¦¥à",maxcp:2227,atk:168,def:202,hp:160},
{no:155,name:"¥Ò¥Î¥¢¥é¥·",maxcp:831,atk:116,def:96,hp:78},
{no:156,name:"¥Þ¥°¥Þ¥é¥·",maxcp:1484,atk:158,def:129,hp:116},
{no:157,name:"¥Ð¥¯¥Õ¡¼¥ó",maxcp:2686,atk:223,def:176,hp:156},
{no:158,name:"¥ï¥Ë¥Î¥³",maxcp:1011,atk:117,def:116,hp:100},
{no:159,name:"¥¢¥ê¥²¥¤¥Ä",maxcp:1598,atk:150,def:151,hp:130},
{no:160,name:"¥ª¡¼¥À¥¤¥ë",maxcp:2721,atk:205,def:197,hp:170},
{no:161,name:"¥ª¥¿¥Á",maxcp:519,atk:79,def:77,hp:70},
{no:162,name:"¥ª¥ª¥¿¥Á",maxcp:1667,atk:148,def:130,hp:170},
{no:163,name:"¥Û¡¼¥Û¡¼",maxcp:640,atk:67,def:101,hp:120},
{no:164,name:"¥è¥ë¥Î¥º¥¯",maxcp:2040,atk:145,def:179,hp:200},
{no:165,name:"¥ì¥Ç¥£¥Ð",maxcp:663,atk:72,def:142,hp:80},
{no:166,name:"¥ì¥Ç¥£¥¢¥ó",maxcp:1275,atk:107,def:209,hp:110},
{no:167,name:"¥¤¥È¥Þ¥ë",maxcp:685,atk:105,def:73,hp:80},
{no:168,name:"¥¢¥ê¥¢¥É¥¹",maxcp:1636,atk:161,def:128,hp:140},
{no:169,name:"¥¯¥í¥Ð¥Ã¥È",maxcp:2466,atk:194,def:178,hp:170},
{no:170,name:"¥Á¥ç¥ó¥Á¡¼",maxcp:1067,atk:106,def:106,hp:150},
{no:171,name:"¥é¥ó¥¿¡¼¥ó",maxcp:2077,atk:146,def:146,hp:250},
{no:172,name:"¥Ô¥Á¥å¡¼",maxcp:376,atk:77,def:63,hp:40},
{no:173,name:"¥Ô¥£",maxcp:620,atk:75,def:91,hp:100},
{no:174,name:"¥×¥×¥ê¥ó",maxcp:512,atk:69,def:34,hp:180},
{no:175,name:"¥È¥²¥Ô¡¼",maxcp:540,atk:67,def:116,hp:70},
{no:176,name:"¥È¥²¥Á¥Ã¥¯",maxcp:1543,atk:139,def:191,hp:110},
{no:177,name:"¥Í¥¤¥Æ¥£",maxcp:925,atk:134,def:89,hp:80},
{no:178,name:"¥Í¥¤¥Æ¥£¥ª",maxcp:1975,atk:192,def:146,hp:130},
{no:179,name:"¥á¥ê¡¼¥×",maxcp:887,atk:114,def:82,hp:110},
{no:180,name:"¥â¥³¥³",maxcp:1402,atk:145,def:112,hp:140},
{no:181,name:"¥Ç¥ó¥ê¥å¥¦",maxcp:2695,atk:211,def:172,hp:180},
{no:182,name:"¥­¥ì¥¤¥Ï¥Ê",maxcp:2108,atk:169,def:189,hp:150},
{no:183,name:"¥Þ¥ê¥ë",maxcp:420,atk:37,def:93,hp:140},
{no:184,name:"¥Þ¥ê¥ë¥ê",maxcp:1503,atk:112,def:152,hp:200},
{no:185,name:"¥¦¥½¥Ã¥­¡¼",maxcp:2065,atk:167,def:198,hp:140},
{no:186,name:"¥Ë¥ç¥í¥È¥Î",maxcp:2371,atk:174,def:192,hp:180},
{no:187,name:"¥Ï¥Í¥Ã¥³",maxcp:508,atk:67,def:101,hp:70},
{no:188,name:"¥Ý¥Ý¥Ã¥³",maxcp:882,atk:91,def:127,hp:110},
{no:189,name:"¥ï¥¿¥Ã¥³",maxcp:1553,atk:118,def:197,hp:150},
{no:190,name:"¥¨¥¤¥Ñ¥à",maxcp:1188,atk:136,def:112,hp:110},
{no:191,name:"¥Ò¥Þ¥Ê¥Ã¥Ä",maxcp:316,atk:55,def:55,hp:60},
{no:192,name:"¥­¥Þ¥ï¥ê",maxcp:2048,atk:185,def:148,hp:150},
{no:193,name:"¥ä¥ó¥ä¥ó¥Þ",maxcp:1326,atk:154,def:94,hp:130},
{no:194,name:"¥¦¥Ñ¡¼",maxcp:596,atk:75,def:75,hp:110},
{no:195,name:"¥Ì¥ª¡¼",maxcp:1929,atk:152,def:152,hp:190},
{no:196,name:"¥¨¡¼¥Õ¥£",maxcp:3000,atk:261,def:194,hp:130},
{no:197,name:"¥Ö¥é¥Ã¥­¡¼",maxcp:2052,atk:126,def:250,hp:190},
{no:198,name:"¥ä¥ß¥«¥é¥¹",maxcp:1392,atk:175,def:87,hp:120},
{no:199,name:"¥ä¥É¥­¥ó¥°",maxcp:2482,atk:177,def:194,hp:190},
{no:200,name:"¥à¥¦¥Þ",maxcp:1781,atk:167,def:167,hp:120},
{no:201,name:"¥¢¥ó¥Î¡¼¥ó",maxcp:1022,atk:136,def:91,hp:96},
{no:202,name:"¥½¡¼¥Ê¥ó¥¹",maxcp:1024,atk:60,def:106,hp:380},
{no:203,name:"¥­¥ê¥ó¥ê¥­",maxcp:1863,atk:182,def:133,hp:140},
{no:204,name:"¥¯¥Ì¥®¥À¥Þ",maxcp:1045,atk:108,def:146,hp:100},
{no:205,name:"¥Õ¥©¥ì¥È¥¹",maxcp:2263,atk:161,def:242,hp:150},
{no:206,name:"¥Î¥³¥Ã¥Á",maxcp:1615,atk:131,def:131,hp:200},
{no:207,name:"¥°¥é¥¤¥¬¡¼",maxcp:1758,atk:143,def:204,hp:130},
{no:208,name:"¥Ï¥¬¥Í¡¼¥ë",maxcp:2439,atk:148,def:333,hp:150},
{no:209,name:"¥Ö¥ë¡¼",maxcp:1124,atk:137,def:89,hp:120},
{no:210,name:"¥°¥é¥ó¥Ö¥ë",maxcp:2440,atk:212,def:137,hp:180},
{no:211,name:"¥Ï¥ê¡¼¥»¥ó",maxcp:1910,atk:184,def:148,hp:130},
{no:212,name:"¥Ï¥Ã¥µ¥à",maxcp:2801,atk:236,def:191,hp:140},
{no:213,name:"¥Ä¥Ü¥Ä¥Ü",maxcp:300,atk:17,def:396,hp:40},
{no:214,name:"¥Ø¥é¥¯¥í¥¹",maxcp:2938,atk:234,def:189,hp:160},
{no:215,name:"¥Ë¥å¡¼¥é",maxcp:1868,atk:189,def:157,hp:110},
{no:216,name:"¥Ò¥á¥°¥Þ",maxcp:1184,atk:142,def:93,hp:120},
{no:217,name:"¥ê¥ó¥°¥Þ",maxcp:2760,atk:236,def:144,hp:180},
{no:218,name:"¥Þ¥°¥Þ¥Ã¥°",maxcp:750,atk:118,def:71,hp:80},
{no:219,name:"¥Þ¥°¥«¥ë¥´",maxcp:1543,atk:139,def:209,hp:100},
{no:220,name:"¥¦¥ê¥à¡¼",maxcp:663,atk:90,def:74,hp:100},
{no:221,name:"¥¤¥Î¥à¡¼",maxcp:2284,atk:181,def:147,hp:200},
{no:222,name:"¥µ¥Ë¡¼¥´",maxcp:1214,atk:118,def:156,hp:110},
{no:223,name:"¥Æ¥Ã¥Ý¥¦¥ª",maxcp:749,atk:127,def:69,hp:70},
{no:224,name:"¥ª¥¯¥¿¥ó",maxcp:2124,atk:197,def:141,hp:150},
{no:225,name:"¥Ç¥ê¥Ð¡¼¥É",maxcp:937,atk:128,def:90,hp:90},
{no:226,name:"¥Þ¥ó¥¿¥¤¥ó",maxcp:2032,atk:148,def:260,hp:130},
{no:227,name:"¥¨¥¢¡¼¥à¥É",maxcp:2032,atk:148,def:260,hp:130},
{no:228,name:"¥Ç¥ë¥Ó¥ë",maxcp:1110,atk:152,def:93,hp:90},
{no:229,name:"¥Ø¥ë¥¬¡¼",maxcp:2529,atk:224,def:159,hp:150},
{no:230,name:"¥­¥ó¥°¥É¥é",maxcp:2424,atk:194,def:194,hp:150},
{no:231,name:"¥´¥Þ¥¾¥¦",maxcp:1175,atk:107,def:107,hp:180},
{no:232,name:"¥É¥ó¥Õ¥¡¥ó",maxcp:3022,atk:214,def:214,hp:180},
{no:233,name:"¥Ý¥ê¥´¥ó2",maxcp:2546,atk:198,def:183,hp:170},
{no:234,name:"¥ª¥É¥·¥·",maxcp:1988,atk:192,def:132,hp:146},
{no:235,name:"¥É¡¼¥Ö¥ë",maxcp:389,atk:40,def:88,hp:110},
{no:236,name:"¥Ð¥ë¥­¡¼",maxcp:404,atk:64,def:64,hp:70},
{no:237,name:"¥«¥Ý¥¨¥é¡¼",maxcp:1905,atk:173,def:214,hp:100},
{no:238,name:"¥à¥Á¥å¡¼¥ë",maxcp:1230,atk:153,def:116,hp:90},
{no:239,name:"¥¨¥ì¥­¥Ã¥É",maxcp:1073,atk:135,def:110,hp:90},
{no:240,name:"¥Ö¥Ó¥£",maxcp:1178,atk:151,def:108,hp:90},
{no:241,name:"¥ß¥ë¥¿¥ó¥¯",maxcp:2312,atk:157,def:211,hp:190},
{no:242,name:"¥Ï¥Ô¥Ê¥¹",maxcp:3219,atk:129,def:229,hp:510},
{no:243,name:"¥é¥¤¥³¥¦",maxcp:3349,atk:241,def:210,hp:180},
{no:244,name:"¥¨¥ó¥Æ¥¤",maxcp:3377,atk:235,def:176,hp:230},
{no:245,name:"¥¹¥¤¥¯¥ó",maxcp:2823,atk:180,def:235,hp:200},
{no:246,name:"¥è¡¼¥®¥é¥¹",maxcp:904,atk:115,def:93,hp:100},
{no:247,name:"¥µ¥Ê¥®¥é¥¹",maxcp:1608,atk:155,def:133,hp:140},
{no:248,name:"¥Ð¥ó¥®¥é¥¹",maxcp:3670,atk:251,def:212,hp:200},
{no:249,name:"¥ë¥®¥¢",maxcp:3598,atk:193,def:323,hp:212},
{no:250,name:"¥Û¥¦¥ª¥¦",maxcp:4650,atk:263,def:301,hp:212},
{no:251,name:"¥»¥ì¥Ó¥£",maxcp:3090,atk:210,def:210,hp:200},
];

// ¥Ý¥±¥â¥ó̾¥Ü¥¿¥ó¤ò¡¢ÈÖ¹æ½ç¤Þ¤¿¤Ï̾Á°½ç¤Ëʤ٤Æɽ¼¨
var changetbl = function(mode){
	var len = pktbl.length;
	var div = document.getElementById("namediv");
	while (div.firstChild){
		div.removeChild(div.firstChild);
	}

	if (mode == 0){
		pktbl.sort(function(a,b){
			if (a.no > b.no) return 1;
			if (a.no < b.no) return -1;
			return 0;
		});
	}else if (mode == 1){
		pktbl.sort(function(a,b){
			if (a.name > b.name) return 1;
			if (a.name < b.name) return -1;
			return 0;
		});
	}

	for (var i=0; i<len; i++){
		var inp = document.createElement("input");
		inp.type = "button";
		inp.value = pktbl[i].name;
		if (pktbl[i].no < 152){
			inp.style.backgroundColor = "#8ca";
		}else{
			inp.style.backgroundColor = "#c8a";
		}
		inp.onclick = function(e){setname(this.value);};
		div.appendChild(inp);
	}
};

// ÆþÎÏÆâÍƤΥ¯¥ê¥¢
var clearinp = function(mode){
	var elm = null;
	if (mode){
		elm = document.getElementById("pkname");
		elm.value = "";
		elm = document.getElementById("pk_cp");
		elm.value = "";
		elm = document.getElementById("pk_hp");
		elm.value = "";
		elm = document.getElementById("selsand");
		elm.selectedIndex = 0;
	}

	elm = document.getElementById("pk_choice1_1");
	elm.checked = false;
	elm = document.getElementById("pk_choice1_2");
	elm.checked = false;
	elm = document.getElementById("pk_choice1_3");
	elm.checked = false;
	elm = document.getElementById("pk_choice1_4");
	elm.checked = false;
	elm = document.getElementById("pk_choice2_1");
	elm.checked = false;
	elm = document.getElementById("pk_choice2_2");
	elm.checked = false;
	elm = document.getElementById("pk_choice2_3");
	elm.checked = false;
	elm = document.getElementById("pk_choice2_4");
	elm.checked = false;
	elm = document.getElementById("pk_choice3_1");
	elm.checked = false;
	elm = document.getElementById("pk_choice3_2");
	elm.checked = false;
	elm = document.getElementById("pk_choice3_3");
	elm.checked = false;

	elm = document.getElementById("answer");
	while (elm.firstChild){
		elm.removeChild(elm.firstChild);
	}
};

// ½é´ü½èÍý
var init = function(){
	changetbl(0);
};

// ¥Ý¥±¥â¥ó¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤È¤­¸Æ¤Ð¤ì¤ë
var setname = function(name){
	var inp = document.getElementById("pkname");
	inp.value = name;
	inp = document.getElementById("pk_cp");
	inp.focus();
};

// ÆþÎÏ¥Á¥§¥Ã¥¯
var precheck = function(cp, hp, sand){
	var str = "³ºÅö¤Ê¤·";
	var n = pktbl.length;
	var inp = document.getElementById("pkname");
	var pid = -1;
	for (var i=0; i<n; i++){
		if (inp.value == pktbl[i].name){
			pid = i;
			break;
		}
	}

	if (pid < 0){
		str = "¥Ý¥±¥â¥ó¤òÁªÂò¤·¤Æ²¼¤µ¤¤¡£"
	}else{
		if (!sand){
			str = "¶¯²½¤ËɬÍפÊÀ±¤Îº½¤òÁªÂò¤·¤Æ²¼¤µ¤¤¡£"
			pid = -1;
		}
		if (!hp){
			str = "HP¤òȾ³Ñ¿ô»ú¤ÇÆþÎϤ·¤Æ²¼¤µ¤¤¡£"
			pid = -1;
		}
		if (!cp){
			str = "CP¤òȾ³Ñ¿ô»ú¤ÇÆþÎϤ·¤Æ²¼¤µ¤¤¡£"
			pid = -1;
		}
	}

	return {pid:pid, str:str};
};

// CP·×»»
var cpcalc = function(p_atk, p_def, p_hp, m_atk, m_def, m_hp, m_c){
	return parseInt((p_atk+m_atk)*Math.sqrt(p_def+m_def)*Math.sqrt(p_hp+m_hp)*m_c*m_c/10.0);
};

// ·×»»½èÍý¥á¥¤¥ó
var calcmain = function(pid, cp, hp, sand, k1, k2, k2f, ares){
	var atk_range = {min:0, max:15}; // ¹¶·â¥ì¥ó¥¸ »Þ´¢
	var def_range = {min:0, max:15}; // Ëɸæ¥ì¥ó¥¸ »Þ´¢
	var hp_range = {min:0, max:15};  // ÂÎÎÏ¥ì¥ó¥¸ »Þ´¢

	var kotai1 = [ // ¥Á¡¼¥à¥ê¡¼¥À¡¼Âè°ìɾ²Á
		{min:37, max:45},
		{min:30, max:36},
		{min:23, max:29},
		{min:0, max:22}
	];
	var kotai2 = [ // ¥Á¡¼¥à¥ê¡¼¥À¡¼ÂèÆóɾ²Á
		{min:15, max:15},
		{min:13, max:14},
		{min:8, max:12},
		{min:0, max:7}
	];

	var m = mltbl.length;
	var ahp = [];
	var batk = parseInt(pktbl[pid].atk); // ¼ï²ÃÍ ¹¶·â
	var bdef = parseInt(pktbl[pid].def); // ¼ï²ÃÍ Ëɸæ
	var bhp = parseInt(pktbl[pid].hp);   // ¼ï²ÃÍ ÂÎÎÏ

	if (k2){
		if (k2f & 1){ // ÂèÆóɾ²Á ¹¶·âON
			atk_range = kotai2[k2-1];
			def_range.max = kotai2[k2-1].max;
			hp_range.max = kotai2[k2-1].max;
		}
		if (k2f & 2){ // ÂèÆóɾ²Á ËɸæON
			def_range = kotai2[k2-1];
			atk_range.max = kotai2[k2-1].max;
			hp_range.max = kotai2[k2-1].max;
		}
		if (k2f & 4){ // ÂèÆóɾ²Á ÂÎÎÏON
			hp_range = kotai2[k2-1];
			atk_range.max = kotai2[k2-1].max;
			def_range.max = kotai2[k2-1].max;
		}
	}

	// Í¿¤¨¤é¤ì¤¿¥Ñ¥é¥á¡¼¥¿¤Ë¹çÃפ¹¤ë£È£Ð¤È¥Ý¥±¥â¥ó¥ì¥Ù¥ë¤Î¥Ú¥¢°ìÍ÷¤ò¼èÆÀ »Þ´¢
	for (var i=hp_range.min; i<=hp_range.max; i++){
		for (var j=0; j<m-1; j++){
			if (mltbl[j+1].sand == sand){
				var thp = parseInt((bhp+i) * mltbl[j].c);
				if (thp == hp){
					ahp.push({hp:i, mli:j});
				}
			}
		}
	}

	for (var i=0; i<ahp.length; i++){ // £È£Ð¥ë¡¼¥×
		var mlt = mltbl[ahp[i].mli];
		for (var j=atk_range.min; j<=atk_range.max; j++){ // ¹¶·â¥ë¡¼¥×
			for (var k=def_range.min; k<=def_range.max; k++){ // Ëɸæ¥ë¡¼¥×
				// CP·×»»
				var t = cpcalc(j,k,ahp[i].hp, batk,bdef,bhp, mlt.c);
				if (t == cp){ // CP°ìÃ×
					var h = ahp[i].hp; // j:¹¶·â, k:Ëɸæ, h:ÂÎÎÏ
					var tot = j+k+h;
					if (k1){
						// ¹ç·×¤¬Âè°ìɾ²Á¤òËþ¤¿¤¹¤«
						if (tot < kotai1[k1-1].min || kotai1[k1-1].max < tot){
							continue;
						}
					}
					if (k2){
						// ¹¶·â¤¬Âè2ɾ²ÁÈϰϤòËþ¤¿¤·¤Æ¤¤¤ë¤«
						if (j < atk_range.min || atk_range.max < j){
							continue;
						}
						// Ëɸ椬Âè2ɾ²ÁÈϰϤòËþ¤¿¤·¤Æ¤¤¤ë¤«
						if (k < def_range.min || def_range.max < k){
							continue;
						}
						// ÂÎÎϤ¬Âè2ɾ²ÁÈϰϤòËþ¤¿¤·¤Æ¤¤¤ë¤«
						if (h < hp_range.min || hp_range.max < h){
							continue;
						}
						// ¹¶·â¤Î¤ß¥Á¥§¥Ã¥¯¤Î»þ¡¢¹¶·â > Ëɸæ,ÂÎÎϤǤ¢¤ë¤³¤È
						if (k2f == 1 && (j <= k || j <= h)){
							continue;
						}
						// Ëɸæ¤Î¤ß¥Á¥§¥Ã¥¯¤Î»þ¡¢Ëɸæ > ¹¶·â,ÂÎÎϤǤ¢¤ë¤³¤È
						if (k2f == 2 && (k <= j || k <= h)){
							continue;
						}
						// ÂÎÎϤΤߥÁ¥§¥Ã¥¯¤Î»þ¡¢ÂÎÎÏ > ¹¶·â,Ëɸæ¤Ç¤¢¤ë¤³¤È
						if (k2f == 4 && (h <= j || h <= k)){
							continue;
						}
						// ¹¶·â/Ëɸæ¥Á¥§¥Ã¥¯¤Î»þ¡¢¹¶·â¡áËɸ椫¤Ä¡¢¹¶·â¡äÂÎÎϤǤ¢¤ë¤³¤È
						if (k2f == 3 && (j != k || j <= h)){
							continue;
						}
						// ¹¶·â/ÂÎÎÏ¥Á¥§¥Ã¥¯¤Î»þ¡¢¹¶·â¡áÂÎÎϤ«¤Ä¡¢¹¶·â¡äËɸæ¤Ç¤¢¤ë¤³¤È
						if (k2f == 5 && (j != h || j <= k)){
							continue;
						}
						// Ëɸæ/ÂÎÎÏ¥Á¥§¥Ã¥¯¤Î»þ¡¢Ëɸæ¡áÂÎÎϤ«¤Ä¡¢Ëɸæ¡ä¹¶·â¤Ç¤¢¤ë¤³¤È
						if (k2f == 6 && (k != h || k <= j)){
							continue;
						}
						// ¹¶·â/Ëɸæ/ÂÎÎÏ¥Á¥§¥Ã¥¯¤Î»þ¡¢¹¶·â¡áËɸæ¡áÂÎÎϤǤ¢¤ë¤³¤È
						if (k2f == 7 && (j != k || j != h)){
							continue;
						}
					}
					// ÇÛÎó¤ËÄɲÃ, {¡ó, ¥ì¥Ù¥ë, ¹¶·â, Ëɸæ, £È£Ð}
					ares.push({per:tot/45, ml:mlt.ml, atk:j, def:k, hp:h});
				}
			}
		}
	}
};

// ·×»»¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤È¤­¸Æ¤Ð¤ì¤ë
var calc = function(){
	var cp = parseInt(document.getElementById("pk_cp").value);
	var hp = parseInt(document.getElementById("pk_hp").value);
	var sel = document.getElementById("selsand");
	var sand = parseInt( sel.options[sel.selectedIndex].value);
	var pchk = precheck(cp, hp, sand); // ÆþÎÏ¥Á¥§¥Ã¥¯
	var ares = [];
	var answerstr = pchk.str;
	var div = document.getElementById("answer");
	var k1 = parseInt(hyouka.pk_choice1.value);
	var k2 = parseInt(hyouka.pk_choice2.value);
	var k2f = 0;
	if (k2){
		if (hyouka.pk_choice3a.checked){
			k2f |= 1;
		}
		if (hyouka.pk_choice3b.checked){
			k2f |= 2;
		}
		if (hyouka.pk_choice3c.checked){
			k2f |= 4;
		}
	}

	if (pchk.pid >= 0){
		// ·×»»µ¡¥á¥¤¥ó aresÇÛÎó¤Ë·ë²Ì¤¬ÊÖ¤ë
		calcmain(pchk.pid, cp, hp, sand, k1, k2, k2f, ares);

		if (ares.length){
			// ¡ó¤òÍ¥À褷¤Æ¹ß½ç¥½¡¼¥È
			ares.sort(function(a,b){
				if (a.per < b.per) return 1;
				if (a.per > b.per) return -1;
				if (a.ml < b.ml) return 1;
				if (a.ml > b.ml) return -1;
				return 0;
			});

			// ·ë²Ì¤ò¥Æ¡¼¥Ö¥ë¤Î·Á¤ËÀ°·Á
			answerstr = "<table border='1'><tr><th>¡ó</th><th>Lv</th><th>¹¶·â</th><th>Ëɸæ</th><th>£È£Ð</th></tr>";
			for (var i=0; i<ares.length; i++){
				answerstr += "<tr><td>" + Math.round(ares[i].per * 10000) / 100 + "</td><td>" + ares[i].ml
 + "</td><td>" + ares[i].atk + "</td><td>" + ares[i].def + "</td><td>" + ares[i].hp + "</td></tr>";
			}
			answerstr += "</table>";
		}
	}

	div.innerHTML = answerstr;
};

</script>

</head>

<body onload="init();">
¸ÄÂÎÃÍ·×»»¥Ä¡¼¥ë¡¡
<input class="pk_choice1" type="radio" name="btn_choice" value="0" checked="checked" onclick="changetbl(0);">ÈÖ¹æ½ç¡¡
<input class="pk_choice1" type="radio" name="btn_choice" value="1" onclick="changetbl(1);">̾Á°½ç
<br />
<div id="namediv"></div>
<br />
<span class="inp_lavel">Name </span><input id="pkname" class="pk_inp" type="text" value="" readonly="true">
<span class="inp_lavel">CP </span><input id="pk_cp" class="pk_inp" type="text" value="">
<span class="inp_lavel">HP </span><input id="pk_hp" class="pk_inp" type="text" value="">
<select id="selsand">
<option value="0">¶¯²½¤ËɬÍפÊÀ±¤Îº½</option>
<option value="200">200</option>
<option value="400">400</option>
<option value="600">600</option>
<option value="800">800</option>
<option value="1000">1000</option>
<option value="1300">1300</option>
<option value="1600">1600</option>
<option value="1900">1900</option>
<option value="2200">2200</option>
<option value="2500">2500</option>
<option value="3000">3000</option>
<option value="3500">3500</option>
<option value="4000">4000</option>
<option value="4500">4500</option>
<option value="5000">5000</option>
<option value="6000">6000</option>
<option value="7000">7000</option>
<option value="8000">8000</option>
<option value="9000">9000</option>
<option value="10000">10000</option>
</select>
<br />
<br />
<form class="hyouka" name="hyouka">
Âè°ìɾ²Á<br />
<input id="pk_choice1_1" class="pk_choice1" type="radio" name="pk_choice1" value="1">1st
<input id="pk_choice1_2" class="pk_choice1" type="radio" name="pk_choice1" value="2">2nd
<input id="pk_choice1_3" class="pk_choice1" type="radio" name="pk_choice1" value="3">3rd
<input id="pk_choice1_4" class="pk_choice1" type="radio" name="pk_choice1" value="4">4th
<br />
ÂèÆóɾ²Á<br />
<div>
<input id="pk_choice2_1" class="pk_choice2" type="radio" name="pk_choice2" value="1">1st
<input id="pk_choice2_2" class="pk_choice2" type="radio" name="pk_choice2" value="2">2nd
<input id="pk_choice2_3" class="pk_choice2" type="radio" name="pk_choice2" value="3">3rd
<input id="pk_choice2_4" class="pk_choice2" type="radio" name="pk_choice2" value="4">4th
<br />
<input id="pk_choice3_1" class="pk_choice3" type="checkbox" name="pk_choice3a" value="1">¹¶·â
<input id="pk_choice3_2" class="pk_choice3" type="checkbox" name="pk_choice3b" value="2">Ëɸæ
<input id="pk_choice3_3" class="pk_choice3" type="checkbox" name="pk_choice3c" value="3">£È£Ð
</div>
</form>
<br />
<input type="button" value="¡¡·×¡¡»»¡¡" onclick="calc(); return false;">
<input type="button" value="¡¡É¾²Á¥¯¥ê¥¢¡¡" onclick="clearinp(false); return false;">
<input type="button" value="¡¡ALL¥¯¥ê¥¢¡¡" onclick="clearinp(true); return false;">
<br />
<br />
<hr>
<div id="answer">
</div>
</body>
</html>




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

Åì¼Ç¤ÎFlashAir¥¨¥ß¥å¥ì¡¼¥¿

FlashAir¥¨¥ß¥å¥ì¡¼¥¿¡¡flashair-lua-dev ¤Ç¾¯¤·º¤¤Ã¤¿¡£


FlashAir¤Î¥¨¥ß¥å¥ì¡¼¥¿¤òõ¤·¤Æ¤¤¤Æ
https://flashair-developers.com/ja/documents/resources/
¤Î²¼¤ÎÊý¤Ëɽ¼¨¤µ¤ì¤ë¡¢flashair-lua-dev ¤ò»î¤·¤¿¡£

fa ¥ª¥Ö¥¸¥§¥¯¥È¤¬¥¨¥ß¥å¥ì¡¼¥È¤Ç¤­¤ë¤Î¤ÇÂçÊÑÊØÍø¤Ç½õ¤«¤Ã¤¿¤Î¤Ç¤¹¤¬¡¢
¥Õ¥¡¥¤¥ë¤ò multipart/form-data ¤Ç¥¢¥Ã¥×¥í¡¼¥É¤¬½ÐÍè¤Ê¤«¤Ã¤¿¡£

¡Ú¼ê½ç¡Û
https://flashair-developers.com/ja/documents/api/lua/reference/#request
¤Î¥Õ¥¡¥¤¥ë¥¢¥Ã¥×¥í¡¼¥É¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤ò»È¤¤¡¢flashair.lua¤ò¸Æ¤Ó½Ð¤¹¤¬¡¢ÄÌ¿®¤¬´°Î»¤·¤Ê¤¤¡£
(CentOS 6.7 x86)

¡ÚÌäÂêÅÀ¡Û
¡Ö°ú¿ôbody¤Ë¡¢<!--WLANSDFILE-->¤¬µ­½Ò¤µ¤ì¤¿¾ì¹ç¡¢ÃÖ¤­´¹¤¨¤Ç¡¢fileÆâÍƤòËä¤á¹þ¤à¡×
¤È¤¤¤¦FlashAirÆȼ«»ÅÍͤ¬Ëþ¤¿¤µ¤ì¤Æ¤¤¤Ê¤¤¤è¤¦¤Ë¸«¤¨¤Þ¤¹¡£

¡ÚÂкö°Æ¡Û
¾¯¤·¾éŤǤ¹¤¬¡¢flashair.lua¤Îtrequest´Ø¿ô¤ò¡¢¼¡¤ÎÍͤ˽¤Àµ¤¹¤ë¡£
	local trequest = function(...)
		local param = ...
		local url      = param["url"]
		local method   = param["method"]
		local headers  = param["headers"]
		local file     = param["file"]
		local reqbody  = param["body"]
		local bufsize  = param["bufsize"]
		local redirect = param["redirect"]

		-- Hundredsoft add start
		if (file ~= nil) then
			local fp = io.open(file, "rb")
			if (fp ~= nil) then
				local r1, r2 = string.match(reqbody, "(.-)%<%!%-%-WLANSDFILE%-%-%>(.+)")
				if (r1 ~= nil and r2 ~= nil) then
					reqbody = r1 .. fp:read("*a") .. r2
				end
				fp:close()
			end
		end
		-- Hundredsoft add end

		local http = require("socket.http")
		local ltn12 = require("ltn12")

		local body = {}
		local b, c, h = http.request {
			url = url,
			sink = ltn12.sink.table(body),
			method = method,
			headers = headers,
			source = ltn12.source.string(reqbody), 
			step = nil,
			proxy = nil, 
			redirect = redirect,
			create = nil,
		}
		return table.concat(body), c, h
	end

¤Ç¡¢Æ°¤¤¤¿¡£

CentOS¾å¤Ç¤Ï¡¢¥á¥â¥ê¤¬Ë­ÉÙ¤Ê¤Î¤Ç body¤Ë¡¢<!--WLANSDFILE--> ¤Ê¤É¤ÈÂǤÁ¹þ¤Þ¤º¡¢
¥Õ¥¡¥¤¥ëÆâÍƤò¡¢¤½¤Î¤Þ¤ÞÆþ¤ì¹þ¤àÊýË¡¤Ç¤âÆ°¤­¤Þ¤¹¤¬¡¢
¼Âµ¡(FlashAir)¤Ç¤Ï¡¢Â礭¤Ê¼Ì¿¿¤òÁ÷¤í¤¦¤È¤¹¤ë¤È¡¢¥á¥â¥êÉÔ­¤Ç¥³¥±¤Æ¤·¤Þ¤¤¤Þ¤¹¡£
Â礭¤Ê²èÁü¤òÁ÷¤ë¤È¤­¤Ë¤Ï¡¢<!--WLANSDFILE--> ¤Ï¡¢É¬¿Ü¤Î¤è¤¦¤Ç¤¹¡£

¸Ä¿ÍŪ¤Ë¤Ï¡¢¤¢¤È¤Ï¡¢FTP ¥¨¥ß¥å¥ì¡¼¥¿¤¬¤Ç¤­¤ë¤È¡¢¤È¤Æ¤â´ò¤·¤¤¡£




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

DicomViewer HTML5ÈÇ

HTML¤Èjavascript¤À¤±¤ÇºîÀ®¤·¤¿DICOM Viewer¤Ç¤¹¡£


¤³¤Á¤é¤«¤é¡¢ÍøÍѤǤ­¤Þ¤¹¡£

WindowsOS¤À¤±¤Ç¤Ê¤¯¡¢Android¥¿¥Ö¥ì¥Ã¥ÈÅù¤Ç¤âÍøÍѲÄǽ¤Ç¤¹¡£
¥Ö¥é¥¦¥¶Ã±ÆȤÇÆ°ºî¤¹¤ë¤Î¤Ç¡¢ÀìÍѤΥ½¥Õ¥È¥¦¥§¥¢¤ò¥¤¥ó¥¹¥È¡¼¥ë¤¹¤ë¤³¤È¤Ê¤¯¤´ÍøÍÑ失¤Þ¤¹¡£



¤É¤¦¤·¤Æ¤â¿´ÇÛ¤µ¤ì¤ë¾ì¹ç¤Ï¡¢¤³¤Á¤é ¤«¤éËÜ¥¢¥×¥ê¤ò¥À¥¦¥ó¥í¡¼¥É¤·¤Æ¡¢
³°Éô¤È¤ÏÀÚÃǤµ¤ì¤¿¥Í¥Ã¥È¥ï¡¼¥¯´Ä¶­¤ÎÃæ¤Ç¤ª»È¤¤²¼¤µ¤¤¡£

¥í¡¼¥«¥ë´Ä¶­¤ÇÆ°ºî¤µ¤»¤ë¤³¤È¤â²Äǽ¤Ç¤¹¤¬¡¢IE,Chrome¤Ç¤Ï¡¢URL»ØÄ꤬¤Ç¤­¤Þ¤»¤ó¡£
(Ê£¿ô¥Õ¥¡¥¤¥ë»ØÄê¤ä¥Õ¥¡¥¤¥ë¥É¥í¥Ã¥×¤Ï²Äǽ¤Ç¤¹¡£)



¡ÚÁàºî¥¬¥¤¥É¡Û

¤Þ¤º½é¤á¤Ë¡¢URL»ØÄê¤Ça.dcm¤òɽ¼¨¤·¤Æ²¼¤µ¤¤(Read¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯)¡£












²èÁüÉôʬ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢Æ°²è¤Î¾ì¹ç¡¢¾å¿Þ¤Î¥á¥Ã¥»¡¼¥¸¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
OK¤ò²¡¤¹¤È¡¢²èÁü¤ò¥á¥â¥ê¾å¤ËŸ³«¤·¤ÆÆ°²èºÆÀ¸¤ò¹Ô¤¤¤Þ¤¹¡£
ºÆÀ¸Â®Å٤ϡ¢DICOM¾ðÊó¤Ë½¾¤¤¤Þ¤¹¡£
²èÁü¥µ¥¤¥º¤ä²èÁüËç¿ô¤Ë¤è¤ê¡¢Èó¾ï¤Ë»þ´Ö¤¬³Ý¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£
¤³¤Î¤è¤¦¤Ê¥±¡¼¥¹¤Ç¤Ï¡¢¥Ö¥é¥¦¥¶¤«¤é¡¢¥¹¥¯¥ê¥×¥È¤òÄä»ß¤¹¤ë¤«¤É¤¦¤«¤Î·Ù¹ð¥á¥Ã¥»¡¼¥¸¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£

ºÆÀ¸¤ÎÄä»ß¤Ï¡¢ºÆÅÙ¡¢²èÌ̾å¤ò¥¯¥ê¥Ã¥¯¤·¤Æ²¼¤µ¤¤¡£
Ää»ß¸å¡¢ºÆ¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢ºÆÀ¸¤¬»Ï¤Þ¤ê¤Þ¤¹¡£

ÀŻ߲è¤Î¾ì¹ç¤Ï¡¢¼¡¤Î¥á¥Ã¥»¡¼¥¸¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£



IIS¥µ¡¼¥Ð¡¼¤Ë¥¤¥ó¥¹¥È¡¼¥ë¤¹¤ë¾ì¹ç¤Ç¡¢URL»ØÄê¤ÇDICOM¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤¹¤ë»þ¤Ë¤Ï¡¢
¥µ¡¼¥Ð¡¼Â¦¤ËMIMEÀßÄê¤ò¹Ô¤Ã¤Æ²¼¤µ¤¤¡£



DICOM¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò¤¬¡Ö.dcm¡×¤Ç¤¢¤ë¾ì¹ç¤Ï¡¢
¾å¿Þ¤Î¤è¤¦¤Ë¡Öapplication/x-www-form-urlencoded¡×¤òÀßÄꤷ¤Æ²¼¤µ¤¤¡£
DICOM¥Õ¥¡¥¤¥ë¤ËÊ£¿ô¤Î³ÈÄ¥»Ò¤¬¤¢¤ë¾ì¹ç¤Ï¡¢¤½¤ì¤¾¤ì¤Î³ÈÄ¥»ÒËè¤ËÀßÄ꤬ɬÍפǤ¹¡£




¸Å¤¤¥Ö¥é¥¦¥¶¤ò¤ª»È¤¤¤Î¾ì¹ç¡¢¾åµ­¤Îɽ¼¨¤Ë¤Ê¤ê¤Þ¤¹¡£
IE10°Ê¹ß¡¦Firefox34°Ê¹ß¡¦Chrome31°Ê¹ß¡¦Safari7.1°Ê¹ß¡¦Opera26°Ê¹ß¡¦
Android ¥Ö¥é¥¦¥¶4.4.3°Ê¹ß¤Ç¤ª»È¤¤²¼¤µ¤¤¡£
WindowsÈÇSafari(5.1.7)¤Ç¤ÏÆ°ºî¤·¤Þ¤»¤ó¡£


ÂбþDICOM¥Õ¥¡¥¤¥ë

²èÁüÂбþ
Explicit VR Little Endian
Implicit VR Little Endian
Jpeg Lossy
RLE Lossless

²èÁṳ̈Âбþ¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç¤¢¤Ã¤Æ¤â¡¢¥¿¥°Åù¤ÎDICOM¥Ç¡¼¥¿¤Ï¡¢É½¼¨¤·¤Þ¤¹¡£




ǧ¼±¤Ç¤­¤Ê¤¤¥Õ¥¡¥¤¥ë¤Ë¤Ä¤¤¤Æ¤Ï¡¢¾å¿Þ¤Î¤è¤¦¤Ë¡Ö²òÀÏÉÔǽ¤Ç¤·¤¿¡£¡×¤Èɽ¼¨¤µ¤ì¤Þ¤¹¡£


¤³¤Á¤é¤«¤é¡¢ÍøÍѤǤ­¤Þ¤¹¡£




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

ModifiedSimpson

Echo¤ò»È¤Ã¤¿º¸¼¼ÍÆÀѤη׻»ÊýË¡¤Ë¤Ï´ö¤Ä¤«¤¢¤ë¤Î¤Ç¤¹¤¬¡¢£´¹ÐÃÇÌÌ¡¦£²¹ÐÃÇÌ̤ÎξÊý¤¬ÆÀ¤é¤ì¤ë¾ì¹ç¤Ë¡¢Îɤ¯»È¤ï¤ì¤ë¤Î¤¬ Modified SimpsonË¡¤Ç¤¹¡£

ÆüËÜ°å»Õ²ñ»¨»ï¤Î¡Ö¿´¥¨¥³¡¼¤ÎABC¡×¤«¤é·×»»Éôʬ¤òÈ´¿è¡£


°ì¸«¡¢´Êñ¤Ê¥×¥í¥°¥é¥à¤Ç¹½ÃۤǤ­¤½¤¦¤Ç¤¹¤¬¡¢¸òÅÀ»»½Ð¤¬³ä¤ÈÌÌÅݤǤ¹¡£
¤³¤³¤Ç¤Ï¡¢javascript¤Ç¤Î¼ÂÁõ¤òÌܻؤ·¤Þ¤¹¡£



¥È¥ì¡¼¥¹¥é¥¤¥ó¤ò Q0, Q1, Q2, ...¤Çɽ¤·¡¢¤½¤Îŷ¤òMP¤Çɽ¤¹¡£
MP¤òmʬ³ä¤·¡¢Ê¬³äÅÀ¤òP0, P1, P2, ... ¤È¤¹¤ë¡£



Åù´Ö³Ö¤Çʬ³ä¤¹¤ë¤³¤È¤Ë¤·¤Æ¡¢kÈÖÌܤÎʬ³äÀþ¤Î¿âÀþ¤¬¡¢¥È¥ì¡¼¥¹ºÂɸ¤ÎQi, Qi+1Àþʬ¤ò²£Àڤ뤳¤È¤ò¹Í¤¨¤ë¡£
ľÀþMP¤È ľÀþ(Pk)-(Qi)¤Î¥Ù¥¯¥È¥ëÆâÀѤÏÉé¤Ë¤Ê¤ë¤¬¡¢MP¤È (Pk)-(Qi+1)¤Î¥Ù¥¯¥È¥ëÆâÀѤÏÀµ¤Ë¤Ê¤ë¡£
ÆâÀÑÉä¹æ¤¬°Û¤Ê¤Ã¤¿¾ì¹ç¤Ë¡¢³Æ¥È¥ì¡¼¥¹ºÂɸ´Ö¤ÎľÀþ(Q)¤Èʬ³äÅÀ(Pk)¤«¤é¤ÎMP¤Îľ¸ò¥Ù¥¯¥È¥ë¤È¤Î¸òÅÀ¤¬¡¢¸õÊä¤Ë¤Ê¤ë¡£
¥È¥ì¡¼¥¹¥é¥¤¥ó¤¬Ç±¤¸¤ì¤ë¾ì¹ç¤â¤¢¤ë¤Î¤Ç¡¢Ê¬³äÅÀ(Pk)¤«¤éºÇ¤â±ó¤¤¸õÊä¤ò²ò¤È¤¹¤ë¡£
¤Þ¤¿¡¢º¸±¦¤½¤ì¤¾¤ì¤Ë²ò¤òµá¤á¤ëɬÍפ¬¤¢¤ë¤Î¤Ç¡¢MP¤Èʬ³äÅÀ(Pk)¤«¤é²ò¤Þ¤Ç¤Î¥Ù¥¯¥È¥ë¤È¤Ç¡¢
³°ÀѤò¼è¤ê¡¢º¸±¦¤É¤Á¤é¤Î²ò¤Ç¤¢¤ë¤«¤ò³Îǧ¤¹¤ë¡£

Ê£»¨¤½¤¦¤Ë»×¤¨¤ë¤«¤â¤·¤ì¤Ê¤¤¤¬¡¢¥ë¡¼¥×²ó¿ô¤Ï¡¢¥È¥ì¡¼¥¹¥Ý¥¤¥ó¥È¿ô x ʬ³ä¿ô ¤Ç¤·¤«¤Ê¤¯¡¢
»Í§±é»»¤À¤±¤Ç¥³¡¼¥É¤¬½ñ¤±¤ë¡£
¤³¤Î²òÀâÉôʬ¤Ë³ºÅö¤¹¤ë´Ø¿ô̾¤Ï¡¢calc() ¤Ç¡¢ 85¹Ô¤·¤«¤Ê¤¤¡£




¥Ç¥â¥×¥í¥°¥é¥à¤Ç¤Ï¡¢¼Â±¿ÍѤ˶á¤Å¤±¤ë¤¿¤á¡¢B-DUAL²èÁü¤òÌϤ·¤Æº¸±¦¤Ë¡¢£´¹ÐÃÇÌ̤ȣ²¹ÐÃÇÌ̤òÇÛÃÖ¤·¡¢
²¼Ãʤˡ¢Modified Simpon¤Ë¤è¤ëÂÎÀѤòɽ¼¨¤¹¤ë¡£
º¸±¦²èÁü¾å¤Ëɽ¼¨¤µ¤ì¤ëSimpsonÃͤϡ¢Ã±²èÁü¤Ë¤è¤ëÅùʬ³ä¤Ç¡¢²óžÂΤˤè¤êÂÎÀѤòµá¤á¤¿¾ì¹ç¤Î¿ôÃͤǡ¢
ºÇ½é¤ËºÜ¤»¤¿Ê¸¸¥¤Ë¤è¤ì¤Ð¡¢¤³¤ì¤ò·×¬ÃͤȤ¹¤ë¤³¤È¤Ï¾¯¤Ê¤¤¤è¤¦¤Ç¤¹¡£

¤³¤³¤Ç¤Ï¡¢¥¢¥ë¥´¥ê¥º¥à¤Î¾Ò²ð¤Ç¤¢¤ë¤Î¤Ç¡¢[pix]ñ°Ì¤Î·×»»·ë²Ì¤òɽ¼¨¤·¤Æ¤¤¤ë¡£
À¸ÂÎĹ´¹»»ÃÍ [cm/pix]¤¬¤¢¤ì¤Ð¡¢À¸ÂÎĹ´¹»»Ãͤò£³²ó³Ý¤±¤ì¤Ð [mL] ¤Ç¤Î·ë²Ì¤¬µá¤Þ¤ë¡£


Canvas¤Ï¡¢º¸±¦¤È²¼ÃʤÎ3Ëç¤ò»È¤Ã¤Æ¤¤¤ë¡£
¥¹¥é¥¤¥¹»»½ÐÉô¤Ï¡¢£²¤Änew¤·¤Æ¡¢º¸±¦¤½¤ì¤¾¤ì¤Ë¿¶¤ê¡¢
·ë²Ì¤¬µá¤Þ¤Ã¤¿»þÅÀ¤Ç¡¢callback¤Ë¤è¤ê¡¢²¼ÃʤΥ¹¥¯¥ê¥×¥È¤ò¸Æ¤Ó½Ð¤¹»ÅÁȤߤˤ·¤¿¡£

¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é

Chrome, FF, IE11 ¤ÇÆ°ºî³Îǧ¤·¤Æ¤¤¤Þ¤¹¡£

°Ê²¼¤Ï¥½¡¼¥¹¥³¡¼¥É¤Ç¤¹¡£
html ¤È js ¤Î³Æ£±ËܤǤ¹¡£

[html]

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>Modified Simpson</title>

<style type="text/css">
#div1 {
	width:800px;
	height:600px;
}
#canvas1 {
	width:400px;
	height:500px;
	background-color:#f0f0e0;
	float:left;
}
#canvas2 {
	width:400px;
	height:500px;
	background-color:#e0f0f0;
	float:left;
}
#canvas3 {
	width:800px;
	height:100px;
	background-color:#f0e0f0;
	float:left;
	clear: both;
}
</style>

<script type="text/javascript" src="DSM.js"></script>

<script type="text/javascript">
var init = function(){
	ModifiedSimpson.init(document.getElementById("canvas3"), 20);
	var dsm1 = new DSMPublic.DSM(document.getElementById("canvas1"), 
		function(hd){
			ModifiedSimpson.paint(1, hd);
		});
	var dsm2 = new DSMPublic.DSM(document.getElementById("canvas2"),
		function(hd){
			ModifiedSimpson.paint(2, hd);
		});
};
</script>
</head>


<body onload="init();">
Modified Simpson's Rule Sample<br /><br />
<div id="div1">
<canvas id="canvas1" width="400" height="500"></canvas>
<canvas id="canvas2" width="400" height="500"></canvas>
<canvas id="canvas3" width="800" height="100"></canvas>
</div>

</body>
</html>


[js]

// (c)Hundredsoft Corporation. 2015 All right reserved.
//	NAME
//		DSM.js
//
//	FUNCTION
//		Modified Simpson's rule.
//
//	REVISION
//		1.00	T.Furumoto	Jan-30-2015	Original
//
//	UTF-8¤ÇÊݸ¤·¤Æ²¼¤µ¤¤
//
////////////////////////////////////////////////////////////

new function() {

///////////////////////////////////
 // Private Scope
///////////////////////////////////

var m_linesz = 1;
var m_Slice = 20;
var m_Chain = 2;

var mdown = function(p, mouseX, mouseY){
	if (p.m_mode != 1){
		clear(p);
	}
};

var mup = function(p, mouseX, mouseY){
	var ret;
	if (p.m_mode == 0){
		p.m_trace = traceChain(p.m_trace);
		p.m_P = autoL(p.m_trace);
		ret = calc(p.m_trace, p.m_P);
		if (ret){
			paint(p, ret);
			p.m_mode = 1;
		}else{
			errorDisp(p);
		}
	}else if (p.m_mode == 1){
		p.m_mode = 0;
		ret = calc(p.m_trace, p.m_P);
		if (ret){
			paint(p, ret);
		}else{
			errorDisp(p);
		}
	}
};

var mmove = function(p, mouseX, mouseY){
	if (p.m_mode == 0){
		var n = p.m_trace.x.length;
		p.m_trace.x[n] = mouseX;
		p.m_trace.y[n] = mouseY;
		drawROI(p);

	}else{
		p.m_P = manualL(p.m_trace, mouseX, mouseY);
		var ret = calc(p.m_trace, p.m_P);
		if (ret){
			paint(p, ret);
		}else{
			errorDisp(p);
		}
	}
};


var intersection = function(p1x, p1y, p2x, p2y, q1x, q1y, q2x, q2y){
	var a =  p1y - p2y;
	var b = -p1x + p2x;
	var c =  q1y - q2y;
	var d = -q1x + q2x;
	var det = a*d - b*c;
	if( det * det < 0.01 ) // Ê¿¹Ô
		return false;

	var e = a * p1x + b * p1y;
	var f = c * q1x + d * q1y;
	return {"x" : (d*e - b*f) / det, "y" : (-c*e + a*f) / det};
};

var autoL = function(trace){
	var n = trace.x.length;
	var mx = (trace.x[n-1] + trace.x[0]) / 2;
	var my = (trace.y[n-1] + trace.y[0]) / 2;
	var len2 = 0;
	var px = false;
	var py = false;
	for (var i=0; i<n; i++){
		var w = (mx - trace.x[i]) * (mx - trace.x[i])
			+ (my - trace.y[i]) * (my - trace.y[i]);
		if (w > len2){
			len2 = w;
			px = trace.x[i];
			py = trace.y[i];
		}
	}
	return {"x": px, "y": py};
};

var manualL = function(trace, mouseX, mouseY){
	var n = trace.x.length;
	// Point¤«¤éºÇ¤â¶á¤¤ÅÀ(p)
	var px = trace.x[0];
	var py = trace.y[0];
	var lmin = (px - mouseX) * (px - mouseX) + (py - mouseY) * (py - mouseY);
	for( var i=1; i<n; i++ ){
		var l = (trace.x[i] - mouseX) * (trace.x[i] - mouseX)
			 + (trace.y[i] - mouseY) * (trace.y[i] - mouseY);
		if( l < lmin ){
			px = trace.x[i];
			py = trace.y[i];
			lmin = l;
		}
	}
	return {"x": px, "y": py};
};

var traceChain = function(o_trace){
	var n = o_trace.x.length;
	var traceX = [];
	var traceY = [];
	traceX.push(o_trace.x[0]);
	traceY.push(o_trace.y[0]);
	for (var i=1; i<n; i++){
		var dx = o_trace.x[i] - o_trace.x[i-1];
		var dy = o_trace.y[i] - o_trace.y[i-1];
		var len = dx * dx + dy * dy;
		if (len > m_Chain * m_Chain * m_Chain * m_Chain){
			var m = ~~(Math.sqrt(len) / m_Chain);
			var ex = dx / m;
			var ey = dy / m;
			var x = o_trace.x[i-1] + ex;
			var y = o_trace.y[i-1] + ey;
			for (var j=1; j<m-1; j++){
				traceX.push(x);
				traceY.push(y);
				x += ex;
				y += ey;
			}
		}
		traceX.push(o_trace.x[i]);
		traceY.push(o_trace.y[i]);
	}
	return {"x": traceX, "y": traceY};
};

var calc = function(trace, p){
	var n = trace.x.length;
	if (n < m_Slice * 2 + 2){
		return false;
	}

	var mx = (trace.x[n-1] + trace.x[0]) / 2;
	var my = (trace.y[n-1] + trace.y[0]) / 2;

	// M-P¥Ù¥¯¥È¥ë
	var lx = p.x - mx;
	var ly = p.y - my;

	// M-P¤Ëľ¹Ô¤¹¤ë¥Ù¥¯¥È¥ë
	var vx = ly;
	var vy = -lx;

	var out_plx = [];
	var out_ply = [];

	var rlen = [];
	var llen = [];
	for( var i=0; i<m_Slice+1; i++ ){
		rlen[i] = -9999999999;
		llen[i] =  9999999999;
	}

	var qox = mx;
	var qoy = my;
	for (var i=0; i<n+1; i++){
		var qnx = mx;
		var qny = my;
		if( i != n ){
			qnx = trace.x[i];
			qny = trace.y[i];
		}
		for (var j=0; j<m_Slice+1; j++){
			var px = (mx * (m_Slice-j) + p.x * j) / m_Slice;
			var py = (my * (m_Slice-j) + p.y * j) / m_Slice;
			// Àþ¤ò¤Þ¤¿¤°¤«¡©
			if( ( (qox - px) * lx >= -(qoy - py) * ly
			   && (qnx - px) * lx <  -(qny - py) * ly )
			 || ( (qox - px) * lx <  -(qoy - py) * ly
			   && (qnx - px) * lx >= -(qny - py) * ly ) )
			{
				// ¸òÅÀºÂɸ
				var t = intersection(qox, qoy, qnx, qny, px, py, px+vx, py+vy);
				if (!t){
					var d1x = qnx - px;
					var d1y = qny - py;
					var d2x = qox - px;
					var d2y = qoy - py;
					if( (d1x * d1x + d1y * d1y) > (d2x * d2x + d2y * d2y) ){
						t = {"x" : qnx, "y" : qny};
					}else{
						t = {"x" : qox, "y" : qoy};
					}
				}

				var qtlen = (t.x-px) * (t.x-px) + (t.y-py) * (t.y-py);

				// Êý¸þ³Îǧ
				if( (t.x - px) * vx + (t.y - py) * vy > 0 ){
					qtlen *= -1.;
				}
				// ºÇ±óÊýÅÀ¤Ê¤é¹¹¿·
				if( qtlen < llen[j] ){
					out_plx[j*2] = t.x;
					out_ply[j*2] = t.y;
					llen[j] = qtlen;
				}
				if( qtlen > rlen[j] ){
					out_plx[j*2+1] = t.x;
					out_ply[j*2+1] = t.y;
					rlen[j] = qtlen;
				}
			}
		}
		qox = qnx;
		qoy = qny;
	}

	return {"x": out_plx, "y": out_ply};
};

var clear = function(p){
	m_Slice = ModifiedSimpson.getSlice();
	p.m_trace.x = [];
	p.m_trace.y = [];
	p.m_ctx.font = "16px 'MS Gothic'";
	p.m_mode = 0;
	p.m_ctx.clearRect(0, 0, p.m_width, p.m_height);
	p.callback({"H":0, "D":false});
};

var drawROI = function(p){
	var ctx = p.m_ctx;
	ctx.clearRect(0, 0, p.m_width, p.m_height);

	ctx.beginPath();
	ctx.arc(p.m_trace.x[0], p.m_trace.y[0], m_linesz, 0, Math.PI*2, false);
	ctx.fill();
	ctx.closePath();
	var n = p.m_trace.x.length;
	for (var i=1; i<n+1; i++){
		ctx.beginPath();
		ctx.arc(p.m_trace.x[i], p.m_trace.y[i], m_linesz, 0, Math.PI*2, false);
		ctx.fill();
		ctx.closePath();

		ctx.lineWidth = m_linesz * 2;
		ctx.strokeStyle = "#808000";
		ctx.beginPath();
		ctx.moveTo(p.m_trace.x[i-1], p.m_trace.y[i-1]);
		ctx.lineTo(p.m_trace.x[i], p.m_trace.y[i]);
		ctx.stroke();
		ctx.closePath();
	}
};

var paint = function(p, out_pl){
	drawROI(p);

	var ctx = p.m_ctx;
	var n = p.m_trace.x.length;
	var mx = (p.m_trace.x[n-1] + p.m_trace.x[0]) / 2;
	var my = (p.m_trace.y[n-1] + p.m_trace.y[0]) / 2;

	ctx.lineWidth = m_linesz * 2;
	ctx.strokeStyle = "#808000";
	ctx.beginPath();
	ctx.moveTo(p.m_trace.x[0], p.m_trace.y[0]);
	ctx.lineTo(p.m_trace.x[n-1], p.m_trace.y[n-1]);
	ctx.stroke();

	ctx.moveTo(mx, my);
	ctx.lineTo(p.m_P.x, p.m_P.y);
	ctx.stroke();
	ctx.closePath();

	// M-P¥Ù¥¯¥È¥ë
	var lx = p.m_P.x - mx;
	var ly = p.m_P.y - my;

	var leng = Math.sqrt(lx*lx + ly*ly);
	var area = 0;
	for (var i=0; i<n; i++){
		var j = (i == n-1) ? 0 : i+1;
		area += p.m_trace.x[i] * p.m_trace.y[j] - p.m_trace.x[j] * p.m_trace.y[i];
	}
	area = Math.abs(area);

	var v = 0;
	var h = leng / m_Slice;
	var d2 = [];
	var hpi = Math.PI * h / 4.0;
	for (var i=0; i<m_Slice+1; i++){
		if (i < m_Slice){
			var dx = out_pl.x[i*2+1] - out_pl.x[i*2  ];
			var dy = out_pl.y[i*2+1] - out_pl.y[i*2  ];
			var d = (dx*dx + dy*dy);
			d2.push(d);
			v += hpi * d;
		}
		ctx.beginPath();
		ctx.moveTo(out_pl.x[i*2  ], out_pl.y[i*2  ]);
		ctx.lineTo(out_pl.x[i*2+1], out_pl.y[i*2+1]);
		ctx.stroke();
		ctx.closePath();
	}
	ctx.fillText("Simpson: " + Math.round(v) + " [pix^3]", 20, 20);
	ctx.fillText("Area:    " + Math.round(area) + " [pix^2]", 20, 40);
	ctx.fillText("L:       " + Math.round(leng) + " [pix]", 20, 60);

	p.callback({"H":h, "D":d2});
};

var errorDisp = function(p){
	var ctx = p.m_ctx;
	var n = p.m_trace.x.length;
	ctx.beginPath();
	ctx.moveTo(p.m_trace.x[0], p.m_trace.y[0]);
	ctx.lineTo(p.m_trace.x[n-1], p.m_trace.y[n-1]);
	ctx.stroke();
	ctx.closePath();
	ctx.fillText("¥È¥ì¡¼¥¹¥é¥¤¥ó¤¬Ã»¤¹¤®¤Þ¤¹", 20, 50);
};


///////////////////////////////////
// Public Scope
///////////////////////////////////
DSMPublic = {

DSM: function(canvas, callback){
	this.m_ctx = null;
	this.m_width = 400;
	this.m_height = 400;
	this.m_trace = {"x": [], "y": []};
	this.m_mode = 0;
	this.m_P = {"x": 0, "y": 0};
	this.callback = callback;

	var iam = this;
	var mouseDown = false;
	var mouseX = 0;
	var mouseY = 0;

	if (navigator.userAgent.indexOf('iPhone')>0 ||
		navigator.userAgent.indexOf('iPod')>0 || 
		navigator.userAgent.indexOf('iPad')>0 ||
		navigator.userAgent.indexOf('Android')>0) {

		canvas.addEventListener('touchstart',
			function(e) {
				e.preventDefault();
				var n = e.touches.length;
				if (n > 0) {
					e = e || window.event;
					mouseDown = true;
					var rect=e.target.getBoundingClientRect();
					mouseX = e.touches[n-1].pageX-rect.left;
					mouseY = e.touches[n-1].pageY-rect.top;
					mdown(iam, mouseX, mouseY);
				}
			}, false);

		canvas.addEventListener('touchend',
			function(e) {
				mouseDown = false;
				mup(iam, mouseX, mouseY);
			}, false);

		canvas.addEventListener('touchmove',
			function (e) {
				e.preventDefault();
				var rect=e.target.getBoundingClientRect();
				var n = e.touches.length;
				if (n > 0){
					mouseX = e.touches[n-1].pageX-rect.left;
					mouseY = e.touches[n-1].pageY-rect.top;
					if (mouseDown) {
						mmove(iam, mouseX, mouseY);
					}
				}
			}, false
		);

	}else{
		canvas.addEventListener('mousedown',
			function(e) {
				e.preventDefault();
				mouseDown = true;
				e = e || window.event;
				var rect=e.target.getBoundingClientRect();
				mouseX = e.clientX-rect.left;
				mouseY = e.clientY-rect.top;
				mdown(iam, mouseX, mouseY);
			}, false);


		canvas.addEventListener('mouseup',
			function(e) {
				mouseDown = false;
				mup(iam, mouseX, mouseY);
			}, false);

		canvas.addEventListener('mousemove',
			function (e) {
				e.preventDefault();
				var rect=e.target.getBoundingClientRect();
				mouseX = e.clientX-rect.left;
				mouseY = e.clientY-rect.top;
				if (mouseDown) {
					mmove(iam, mouseX, mouseY);
				}
			}, false
		);
	}

	this.m_ctx = canvas.getContext('2d');
	this.m_width = canvas.width;
	this.m_height = canvas.height;

	clear(this);
}

} // Public Scope
}; // Constructor



///////////////////////////////////
//
// Measurement Display Area
//
///////////////////////////////////

new function() {

///////////////////////////////////
 // Private Scope
///////////////////////////////////
var m_ctx = null;
var m_width = 100;
var m_height = 100;
var m_m1 = {"H": 0, "D": false};
var m_m2 = {"H": 0, "D": false};
var m_Slice = 20;

var report = function(){
	if (!m_ctx){
		return;
	}
	m_ctx.clearRect(0, 0, m_width, m_height);

	if (m_m1.D && m_m2.D){
		var h = (m_m1.H + m_m2.H) / 2;
		var v = 0;
		var hpi = Math.PI * h / 4.0;
		for (var i=0; i<m_Slice; i++){
			v += hpi * Math.sqrt( m_m1.D[i] * m_m2.D[i] );
		}
		m_ctx.fillText("Modified Simpson: " + Math.round(v) + " [pix^3]", 50, 50);
	}
};

///////////////////////////////////
// Public Scope
///////////////////////////////////
ModifiedSimpson = {
init: function(canvas, slc){
	if (slc){
		m_Slice = slc;
	}
	m_ctx = canvas.getContext('2d');
	m_width = canvas.width;
	m_height = canvas.height;
	m_ctx.font = "16px 'MS Gothic'";
	m_ctx.clearRect(0, 0, m_width, m_height);
},

paint: function(id, hd){
	if (id == 1){
		m_m1 = hd;
	}else if (id == 2){
		m_m2 = hd;
	}
	report();
},

getSlice: function(){
	return m_Slice;
}

} // Public Scope
}; // Constructor




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

XP¤Ï½ª¤ï¤ê¤Ç¤¹¤«¡£

µ×¤·¤Ö¤ê¤Ë¡¢WordPress¤ò¿¨¤ëµ¡²ñ¤¬¤¢¤ê¡¢

¤´¤Á¤ã¤´¤Á¤ã¤È¡ÖContact Form 7¡×¤Î¥á¡¼¥ë¥Õ¥©¡¼¥à¤ò¡¢¤¤¤í¤¤¤íÊѹ¹¤·¤Æ¤¤¤¿¤Î¤Ç¤¹¤¬¡¢
¤Ê¤¼¤«¡¢XP IE8 ¤«¤é¥á¡¼¥ë¤¬Á÷¤ì¤Ê¤¤¡£
(XP-IE6 ¤«¤é¤âÁ÷¤ì¤Ê¤«¤Ã¤¿¤¬¡¢IE6¤Ï¤µ¤¹¤¬¤Ë¤â¤¦¤¤¤¤¤Ç¤·¤ç¤¦¡£)

¤¤¤í¤¤¤í¤ä¤ê²á¤®¤Æ¤·¤Þ¤Ã¤¿´¶¤â¤¢¤ê¡¢¤·¤Ð¤é¤¯³ÊÆ®¤·¤¿¤¬¡¢
¤ä¤Ï¤ê¡¢XP ¤«¤é¤ÏÁ÷¤ì¤Ê¤¤¡£

¤·¤ç¤¦¤¬¤Ê¤¤¤Î¤Ç¡¢CentOS(6.4),PHP(5.3.3),mysql(14.14)¤Ë ºÇ¿·¤ÎWordPress(3.8.1)¤òÆþ¤ì¤Æ¡¢
¤Þ¤Ã¤µ¤é¤Ê WP´Ä¶­¤Ç¡ÖContact Form 7 (3.7)¡×¤À¤±Æþ¤ì¤Æ»î¤·¤¿¤¬¡ÊWP Multibyte Patch¤ÏÆþ¤ì¤¿¤¬¡Ë¡¢
XP IE8 ¤«¤é¤Ï¥á¡¼¥ë¤¬Á÷¤ì¤Ê¤¤¡£
(IE10, FF, Chrome, Safari ¤Ï OK¡£)

µ¤¤Ë¤Ê¤Ã¤ÆÄ´¤Ù¤¿¤é¡¢3.7 ¤Î¹¹¿·Æü¤Ï¤Ê¤ó¤È¡¢2014/2/04 ¤À¤Ã¤¿¡Ê°ìºòÆü¡ª¡Ë¡£

¤½¤¦¸À¤¨¤Ð¤¢¤ó¤Þ¤ê¹Í¤¨¤º¤Ë¡¢Update¤ä¤Ã¤Á¤Þ¤Ã¤¿¤Ê¡Á¤È»×¤¤¡¢
3.7¤ò¾Ã¤·¤Æ¡¢3.6¤ò¥À¥¦¥ó¥í¡¼¥É¤·¤ÆÆþ¤ìľ¤¹¤È¡¢XP-IE8 ¤«¤é¤¢¤Ã¤µ¤ê¥á¡¼¥ë¤¬Á÷¤ì¤¿¡£
Ç°¤Î¤¿¤á¡¢IE10,IE6,FF,Chrome,Safari ¤«¤é¤âÁ÷¤Ã¤Æ¤ß¤¿¤¬ÌäÂê¤Ê¤·¡£



¢¨Äɵ­

http://ja.forums.wordpress.org/topic/69307

¤³¤Á¤é¤Ë²ò·èºö¤¬¤¢¤ê¤Þ¤·¤¿¡£


Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

Javascript¤ÇºÙÀþ²½

£²ÃͲ½²èÁü¤Î¥é¥¤¥ó¤òºÙÀþ²½¤¹¤ë¥¢¥ë¥´¥ê¥º¥à¤ÏÂô»³¤¢¤ê¤Þ¤¹¤¬¡¢
¥ë¡¼¥×²ó¿ô¤¬¤É¤¦¤·¤Æ¤â¿¤¯¤Ê¤ë¤Î¤Ç¡¢javascript¤Ç¤Î¼ÂÁõÎã¤Ï¾¯¤Ê¤¤¤Ç¤¹¡£

¤³¤³¤Ç¤Ï¡¢Èæ³ÓŪ¹â®¤ÊZhang-Suen, NWG¤È¡¢Åļ¤ÎÊý¼°¤ò¼ÂÁõ¤·¤Æ¤ß¤Þ¤¹¡£

¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é

Zhang-Suen¤Î¥¢¥ë¥´¥ê¥º¥à¤Ï¡¢Èæ³ÓŪñ½ã¤Ç¤¢¤ë¤Î¤Ç¼ÂÁõ¤·°×¤¤¤Ç¤¹¡£

¥é¥¹¥¿¥¹¥­¥ã¥ó¤Ë¤è¤ê²èÁǾðÊó¤òÆɤ߹þ¤ß¡¢
Ä´ºº²èÁǤò´Þ¤à¡¢3x3pix¤Î²èÁÇÃͤËÂФ·¡¢3¼ï¤Î¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ì¤Ð¡¢
Ä´ºº²èÁǤòÇò(1)¤«¤é¹õ(0)¤ËÃÖ¤­´¹¤¨¤Þ¤¹¡£

Ä´ºº²èÁÇ(P1)¤ò´Þ¤à¡¢3x3pix¤Î²èÁǤ˼¡¤Î¤è¤¦¤ËÈÖ¹æ¤ò¿¶¤ë¡£


¾ò·ï£±¡¥
¡¡³°¼þ°ì¼þ¤òį¤á¤¿»þ¡¢
¡¡(P2->P3->P4->P5->P6->P7->P8->P9->P2)
¡¡¹õ¢ªÇò¤È¤Ê¤ëʤӤ¬°ì¤Ä¤À¤±¤Ç¤¢¤ë¤³¤È¡£

¡¡(±Ñʸ:A(P1)=number of 0,1 patterns(transitions from 0 to 1) in the ordered sequence of P2,P3,P4,P5,P6,P7,P8,P9,P2.
¡¡Condition: A(P1) = 1 )

¾ò·ï£²¡¥
¡¡³°¼þ¤Î²Ã»»(Çò¤Ê¤é+1)¤Î·ë²Ì(B)¤¬¡¢2<= B <=6¡¢¤òËþ¤¿¤¹¡£

¡¡(±Ñʸ:B(P1)=P2+P3+P4+P5+P6+P7+P8+P9 (number of nonzero neighbords of P1.)
¡¡Condition: 2 <= B(P1) <= 6 )

¾ò·ï£³(1)¡¥
¡¡P2 x P4 x P6 = 0 ¤«¤Ä¡¢P4 x P6 x P8 = 0 ¤òËþ¤¿¤¹¡£

¾ò·ï£³(2)¡¥
¡¡P2 x P4 x P8 = 0 ¤«¤Ä¡¢P2 x P6 x P8 = 0 ¤òËþ¤¿¤¹¡£

¤Þ¤º¡¢¾ò·ï£±¡¥£²¡¥£³(1)¤ÎȽÄê¤ò¹Ô¤¤¡¢¾ò·ï¤òËþ¤¿¤·¤¿¾ì¹ç¡¢³ºÅö²èÁǤò½üµî¥ê¥¹¥È¤ËÄɲ乤롣
Á´²èÁÇÄ´ºº¸å¡¢½üµî¥ê¥¹¥È¤Ë²èÁǤ¬¤¢¤ì¤Ð¡¢¤½¤Î²èÁǤòÁ´¤Æ¹õ(0)¤ËÊѤ¨¤ë¡£¤Ê¤±¤ì¤Ð½ªÎ»¤¹¤ë¡£

¼¡¤Ë¡¢¾ò·ï£±¡¥£²¡¥£³(2)¤ÎȽÄê¤ò¹Ô¤¤¡¢Æ±ÍͤνèÍý¤ò³¤±¤ë¡£
°Ê¹ß¡¢¾ò·ï£³(1)(2)¤òÀÚ¤êÂؤ¨¤Ê¤¬¤é¡¢¾ò·ï¤òËþ¤¿¤¹²èÁǤ¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç¡¢·«¤êÊÖ¤·¹Ô¤¦¡£




NWG (Nagendraprasad-Wang-Gupta)¤Ë¤Ä¤¤¤Æ ¤Ï¡¢Zhang-Suen¤ÈÈó¾ï¤Ë»÷¤¿½èÍý¤Ç¤¢¤ë¤¿¤á¡¢
ÀâÌÀ¤Ï³ä°¦¤·¤Þ¤¹¡£
¾ÜºÙ¤Ï¡¢¥½¡¼¥¹¥³¡¼¥É¤«¡¢
A note on the Nagendraprasad-Wang-Gupta thinning algorithm ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£




Zhang-Suen¤Î¥¢¥ë¥´¥ê¥º¥à¤¬¼ç¤Ë·×»»¤Ë¤è¤ëȽÄê¤ò¹Ô¤¦¤Î¤ËÂФ·¡¢
Åļ¤Î¥¢¥ë¥´¥ê¥º¥à¤Ï¡¢¿Þ·Á¤Î¥Þ¥Ã¥Á¥ó¥°¤òÍøÍѤ·¤Þ¤¹¡£

Âç¤Þ¤«¤Ê½èÍý¤È¤·¤Æ¤Ï¡¢
2¼ïÎà¤Î¥Ñ¥¿¡¼¥ó¤¬¤¢¤ê¡¢¤½¤ì¤¾¤ì¤Î¥Ñ¥¿¡¼¥ó¤Ï¡¢
3x3¤Î½üµî¥Ñ¥¿¡¼¥ó¤È3x3¤ÎÈó½üµî¥Ñ¥¿¡¼¥ó¤Ëʬ¤«¤ì¤ë¡£
¡Ê¤³¤³¤Ç¸À¤¦½üµî¤Ï¡¢Çò¤«¤é¹õ¤Ø¤ÎÊѹ¹¤ò°ÕÌ£¤¹¤ë¡£¡Ë

¥é¥¹¥¿¥¹¥­¥ã¥ó¤Ë¤è¤ê²èÁǾðÊó¤òÆɤ߹þ¤ß¡¢
³Æ²èÁǤˤĤ¤¤Æ3x3¤Î¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤ò¹Ô¤¦¡£

¥Ñ¥¿¡¼¥ó¤Ë¤Ï¼¡¤Î¤â¤Î¤¬¤¢¤ë¡£



¡Ú½èÍý³µÍסÛ

­¡ ¥Ñ¥¿¡¼¥ó£±¤Î½üµî¥Ñ¥¿¡¼¥ó¤Ç¥Þ¥Ã¥Á¥ó¥°¤¹¤ì¤Ð­¢¤Ø¡¢°ìÃפ·¤Ê¤±¤ì¤Ð¼¡²èÁǤء£
­¢ ¥Ñ¥¿¡¼¥ó£±¤ÎÈó½üµî¥Ñ¥¿¡¼¥ó¤Ç¥Þ¥Ã¥Á¥ó¥°¤¹¤ì¤Ð¼¡²èÁǤء¢°ìÃפ·¤Ê¤±¤ì¤Ð­£¤Ø¡£
­£ ³ºÅö²èÁǤò½üµî¥ê¥¹¥È¤ËÄɲä·¡¢¼¡²èÁǤء£
­¤ ­¡¡Á­£¤Î½èÍý¤òÁ´²èÁǤËÂФ·¤Æ¹Ô¤¦¡£
­¥ ½üµî¥ê¥¹¥È¤Ë²èÁǤ¬¤¢¤ì¤Ð¡¢¤½¤Î²èÁǤòÁ´¤Æ¹õ(0)¤ËÊѤ¨¤ë¡£¤Ê¤±¤ì¤Ð½ªÎ»¡£

­¦ ¥Ñ¥¿¡¼¥ó£²¤Î½üµî¥Ñ¥¿¡¼¥ó¤Ç¥Þ¥Ã¥Á¥ó¥°¤¹¤ì¤Ð­§¤Ø¡¢°ìÃפ·¤Ê¤±¤ì¤Ð¼¡²èÁǤء£
­§ ¥Ñ¥¿¡¼¥ó£²¤ÎÈó½üµî¥Ñ¥¿¡¼¥ó¤Ç¥Þ¥Ã¥Á¥ó¥°¤¹¤ì¤Ð¼¡²èÁǤء¢°ìÃפ·¤Ê¤±¤ì¤Ð­¨¤Ø¡£
­¨ ³ºÅö²èÁǤò½üµî¥ê¥¹¥È¤ËÄɲä·¡¢¼¡²èÁǤء£
­© ­¦¡Á­¨¤Î½èÍý¤òÁ´²èÁǤËÂФ·¤Æ¹Ô¤¦¡£
­ª ½üµî¥ê¥¹¥È¤Ë²èÁǤ¬¤¢¤ì¤Ð¡¢¤½¤Î²èÁǤòÁ´¤Æ¹õ(0)¤ËÊѤ¨¤ë¡£¤Ê¤±¤ì¤Ð½ªÎ»¡£
­« ­¡¤ËÌá¤ë¡£


¡Ú¥Þ¥Ã¥Á¥ó¥°¥³¡¼¥ÉÎã¡Û

ÀâÌÀ¤Î°Ù¤Ë¡¢3x3pix¤Çɽ¸½¤µ¤ì¤ë£±¤Ä¤Î¥Ñ¥¿¡¼¥ó¤ËP0¡ÁP8¤ÎÈÖ¹æ¤ò¿¶¤ê¤Þ¤¹¡£


P0¡ÁP8¤ò³Æ2bit¤Çɽ¤¹¤â¤Î¤È¤·¡¢
Çòbit:10, ¹õbit:01, ¤É¤Á¤é¤Ç¤âÎɤ¤¤â¤Î¤Ïbit:00¡¡¤È¤·¤Þ¤¹¡£
³ÆÎó¤ÎÀèƬ2bit¤Ë00¤òÉղä·¡¢£±¥Ð¥¤¥È/Îó¤Çɽ¸½¤¹¤ë¤È¡¢
£±¥Ñ¥¿¡¼¥ó¤Ï£³¥Ð¥¤¥È¤Ë¤Ê¤ê¤Þ¤¹¡£

Î㤨¤Ð¡¢¥Ñ¥¿¡¼¥ó£±¤Î½üµî¥Ñ¥¿¡¼¥ó¤Ç¤¢¤ì¤Ð¡¢


¤³¤³¤Ç¡¢¤¢¤ë²èÁǤò´Þ¤à3x3pix¤Î¾õÂÖ¤¬¼¡¤ÎÍͤˤʤäƤ¤¤ë¤È¤¹¤ë¤È

¤³¤ì¤Ï¡¢¥Ñ¥¿¡¼¥ó£±¡¦Èó½üµî¥Ñ¥¿¡¼¥ó¤Î6ÈÖÌܤȥޥåÁ¤·¤Þ¤¹¡£

Èó½üµî¥Ñ¥¿¡¼¥ó(6)¤Ï¡¢P = 0x040A04¤Çɽ¸½¤µ¤ì¤ë¤Î¤Ç

G AND P = P ¤¬À®¤êΩ¤Ä¡£

¤³¤ÎÏÀÍý¼°¤¬À®¤êΩ¤Ä¾ì¹ç¤Ë¡¢¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤ÈǧÄê¤Ç¤­¤Þ¤¹¡£

Åļ¤ÎÊý¼°¤Ç¤Ï¡¢¤½¤ì¤Û¤É¥Ñ¥¿¡¼¥ó¤¬Â¿¤¯¤Ê¤¤¤Î¤Ç¡¢
³ä¤È´Êñ¤Ê¥³¡¼¥Ç¥£¥ó¥°¤ÇºÑ¤ß¤Þ¤¹¡£




<!DOCTYPE html>
<html>
<!-- 
// (c)Hundredsoft Corporation. 2013 All right reserved.
//
//    UTF-8¤ÇÊݸ¤·¤Æ²¼¤µ¤¤
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>ºÙÀþ²½¥µ¥ó¥×¥ë</title>

<script type="text/javascript">
//
// Zhang-Suen Algorithm
//
var zhangsuen = function(imgdata){
    var w = imgdata.width;
    var h = imgdata.height;
    var ind = imgdata.data;

    var x, y, rAry;
    var bFlag = true;

    for (var k=0; k<100 && bFlag; k++){
        if (!(k & 1)){
            bFlag = false;
        }
        rAry = new Uint8Array(ind);
        for (y=1; y<h-1; y++){
            for (x=1; x<w-1; x++){
                var i = (y*w + x)*4;
                if (rAry[i]){
                    var a,b,p1,p2,p3,p4,p5,p6,p7,p8,p9;
                    // [p9 p2 p3]
                    // [p8 p1 p4]
                    // [p7 p6 p5]
                    p1 = 1;
                    p2 = (rAry[i-w*4  ]) ? 1 : 0;
                    p3 = (rAry[i-w*4+4]) ? 1 : 0;
                    p4 = (rAry[i    +4]) ? 1 : 0;
                    p5 = (rAry[i+w*4+4]) ? 1 : 0;
                    p6 = (rAry[i+w*4  ]) ? 1 : 0;
                    p7 = (rAry[i+w*4-4]) ? 1 : 0;
                    p8 = (rAry[i    -4]) ? 1 : 0;
                    p9 = (rAry[i-w*4-4]) ? 1 : 0;
                    a = 0;
                    if (!p2 && p3){a++;}
                    if (!p3 && p4){a++;}
                    if (!p4 && p5){a++;}
                    if (!p5 && p6){a++;}
                    if (!p6 && p7){a++;}
                    if (!p7 && p8){a++;}
                    if (!p8 && p9){a++;}
                    if (!p9 && p2){a++;}
                    b = p2+p3+p4+p5+p6+p7+p8+p9;

                    if (a == 1 && 2 <= b && b <= 6){
                        if ((!(k & 1) && p2*p4*p6 == 0 && p4*p6*p8 == 0)
                         || ( (k & 1) && p2*p4*p8 == 0 && p2*p6*p8 == 0))
                        {
                            ind[i] = ind[i+1] = ind[i+2] = 0;
                            bFlag = true;
                        }
                    }
                }
            }
        }
    }
};

//
// NWG Algorithm
//
var nwg_method = function(imgdata){
    var w = imgdata.width;
    var h = imgdata.height;
    var ind = imgdata.data;

    var x, y, rAry;
    var bFlag = true;

    for (var k=0; k<100 && bFlag; k++){
        bFlag = false;
        rAry = new Uint8Array(ind);
        for (y=1; y<h-1; y++){
            for (x=1; x<w-1; x++){
                var i = (y*w + x)*4;
                if (rAry[i]){
                    var a,b,c,e,f,p0,p1,p2,p3,p4,p5,p6,p7;
                    // [p7 p0 p1]
                    // [p6    p2]
                    // [p5 p4 p3]
                    p0 = (rAry[i-w*4  ]) ? 1 : 0;
                    p1 = (rAry[i-w*4+4]) ? 1 : 0;
                    p2 = (rAry[i    +4]) ? 1 : 0;
                    p3 = (rAry[i+w*4+4]) ? 1 : 0;
                    p4 = (rAry[i+w*4  ]) ? 1 : 0;
                    p5 = (rAry[i+w*4-4]) ? 1 : 0;
                    p6 = (rAry[i    -4]) ? 1 : 0;
                    p7 = (rAry[i-w*4-4]) ? 1 : 0;
                    a = 0;
                    if (!p0 && p1){a++;}
                    if (!p1 && p2){a++;}
                    if (!p2 && p3){a++;}
                    if (!p3 && p4){a++;}
                    if (!p4 && p5){a++;}
                    if (!p5 && p6){a++;}
                    if (!p6 && p7){a++;}
                    if (!p7 && p0){a++;}
                    b = p0+p1+p2+p3+p4+p5+p6+p7;

                    if (2 <= b && b <= 6){
                        c = 0;
                        if ((p0+p1+p2+p5 == 0 && p4+p6 == 2)
                         || (p2+p3+p4+p7 == 0 && p0+p6 == 2)){
                            c = 1;
                        }
                        if (a == 1 || c == 1){
                            e = (p2+p4) * p0 * p6;
                            f = (p0+p6) * p2 * p4;
                            if ((!(k & 1) && e == 0)
                             || ( (k & 1) && f == 0)){
                                ind[i] = ind[i+1] = ind[i+2] = 0;
                                bFlag = true;
                            }
                        }
                    }
                }
            }
        }
    }
};

//
// Åļ Algorithm
//
var tamura = function(imgdata){
    // [p0 p1 p2]
    // [p3 p4 p5]
    // [p6 p7 p8]
    //
    // P[0-8]¤ò2bit¤Çɽ¤¹¡£Çòbit:10, ¹õbit:01, ¤½¤Î¾bit:00
    // ÀèƬ¤Ëbit00¤òÉղä·¡¢£±¥Ð¥¤¥È/Îó¤Ç£±¤Ä¤Î¥Ñ¥¿¡¼¥ó¤ò£³¥Ð¥¤¥È¤Çɽ¸½¡£
    // BitʤӤϡ¢00[p0][p1][p2]00[p3][p4][p5]00[p6][p7][p8]¤È¤¹¤ë¡£

    // ½üµî¤¹¤ë¥Ñ¥¿¡¼¥ó(1)
    var pat1  = new Array(0x040800, 0x000900);
    // ½üµî¤·¤Ê¤¤¥Ñ¥¿¡¼¥ó(1)
    var pat1n = new Array(0x040a09, 0x182900,
                0x001908, 0x042804, 0x081900, 0x040a04, 0x001824, 0x241800,
                0x060900, 0x000906, 0x192a11, 0x190a19, 0x112a19, 0x192819);

    // ½üµî¤¹¤ë¥Ñ¥¿¡¼¥ó(2)
    var pat2  = new Array(0x000804, 0x001800);
    // ½üµî¤·¤Ê¤¤¥Ñ¥¿¡¼¥ó(2)
    var pat2n = new Array(0x182804, 0x001a09,
                0x001908, 0x042804, 0x081900, 0x040a04, 0x001824, 0x241800,
                0x060900, 0x000906, 0x192a11, 0x190a19, 0x112a19, 0x192819);

    var w = imgdata.width;
    var h = imgdata.height;
    var ind = imgdata.data;

    var bFlag = true;
    for (var k=0; k<100 && bFlag; k++){
        bFlag = false;
        var rAry = new Uint8Array(ind);
        var pat, patn;
        if (k & 1){
            pat = pat2;
            patn = pat2n;
        }else{
            pat = pat1;
            patn = pat1n;
        }

        var x,y;
        for (y=1; y<h-1; y++){
            for (x=1; x<w-1; x++){
                var i = (y*w + x)*4;
                if (rAry[i]){
                    var f = 0x000800;

                    if (rAry[i-w*4-4]){f |= 0x200000;}
                    else              {f |= 0x100000;}
                    if (rAry[i-w*4    ]){f |= 0x080000;}
                    else              {f |= 0x040000;}
                    if (rAry[i-w*4+4]){f |= 0x020000;}
                    else              {f |= 0x010000;}
                    if (rAry[i      -4]){f |= 0x002000;}
                    else              {f |= 0x001000;}
//                    if (rAry[i        ]){f |= 0x000800;}
//                    else              {f |= 0x000400;}
                    if (rAry[i      +4]){f |= 0x000200;}
                    else              {f |= 0x000100;}
                    if (rAry[i+w*4-4]){f |= 0x000020;}
                    else              {f |= 0x000010;}
                    if (rAry[i+w*4    ]){f |= 0x000008;}
                    else              {f |= 0x000004;}
                    if (rAry[i+w*4+4]){f |= 0x000002;}
                    else              {f |= 0x000001;}

                    // ½üµî¤¹¤ë¥Ñ¥¿¡¼¥ó¤Ë°ìÃ×
                    if ((f & pat[0]) == pat[0] || (f & pat[1]) == pat[1]){
                        // ½üµî¤·¤Ê¤¤¥Ñ¥¿¡¼¥ó¤Ë°ìÃ×
                        if ((f & patn[ 0]) == patn[ 0] || (f & patn[ 1]) == patn[ 1]
                         || (f & patn[ 2]) == patn[ 2] || (f & patn[ 3]) == patn[ 3]
                         || (f & patn[ 4]) == patn[ 4] || (f & patn[ 5]) == patn[ 5]
                         || (f & patn[ 6]) == patn[ 6] || (f & patn[ 7]) == patn[ 7]
                         || (f & patn[ 8]) == patn[ 8] || (f & patn[ 9]) == patn[ 9]
                         || (f & patn[10]) == patn[10] || (f & patn[11]) == patn[11]
                         || (f & patn[12]) == patn[12] || (f & patn[13]) == patn[13]){
                            ;
                        }else{
                            ind[i] = ind[i+1] = ind[i+2] = 0;
                            bFlag = true;
                        }
                    }
                }
            }
        }
    }
};

var thinning = function(pattern){
    var chk = document.getElementById('difftm')
    var cvs = document.getElementById('IDcanvas')
    var ctx = cvs.getContext("2d");
    var imgdata = ctx.getImageData(0, 0, cvs.width, cvs.height);
    var stt = new Date;
    if (pattern == 0){
        tamura(imgdata);
    }else if (pattern == 1){
        zhangsuen(imgdata);
    }else{
        nwg_method(imgdata);
    }
    chk.innerHTML = "ConvertTime:" + ((new Date) - stt) + "ms";
    ctx.putImageData(imgdata, 0, 0);
};

var init = function(filename){
    var cvs = document.getElementById('IDcanvas')
    var ctx = cvs.getContext("2d");
    var img = new Image();
    img.onload = (function(){
        ctx.drawImage(img, 0, 0);
    });
    img.src = filename;
};
</script>
</head>

<body onload="init('test.png');">
<canvas id="IDcanvas" width="512" height="512"></canvas>
<hr />
<input type="button" value="²èÁü£±" style="width:100px; height:50px;" onclick="init('test.png'); return false;">
<input type="button" value="²èÁü£²" style="width:100px; height:50px;" onclick="init('test2.png'); return false;">
<input type="button" value="²èÁü£³" style="width:100px; height:50px;" onclick="init('test3.png'); return false;">
<br />
<input type="button" value="Åļ" style="width:100px; height:50px;" onclick="thinning('0'); return false;">
<input type="button" value="Zhang-Suen" style="width:100px; height:50px;" onclick="thinning('1'); return false;">
<input type="button" value="NWG" style="width:100px; height:50px;" onclick="thinning('2'); return false;">

<hr />
²èÁü¤òÁª¤ó¤Ç¤«¤é¡¢Åļ or Zhang-Suen oe NWG ¤ò¥¯¥ê¥Ã¥¯¡ª<br />
¡ÊChrome,FireFox¤À¤È0.5ÉÃÄøÅ٤Ǥ¹¤¬¡¢IE10¤À¤ÈÊÑ´¹¤Ë5ÉÃÄøÅٳݤê¤Þ¤¹¡£¡Ë<br />
<br />
<div id="difftm"></div>
</body>
</html>


ÀâÌÀ¤Ç¤Ïºï½ü¥ê¥¹¥È¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢¸µ¥Ç¡¼¥¿¤òTypedArray(Uint8Array)¤Ë¥³¥Ô¡¼¤·¤¿Êý¤¬Áᤫ¤Ã¤¿¤Î¤Ç¡¢
¼ÂÁõ¤Ç¤Ï¡¢ÊѤ¨¤Æ¤¤¤Þ¤¹¡£(ÆâÍÆŪ¤ËÊѤï¤ë¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£)

Zhang-Suen,NWG,Åļ¤Ç¡¢¤É¤ÎÊýË¡¤¬Îɤ¤¤«¤Ï¡¢ÆþÎϲèÁü¤Ë¤è¤Ã¤ÆÊѤï¤ë¤Î¤Ç°ì³µ¤Ë¤Ï¸À¤¨¤Þ¤»¤ó¡£
¥µ¥ó¥×¥ë¤òÆ°¤«¤¹¤È¤ï¤«¤ê¤Þ¤¹¤¬¡¢½èÍý»þ´Ö¤Ë´Ø¤·¤Æ¤Ï¡¢NWG¤è¤ê¡¢Zhang-Suen¤ÎÊý¤¬Áᤤ¤Ç¤¹¡£
NWG¤Ï¡¢Zhang-Suen¤Î²þÎÉÈǤǤ¢¤ë¤¿¤á¼ã´³½èÍý¤¬Áý¤¨¤Æ¤¤¤ë¤¿¤á¤Ç¤¹¡£
¿Í´Ö¤ÎÌܤǸ«¤ë¤È¶Ï¤«¤Ê°ã¤¤¤Ç¤¹¤¬¡¢NWG¤ÎÊý¤¬åºÎï¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤è¤¦¤Ç¤¹¡£

Åļ¤Ë´Ø¤·¤Æ¤Ï¡¢¥µ¥ó¥×¥ë¤Î²èÁü£±¡¦²èÁü£²¤Ç¤Ï®ÅÙ¤¬Îô¤ê¤Þ¤¹¤¬¡¢²èÁü£³¤Ç¤Ï°µÅÝŪ¤ËÁᤤ¤Ç¤¹¡£
ʸ»ú·Ï¤Ç¤Ï̯¤Ê¤Ò¤²¤¬½Ð¤ä¤¹¤¤¤Ç¤¹¤¬¡¢¼Ì¿¿Åù¤Î¥¨¥Ã¥¸Ãê½Ð²èÁü¤ËÂФ·¤Æ¤ÏÎɤ¤·ë²Ì¤¬½Ð¤Æ¤¤¤Þ¤¹¡£

(ÏÀʸȯɽ½ç¤Ç¤Ï¡¢¡ÚHilditch(1968)¡Û¢ª¡ÚÅļ(1978)¡Û¢ª¡ÚZhang-Suen(1984)¡Û¢ª¡ÚNWG(1989)¡Û)

º£²ó¼ÂÁõ¤·¤Æ¤¤¤Þ¤»¤ó¤¬¡¢
Hilditch¤ÎÊýË¡¤ÏºÙÀþ²½½èÍý¤Î¸µÁĤȤâ¸À¤¨¤Þ¤¹¤¬¡¢½½Ê¬¤Ê·ë²Ì¤¬ÆÀ¤é¤ì¤Ê¤¤¾ì¹ç¤¬¤¢¤ë¤é¤·¤¤¡£
Rosenfeld¤Ï¡¢Zhang-Suen,NWG,Åļ¤ËÈæ¤Ù¡¢¤«¤Ê¤ê½èÍý¤¬½Å¤¯¤Ê¤ë¤é¤·¤¤¡£
¡Ê»²¹Í¡§ Comparing Hilditch, Rosenfeld, Zhang-Suen,and Nagendraprasad - Wang-Gupta Thinning ¡Ë


¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é


IE10/Chrome/FF/Android¤Ç¡¢³Îǧ¤·¤Æ¤¤¤Þ¤¹¡£

IE9¤Ï¡¢TypedArray(Uint8Array)¤ËÂбþ¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢ºï½ü¥ê¥¹¥È¤ò»È¤¦Êý¼°¤Ë½¤Àµ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
IE10¤Ç¤â¡¢Uint8ClampedArray¡Ê˰ϱ黻ÉÕ¤­8bit¡Ë¤Ë¤ÏÂбþ¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢
¤³¤Î¥µ¥ó¥×¥ë¤Ç¤Ï¡¢Uint8Array¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£
(Chrome,FF¤Ç¤Î¡¢ImageData.data¤Î·¿¤ÏUint8ClampedArray¤Ç¤¹¡£)

¤³¤Î¥ë¡¼¥×¿ô¤Ë¤Ê¤ë¤ÈChrome¤äFF¤Ï®¤¤¤Ç¤¹¤¬¡¢IE¤À¤È¤«¤Ê¤êÃÙ¤¤¤Î¤Ç¡¢
²èÁü¥µ¥¤¥º¤Ë¤è¤Ã¤Æ¤Ï¡¢Web Workers¤Ë¤è¤ë¥Þ¥ë¥Á¥¹¥ì¥Ã¥É²½¤ò¸¡Æ¤¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
⤷¡¢IE¤Ç¤ÏImageData.data¤Î·¿(CanvasPixelArray)¤¬°Û¤Ê¤ë¤Î¤Ç¡¢Ãí°Õ¤¬É¬ÍפǤ¹¡£


--------------- ʸ¸¥ ---------------
¡ÚÅļ¤ÎÊý¼°¡Û
H. Tamura: A comparison of line thinning algorithms from digital geometry viewpoint, Proc. 4th Int. Joint Conf. on Pattern Recognition, pp. 715 - 719 (1978.11)

¡ÚZhang-Suen¤ÎÊý¼°¡Û
Zhang, T. Y. and Suen, Ching Y., ¡ÈA Fast Parallel Algorithms ForThinning Digital Patterns¡É,Communication of the ACM,Vol 27, No. 3,Maret 1984, pp.236-239.

¡ÚNWG¤ÎÊý¼°¡Û
P.S.P. Wang and Y.Y. Zhang (1989). A fast and flexible thinning algo-rithm. IEEE Transactions on Computation C-38, 741–745




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

Catmull-Rom¥¹¥×¥é¥¤¥ó

Catmull-Rom¥¹¥×¥é¥¤¥ó

Edwin Catmull¤ÈRaphael Rom¤Ë¤è¤ê³«È¯¤µ¤ì¤¿¶ÊÀþÊä´Ö¤Ç¤¹¤¬¡¢
Edwin Catmull¤Ï¥Ô¥¯¥µ¡¼¡¦¥¢¥Ë¥á¡¼¥·¥ç¥ó¡¦¥¹¥¿¥¸¥ª¤Î¸½¼ÒŤÀ¤½¤¦¤Ç¤¹¡£

»ä¤¬Catmull¤Î¥¹¥×¥é¥¤¥ó¤òºÇ½é¤ËÄ´¤Ù¤¿¤Î¤Ï¡¢£¸Ç¯¤âÁ°¤Ë¤Ê¤ê¤Þ¤¹¤¬¡¢
¤½¤Î¤³¤í¤Ïµ­»ö¤äÏÀʸ¤¬¤Û¤È¤ó¤É¤Ê¤¯¤Æ¶ìÏ«¤·¤¿µ­²±¤¬¤¢¤ê¤Þ¤¹¡£

3¼¡¤ÎB-Spline(Cardinal)¤ËÈæ¤Ù¤Æ¤ä¤ä±Ô³Ñ¤Ê°õ¾Ý¤¬¤¢¤ê¤Þ¤¹¡£
¤½¤Îʬ¡¢Creater¤Î°Õ»×¤¬È¿±Ç¤Ç¤­¤Þ¤¹¡£
Àµ³Î¤Ê¥Ç¥¶¥¤¥ó¤Ï¡¢Bezier¤ò»È¤Ã¤¿Êý¤¬Îɤ¤¤Ç¤¹¤¬¡¢
¥é¥Õ¤Ê¥Ç¥¶¥¤¥ó¤ä¡¢Î®Àþ·¿¤Ë¸Â¤ì¤Ð´Êñ¤Ç½ÅÊõ¤·¤Þ¤¹¡£

º£²ó¤â´Êñ¤Ëjavascript¤Ç¥×¥í¥°¥é¥à¤·¤Æ¤ß¤Þ¤¹¡£
Opener¡Ê³«¶ÊÀþ¡Ë¤Ê¥«¡¼¥Ö¤Ï¡¢¸¡º÷¤¹¤ì¤Ð¤¤¤¯¤é¤Ç¤â¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢
Closed¡ÊÊĶÊÀþ¡Ë¤Ê¥«¡¼¥Ö¤òÉÁ¤¤¤Æ¤ß¤Þ¤¹¡£

¤È¤Ï¸À¤Ã¤Æ¤â¡¢¹ÔÎ󼰤Ϸè¤Þ¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢
ÇÞ²ðÊÑ¿ô¤ò»È¤Ã¤Æ2²Á´Ø¿ô¤òµö¤·¡¢»ÏÅÀ¡¦½ªÅÀ¤ÎÀáÅÀ¤òÄ´À᤹¤ë¤À¤±¤Ç¤¹¡£

Catmull-Spline¤Ç¤Ï£´¤Ä¤ÎÀáÅÀ¤«¤é¡¢£³¼¡¤ÎÊä´Ö¼°¤òºî¤ë¤Î¤Ç¡¢
»ÏÅÀ¤ò¡¢P[n-1],P[0],P[1],P[2]¤«¤éºî¤ê¡¢
½ªÅÀ¤Ï¡¢P[n-2],P[n-1],P[0],P[1]¤«¤éºî¤ê¤Þ¤¹¡£

´Ø¿ôcatmullCircuit¤Ë¡¢ÀáÅÀ¤ÎX,YºÂɸÎó¤òÍ¿¤¨¤ë¤È¡¢
ÀáÅÀ´Ö¤Î20¸Ä¤ÎÊä´ÖºÂɸ¤òÊÖ¤·¤Þ¤¹¡£

¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é

<!DOCTYPE html>
<html>
<!-- 
// (c)Hundredsoft Corporation. 2013 All right reserved.
//
//	UTF-8¤ÇÊݸ¤·¤Æ²¼¤µ¤¤
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>CatMull-Spline Circuit</title>

<script type="text/javascript">
new function() {

var m_x = [];
var m_y = [];

var draw = function(w, h){
	m_ctx.clearRect(0, 0, w, h);

	m_ctx.lineJoin = "round";
	m_ctx.lineCap = "round";
	m_ctx.lineWidth = 2;
	m_ctx.strokeStyle = "#000000";

	var n = m_x.length;
	var i;
	// ÀáÅÀ¤ÎÉÁ²è
	for (i=0; i<n; i++){
		m_ctx.beginPath();
		m_ctx.arc(m_x[i], m_y[i], 4, 0, Math.PI*2, false);
		m_ctx.fill();
		m_ctx.closePath();
	}
	if (n > 2){
		var cc = catmullCircuit(m_x, m_y);
		var nc = cc.x.length;

		// ¥¹¥×¥é¥¤¥óÉÁ²è
		m_ctx.beginPath();
		m_ctx.moveTo(cc.x[0], cc.y[0]);
		for (var i=1; i<nc; i++){
			m_ctx.lineTo(cc.x[i], cc.y[i]);
		}
		m_ctx.stroke();
		m_ctx.closePath();
	}

};

var catmullCircuit = function (xi, yi){
	var n = xi.length;
	var x=[], y=[];
	var ox=[], oy=[];

	x.push(xi[n-1]);	y.push(yi[n-1]);
	x.push(xi[0]);	y.push(yi[0]);
	for (var i=1; i<n ;i++){
		x.push(xi[i]);	y.push(yi[i]);
	}
	x.push(xi[0]);	y.push(yi[0]);
	x.push(xi[1]);	y.push(yi[1]);

	n += 1;

	for (var i=1; i<n ;i++){
		var ax = -1 * x[i-1] + 3 * x[i] - 3 * x[i+1] + 1 * x[i+2];
		var bx =  2 * x[i-1] - 5 * x[i] + 4 * x[i+1] - 1 * x[i+2];
		var cx = -1 * x[i-1] + 0 * x[i] + 1 * x[i+1] + 0 * x[i+2];
		var dx =  0 * x[i-1] + 2 * x[i] + 0 * x[i+1] + 0 * x[i+2];

		var ay = -1 * y[i-1] + 3 * y[i] - 3 * y[i+1] + 1 * y[i+2];
		var by =  2 * y[i-1] - 5 * y[i] + 4 * y[i+1] - 1 * y[i+2];
		var cy = -1 * y[i-1] + 0 * y[i] + 1 * y[i+1] + 0 * y[i+2];
		var dy =  0 * y[i-1] + 2 * y[i] + 0 * y[i+1] + 0 * y[i+2];

		// 20ʬ³ä¡Ê¹Ó¤¤¡Ë
		for (var j=0; j<=20; j++){
			var t = j / 20;
			ox.push(((ax *t*t*t) + (bx *t*t) + (cx *t) + dx) / 2);
			oy.push(((ay *t*t*t) + (by *t*t) + (cy *t) + dy) / 2);
		}
	}
	return {"x": ox, "y":oy};
};


test2 = {
init: function(){
	var canvas = document.getElementById('c');
	m_ctx = canvas.getContext("2d");

	canvas.addEventListener('touchstart',
		function(e) {
			e.preventDefault();
			var n = e.touches.length;
			var rect=e.target.getBoundingClientRect();
			m_x.push(e.touches[n-1].pageX-rect.left);
			m_y.push(e.touches[n-1].pageY-rect.top);
			draw(canvas.width, canvas.height);
		}, false);

	canvas.addEventListener('mousedown',
		function(e) {
			e.preventDefault();
			var rect=e.target.getBoundingClientRect();
			m_x.push(e.clientX-rect.left);
			m_y.push(e.clientY-rect.top);
			draw(canvas.width, canvas.height);
		}, false);
}
}
};

</script>
</head>

<body onload="test2.init()">
<canvas id="c" width="640" height="640" style="background-color:#e0e0e0;">
</canvas>
</body>
</html>



¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é


IE9°Ê¹ß/Chrome/Safari/FF/Android¤Ç¡¢³Îǧ¤·¤Æ¤¤¤Þ¤¹¡£




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

2DÊ¿Ì̤DzÃË¡ÄêÍý¤ò»È¤¦

»°³Ñ´Ø¿ô¤Î²ÃË¡ÄêÍý¤ò¤´Â¸¤¸¤Ç¤·¤ç¤¦¤«¡©

¹â¹»¤Î¿ô³Ø¤Ç½¬¤¦¤ä¤Ä¤Ç¤¹¡£
¸¡º÷¤·¤Æ¤â¡¢¼ÂºÝ¤Î¥×¥í¥°¥é¥à¤Ç¤Î»È¤¤Êý¤äÍ­¸úÅÀ¤¬¸«¤Ä¤«¤ë¤³¤È¤Ï³§Ìµ¤Ë¶á¤¤¡£
¤Þ¤ë¤Ç¡¢Æþ³Ø»î¸³¤Î¤¿¤á¤À¤±¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£

¿Þ·Á¤Î²óž¤¬Ï¢Â³¤¹¤ë¥±¡¼¥¹¤Ç¤Ï¡¢³ÑÅÙ¤òÊÝ»ý¤¹¤ë¥×¥í¥°¥é¥à¤¬¤Û¤È¤ó¤É¤Ç¤¹¡£
¤·¤«¤·¡¢¤³¤¦¤¤¤Ã¤¿¥±¡¼¥¹¤Ç¤Ï¡¢sin, cos ÃͤòÊݸ¤·¤Æ¤ª¤¤¤¿Êý¤¬¡¢
if ʸ¤¬¾¯¤Ê¤¯¤Ê¤ê¡¢ÉÔ¶ñ¹ç¤¬¾¯¤Ê¤¯¤Ê¤Ã¤¿¤ê¤·¤Þ¤¹¡£

-------

¤¢¤ë¶ë·ÁABCD¤¬¤¢¤Ã¤¿¤È¤·¤Æ¡¢AÅÀ¤ò¸ÇÄê¤Ë¤·¤ÆCÅÀ¤òÆ°¤«¤¹¡£
ÊѲ½¸å¤Î¶ë·ÁAB¡ÇC¡ÇD¡Ç ¤òµá¤á¤ë¡£
⤷¡¢¶ë·Á¤Î½Ä²£Èæ¡ÊAspectÈæ¡Ë¤ÏÊѤ¨¤Ê¤¤¤â¤Î¤È¤¹¤ë¡£



¶ë·Á¤Î³ÈÂçΨ(¦Á)¤Ï¡¢¼¡¼°¤Çµá¤Þ¤ë¡£

¸µ¤Î¶ë·Á¤ÎÉý¤È¹â¤µ¤ò¤½¤ì¤¾¤ì¡¢w,h¤È¤·¡¢ÊѲ½¸å¤ÎÉý¤È¹â¤µ¤òw¡Ç,h¡Ç ¤È¤¹¤ë¡£
¤Þ¤¿¡¢²óž³Ñ¤ò¦È ¤È¤¹¤ë¡£
A,C¡Ç ¤Ï´ûÃΤǤ¢¤ë¤Î¤Ç¡¢B¡Ç ¤«D¡Ç ¤Î¤¤¤º¤ì¤«¤¬¤ï¤«¤ì¤ÐÎɤ¤¡£

´ö¤Ä¤«¤ÎÊýË¡¤¬¹Í¤¨¤é¤ì¤ë¤¬¡¢
ñ½ã¤Ê¤Î¤Ï¡¢³ÈÂçΨ(¦Á)¤È²óž³Ñ(¦È) ¤òµá¤á¤Æ¡¢¼¡¤Î¹ÔÎó¤ËÂåÆþ¤·¤Æ·×»»¤¹¤ëÊýË¡¤À¤í¤¦¡£

¤³¤ÎÊýË¡¤Î·çÅÀ¤Ï¡¢¦È ¤òµá¤á¤ë¤ÈÆÃÄê¤Î¾Ý¸Â¤Ë¤ª¤¤¤Æ¡¢Éä¹æ¤ÎÁàºî¤¬É¬Íפˤʤ뤳¤È¤À¤í¤¦¡£
Î㤨¤Ðatan¤Ç¤Ï¡¢(-¦Ð/2 ¡å ¦È ¡å ¦Ð/2)¤ÎÈϰϤǤ·¤«¡¢Åú¤¨¤¬µá¤Þ¤é¤º¡¢
acos¤Ç¤Ï(0 ¡å ¦È ¡å ¦Ð)¤ÎÈϰϤǤ·¤«µá¤Þ¤é¤Ê¤¤¡£
C¡Ç ¤òAÅÀ¤òÃæ¿´¤Ë²óž¤µ¤»¤ë¤È¤ï¤«¤ê¤ä¤¹¤¤¡£
¤³¤ÎÊýË¡¤Ï°Õ³°¤È´Ö°ã¤¤¤òÈȤ·¤ä¤¹¤¯¡¢¥Æ¥¹¥È¥±¡¼¥¹¤âÁý¤¨¤ë¤Î¤Ç¡¢ÁªÂò¤¹¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£

A,C,C¡Ç ¤ÎºÂɸ¤¬¤ï¤«¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢
¥Ù¥¯¥È¥ëAC¡¢AC¡Ç ¤ÎÆâÀѤȳ°ÀѤ«¤écos¦È,sin¦È ¤ò»»½Ð¤¹¤ë¡£

ÆâÀѤθø¼°


³°ÀѤθø¼°


º£²ó¤Î¥±¡¼¥¹¤ËÅö¤Æ¤Ï¤á¡¢cos,sin¤ò²ò¤¯¤È¡¢


HTML5¤Îcanvas¥¯¥é¥¹¤Ç¤Ï¡¢Context.transform¤Ç¹ÔÎó±é»»¤¬²Äǽ¤Ê¤Î¤Ç
¹ÔÎ󼰤Υѥé¥á¥¿(cos,sin,-sin,cos)¤ò»ØÄꤹ¤ì¤ÐÎɤ¤¡£

°ìÅٲ󞤵¤»¤Æ¡¢¸å¤«¤é¹¹¤Ë²óž¤òÄɲ乤ë¾ì¹ç¤ò¹Í¤¨¤ë¡£
¿Þ¤Ç¤Ï¡¢C¡Ç ¤«¤éC'¡Ç ¤ËÀ©¸æÅÀ¤¬°ÜÆ°¤·¤¿¤È¤¹¤ë¡£


¤Þ¤ºÁ°½Ð¤ÎÊýË¡¤Ç¡¢¥Ù¥¯¥È¥ëAC¡Ç¡¢AC'¡Ç ¤ÎÆâÀѤȳ°ÀѤ«¤écos(¦Å),sin(¦Å)¤ò»»½Ð¤¹¤ë¡£

´û¤Ë¦È ²óž¤·¤Æ¤¤¤Æ¡¢¹¹¤Ë¦Å ¤Î²óž¤¬²Ã¤ï¤ë¤È¤¹¤ë¤È¡¢²ÃË¡ÄêÍý¤Ë¤è¤ê


³ÈÂçΨ¤âƱÍͤˡ¢´û¤Ë³ÈÂçΨ¦Â ¤Ç¤¢¤ê¡¢
¤³¤ì¤Ë³ÈÂçΨ¦Á ¤¬²Ã¤ï¤ë¤È¤¹¤ì¤Ð¡¢¦Â£ø¦Á ¤¬¹çÀ®³ÈÂçΨ¤Ë¤Ê¤ë¡£


¹¹¤ËȯŸ¤µ¤»¤Æ¡¢³ÈÂç½Ì¾®²óž¤¬ÃdzŪ¤ËϢ³ȯÀ¸¤¹¤ë¥±¡¼¥¹¤ò¹Í¤¨¤Æ¤ß¤Þ¤¹¡£



¥µ¥ó¥×¥ë¤ò¼Â¹Ô¤¹¤ë¤È¤ï¤«¤ê¤ä¤¹¤¤¡£

Áàºî¤È¤·¤Æ¤Ï¡¢
AÅÀ¤òCanvasÃæ±ûÅÀ¤È¤·¤Æ¡¢¥¯¥ê¥Ã¥¯ÅÀ¤òP¤È¤¹¤ë¡£
¡¡¡¡¡¡¡¡¤³¤Î»þ²èÌ̤ˤϡ¢­¡¤Î¶ë·Á¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£

¤½¤Î¸å¡¢¥¹¥ï¥¤¥×Áàºî¤ÇP¡Ç ¤Þ¤Ç°ÜÆ°¤·¡¢¤³¤³¤Ç»Ø¤òÎ¥¤¹¡£
¡¡¡¡¡¡¡¡¤³¤Î»þ²èÌ̤ˤϡ¢­¢¤Î¶ë·Á¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£

ºÆ¤Ó¡¢QÅÀ¤Ç¥¯¥ê¥Ã¥¯¤ò¹Ô¤¦¡£
¡¡¡¡¡¡¡¡¤³¤Î»þ²èÌ̤ˤϡ¢­¢¤Î¶ë·Á¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£

¥¹¥ï¥¤¥×¤ÇQ¡Ç ¤Þ¤Ç°ÜÆ°¤·»Ø¤òÎ¥¤¹¡£
¡¡¡¡¡¡¡¡¤³¤Î»þ²èÌ̤ˤϡ¢­£¤Î¶ë·Á¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£

¼Â¸½ÊýË¡¤Ï¤¤¤í¤¤¤í¤¢¤ë¤¬¡¢
¥¹¥ï¥¤¥×OFF»þ¤Ë¡¢¤½¤Î»þÅÀ¤Î³ÈÂçΨ(¦Âx¦Á)¡¦²óž¾õÂÖ(sin(¦È+¦Å),cos(¦È+¦Å))¤òÊݸ¤·¤Æ¤ª¤­¡¢
¥¯¥ê¥Ã¥¯»þ¤Ë¡¢¦Â¡á¦Âx¦Á, sin(¦È)¡ásin(¦È+¦Å), cos(¦È)¡ácos(¦È+¦Å)
¤È¤·¤ÆºÆ³«»Ï¤¹¤ì¤ÐÎɤ¤¡£

Javascript¤Ç¤Î¥½¡¼¥¹¥³¡¼¥É¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
<!DOCTYPE html>
<html>
<!-- 
// (c)Hundredsoft Corporation. 2013 All right reserved.
//
//	UTF-8¤ÇÊݸ¤·¤Æ²¼¤µ¤¤
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>³ÈÂç½Ì¾®²óž</title>

<script type="text/javascript">
new function() {
var m_img = new Image();
var m_ctx = null;
var m_O = null;
var m_baseX = 0;
var m_baseY = 0;
var m_cos = 1;
var m_sin = 0;
var m_prop = 1;
var m_Lcos = 1;
var m_Lsin = 0;
var m_Lprop = 1;

var mmove = function(x, y){
	// ClickºÂɸ-Ãæ¿´ ¥Ù¥¯¥È¥ë
	var vx0 = m_baseX - m_O.x;
	var vy0 = m_baseY - m_O.y;
	var r0 = Math.sqrt(vx0*vx0 + vy0*vy0);

	// ¥¹¥ï¥¤¥×ºÂɸ-Ãæ¿´ ¥Ù¥¯¥È¥ë
	var vx1 = x - m_O.x;
	var vy1 = y - m_O.y;
	var r1 = Math.sqrt(vx1*vx1 + vy1*vy1);

	var cos = (vx0*vx1 + vy0*vy1) / (r0*r1); // ÆâÀѤ«¤é
	var sin = (vx0*vy1 - vy0*vx1) / (r0*r1); // ³°ÀѤ«¤é
	var prop = r1 / r0;
	draw(prop, cos, sin);
};
var draw = function(prop, cos, sin){
	m_Lcos = m_cos*cos - m_sin*sin; // ²ÃË¡ÄêÍý(cos)
	m_Lsin = m_sin*cos + m_cos*sin; // ²ÃË¡ÄêÍý(sin)
	m_Lprop = m_prop * prop;     // ³ÈÂçΨ¤Î²ÃË¡¤Ï¾è¤¸¤ë¤À¤±
	m_ctx.clearRect(0, 0, m_O.x*2, m_O.y*2);
	m_ctx.save();

	 // ¹ÔÎó·×»»
	m_ctx.transform(
		m_Lcos*m_Lprop,  m_Lsin*m_Lprop,
		-m_Lsin*m_Lprop, m_Lcos*m_Lprop,  m_O.x, m_O.y);

	// Àè¤Ë²èÁüÃæ¿´¤ò¸¶ÅÀ¤Ë°ÜÆ°(ŬÍѽç¤ËÃí°Õ)
	m_ctx.transform(1, 0, 0, 1, -m_img.width/2, -m_img.height/2);

	m_ctx.drawImage(m_img, 0, 0);
	m_ctx.restore();
};

test1 = {
init: function(){
	var mouseDown = false;
	var canvas = document.getElementById('c');

	canvas.addEventListener('touchstart',
		function(e) {
			e.preventDefault();
			mouseDown = true;
			var n = e.touches.length;
			var rect=e.target.getBoundingClientRect();
			m_baseX = e.touches[n-1].pageX-rect.left;
			m_baseY = e.touches[n-1].pageY-rect.top;
			m_cos = m_Lcos;
			m_sin = m_Lsin;
			m_prop = m_Lprop;
		}, false);

	canvas.addEventListener('mousedown',
		function(e) {
			e.preventDefault();
			mouseDown = true;
			var rect=e.target.getBoundingClientRect();
			m_baseX = e.clientX-rect.left;
			m_baseY = e.clientY-rect.top;
			m_cos = m_Lcos;
			m_sin = m_Lsin;
			m_prop = m_Lprop;
		}, false);

	canvas.addEventListener('touchend',
		function(e) {mouseDown = false;}, false);

	canvas.addEventListener('mouseup',
		function(e) {mouseDown = false;}, false);

	canvas.addEventListener('touchmove',
		function (e) {
			e.preventDefault();
			var rect = e.target.getBoundingClientRect();
			if (mouseDown) {
				var n = e.touches.length;
				mmove(e.touches[n-1].pageX-rect.left,
					e.touches[n-1].pageY-rect.top);
			}
		}, false);

	canvas.addEventListener('mousemove',
		function (e) {
			e.preventDefault();
			var rect = e.target.getBoundingClientRect();
			if (mouseDown) {
				mmove(e.clientX-rect.left, e.clientY-rect.top);
			}
		}, false);

	m_img.onload = (function(){
		m_O = {x: canvas.width/2, y: canvas.height/2};
		m_ctx = canvas.getContext("2d");
		draw(1, 1 ,0);
	});
	m_img.width = 260;
	m_img.height = 390;
	m_img.src = "test.jpg";
}
}
};
</script>
</head>
<body onload="test1.init()">
<canvas id="c" width="640" height="640" style="background-color:#e0e0e0;">
</canvas>
</body>
</html>


°Õ³°¤ÈÌÌÅݤʽèÍý¤Ç¤¹¤¬¡¢¥³¡¼¥É¤ÎÄ̤ꡢ±é»»½èÍý¤Çifʸ¤Ï°ì¤Ä¤â¤¢¤ê¤Þ¤»¤ó¡£
¤³¤ÎÊýË¡¤ÎÍøÅÀ¤Ï¡¢¥á¥ó¥ÐÊÑ¿ô¤Î»ÈÍѤ¬¾¯¤Ê¤¤»ö¤È¡¢¦È ¤ò·×»»¤·¤Ê¤¤¡Ê»°³Ñ´Ø¿ô¤Î¸ø¼°¤Ï»È¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢ ´Ø¿ô¤È¤·¤Æ¤Îsin¤äcos ¤Ï»È¤Ã¤Æ¤¤¤Ê¤¤¡£»È¤Ã¤Æ¤¤¤ë¤Î¤Ï²Ã¸º¾è½ü¤È¥ë¡¼¥È¤Î¤ß¡£¡Ë¤³¤È¤Ç¡¢if ʸ¤ò¾Ê¤±¤ë»ö¤¬µó¤²¤é¤ì¤Þ¤¹¡£


¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é


IE9°Ê¹ß/Chrome/Safari/FF/Android¤Ç¡¢³Îǧ¤·¤Æ¤¤¤Þ¤¹¡£




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

HTML5¤ÎCanvas¥µ¥ó¥×¥ë

HTML5¤ÇCanvas¤ò»È¤Ã¤Æ¤ª³¨¤«¤­¤ò¤¹¤ë¥µ¥ó¥×¥ë¡£


¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é




¤¢¤ëÇ۴ɤ¬¤¢¤Ã¤¿¤È¤·¤Æ¡¢ÇÛ´ÉÆâÉô¤Î»¬¤ä±ø¤ì¤Ë¤è¤êήÎ̤¬¾¯¤Ê¤¯¤Ê¤ë¥±¡¼¥¹¤òÁÛÄꤹ¤ë¡£
¸¡ºº¤Ë¤è¤êÆâÉô¤Î¾õÂÖ¤òÄ´¤Ù¡¢¸¡ºº»ñÎÁ¤È¤·¤Æ¤Þ¤È¤á¤ë¡£

ÆÃÄê²Õ½ê¤ÎÃÇÌ̤«¤é¡¢ÇÛ´ÉĹ¼´¤ÎÁÛÁü¿Þ¤òÉÁ¤¯¡£
¤³¤Î¤è¤¦¤Ê¥¢¥×¥ê¤¬¤¢¤ë¤È¡¢¤ï¤«¤ê¤ä¤¹¤¤¡£

ActiveX¤â¼÷Ì¿¤Ê¤Î¤Ç¡¢¥¿¥Ö¥ì¥Ã¥È¤Ç´Êñ¤ËÁàºî¤Ç¤­¤ë¤è¤¦¤Ë¹Í°Æ¤·¤¿¤â¤Î¤Ç¤¹¡£


¤³¤Î¥¢¥×¥ê¤Ï¡¢¤ª¤è¤½£±Ç¯Á°¤Ëºî¤Ã¤¿¤â¤Î¤Ç¤¹¡£
ɾȽ¤ÏÎɤ«¤Ã¤¿¤Î¤Ç¤¹¤¬¡¢Çä¤êʪ¤Ë¤Ï¤Ê¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£
¤ä¤Ï¤ê¡¢IE8¤Çcanvas¤ËÂбþ¤·¤Æ¤¤¤Ê¤¤¤³¤È¤¬ºÇÂç¤Î¥Í¥Ã¥¯¤Ç¤¹¡£
XP¥æ¡¼¥¶¡¼¤¬¤¤¤ë¸Â¤ê¡¢Ë¡¿Í¸þ¤±¤ËHTML5¤ÏÆñ¤·¤¤¤Ç¤¹¡£
¤â¤¦¾¯¤·²æËý¤Ç¤¹¤Í¡£


¼ÂºÝ¤Ë¤Ï¡¢Ç۴ɤȤÏðôÆ°Ì®¤Î¤³¤È¤Ç¤¢¤ê¡¢»¬¤ä±ø¤ì¤Ï¥Ý¥ê¡¼¥×¤Ç¤¹¡£
¥«¥ë¥Æ¤ËźÉÕ¤¹¤ë¥·¥§¡¼¥Þ¤òͽÄꤷ¤Æ¤¤¤¿¤â¤Î¤Ç¤¹¡£


Æü¤ÎÌܤò¸«¤Ê¤¤¤Î¤âáû¤Ê¤Î¤Ç¡¢°ìÉô¤òÀÚ¤ê½Ð¤·¤Æ¤ß¤Þ¤·¤¿¡£
IE9°Ê¹ß/Chrome/Safari/FF¤Ç¡¢³Îǧ¤·¤Æ¤¤¤Þ¤¹¡£
¥³¡¼¥É°ì¼°¤Ï¤³¤Á¤é




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

¥Ü¥¿¥ó¤Î¿§¤òÊѤ¨¤ë

Javascript¤Ç¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ëÅÙ¤ËÇØ·Ê¿§¤òÊѤ¨¤ë¾ì¹ç¡¢
¥¯¥í¡¼¥¸¥ã¤¬ÍøÍѤǤ­¤ë¡£

¢«¥¯¥ê¥Ã¥¯
¢«¥¯¥ê¥Ã¥¯



<body>
<input id="testb1" type="button" value="color" />
<br />
<input id="testb2" type="button" value="color" />
<br />

<script type='text/javascript'>
new function() {
var ctbl = new Array('#00FF00', '#00E0FF', '#FF0000');
var changecolor = function (a, b){
	var x = a;
	var y = b;
	x.style.backgroundColor = ctbl[y];
	return function(){
		y = (y + 1) % (ctbl.length);
		x.style.backgroundColor = ctbl[y];
	};
};
var test = function (){
	var btn;
	btn = document.getElementById('testb1');
	btn.onclick=changecolor(btn, 0);
	btn = document.getElementById('testb2');
	btn.onclick=changecolor(btn, 1);
}

test();

};
</script>
</body>




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

asmx¤è¡¢±Ê±ó¤Ë¡£

HTML5¤ÇCanvas¤ò»È¤Ã¤Æ¤ª³¨¤«¤­¤ò¤·¤Æ¡¢¤½¤Î·ë²Ì¤ò²èÁü¥Õ¥¡¥¤¥ë¤È¤·¤Æ¥µ¡¼¥Ð¡¼¤ËÊݸ¤¹¤ë¤³¤È¤ò¹Í¤¨¤ë¡£

ÊýË¡¤È¤·¤Æ¤Ï²¿¤âÌÜ¿·¤·¤¤¤â¤Î¤Ï¤Ê¤¯¡¢
canvas.toDataURL()¤ÇÆÀ¤é¤ì¤ë²èÁü(Base64¤Ç¥¨¥ó¥³¡¼¥É¤¬³Ý¤Ã¤Æ¤¤¤ë)¤ò
¥µ¡¼¥Ð¡¼¤ËÁ÷¤Ã¤Æ¡¢¥µ¡¼¥Ð¡¼Â¦¤Ç¥Ç¥³¡¼¥É¤·¤Æ.png¥Õ¥¡¥¤¥ë¤ËÍî¤È¤¹¤À¤±¤Ç¤¹¡£

Perl,PHP,ASP.NETÅù¡¢²¿¤ò»È¤Ã¤Æ¤â¼Â¸½²Äǽ¤Ç¤¹¤¬¡¢
³«È¯¼÷Ì¿¤Î¶á¤Å¤¤¤Æ¤¤¤ë¡¢.asmx¤ò»È¤Ã¤ÆWEB¥µ¡¼¥Ó¥¹¤Ç½èÍý¤·¤Æ¤ß¤Þ¤¹¡£
º£¤Ê¤éWCF¤Ç¤¹¤¬¡¢¥á¥ó¥ÆÅù¤Ç¤Ï¸«¤ëµ¡²ñ¤¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¤Î¤Ç¥á¥â¤È¤·¤Æ»Ä¤·¤Æ¤ª¤­¤Þ¤¹¡£

²¼µ­¤Ë¼¨¤¹ÊýË¡¤ò²¿¤È¸À¤¦¤Î¤«¤ï¤«¤ê¤Þ¤»¤ó¤¬¡¢microsoftajax.js¤ò»È¤Ã¤Æ¤¤¤ë¤Î¤Ç
¥Ö¥é¥¦¥¶¤Ï²¿¤Ç¤âÎɤ¯¡¢Client¦¤ÏMS¤Î¥ë¡¼¥ë¤ËÇû¤é¤ì¤º¤Ë
¡Ê¥µ¡¼¥Ð¡¼¤¬IIS¤Ç¤¢¤ë¤³¤È¤Ïɬ¿Ü¤Ç¤¹¤¬¡¢ASPÍѤÎÀë¸À¤äÄêµÁ¤È¤«¤ÏÉÔÍס¢¡Ë¡¢
¼«Í³¤Ê .html¤ä .js ¤òʤ٤뤳¤È¤¬¤Ç¤­¤Þ¤¹¡£
.asmx¤âBuild¤ÎɬÍפϤʤ¯¡¢¥½¡¼¥¹¤È¤·¤Æ¥¢¥Ã¥×¤Ç¤­¤ë¤Î¤Ç¡¢´Êñ¤Ë½¤Àµ¤Ç¤­¤Þ¤¹¡£

½ÐÎÏ¥Õ¥¡¥¤¥ë̾(ÁêÂХѥ¹)¤ò fname¡¢Base64¤Ç¥¨¥ó¥³¡¼¥É¤µ¤ì¤¿¥Ç¡¼¥¿
(ÀèƬ¤Î'data:image/png;base64,'¤Ïºï½üºÑ¤ß)¤ò datauri ¤È¤·¤Æ¡¢Âç³µ¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£

    [WebMethod]
    public void imgwrite(string fname, string datauri)
    {
        byte[] todecode_byte = null;
        try{
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decode = encoder.GetDecoder();

            todecode_byte = Convert.FromBase64String(datauri);

        }catch (Exception e){
            throw new Exception("Error in imgwrite:" + e.Message);
        }

        string filename = HttpContext.Current.Request.PhysicalApplicationPath + fname.Replace("/", "\\");
        FileStream fs = null;
        BinaryWriter bw = null;
        try{
            fs = new FileStream(filename, FileMode.Append, FileAccess.Write);
            bw = new BinaryWriter(fs);
            bw.Write(todecode_byte);

        }catch (Exception e){
            throw new Exception("Error in imgwrite:" + e.Message);
        }finally{
            if (bw != null) bw.Close();
            if (fs != null) fs.Close();
        }
    }

¤³¤ì¤À¤±¤À¤È¤Ä¤Þ¤é¤Ê¤¤¤Î¤Ç¡¢javascript¤Î¤ß¤Ç¥µ¡¼¥Ð¡¼Â¦¤Î¥Õ¥¡¥¤¥ëÁàºî¤ò²Äǽ¤Ë¤¹¤ë¥µ¡¼¥Ó¥¹½¸¹ç¤Ë¤·¤Þ¤¹¡£
¤Þ¤º¤Ï¡¢UploadService.asmx

<%@ WebService Language="C#" CodeBehind="UploadService.asmx.cs" Class="UploadService.UploadService" %>

³¤¤¤Æ¡¢UploadService.asmx.cs ¤Ç¤¹¡£

// (c) Copyright HUNDREDSOFT Corporation 2012
//	All Rights Reserved.
//
//	NAME
//		UploadService.asmx.cs
//
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Text;

namespace UploadService
{
    /// <summary>
    /// imgupload()
    /// imgwrite(fname, datauri)
    /// txtwrite(fname, cname, datatxt)
    /// download(fname, uri)
    /// filecopy(fname, src)
    /// filedelete(fname)
    /// filemove(fname, src)
    /// 
    /// [fname]
    /// ½ÐÎÏ¥Õ¥¡¥¤¥ë̾¡ÊÁêÂХѥ¹¡Ë
    /// 
    /// [uri]
    /// ÆþÎÏ¥Õ¥¡¥¤¥ë̾¡ÊURL¥¢¥É¥ì¥¹¡Ë
    /// 
    /// [src]
    /// ÆþÎÏ¥Õ¥¡¥¤¥ë̾¡ÊÁêÂХѥ¹¡Ë
    /// 
    /// [datauri]
    /// ²èÁü¥Ç¡¼¥¿¤òBase64¤Ç¥¨¥ó¥³¡¼¥É¤·¤¿Ê¸»úÎó
    /// 
    /// [cname]
    /// ½ÐÎÏʸ»ú¥¨¥ó¥³¡¼¥É(Îã)
    /// "shift_jis"
    /// "EUC-JP"
    /// "UNICODE"
    /// "UTF-8"
    /// 
    /// [datatxt]
    /// ʸ»úÎó
    /// 
    /// imgupload¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¸Æ¤Ó½Ð¤¹¡£
    ///  <form method='POST' enctype='multipart/form-data' action='UploadService.asmx/imgupload'>
    ///  <input type='text' name='filename'></input>
    ///  <input type='file' name='file'></input>
    ///  <input type='submit' value='imgupload'></input>
    ///  </form>
    /// 
    /// ¡ÊÃí¡Ëimgwrite,txtwrite¤Ç¤Ï¡¢100k¤òĶ¤¨¤ëʸ»úÎó¤Ï100k°Ê²¼¤Çʬ³ä¤·¤ÆÁ÷¿®¤¹¤ë¤³¤È
    /// 
    /// </summary>
    /// 
    [WebService(Namespace = "http://localhost/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    [ToolboxItem(false)]

    public class UploadService : System.Web.Services.WebService
    {
        // function imgupload
        // Multi-form¤ÇUpload¤µ¤ì¤¿¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë¤ò¥µ¡¼¥Ð¡¼¾å¤Ë½ñ¤­½Ð¤·¤Þ¤¹¡£
        //
        [WebMethod]
        public void imgupload()
        {
            FileStream fs = null;
            try{
                HttpFileCollection hfc = HttpContext.Current.Request.Files;

                if (hfc.Count > 0){
                    string fname = HttpContext.Current.Request.Form["filename"];
                    string filename = HttpContext.Current.Request.PhysicalApplicationPath + fname.Replace("/", "\\");

                    Stream his = hfc[0].InputStream;
                    byte[] bdata = new byte[his.Length];
                    his.Read(bdata, 0, (int)his.Length);

                    fs = new FileStream(filename, FileMode.Append, FileAccess.Write);
                    fs.Write(bdata, 0, bdata.Length);
                }

            }catch (Exception e){
                throw new Exception("Error in imgupload:" + e.Message);
            }finally{
                if (fs != null) fs.Close();
            }
        }

        // function imgwrite
        // Base64¤Ç¥¨¥ó¥³¡¼¥É¤µ¤ì¤¿¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë¤ò¥µ¡¼¥Ð¡¼¾å¤Ç¥Ç¥³¡¼¥É¤·¤Æ½ñ¤­½Ð¤·¤Þ¤¹¡£
        //
        [WebMethod]
        public void imgwrite(string fname, string datauri)
        {
            byte[] todecode_byte = null;
            try{
                System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
                System.Text.Decoder utf8Decode = encoder.GetDecoder();

                todecode_byte = Convert.FromBase64String(datauri);

            }catch (Exception e){
                throw new Exception("Error in imgwrite:" + e.Message);
            }

            string filename = HttpContext.Current.Request.PhysicalApplicationPath + fname.Replace("/", "\\");
            FileStream fs = null;
            BinaryWriter bw = null;
            try{
                fs = new FileStream(filename, FileMode.Append, FileAccess.Write);
                bw = new BinaryWriter(fs);
                bw.Write(todecode_byte);

            }catch (Exception e){
                throw new Exception("Error in imgwrite:" + e.Message);
            }finally{
                if (bw != null) bw.Close();
                if (fs != null) fs.Close();
            }
        }

        // function txtwrite
        // ¥µ¡¼¥Ð¡¼¾å¤Ë¡¢ÍÍ¡¹¤ÊÆüËܸ쥳¡¼¥É¤Ç¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤Ë½ÐÎϤ·¤Þ¤¹¡£
        //
        [WebMethod]
        public void txtwrite(String fname, String cname, String datatxt)
        {
            System.IO.StreamWriter sw = null;
            try{
                System.Text.Encoding enc = System.Text.Encoding.GetEncoding(cname);
                // BOM¤Ê¤·
                if (cname == "UTF-8"){
                    enc = new System.Text.UTF8Encoding(false);
                }else if (cname == "UNICODE"){
                    enc = new System.Text.UnicodeEncoding(false, false);
                }
                string filename = HttpContext.Current.Request.PhysicalApplicationPath + fname.Replace("/", "\\");
                sw = new System.IO.StreamWriter(filename, true, enc);
                sw.Write(datatxt);

            }catch (Exception e){
                throw new Exception("Error in txtwrite:" + e.Message);
            }finally{
                if (sw != null) sw.Close();
            }
        }

        // function download
        // URI¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤ò¡¢¥µ¡¼¥Ð¡¼¾å¤Ë¥À¥¦¥ó¥í¡¼¥É¤·¤Þ¤¹¡£
        //
        [WebMethod]
        public void download(string fname, string uri)
        {
            BinaryReader br = null;
            FileStream fs = null;
            BinaryWriter bw = null;
            try{
                WebClient wc = new WebClient();
                br = new BinaryReader(wc.OpenRead(uri));
                byte[] read_byte = null;
                int read_count = 0;

                string filename = HttpContext.Current.Request.PhysicalApplicationPath + fname.Replace("/", "\\");
                fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
                bw = new BinaryWriter(fs);

                do{
                    read_byte = br.ReadBytes(1024);
                    read_count = read_byte.Length;
                    bw.Write(read_byte);
                } while (read_count == 1024);

            }catch (Exception e){
                throw new Exception("Error in download:" + e.Message);
            }finally{
                if (br != null) br.Close();
                if (bw != null) bw.Close();
                if (fs != null) fs.Close();
            }
        }

        // function filecopy, filedelete, filemove
        // ¥µ¡¼¥Ð¡¼¾å¤Ç¥Õ¥¡¥¤¥ë¤ò¥³¥Ô¡¼¡¢ºï½ü¡¢°ÜÆ°¤·¤Þ¤¹¡£
        //
        [WebMethod]
        public void filecopy(string fname, string src)
        {
            try{
                string psrc = HttpContext.Current.Request.MapPath(src);
                string filename = HttpContext.Current.Request.PhysicalApplicationPath + fname.Replace("/", "\\");
                File.Copy(psrc, filename, true);

            }catch (Exception e){
                throw new Exception("Error in filecopy:" + e.Message);
            }
        }

        [WebMethod]
        public void filedelete(string fname)
        {
            try{
                string filename = HttpContext.Current.Request.PhysicalApplicationPath + fname.Replace("/", "\\");
                File.Delete(filename);

            }catch (Exception e){
                throw new Exception("Error in filedelete:" + e.Message);
            }
        }

        [WebMethod]
        public void filemove(string fname, string src)
        {
            try{
                string psrc = HttpContext.Current.Request.PhysicalApplicationPath + src.Replace("/", "\\");
                string filename = HttpContext.Current.Request.PhysicalApplicationPath + fname.Replace("/", "\\");
                File.Move(psrc, filename);

            }catch (Exception e){
                throw new Exception("Error in filemove:" + e.Message);
            }
        }

        // function getfilenames
        // ¥µ¡¼¥Ð¡¼¾å¤Î¥Õ¥¡¥¤¥ë°ìÍ÷¤ò¼èÆÀ¤·¤Þ¤¹¡£
        //
        [WebMethod]
        public string getfilenames(string src)
        {
            string ret = "";
            try{
                string psrc = HttpContext.Current.Request.PhysicalApplicationPath + src.Replace("/", "\\");
                ret = getdir(psrc, ret);

            }catch (Exception e){
                throw new Exception("Error in getfilenames:" + e.Message);
            }
            return ret;
        }

        private string getdir(string dir, string ret)
        {
            string[] files = Directory.GetFiles(dir);
            foreach (string s in files){
                ret += s + ",";
            }
            string[] dirs = Directory.GetDirectories(dir);
            foreach (string s in dirs){
                ret = getdir(s, ret);
            }
            char[] tc = {','};
            return ret.TrimEnd(tc);
        }
    }
}

ºÇ¸å¤Ë¥Æ¥¹¥ÈÍѤΠtest.html ¤Ç¤¹¡£¡Ê¥Æ¥¹¥ÈÍѤʤΤÇ,IE9(canvas¥µ¥Ý¡¼¥È)¤À¤±¤òÁª¤Ð¤Ê¤¤¡£¡Ë


<html>
<head>
<title>test UploadService.asmx</title>
<script type="text/javascript" src="microsoftajax.js" ></script>
<script type="text/javascript" src="uploadservice.asmx/js" ></script>
<script type="text/javascript">
function test_imgwrite()
{
	var data =
	'R0lGODlhIQAkAPcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
	'/wD//////yH+DEh1bmRyZWRzb2Z0AAAsAAAAACEAJAAACM0A/wkcSLCgwYMIEypcyLDhQn8QI0qcSHEiv4IQ+2' +
	'ncyLGjx40QLw7M2M+hQY0hCZI0WRClP5ECV7Ic6BLmP5kz/9VU6U9jToE7R/b8SJRoSqEVkyo9GnNo0acgX/L0' +
	'+TNoU6o5rd4c+lNnP6Zbsc7UinPsV6lCoao9a3Op24pt38oFG5EjSZd2nZK9ezav37xx574N/Bdv1I50+SrWy5' +
	'ctT8FuCR+ebDiq5Mp9Ke+FvPRyZswfEzMeDRXsVs5wDfJbzbq169euu8qefTAgADs=';

	UploadService.UploadService.imgwrite("save/b.gif", data, 
		function(){
			alert("OK");
		}, function(){
			alert("error");
		}
	);
}

function test_txtwrite()
{
	UploadService.UploadService.txtwrite("save/sjis.txt", "shift_jis", "abc¤¢¤¤¤¦¤¨¤ª0123456789",
		function(){}, function(){});

	UploadService.UploadService.txtwrite("save/UNICODE.txt", "UNICODE", "abc¤¢¤¤¤¦¤¨¤ª0123456789",
		function(){}, function(){});

	UploadService.UploadService.txtwrite("save/UTF-8.txt", "UTF-8", "abc¤¢¤¤¤¦¤¨¤ª0123456789",
		function(){}, function(){});
}

function test_download()
{
	UploadService.UploadService.download("save/a.gif", "http://www.hundredsoft.jp/hundredsoft.gif", 
		function(){
			alert("OK");
		}, function(){
			alert("error");
		}
	);
}

function test_filecopy()
{
	UploadService.UploadService.filecopy("save/b.gif", "save/a.gif", 
		function(){
			alert("OK");
		}, function(){
			alert("error");
		}
	);
}

function test_filedelete()
{
	UploadService.UploadService.filedelete("save/b.gif", 
		function(){
			alert("OK");
		}, function(){
			alert("error");
		}
	);
}

function test_filemove()
{
	UploadService.UploadService.filemove("save/b.gif", "save/a.gif", 
		function(){
			alert("OK");
		}, function(){
			alert("error");
		}
	);
}

function test_getfilenames()
{
	UploadService.UploadService.getfilenames("save",
		function(dirstr){
			//var dirs = dirstr.split(",");
			var dirs = dirstr.replace(/,/g, "\r\n");
			alert(dirs);
		}, function(){
			alert("error");
		}
	);
}
</script>
</head>
<body>
<h3>test UploadService.asmx</h3>
<hr />
 <input type="button" id="test01button" name="test01" value="test_imgwrite" onclick="test_imgwrite()"></input>
 <input type="button" id="test02button" name="test02" value="test_txtwrite" onclick="test_txtwrite()"></input>
 <input type="button" id="test03button" name="test03" value="test_download" onclick="test_download()"></input>
 <input type="button" id="test04button" name="test04" value="test_filecopy" onclick="test_filecopy()"></input>
 <input type="button" id="test05button" name="test05" value="test_filedelete" onclick="test_filedelete()"></input>
 <input type="button" id="test06button" name="test06" value="test_filemove" onclick="test_filemove()"></input>
 <input type="button" id="test07button" name="test07" value="test_getfilenames" onclick="test_getfilenames()"></input>
<br />
<hr />
test_imgupload<br />
<form method="POST" enctype="multipart/form-data" action="UploadService.asmx/imgupload" target="idmy">
Êݸ¥Ñ¥¹¡¡¡¡¡§ <input type="text" name="filename"></input><br />
²èÁü¥Õ¥¡¥¤¥ë¡§ <input type="file" name="file"></input>
 <input type="submit" value="imgupload"></input>
</form>
<hr />
<iframe name="idmy" width="0" height="0" style="visibility:hidden"></iframe>
</body>
</html>

¾åµ­¡¢¼Â¹Ô´Ä¶­¤ò¤Þ¤È¤á¤¿¤â¤Î¤òÃÖ¤­¤Þ¤¹¡£
.NET Framework V4.0¤¬Æþ¤Ã¤¿´Ä¶­¤Ê¤é¡¢App_Code¥Õ¥©¥ë¥À¤Ë¥½¡¼¥¹¤À¤±Æþ¤ì¤Æ¤ª¤±¤ÐÎɤ¤¤Î¤Ç¤¹¤¬¡¢
¤½¤ì°ÊÁ°¤Î´Ä¶­¤À¤È¡¢bin¥Õ¥©¥ë¥À¤Ë¥³¥ó¥Ñ¥¤¥ë¤·¤¿¤â¤Î¤òÆþ¤ì¤Ê¤¤¤È¡¢¤¦¤Þ¤¯Æ°¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£
¡¡¡¡ .NET V4.0°Ê¹ß (App_Code)
¡¡¡¡ .NET V3.5°ÊÁ° (bin)
°ã¤¤¤ÏBuildºÑ¤ß¤«¡¢¤½¤¦¤Ç¤Ê¤¤¤«¤À¤±¤Ç¤¹¤Î¤Ç¼Â¹Ô¤Ë°ã¤¤¤Ï¤¢¤ê¤Þ¤»¤ó¡£

¤µ¤Æ¡¢°ìÈÖÌäÂê¤Ë¤Ê¤ë´Ä¶­¹½ÃۤˤĤ¤¤ÆÀâÌÀ¤·¤Þ¤¹¤¬¡¢
ºî¶È¤·¤¿¤³¤È¤¬¤¢¤ë¿Í¤Ê¤é¡Ö¼á²à¤ËÀâË¡¡×¤Ê¤Î¤Ç¡¢°Ê¹ß¤ÏŬÅö¤ËÆɤßÈô¤Ð¤·¤Æ¤¯¤À¤µ¤¤¡£




Tags: ¥×¥í¥°¥é¥à¥á¥â
³¤­¤òÆɤà¡ä¡ä
author : HUNDREDSOFT | - | -

x64¤Ç¤â³ÈÄ¥ÇÜÀºÅÙ¤ò»È¤¤¤¿¤¤

x64¤Ç¤ÏºÇÄã¤Ç¤âSSE2¤Þ¤Ç»È¤¨¤ë¤Î¤Ç¡¢º£¹¹FPU¤ò»È¤¦¤³¤È¤Ï¤¢¤Þ¤ê¤¢¤ê¤Þ¤»¤ó¡£

¤â¤·¡¢ÇÜÀºÅÙ(²¾¿ôÉô53bit)¤Ç¤âÀºÅÙ¤¬Â­¤ê¤Ê¤¤¾ì¹ç¡¢
SSE2¤ò»È¤Ã¤Æ£´ÇÜÀºÅÙÉâÆ°¾®¿ôÅÀ¥é¥¤¥Ö¥é¥ê¤òÁȤफ¡¢
£´ÇÜÀºÅÙ¤ËÂбþ¤·¤¿ x64¸þ¤±¤Î¥³¥ó¥Ñ¥¤¥é¤òÍÑ°Õ¤¹¤ë¤Î¤¬ÉáÄ̤Ǥ·¤ç¤¦¡£

¤·¤«¤·¡¢·×»»Â®ÅÙ¤òÍ׵ᤵ¤ì¤ë¤è¤¦¤Ê¥±¡¼¥¹¤Ç¡¢¤â¤·64bitÀºÅ٤ǭ¤ê¤ë¤Ê¤é¡¢
FPU¤Ë¤è¤ë³ÈÄ¥ÇÜÀºÅÙ(²¾¿ôÉô64bit)¤È¤¤¤¦ÁªÂò»è¤â¤¢¤ê¤Þ¤¹¡£
¡ÊÎ㤨¤Ð10¿Ê¤Ç¡¢¤¢¤È1·å¤À¤±ÀºÅÙ¤¬Íߤ·¤¤¾ì¹ç¤Ë¥³¥ó¥Ñ¥¤¥é¤Þ¤ÇÊѤ¨¤Ê¤¤¤Ç¤¹¤è¤Í¡Ë

°ÊÁ°¤Ëx86ÍѤγÈÄ¥ÇÜÀºÅÙ¥¯¥é¥¹¤ò½ñ¤­¤Þ¤·¤¿¤¬¡¢
º£ÅÙ¤Ïx64ÍѤΥµ¥ó¥×¥ë¥³¡¼¥É¡£

x64¤Ç¤Ï¡¢¥¤¥ó¥é¥¤¥ó¥¢¥»¥ó¥Ö¥é¤¬»È¤¨¤Ê¤¤¤Î¤Ç¡¢ÁȤ߹þ¤ß´Ø¿ô(Compiler Intrinsics)¤ò»È¤¦¤«¡¢
MASM ( ml64.exe ) ¤ò»È¤Ã¤Æ¥¢¥»¥ó¥Ö¥ê¤ò¥³¡¼¥Ç¥£¥ó¥°¤¹¤ë¤«¤ÎÁªÂò¤Ë¤Ê¤ê¤Þ¤¹¤¬¡¢
FPU¤ò»È¤¦¤Î¤Ç¡¢ml64ÍѤÎ.asm¥Õ¥¡¥¤¥ë¤òºî¤ë¤³¤È¤Ë¤·¤Þ¤¹¡£
¥¿¡¼¥²¥Ã¥È¤Ï¡¢x64 ¤ÎWindows¤Ç Visual Studio ¤Ç³«È¯¤·¤Æ¤¤¤ë¤â¤Î¤È¤·¤Þ¤¹¡£
¾¤Î¥³¥ó¥Ñ¥¤¥é¤À¤È¸Æ¤Ó½Ð¤·µ¬Ìó( MS¤ÎFastCall )¤¬°Û¤Ê¤ë¤³¤È¤¬¤¢¤ë¤Î¤ÇÃí°Õ¡£

double ¤ò¥ª¡¼¥Ð¡¼¥é¥Ã¥×¤¹¤ë¤è¤¦¤Ê Ldouble ¥¯¥é¥¹¤òºî¤ë»ö¤Ë¤·¤Þ¤¹¡£
¥á¥ó¥Ð¤È¤·¤Æ¡¢³ÈÄ¥ÇÜÀºÅ٤Υǡ¼¥¿¤ò£±¤Ä»ý¤Á¤Þ¤¹¡£
ɬÍ×¤Ê¤Î¤Ï 10¥Ð¥¤¥È¤Ç¤¹¤¬¡¢ÀÚ¤ê¤ÎÎɤ¤¤È¤³¤í¤Ç 16¥Ð¥¤¥È¼è¤Ã¤Æ¤¤¤Þ¤¹¡£

¤Þ¤º¡¢¥Ø¥Ã¥À¡¼¥Õ¥¡¥¤¥ë¡ÖLdouble.h¡×¤Ç¤¹¡£
´ðËÜŪ¤Ê±é»»¤ò¥¯¥é¥¹¤ËÆþ¤ì¤Æ¡¢»°³Ñ´Ø¿ô,»Ø¿ô´Ø¿ôÅù¤ò³°Éô´Ø¿ô¤È¤·¤Æ¸Æ¤Ó½Ð¤»¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£



¥¢¥»¥ó¥Ö¥ê¤ÇºîÀ®¤¹¤ë¤Î¤Ï¡¢extern "C"¤Î´Ø¿ô·²¤Ç¤¹¡£
¤³¤ì¤¬¡ÖLdouble.asm¡×¤Ç¤¹¡£



ºÇ¸å¤Ë¡¢Ldouble¥¯¥é¥¹¤ò»È¤Ã¤¿¥µ¥ó¥×¥ë¥³¡¼¥É¡Ömain.cpp¡×¤Ç¤¹¡£




VS2010¤ÇBuild¤¹¤ëºÝ¤Ï¡¢¿·µ¬¥×¥í¥¸¥§¥¯¥È(VisualC++,Win32,Win32¥³¥ó¥½¡¼¥ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó,¶õ¤Î¥×¥í¥¸¥§¥¯¥È)¤Ç¡¢
¥½¡¼¥¹( Ldouble.asm, Ldouble.h, main.cpp )¤òÄɲ䷤ơ¢
¹½À®¥Þ¥Í¡¼¥¸¥ã¡¼¤Ç¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¤òx64¤Ë¤·¤Þ¤¹¡£
¿·µ¬¤Çx64¤¬Áª¤Ù¤Ê¤¤¾ì¹ç¤Ï¡¢VC++2010¤Î64bitÂбþ¤Î¥¤¥ó¥¹¥È¡¼¥ë¤¬Â­¤ê¤Ê¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¡£
¤½¤Î¾ì¹ç¤Ï¡¢ml64.exe¤âÆþ¤Ã¤Æ¤Ê¤¤¤«¤â¤·¤ì¤Ê¤¤¤Î¤Ç³Îǧ¤·¤Æ²¼¤µ¤¤¡£

³¤¤¤Æ¡¢¥½¥ê¥å¡¼¥·¥ç¥ó¥¨¥¯¥¹¥×¥í¡¼¥é¤Î Ldouble.asm ¤ò±¦¥¯¥ê¥Ã¥¯¤·¤Æ¡¢¥×¥í¥Ñ¥Æ¥£¡£
¹½À®¥×¥í¥Ñ¥Æ¥£¡¦Á´È̤ǹàÌܤμïÎࢪ¥«¥¹¥¿¥à¥Ó¥ë¥É¥Ä¡¼¥ë¤ËÊѹ¹¤·¤Æ²¼¤µ¤¤¡£

Á´È̤β¼¤Ë½Ð¤Æ¤¯¤ë¥«¥¹¥¿¥à¥Ó¥ë¥É¥Ä¡¼¥ë¤Î¥³¥Þ¥ó¥É¥é¥¤¥óÍó¤Ë¡¢
ml64.exe /DWIN_X64 /Zi /c /Cp /Fl /Fo$(IntDir)\$(InputName).obj Ldouble.asm
½ÐÎÏ¥Õ¥¡¥¤¥ëÍó¤Ë
$(IntDir)\$(InputName).obj
¤ò»ØÄꤷ¤Æ²¼¤µ¤¤¡£

¤³¤ì¤Ç Build ¤¬Ä̤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£

Îã³°¤Ï¹Í¤¨¤Æ¤¤¤Þ¤»¤ó¡£¤´ÍøÍѤκݤˤÏFPUÀ©¸æ¥ï¡¼¥É¤òŬµ¹ÀßÄꤷ¤Æ²¼¤µ¤¤¡£
(Ldouble.asm¤Îdeffcw¤òÊѤ¨¤Æ²¼¤µ¤¤¡£)
(»²¹Í) FPUÀ©¸æ¥ï¡¼¥É¤Ë¤Ä¤¤¤Æ

 MSB
  F  E  D  C  B  A  9  8  7  6  5  4  3  2  1  0
 +-----------+-----+-----+-----+----------------+
      NC      ´Ý¤á  ÀºÅÙ   NC      Îã³°¥Þ¥¹¥¯
 +-----------+-----+-----+-----+----------------+

  Îã³°¥Þ¥¹¥¯ bit5¡Á0
   0:̵¸úÁàºîÎã³°
   1:¥Ç¥Î¡¼¥Þ¥ëÎã³°
   2:Îí½ü»»Îã³°
   3:¥ª¡¼¥Ð¡¼¥Õ¥í¡¼Îã³°
   4:¥¢¥ó¥À¡¼¥Õ¥í¡¼Îã³°
   5:ÉÔÀµ³Î·ë²ÌÎã³°

  ÀºÅÙ bit9,8
   00: 24bit(ñÀºÅÙ)
   01: reserved
   10: 53bit(ÇÜÀºÅÙ)
   11: 64bit(³ÈÄ¥ÇÜÀºÅÙ)

  ´Ý¤á bit11,10
   00: ºÇ¶áÃ͡ʻͼθÞÆþ¤Ë¶á¤¤¡Ë
   01: ÀÚ¤ê¼Î¤Æ(floor)
   10: ÀÚ¤ê¾å¤²(ceil)
   11: ÎíÊý¸þÀÚ¤ê¼Î¤Æ



Ldouble¤Ø¤ÎÆþÎϤϡ¢double ¤«À°¿ô¤Ç¤¹¡£
½ÐÎÏ¤Ï double·¿ ¤À¤±¤Ç¤¹¡£¤³¤ì¤Ï¡¢double ¤Ø¤Î¥­¥ã¥¹¥È¤È¤·¤Æ¼Â¸½¤µ¤ì¤Þ¤¹¡£
¤â¤Á¤í¤ó¡¢Ldouble¤«¤éLdouble¤Ø¤Î¥³¥Ô¡¼¤ÇÀºÅÙ¤¬Íî¤Á¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£

Ldouble¤Ï¡¢64bitÀºÅÙ¤òÊÝ»ý¤·¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢
Ldouble¤ò»È¤Ã¤¿±é»»Ãæ¤Ï¾ï¤Ë64bitÀºÅÙ¤òÊݤÁ¤Þ¤¹¡£
½ÐÎÏ(¥­¥ã¥¹¥È) ¤Ï double(53bit) ÀºÅ٤˴ݤ᤿ÃͤòÊÖ¤·¤Þ¤¹¤¬¡¢
Ldouble ¤¬»ý¤Ã¤Æ¤¤¤ëÃͤ¬ 53bit ¤Ë´Ý¤á¤é¤ì¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£

¤³¤ÎÊýË¡¤Ï¤È¤Æ¤â¤¦¤Þ¤¯ÌäÂê¤ò²ò·è¤·¤Æ¤¯¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
·×»»ÀºÅ٥ܥȥà¤Î°ìÉô¤À¤±¤òLdouble¤Ë¤è¤ë¹âÀºÅÙ·×»»¤ËÃÖ¤­´¹¤¨¤Æ¡¢
¤½¤Î¸å¥­¥ã¥¹¥È¤¹¤ë¤À¤±¤Ç¡¢º£¤Þ¤Ç¤Î·×»»¥ë¡¼¥Á¥ó¤ËÌ᤻¤Þ¤¹¡£
Î㤨¤Ð¡¢£±¤Ä¤Î double·¿¤Î¥¹¥¿¥Ã¥¯ÊÑ¿ô¤ò Ldouble ¤Ë¤·¤¿¤À¤±(1ʸ»ú½¤Àµ)¤ÇÌäÂ꤬²ò·è¤¹¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
¤È¤Æ¤â¼«Á³¤ËÁȤ߹þ¤á¤ë¤Î¤ÏÎɤ¤¤Î¤Ç¤¹¤¬¡¢¥³¡¼¥É¤ò°ì¸«¤·¤¿¤À¤±¤À¤ÈÊѲ½¡Ê±Æ¶Á¡Ë¤¬¤ï¤«¤ê¤Ë¤¯¤¤¤Î¤Ç¡¢
¥³¥á¥ó¥È¤ÏÃúÇ«¤Ë½ñ¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£



¤µ¤Æ¡¢Build¸å¤Ë¤Ç¤­¤¿exe¤ò¼Â¹Ô¤¹¤ë¤È¼¡¤Î·ë²Ì¤¬ÆÀ¤é¤ì¤Þ¤·¤¿¡£

as:= 1.0000000000000000e+001
bs=: 1.2300000000000000e+002

+  : 1.3300000000000000e+002: 1.3300000000000000e+002
-  : -1.1300000000000000e+002: -1.1300000000000000e+002
abs: 1.1300000000000000e+002: 1.1300000000000000e+002
if : -1.1300000000000000e+002: -1.1300000000000000e+002
*  : 1.2300000000000000e+003: 1.2300000000000000e+003
/  : 1.2300000000000001e+001: 1.2300000000000001e+001
%  : 3.0000000000000000e+000: 3.0000000000000000e+000
pi : 3.1415926535897931e+000: 3.1415926535897931e+000
sin: 4.9999999999999994e-001: 5.0000000000000000e-001
cos: 8.6602540378443871e-001: 8.6602540378443860e-001
sin: 4.9999999999999994e-001: 5.0000000000000000e-001
cos: 8.6602540378443871e-001: 8.6602540378443860e-001
tan: 5.7735026918962573e-001: 5.7735026918962573e-001
ata: 4.8234790710102493e-001: 4.8234790710102499e-001
at2: 9.8279372324732905e-001: 9.8279372324732905e-001
sqr: 1.4142135623730951e+000: 1.4142135623730951e+000
exp: 1.6439050426651380e+005: 1.6439050426651380e+005
ln : 1.2010000000000000e+001: 1.2010000000000000e+001
pow: 3.3234387002712369e+000: 3.3234387002712369e+000
int: 3.0000000000000000e+000: 3.0000000000000000e+000
dec: 3.2343870027123689e-001: 3.2343870027123672e-001

Machin's pi: 3.1415926535897936e+000: 3.1415926535897931e+000
Leibniz's pi(5000000¹à¤Ç¤Î¿¿ÃÍ): 3.1415924535897932384646433832795
Leibniz's pi(5000000)  double(3.1415924535897797e+000) time = 0.036[sec]
Leibniz's pi(5000000) Ldouble(3.1415924535897930e+000) time = 0.073[sec]

ºÇ¸å¤ÎLeibniz's pi¤ò½ü¤¤¤Æ¤Ï¡¢´ðËܱ黻¤Î³Îǧ¤Ç¤¹¡£
º¸Â¦¤¬double±é»»¤Ë¤è¤ë·ë²Ì¤Ç¡¢±¦Â¦¤¬Ldouble(FPU)¤Ë¤è¤ë·ë²Ì¤Ç¤¹¡£
Leibniz's pi¤Ï¥é¥¤¥×¥Ë¥Ã¥Ä¤Î¸ø¼°¤Ë¤è¤ë¦Ð¤Î·×»»¤Ç¤¹¤¬¡¢
¤ï¤¶¤È±é»»Î̤òÁý¤ä¤·¤Æ¡¢½èÍý»þ´Ö¤òÈæ³Ó¤·¤Æ¤¤¤Þ¤¹¡£
5,000,000¹à¤ÇÂǤÁÀڤäơ¢±é»»·ë²Ì¤È±é»»¤ËÍפ·¤¿»þ´Ö¤òɽ¼¨¤·¤Þ¤¹¡£

±é»»»þ´Ö¤Ë´Ø¤·¤Æ¤Ï¡¢double±é»»¤Î¤ª¤è¤½Çܤλþ´Ö¤¬³Ý¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢
double±é»»¤Ç¤ÏÎßÀÑ¸íº¹¤Ë¤è¤ê 14 ·å¤ÎÀºÅÙ¤·¤«¤¢¤ê¤Þ¤»¤ó¤¬¡¢FPU¤Ç¤Ï 16 ·å¤ÎÀºÅÙ¤¬¤¢¤ê¤Þ¤¹¡£
»°³Ñ´Ø¿ô¤Ê¤É¤ò»È¤¦¤È¡¢FPU¤ÎÊý¤¬10Çܤ¯¤é¤¤½èÍý»þ´Ö¤¬³Ý¤ë¤³¤È¤â¤¢¤ê¤Þ¤¹¡£
double¤ËÈæ¤Ù¤Æ¡¢11 bit¿¤¯¤ÎÀºÅÙ¤ò½Ð¤¹¤¿¤á½èÍý»þ´Ö¤¬³Ý¤«¤ë¤è¤¦¤Ç¤¹¡£
¤·¤«¤·½ü»»¤Ë¤Ä¤¤¤Æ¤Ï¡¢double±é»»¤ÈFPU¤Ç½èÍý»þ´Ö¤ÏƱÅù¤Ç¤·¤¿¡£

µÕ¥¢¥»¥ó¥Ö¥é¤ò¸«¤Æ¤ß¤ë¤È¡¢double±é»»¤Ç¤ÏSSE2¤¬»È¤ï¤ì¤Æ¤¤¤Þ¤¹¤¬ÊÂÎ󲽤ޤǤϹԤï¤ì¤Æ¤¤¤Þ¤»¤ó¡£
¤¦¤Þ¤¯ÊÂÎ󲽡ʺÇŬ²½¡Ë¤Ç¤­¤ì¤Ð¡¢double±é»»¤Ï¤â¤¦¾¯¤·Á᤯¤Ê¤ê¤Þ¤¹¡£
(Release-Build¤Ç¤Ïdouble±é»»Â¦¤Ë¿¾¯¤Î¥Ù¥¯¥È¥ë²½¤¬¹Ô¤ï¤ì¤Æ¤¤¤Þ¤·¤¿¡£)

Àµ³Î¤µ¤È½èÍý»þ´Ö¤Î¥È¥ì¡¼¥É¥ª¥Õ¤Ç¤¹¤Î¤Ç¡¢¤É¤Á¤é¤¬Îɤ¤¤È¤¤¤¦¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
ÌÜŪ¤Ë¨¤·¤¿²ò·èºö¤¬¸«¤Ä¤±¤é¤ì¤Ê¤±¤ì¤Ð¡¢¤³¤Î¤è¤¦¤ÊÊýË¡¤â¤¢¤ê¤«¤È»×¤¤¤Þ¤¹¡£

¾åµ­¡¢·ÇºÜ¥½¡¼¥¹¤ò°µ½Ì¤·¤¿¤â¤Î¤ò¤³¤³¤ËÃÖ¤¤¤Æ¤ª¤­¤Þ¤¹¡£



Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

¦Ð¤ÎBBP·×»»¤Ç¥â¥ó¥´¥á¥ê¤ò»È¤¦

¸½ºß¤Ç¤Ï10Ãû·å¤òĶ¤¨¤ë¦Ð¤¬µá¤á¤é¤ì¤Æ¤¤¤ë¤¬¡¢¦Ð¤ÎÆÃÄê¤Î·å¤À¤±¤ò»»½Ð¤¹¤ëÊýË¡¤¬ÃΤé¤ì¤Æ¤¤¤Æ¡¢
¦Ð¤ÎÉôʬ»»½Ð¤Îµ­Ï¿¤Ç¤Ï500Ãû·å¤òĶ¤¨¤Æ¤¤¤ë¡£

¤³¤ÎÉôʬ»»½Ð¤Î¸µ¤Ë¤Ê¤Ã¤¿¤Î¤¬¡¢¼¡¤Î¸ø¼°¤Ç¤¹¡£


¤³¤Î¼°¤«¤éd·åÌܤòµá¤á¤ë¤¿¤á¤Ë¡¢16^d¤ò¾è¤¸¤Æ¡¢¾®¿ôÅÀ°Ê²¼¤ò¼è¤ê¤À¤¹¤³¤È¤ò¹Í¤¨¤ë¡£


¤³¤³¤ÇS¤ò¼¡¤Î¤è¤¦¤ËÄêµÁ¤¹¤ë¡£

¤¹¤ë¤È


¤³¤ì¤¬1995ǯ¤ËSimon Plouffe(¥×¥é¥¦¥Õ)¤Ë¤è¤êȯ¸«¤µ¤ì¤¿¡¢BBP(Bailey-Borwein-Plouffe)¸ø¼°¤È¸Æ¤Ð¤ì¤ë¤â¤Î¤Ç¡¢
¤³¤ì¤ò¥×¥í¥°¥é¥à¤·¤¿¤â¤Î¤¬¡¢
http://www.experimentalmath.info/bbp-codes/ ¤Ë¤¢¤ê¤Þ¤¹¡£(piqpr8.c)
¤³¤³¤Ç¤Ï±¦¸þ¤­¥Ð¥¤¥Ê¥êË¡¤ò»È¤Ã¤Æ¾ê;(mod)¤òµá¤á¤Æ¤¤¤ë¤¬¡¢¾ê;·×»»¤Ë¥â¥ó¥´¥á¥êË¡¤ò»È¤¦¤³¤È¤ò¹Í¤¨¤ë¡£

¥â¥ó¥´¥á¥êË¡¤Ë¤Ä¤¤¤Æ¤Ï²áµî¤Ë¤â
http://www.hundredsoft.jp/win7blog/log/eid93.html ¤ä
http://www.hundredsoft.jp/win7blog/log/eid98.html ¤Ç¥µ¥ó¥×¥ë¤òºÜ¤»¤Æ¤¤¤Þ¤¹¤¬¡¢
¹â®¤Ê¥â¥ó¥´¥á¥êË¡¤Ç¤Ï¡¢Ë¡¤Ï´ñ¿ô¤Ç¤¢¤ë¤³¤È¤¬Ë¾¤Þ¤·¤¤¡£

S1,S5¤ÎË¡¤Ï¡¢8k+1,8k+5¤Ç¤¢¤ë¤Î¤Ç´ñ¿ô¤Ç¤¢¤ë¤¬¡¢
S4,S6¤Ï¶ö¿ô¤È¤Ê¤ë¤Î¤Ç¡¢¤³¤Î¤Þ¤Þ¤Ç¤Ï»È¤¨¤Ê¤¤

À°¿ôÏÀ¤ÎÄêÍý¤ÎÃæ¤Ë¼¡¤Î¤â¤Î¤¬¤¢¤ë¡£
¤Ê¤é¤Ð

¤¬À®¤êΩ¤Ä¡£

¤³¤ì¤òS4¤ÎÂè°ì¹à¤ËÅö¤Æ¤Ï¤á¤ë¤È¡¢

¤Ç¤¢¤ë¤«¤é¡¢


ƱÍͤËS6¤ÎÂè°ì¹à¤Ï¡¢


¤³¤ì¤ÇË¡¤¬´ñ¿ô¤È¤Ê¤ê¡¢¹â®¤Ê¥â¥ó¥´¥á¥êË¡¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
¥×¥í¥°¥é¥à¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£ (default¤Ç¤Ï¦Ð¤Î100Ëü·å(Hex)Ìܤò»»½Ð¤¹¤ë¡£)


#include <stdio.h>
#include <math.h>
#include <time.h>

int expmong (int p, int ak);

int main()
{
  double pid, s1, s2, s3, s4;
  double series (int m, int n);
  void ihex (double x, int m, char c[]);
  int id = 1000000;
#define NHX 16
  char chx[NHX];

  clock_t start,end;

/*  id is the digit position.  Digits generated follow immediately after id. */
  start = clock();

  s1 = series (1, id);
  s2 = series (4, id);
  s3 = series (5, id);
  s4 = series (6, id);
  pid = 4. * s1 - 2. * s2 - s3 - s4;
  pid = pid - (int) pid + 1.;
  ihex (pid, NHX, chx);

  end = clock();
  printf (" position = %i\n fraction = %.15f \n hex digits =  %10.10s\n time = %.3f[sec]",
  id, pid, chx, (double)(end-start)/CLOCKS_PER_SEC);

  return 0;
}

void ihex (double x, int nhx, char chx[])

/*  This returns, in chx, the first nhx hex digits of the fraction of x. */

{
  int i;
  double y;
  char hx[] = "0123456789ABCDEF";

  y = fabs (x);

  for (i = 0; i < nhx; i++){
    y = 16. * (y - floor (y));
    chx[i] = hx[(int) y];
  }
}

#define eps 1e-17

double series (int m, int id)

/*  This routine evaluates the series  sum_k 16^(id-k)/(8*k+m) 
    using the modular exponentiation technique. */

{
  int k, ak, p;
  double s, t;

  s = 0.;

/*  Sum the series up to id. */

  if (m == 4){
    for (k = 0; k < id; k++){
      ak = 2 * k + 1;
      p = expmong (id - k - 1, ak);
      t = (p * (4 % ak)) % ak;
      s = s + t / ak;
      s = s - (int) s;
    }
  }else if (m == 6){
    for (k = 0; k < id; k++){
      ak = 4 * k + 3;
      p = expmong (id - k - 1, ak);
      t = (p * (8 % ak)) % ak;
      s = s + t / ak;
      s = s - (int) s;
    }
  }else{
    for (k = 0; k < id; k++){
      ak = 8 * k + m;
      t = expmong (id - k, ak);
      s = s + t / ak;
      s = s - (int) s;
    }
  }

/*  Compute a few terms where k >= id. */

  for (k = id; k <= id + 100; k++){
    ak = 8 * k + m;
    t = pow (16., (double) (id - k)) / ak;
    if (t < eps) break;
    s = s + t;
    s = s - (int) s;
  }
  return s;
}

// t¤Î¥â¥ó¥´¥á¥ê¥ê¥À¥¯¥·¥ç¥ó
int reduction(__int64 t, int n, int n2, int nb)
{
  static int masktbl[] = {
      0,
      0x00000001,0x00000003,0x00000007,0x0000000f,0x0000001f,0x0000003f,0x0000007f,0x000000ff,
      0x000001ff,0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,0x00007fff,0x0000ffff,
      0x0001ffff,0x0003ffff,0x0007ffff,0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff,
      0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff,0x3fffffff,0x7fffffff,0xffffffff,
  };
  __int64 c = t * n2;
  c &= masktbl[nb];    // mod R¤Î°ÕÌ£,(nb)bit°Ê¾å¤ò0¥¯¥ê¥¢
  c = c * n + t;
  c >>= nb;            // 1/r ¤Î°ÕÌ£
  if (c >= n) c -= n;
  return c;
}

// ¥â¥ó¥´¥á¥êÑѾê;·×»»
int expmong (int p, int ak)
{
/*  expm = 16^p mod ak. */

  int nb = 0;          // Í­¸úBit¿ô
  int r;               // r: n¤è¤êÂ礭¤Ê£²¤Î¤Ù¤­
  for (nb=0, r=1; r<ak; nb++, r<<=1) ;

  // r2 = r^2 mod ak
  int r2 = ((__int64)r * r) % ak;

  // n*n2 ¢á -1 mod r
  int n2 = 0; /* µá¤á¤ëN' */
  {
    int t=0, vi=1, ni=nb;
    while (ni--){
      if ((t & 1) == 0){
        t += ak;
        n2 += vi;
      }
      t >>= 1;
      vi <<= 1;
    }
  }

  // ÑѾê; 16^p mod ak, ¥Ð¥¤¥Ê¥êË¡¤Î²¼°Ì·å¤«¤é·×»»
  int q = reduction(16 * r2, ak, n2, nb);
  int x = reduction(r2, ak, n2, nb);
  while (p > 0){
    if (p & 1){
      x = reduction((__int64)x * q, ak, n2, nb);
    }
    q = reduction((__int64)q * q, ak, n2, nb);
    p >>= 1;
  }
  return reduction(x, ak, n2, nb);
}

²þÊѤϡ¢series() ¤Îm=4,m=6¤Î½èÍý¤Èexpm()¢ªexpmong()¤Ç¤¹¡£

intel·Ïx86¥³¡¼¥É¤Ç¤Î64bitÀ°¿ô±é»»¤ÏÁ᤯¤Ê¤¤¤Î¤Ç¡¢ÌÌÇò¤¤·ë²Ì¤¬½Ð¤Þ¤·¤¿¡£

BBP·×»»Â®Å٥ƥ¹¥È (x86ÍÑ,x64ÍÑ¥¿¡¼¥²¥Ã¥È¤òÊѤ¨¤ÆBuild¤·¤Æ¤¤¤ë)


¡Ú±¦¸þ¤­¥Ð¥¤¥Ê¥êË¡(WindowsXP 32bit)¡Û
(1²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 2.763[sec]
(2²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 2.804[sec]
(3²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 2.763[sec]

¡Ú¥â¥ó¥´¥á¥êË¡(WindowsXP 32bit)¡Û
(1²óÌÜ)
position = 1000000
fraction = 0.423429797567801
hex digits = 6C65E52CB4
time = 3.114[sec]
(2²óÌÜ)
position = 1000000
fraction = 0.423429797567801
hex digits = 6C65E52CB4
time = 3.134[sec]
(3²óÌÜ)
position = 1000000
fraction = 0.423429797567801
hex digits = 6C65E52CB4
time = 3.204[sec]

¡Ú·ë²Ì¡Û
¤ª¤è¤½15%¡¢¥â¥ó¥´¥á¥êË¡¤¬»þ´Ö¤¬³Ý¤ë


¡Ú±¦¸þ¤­¥Ð¥¤¥Ê¥êË¡(Windows7 64bit)¡Û
(1²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 1.788[sec]
(2²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 1.801[sec]
(3²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 1.786[sec]

¡Ú¥â¥ó¥´¥á¥êË¡(Windows7 64bit)¡Û
(1²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 1.255[sec]
(2²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 1.258[sec]
(3²óÌÜ)
position = 1000000
fraction = 0.423429797567895
hex digits = 6C65E52CB4
time = 1.223[sec]

¡Ú·ë²Ì¡Û
¤ª¤è¤½30%¡¢¥â¥ó¥´¥á¥êË¡¤¬Áᤤ


VC2010¤ÇBuild¤·¤¿¸Â¤ê¤Ç¤Ï¡¢
32bit¤Ç¤Ï¥Ð¥¤¥Ê¥êË¡¤ÎÊý¤¬Á᤯¡¢64bit¤Ç¤Ï¥â¥ó¥´¥á¥êË¡¤ÎÊý¤¬Á᤯¤Ê¤ê¤Þ¤·¤¿¡£

¥Ð¥¤¥Ê¥êË¡¤Î¥³¡¼¥É¤âÀ°¿ô±é»»²½¤·¤Æ¤ß¤¿¤Î¤Ç¤¹¤¬¡¢
ÉôʬŪ¤Ê¥³¡¼¥ÉÊѹ¹¤À¤È¡¢¤«¤¨¤Ã¤ÆÀ®ÀÓ¤¬°­¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤·¤¿¡£
¥Ð¥¤¥Ê¥êË¡¤Î¥³¥ó¥Ñ¥¤¥é¥ª¥×¥·¥ç¥ó¤ÇSSE2¤òÍ­¸ú¤Ë¤·¤Æ¤ß¤Æ¤â¤¢¤Þ¤ê¸ú²Ì¤Ï¤Ê¤«¤Ã¤¿¤Î¤Ç¤¹¤¬¡¢
Intel¥³¥ó¥Ñ¥¤¥é¤ò»È¤¦¤È¡¢¤â¤¦¾¯¤·Á᤯¤Ê¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£

¤³¤Î¥³¡¼¥É¤Ç¤â¡¢£²¡Á£³ÀéËü·å¤Þ¤Ç¤Ï·×»»¤Ç¤­¤Þ¤¹¤¬¡¢
expmong()¤ÎÊÑ¿ô r2 ¤È series()¤ÎÊÑ¿ô p ¤Î·¿¤ò__int64¤Ë¤¹¤ì¤Ð¡¢£±²¯·å¤Þ¤Ç·×»»¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
⤷¡¢x86(32bit)¤À¤È64bitÀ°¿ô±é»»¤¬Áý¤¨¤ë¤È¤½¤ì¤À¤±½èÍý¤¬ÃÙ¤¯¤Ê¤ê¤Þ¤¹¡£
x64¤Ç£±²¯·å¤Î·×»»¤Ï¡¢»ä¤ÎPC¤Ç¤Ï150ÉäۤɤǤ·¤¿¡£
³ÈÄ¥ÇÜÀºÅÙ(²¾¿ôÉô64bit)¤ÈĹÀ°¿ô(80bitÄøÅÙ)¤òÁȤ߹ç¤ï¤»¤ì¤Ð¡¢¤³¤Î¥¢¥ë¥´¥ê¥º¥à¤Ç¤â100²¯·å¤°¤é¤¤¤Ï¹Ô¤±¤ë¤È»×¤¤¤Þ¤¹¤¬¡¢¤³¤ì¤À¤±¤Î·×»»Î̤ˤʤë¤ÈÉáÄ̤ÎPC¤Ç¤ÏÆñ¤·¤¤¤Ç¤¹¡£¡ÊÅŵ¤Âå¤â¾å¤¬¤ë¤·...¡Ë




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

¿ÇÜĹÀ°¿ô¤ÇStein¤ÎGCD¤ò»È¤¦

¼¡¤Î¤è¤¦¤Ê¡¢32bit·Ï¤Î¿ÇÜĹÀ°¿ô¥¯¥é¥¹¤¬¤¢¤Ã¤¿¤È¤·¤Æ¡¢


class Bigint
{
public:
	Bigint();
	...
	... ÍÍ¡¹¤ÊÄêµÁ(»Í§±é»»¡¢operator=,operator<<=Åù)
	...
private:
	int   m_sz;   // ÇÛÎó¿ô
	int*  m_num;  // ÇÛÎó(¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó)
};

16¿Ê¤Ç¼¡¤Î¤è¤¦¤Ëɽ¤»¤ëÀ°¿ô¤¬¤¢¤ì¤Ð
0x111100002222000033330000

¤³¤Î¥¯¥é¥¹¤Ç¤Ï¼¡¤Î¤è¤¦¤Ë³ÊǼ¤µ¤ì¤ë¤â¤Î¤È¤¹¤ë¡£(Ãí1)

(m_sz=3)
|- m_num[0]-|- m_num[1]-|- m_num[2]-|
| 3333 0000 | 2222 0000 | 1111 0000 |


¤³¤ì¤òÍѤ¤¤Æ¡¢Stein's algorithm¤Ë¤è¤ëGCD·×»»¤ò¹Í¤¨¤ë¡£


Stein¤ÎGCD¤Ë¤Ä¤¤¤Æ¤ÏWikiPedia¤¬¾Ü¤·¤¤¡£
http://en.wikipedia.org/wiki/Binary_GCD_algorithm

°ìÈÌ¤Ë ¥æ¡¼¥¯¥ê¥Ã¥É¤Î¸ß½üË¡(³ÈÄ¥) ¤ÎÊý¤¬¥ë¡¼¥×²ó¿ô¤Ï¾¯¤Ê¤¤¤¬¡¢
¾ê;·×»»¤¬¥Í¥Ã¥¯¤Ë¤Ê¤ê¡¢±þÅúÀ­¤¬°­¤¯¤Ê¤ë¾ì¹ç¤¬Â¿¤¤¡£

⤷¡¢¼ÂÁõ¤¹¤ë¾è»»¡¦¾ê;»»¤Î¥¢¥ë¥´¥ê¥º¥à¤ä¿ôÃͤηå¿ô¤Ë¤è¤Ã¤Æ¤Ï¡¢
¥ë¡¼¥×²ó¿ô¤Î¾¯¤Ê¤¤¥æ¡¼¥¯¥ê¥Ã¥É¤Î¸ß½üË¡(³ÈÄ¥)¤ÎÊý¤¬Áᤤ¾ì¹ç¤â¤¢¤ë¡£

Stein¤Î¥¢¥ë¥´¥ê¥º¥à¤ÇÃÙ¤¤¤È»×¤ï¤ì¤ë¤Î¤Ï¡¢Shift±é»»¤Î²ó¿ô¤Ë¿Ô¤­¤ë¡£
¥µ¥ó¥×¥ë¥³¡¼¥É¤ò¤½¤Î¤Þ¤Þ»È¤¦¤È¡¢¤¤¤¯¤éÉé²Ù¤Î¾¯¤Ê¤¤Shift±é»»¤È¸À¤¨¤É¤â¡¢
¿·å±é»»¤Ç½èÍý²ó¿ô¤¬Â¿¤¯¤Ê¤ë¤ÈÂ礭¤ÊÃÙ±ä¤ò¾·¤­¤Þ¤¹¡£
WikiPedia¤ÎStein¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤ÇÌäÂê¤È¤Ê¤ë¤Î¤Ï¡¢


/* From here on, u is always odd. */
do {
  while ((v & 1) == 0)  /* Loop X */
     v >>= 1;


¤ÎÉôʬ¡£Íפϱ¦Ã¼¤Î£°¤ò½üµî¤·¤Æ¤¤¤ë¤À¤±¤Ç¤¢¤ë¡£
±¦Ã¼¤Ëʤó¤Ç¤¤¤ë£°¤Î¿ô¤ò¿ô¤¨¤ë´Ø¿ô¤òÍÑ°Õ¤·¤Æ¡¢Shift²ó¿ô¤ò¸º¤é¤³¤È¤òÌܻؤ¹¡£

http://en.wikipedia.org/wiki/Count_trailing_zeros ¤Ë¤â¤¢¤ë¤¬¡¢
intel·Ï¤Ç¤¢¤ì¤Ð¡¢¥¢¥»¥ó¥Ö¥é(bsf)¤¬»È¤¨¤ë¡£


//
// ¹â®²½¤Î¤¿¤á¥¼¥í¥Á¥§¥Ã¥¯¤ò¹Ô¤Ã¤Æ¤¤¤Ê¤¤
//  ¥¼¥í¤À¤È¥¢¥¯¥»¥¹°ãÈ¿¤ÎÎã³°¡£
//
int Bigint::bsf() const{
	int* p = m_num;
	__asm{
		mov edx, [p]
		mov eax, edx
bsf_l2:
		bsf ecx, [eax]
		jnz bsf_l1
		add eax, 4
		jmp bsf_l2
bsf_l1:
		sub eax, edx
		shr eax, 2
		mov edx, BITPERBLOCK
		mul edx
		add eax, ecx
	}
}


BITPERBLOCK¤Ï¡¢ÇÛÎ󣱤Ĥ˴ޤޤì¤ë¿ÇÜĹÀ°¿ô¤ÎBit¿ô¤Ç¤¢¤ë¡£
32bit¤Ç¤¢¤ì¤Ð¡¢32¤¬»È¤ï¤ì¤ë¾ì¹ç¤¬Â¿¤¤¡£(Ãí2)
(64bit¤Î¾ì¹ç¡¢bsfq¤ò»È¤¦¡£)

(m_sz=2, BITPERBLOCK=32)¤Î¼¡¤Î¤è¤¦¤Ê¿ÇÜĹÀ°¿ô¤¬¤¢¤ë¤È¤­

|- m_num[0]-|- m_num[1]-|
| 0000 0000 | ABCD 0000 |

bsf()¤Ï¡¢32+16=48 ¤òÊÖ¤¹¡£


¥¢¥»¥ó¥Ö¥é¤ò»È¤ï¤Ê¤¤¼¡¤ÎÊýË¡¤â¤¢¤ë¡£


int Bigint::bsf() const{
	static int table[32] = {0,1,10,2,11,14,22,3,30,12,15,17,19,23,26,4,31,9,13,21,29,16,18,25,8,20,28,24,7,27,6,5};

	int count = 0;
	for (int i=0; i<m_sz; i++){
		int x = m_num[i];
		if (x == 0){
			count += BITPERBLOCK;
		}else{
			count += table[((unsigned int)(x & -x) * 0x07C4ACDDUL) >> 27];
			break;
		}
	}
	return count;
}

// 64bit/Block¤Î¾ì¹ç
int Bigint::bsf64() const{
	static int table[64] = {
		0,1,59,2,60,40,54,3,61,32,49,41,55,19,35,4,62,52,30,33,50,12,14,42,56,16,27,20,36,23,44,5,
		63,58,39,53,31,48,18,34,51,29,11,13,15,26,22,43,57,38,47,17,28,10,25,21,37,46,9,24,45,8,7,6};

	int count = 0;
	for (int i=0; i<m_sz; i++){
		__int64 x = m_num[i];
		if (x == 0){
			count += BITPERBLOCK;
		}else{
			count += table[((unsigned __int64)(x & -x) * 0x03F566ED27179461ULL) >> 58];
			break;
		}
	}
	return count;
}

http://en.wikipedia.org/wiki/Count_trailing_zeros ¤Ë¤â¤¢¤ê¤Þ¤¹¤¬¡¢
£Í·ÏÎó¤ò»È¤Ã¤¿¥Þ¥¸¥Ã¥¯¤Ç¤¹¡£
¤³¤Á¤é¤ÎÊý¤¬¾Ü¤·¤¤¤Ç¤¹¡£ http://d.hatena.ne.jp/siokoshou/20090704


¤¹¤ë¤È¡¢Stein¤Î¥³¡¼¥É¤Ï¼¡¤Î¤è¤¦¤Ë½ñ¤±¤ë¡£


//
// *this = GCD(*this, v)
//
void Bigint::gcd(const Bigint& v) {
	if (v == 0){
		return;
	}
	if (operator==(0)){
		operator= (v);
		return;
	}

	Bigint x[2] = {*this, v};

	if (x[0] < 0)	x[0].operator-();
	if (x[1] < 0)	x[1].operator-();

	int i0 = x[0].bsf();
	int i1 = x[1].bsf();
	int shift = (i0 < i1) ? i0 : i1;
	x[0] >>= i0;
	x[1] >>= shift;

	int id = 0;
	do {
		x[id^1] >>= x[id^1].bsf();

		if (x[id] > x[id^1]){
			id ^= 1;
		}
		x[id^1] -= x[id];
	} while (x[id^1] != 0);

	operator= (x[id] << shift);
}

¤³¤ì¤Ç30¡Á40%¤Ï¡¢½èÍý»þ´Ö¤òû½Ì¤Ç¤­¤Þ¤·¤¿¡£

¤³¤ì¤³¤½¤¬Steins;Gate¤ÎÁªÂò¢ö

¤³¤Î¥³¡¼¥É¤ò¼ÂÁõ¤·¤¿¥µ¥ó¥×¥ë¤Î16¿Ê¡¦£²¿Ê¡¦10¿ÊÅÅÂî¤Ç¤¹¡£
À°¿ô¤À¤±¤Ç¤¹¤¬¤ª¤è¤½100Ëü·å¤Þ¤Ç·×»»¤Ç¤­¤Þ¤¹¡£


(Ãí1) ¸ÇÄêĹ¤Ç¤Ï¤Ê¤¤Bigint¥¯¥é¥¹¤Ç¤Ï¡¢¿­Ä¹¡¦½ÌÂàÅù¤Î¥á¥â¥ê¤Î´ÉÍý¤âɬÍפˤʤë¤Î¤Ç¡¢¤³¤ì¤Û¤Éñ½ã¤Ê¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
(Ãí2) 32bit(Block)Á´¤Æ¤ò»È¤¦¤³¤È¤¬É¬¤º¤·¤âÍ­Íø¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£SSE¤òÍ­¸ú¤Ë»È¤¦¤Ê¤é·å¤¢¤Õ¤ì¤¬È¯À¸¤·¤Ê¤¤¤è¤¦ 31bit °Ê²¼¤Ë¤·¤Þ¤¹¡£


Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

¥«¥é¥Ä¥ÐË¡¤Ç»÷Èó¥´¡¼¥¹¥È°Å»»

¥´¡¼¥¹¥È°Å»»¤è¤êÁᤤ¡ª...¾ì¹ç¤â¤¢¤ë·×»»ÊýË¡....(´À


¥´¡¼¥¹¥È°Å»»¤È¤¤¤¦¤Î¤ò¡¢¾¯¤·Á°¤ËÃΤê¤Þ¤·¤¿¡£
¥´¡¼¥¹¥È°Å»»¤¬É®»»¤Ç¤¢¤ë¤Ê¤é¡¢¾è»»£´²ó¡¦²Ã»»£³¡Á£´²ó¤Î±é»»¤Ë¤Ê¤ê¤Þ¤¹¡£

Î㤨¤Ð¡¢48x53¤ò¹Í¤¨¤Æ¤ß¤ë¤È

¡ÚÄ̾ï¤ÎÉ®»»¡Û
     4 8
   x 5 3
---------
     2 4
   1 2
   4 0
 2 0
---------
 2 5 4 4


¡Ú¥´¡¼¥¹¥È°Å»»¡Û
Àé¤Î°Ì¤È°ì¤Î°Ì¤òÀè¤Ë½Ð¤·¤Æ¡¢»Ä¤ê¤ò¸å¤«¤é²Ã»»¤·¤Þ¤¹¡£
Ä̾ï¤ÎÉ®»»¤Î²Ã»»¤Î½ç½ø¤òÆþ¤ìÂؤ¨¤Æ¤¤¤ë¤³¤È¤¬¤ï¤«¤ê¤Þ¤¹¡£
(¾Ü¤·¤¯¤Ï½ñÀÒ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£µû¤Î³¨¤ò»È¤Ã¤¿¤ï¤«¤ê¤ä¤¹¤¤¤â¤Î¤Ç¤¹)


­¡ (4x5)x10 + 8x5 = 240          ...Àé¤Î°Ì(2)
­¢                   40x10 + 8x3
                  =  424         ...°ì¤Î°Ì(4)
­£                   42 + 4x3    ...Àµ³Î¤Ë¤Ï°ì¤Î°Ì¤È½½¤Î°Ì¤Çʬ²ò¤·¤Æ²Ã»»¤·¤Þ¤¹
                  =  54
-----------------------------
                    2544


¡Ú¥«¥é¥Ä¥Ð¡Û
¤½¤ì¤Ê¤é¤Ð¤È¡¢¥´¡¼¥¹¥È¤Ã¤Ý¤¤¥«¥é¥Ä¥ÐË¡¤ò¹Í¤¨¤Æ¤ß¤Þ¤·¤¿¡£
¤È¤Ï¸À¤Ã¤Æ¤âñ½ã¤Ë ´ð¿ô¤ò£±£° ¤Ë¤·¤¿¤À¤±¤Ç¤¹¤¬¡£
ƱÍͤËÀé¤Î°Ì¤È°ì¤Î°Ì¤òÀè¤Ë½Ð¤·¤Æ¡¢»Ä¤ê¤ò¸å¤«¤é·×»»¤·¤Þ¤¹¡£

­¡ (4x5)x100 + (8x3) = 2024  ¾å°Ì·åƱ»Î¤Î¾è»»¤È²¼°Ì·åƱ»Î¤Î¾è»»¤Ê¤Î¤Ç·«¤ê¾å¤¬¤ê¤Ï¤Ê¤¤¡£Ê¤٤ë¤À¤±¡£
­¢ (4x5)     + (8x3) =  44   ­¡¤Î¾å°ÌÉôʬ¤È²¼°ÌÉôʬ¤Î²Ã»»¡£20+24+2
------------------------------
                        46
­£ -(4-8)x(5-3)      =   8   ¥«¥é¥Ä¥ÐË¡¤Î¥ß¥½¡£
------------------------------
                        54
------------------------------
                       2544

¾å¤ÎÀâÌÀ¤Ç¤Ï¤ï¤«¤ê¤Ë¤¯¤¤¤Î¤Ç¡¢·×»»ÊýË¡¤ò´Êñ¤Ê¥Ñ¥¿¡¼¥ó¤Ë¤·¤Þ¤¹¡£

­¡¾å°Ì·å¤È²¼°Ì·åƱ»Î¤ò³Ý¤±¤Æʤ٤ޤ¹¡£(¢ª2024)
­¢²¼£³·å¤ò­¤·¤Þ¤¹(0+2+4¢ª6)
­£¾å£³·å¤ò­¤·¤Þ¤¹(2+0+2¢ª4)
...¤³¤³¤Ç¸µ¤Î½½¤Î°Ì¤È°ì¤Î°Ì¤Î¿ô¡Ö0,2¡×¤Ï˺¤ì¤Æ¡¢2464¤òµ­²±¤¹¤ë¡£
­¤³Ý¤±¤ë¿ô¡¢³Ý¤±¤é¤ì¤ë¿ô¡¢¤½¤ì¤¾¤ì½½¤Î°Ì¤È°ì¤Î°Ì¤Îº¹¤ò¼è¤Ã¤Æ³Ý¤±¤Þ¤¹¡£(-4x2¢ª-8)
­¥Éä¹æȿž(-8¢ª+8)
­¦ ­£¤È­¢¤Ç¤Ç¤­¤¿¿ô¤Ë¡¢­¥¤Î¿ô¤ò­¤·¤Þ¤¹¡£(46+8¢ª54)
Ê»¤»¤Æ·Ò¤²¤ë¤È¡¢2544¤Î½ÐÍè¾å¤¬¤ê¡£

­¤¤¬¥«¥é¥Ä¥ÐË¡¤Î¥ß¥½¤Ç¡¢¤¿¤¹¤­³Ý¤±¤Î³Ý¤±»»(4x3,8x5)¤ÏɬÍפ¢¤ê¤Þ¤»¤ó¡£

¤¤¤¯¤Ä¤«·×»»¥µ¥ó¥×¥ë¤òʤ٤ޤ¹¡£

¤³¤ì¤â¥«¥é¥Ä¥Ð¤Î¸ú²Ì¤¬Îɤ¯½Ð¤Æ¤¤¤Þ¤¹¡£

ºÇ¤â¸ú²Ì¤¬½Ð¤ë¤Î¤Ï¡¢½½¤È°ì¤Î°Ì¤¬Æ±¤¸¿ô»ú¤Î¾ì¹ç¤Ç¡¢

´Êñ¤¹¤®¤Æ¶Ã¤­¤Þ¤¹¡£

»ÄÇ°¤Ê¤¬¤éÁ´¤Æ¤Î¿ô»ú¤ÎʤӤǴÊñ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
¼¡¤ÎÎã¤ò¤´Í÷¤¯¤À¤µ¤¤¡£

¤³¤ÎÎã¤À¤È¡¢·å¾å¤²¤È·å²¼¤²¤¬È¯À¸¤¹¤ë¤Î¤Ç¡¢¾¯¤·ÌÌÅݤǤ¹¡£

¥«¥é¥Ä¥ÐË¡¤Ë¤Ä¤¤¤Æ¾Ü¤·¤¯¤Ï
http://ja.wikipedia.org/wiki/%E3%82%AB%E3%83%A9%E3%83%84%E3%83%90%E6%B3%95
°ìÈ̤ˤϡ¢Ê¬³äÅý¼£Ë¡¤È¤·¤Æͭ̾¤Ç¡¢¾è»»¤Î¾¤Ë¤â½ü»»¤äÊ¿Êýº¬¤Î¿ÇÜĹ¿ô·×»»¤Ç»È¤ï¤ì¤Þ¤¹¡£(Ãí)
KaratsubaÇî»Î ¤â¤³¤ó¤Ê»È¤¤Êý¤µ¤ì¤ë¤È¤Ï¡¢»×¤ï¤Ê¤«¤Ã¤¿¤Ç¤·¤ç¤¦¡£


¡Ú¤Þ¤È¤á¡Û
´ö¤Ä¤«¤ÎÎã¤Ç¤Ï¡¢¥«¥é¥Ä¥ÐË¡¤ÎÊý¤¬Áᤤ¤è¤¦¤Êµ¤¤â¤·¤Þ¤¹¤¬¡¢
¥´¡¼¥¹¥È°Å»»¤ÎÎɤµ¤Ï¡¢Ã±½ã²½¤µ¤ì¤¿¾®¤µ¤Ê²Ã»»¤òÁȤ߹ç¤ï¤»¤ë¤³¤È¤Ç¡¢¾®³Ø¹»Äã³Øǯ¤Ç¤â·×»»¤Ç¤­¤ë¤È¤³¤í¤Ë¤¢¤ê¤Þ¤¹¡£
¥Ñ¥¿¡¼¥ó¤Ë¤è¤Ã¤ÆÆñ°×ÅÙ¤¬¤¢¤Þ¤ê¾å²¼¤¹¤ë¤Î¤Ï¡¢Äã³Øǯ¤Ç¤Ï¸·¤·¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¡£

¥«¥é¥Ä¥ÐË¡¤Î¾ì¹ç¡¢¾è»»²ó¿ô¤¬¸º¤ê¤Þ¤¹¤¬­¥­¦¤¬¸º»»¤Ë¤Ê¤ë¾ì¹ç¤â¤¢¤ë¤Î¤Ç¤³¤³¤¬°Å»»¾å¤Îµ´Ìç¤Ë¤Ê¤ê¤Þ¤¹¡£
Î㤨¤Ð¡¢¾è¿ô¤äÈï¾è¿ô¤Ë22¤ä77¤Ê¤É¡¢Æ±¤¸¿ô»ú¤¬Ê¤ó¤Ç¤¤¤ë¾ì¹ç¤Ï­¤­¥¤¬¤¤¤é¤Ê¤¯¤Ê¤ë¤Î¤Ç´Êñ¤Ç¤¹¤¬¡¢ºÇ¸å¤ÎÎã¤Ê¤É¥«¥é¥Ä¥Ð°Å»»¤Ç²ò¤¯¤Î¤Ï¸º»»¤Ë¤è¤ë·å²¼¤²¤¬¤¢¤ë¤Î¤ÇÌÌÅݤǤ¹¡£
¤Þ¤¿¡¢¾®¤µ¤Ê·å¿ô¤Ç¤¢¤ì¤Ð¿Í´Ö¤Ë¤È¤Ã¤Æ¤Ï¡¢²Ã»»¤è¤ê¾è»»¤ÎÊý¤¬Áᤤ¤Î¤Ç¡¢
ËÜÍè¤Î¥«¥é¥Ä¥ÐË¡¤Î¸ú²Ì¤Ï¡¢Á´¤¯¤È¸À¤Ã¤Æ¤¤¤¤Äø¤¢¤ê¤Þ¤»¤ó¡£(Ãí)

£²·å£²·å¤Þ¤Ç¤·¤«ÄÌÍѤ·¤Ê¤¤¤È¤«¡Ö¤½¤í¤Ð¤ó¡×¤ÎÊý¤¬Îɤ¤¤È¤«ÈãȽŪ¤Ê°Õ¸«¤â»¶¸«¤·¤Þ¤¹¤¬¡¢
¥´¡¼¥¹¥È°Å»»¤Ï¡¢¥¤¥á¡¼¥¸(µû¥Ñ¥¿¡¼¥ó)¤Ç´Êñ¤Ë¤ï¤«¤ê¤ä¤¹¤¯·×»»ÊýË¡¤ò²òÀ⤷¤¿¤È¤¤¤¦ÅÀ¤Ç¤Ï¡¢
º£¤Þ¤Ç¤Ê¤«¤Ã¤¿¿·¤·¤¤»î¤ß¤Ç¤¢¤ê¡¢¤Á¤ç¤Ã¤È¿¿»÷¤·¤Æ¤ß¤¿¤¯¤Ê¤ê¤Þ¤·¤¿¡£


¤É¤¦¤Ç¤âÎɤ¤¤³¤È¤Ç¤¹¤¬¡¢¤É¤³¤Î¥Ú¡¼¥¸¤â¡Ö48 x 53¡×¤ò»²¹Í¤Ë¤·¤Æ¤¤¤ë¤Î¤Ç¡¢
48x53¤ÎÅú¤¨¤À¤±¤Ï³Ð¤¨¤Á¤ã¤Ã¤Æ¤¤¤ë¿Í¤¬¤¤¤ë¤Î¤Ç¤Ï¤Ê¤¤¤À¤í¤¦¤«¡£



Tags: ¥×¥í¥°¥é¥à¥á¥â
³¤­¤òÆɤà¡ä¡ä
author : HUNDREDSOFT | - | -

Windows7¤Ç´Êñ¤Ë¥Þ¥ë¥Á¥¿¥Ã¥Á¤ò»î¤¹

Windows7¤Ç´Êñ¤Ë¥Þ¥ë¥Á¥¿¥Ã¥Á¤ò»î¤¹ÊýË¡¤È¤·¤Æ¡¢ "Multi-Touch Vista" ¤¬¤¢¤ê¤Þ¤¹¡£
̾Á°¤ÎÄ̤ꡢ¤½¤ì¤Û¤É¿·¤·¤¤¥½¥Õ¥È¤Ç¤Ï¤Ê¤¤¤Î¤Ç¤´Â¸¤¸¤ÎÊý¤â¤¤¤ë¤Ç¤·¤ç¤¦¡£

£²¤Ä¤Î¥Þ¥¦¥¹ÆþÎϤò£²¤Ä¤Î¥¿¥Ã¥Á¥Ý¥¤¥ó¥È¤Ë¸«Î©¤Æ¤Æ¡¢
¥Þ¥ë¥Á¥¿¥Ã¥Á´Ä¶­¤ò¼Â¸½¤·¤Æ¤¯¤ì¤ë¥É¥é¥¤¥Ð¤È¥³¥ó¥È¥í¡¼¥ë¥½¥Õ¥È¤Ç¤¹¡£

Virtual´Ä¶­¤Ç¤³¤ì¤ò²¿¤È¤«Æ°¤«¤»¤Ê¤¤¤«»î¤·¤¿¤Î¤Ç¤¹¤¬¡¢
VMware, VirtualPC, VirtualBox ¤¤¤º¤ì¤âÆ°¤«¤»¤Þ¤»¤ó¤Ç¤·¤¿¡£

¥É¥é¥¤¥Ð¤Îǧ¼±¤Þ¤Ç¤Ï¤Ç¤­¤Æ¡¢¥³¥ó¥È¥í¡¼¥ë¥Ñ¥Í¥ë¤Ë
¡Ö¥Ú¥ó¤È¥¿¥Ã¥Á¡×¤¬Äɲ䵤ì¤ë¤È¤³¤í¤Þ¤Ç¤Ï¹Ô¤¯¤Î¤Ç¤¹¤¬
Multitouch.Configuration.WPF.exe¤Î"Configuer device"¤Ç
Block native windows...¤Î¥Á¥§¥Ã¥¯¤òÆþ¤ì¤ë¤È
¥Þ¥¦¥¹¤¬°ìÀÚ¸ú¤«¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£
¤ä¤Ï¤ê¼Â´Ä¶­¤¬É¬ÍפʤΤ«¤â¤·¤ì¤Þ¤»¤ó¡£

¼Â´Ä¶­¤Ç¤¢¤ì¤Ð¡¢³µ¤ÍÌäÂê¤Ê¤¯»È¤¨¤ë¤Î¤Ç¤¹¤¬¡¢
¥¹¥¿¡¼¥È¥á¥Ë¥å¡¼¤ä¥¿¥¹¥¯¥Þ¥Í¥¸¥ã¡¼¤ò³«¤±¤ë¤È¤Á¤ç¤Ã¤Èº¤¤Ã¤¿ÌäÂ꤬ȯÀ¸¤·¤Þ¤¹¡£
­¡¥¹¥¿¡¼¥È¥á¥Ë¥å¡¼¾å¤Ë¡¢¥¿¥Ã¥Á¤ÎÀÖ¤¤¡û¤Î¥Þ¡¼¥¯¤¬É½¼¨¤µ¤ì¤Ê¤¤¡£
­¢¥¿¥¹¥¯¥Þ¥Í¡¼¥¸¥ã¡¼¾å¤ÇÁàºî¤Ç¤­¤Ê¤¤¡£

­¢¤Ë¤Ä¤¤¤Æ¤Ï¡¢
Multitouch.Service.Console.exe,Multitouch.Driver.Console.exe¤ò
´ÉÍý¼Ô¤È¤·¤Æ¼Â¹Ô¤¹¤ì¤Ð²Äǽ¤Ç¤¹¤¬­¡¤ÎÌäÂ꤬¤¢¤ë¤Î¤Ç¡¢
´ÉÍý¼Ô¸¢¸Â¤Ç¼Â¹Ô¤·¤Æ¤¤¤ëWindow¾å¤Ë¥¿¥Ã¥Á¥Þ¡¼¥¯¤òɽ¼¨¤¹¤ë¤³¤È¤¬¤Ç¤­¤º¤Ë¡¢
´ÉÍý¼Ô¥¢¥×¥ê¤ÎWindowÇØÌ̤˥ޡ¼¥¯¤¬É½¼¨¤µ¤ì¤Æ¤·¤Þ¤¤¤Þ¤¹¡£

"Multi-Touch Vista"¤Ï¡¢¥³¡¼¥É¸ø³«¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç
multitouchvista-30935.zip¤ò¥À¥¦¥ó¥í¡¼¥É¤·¤Æ
Multitouch.InputProviders.sln¤òVS2010¤Ç³«¤¯¤È¡¢
DebugCursor.cs¤¬¥Þ¡¼¥¯¤òɽ¼¨¤·¤Æ¤¤¤ë¤³¤È¤¬¤ï¤«¤ê¤Þ¤¹¡£

Z-Order¤Ë´Ø¤¹¤ëÌäÂê¤Ç¤¹¤¬¡¢¾ï¤ËºÇÁ°Ì̤˥桼¥¶¡¼Window¤òɽ¼¨¤¹¤ëÊýË¡¤Ï¡¢
Windows£Ï£Ó¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤Ã¤Æ¤âÊѤï¤ê¤Þ¤¹¡£

¡¦Form¤Î»ØÄê¤äCreateWindow¤ÇTopMost¤ò»ØÄꤹ¤ë
¡¦SetForegroundWindows¤äAttachThreadInput¤Î¸Æ¤Ó½Ð¤·
¡¦BringWindowToTop¤Î¸Æ¤Ó½Ð¤·

Åù¤¬¤¢¤ê¤Þ¤¹¤¬¡¢

Windows7¤ÇC#¤Ê¤é¡¢Control.BringToFront()¤ò»È¤¦¤Î¤¬´Êñ¤Ç¤¹¡£

DebugCursor¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤ë¤Î¤Ï¡¢DeviceStatus¥¯¥é¥¹¤Ç¤¹¤Î¤Ç
SyncUpdateLocation()¤Ë°ì¹ÔÄɲä·¤Þ¤¹¡£


void SyncUpdateLocation(object state)
{
   debugCursor.BringToFront(); //<-------------- ¤³¤Î¹Ô¤òÄɲÃ
   debugCursor.Location = new Point(Location.X - debugCursor.Width / 2, Location.Y - debugCursor.Height / 2);
}



¤³¤ì¤òBuild¤·¤Æ¡¢Output¥Õ¥©¥ë¥À¤Ë½ÐÎϤµ¤ì¤¿¥Õ¥¡¥¤¥ë¤ò¾å½ñ¤­¤¹¤ì¤Ð¡¢
­¡¥¹¥¿¡¼¥È¥á¥Ë¥å¡¼¾å¤Ë¡¢¥¿¥Ã¥Á¤ÎÀÖ¤¤¡û¤Î¥Þ¡¼¥¯¤¬É½¼¨¤µ¤ì¤Ê¤¤¡£
­¢¥¿¥¹¥¯¥Þ¥Í¡¼¥¸¥ã¡¼¾å¤ÇÁàºî¤Ç¤­¤Ê¤¤¡£
¤ÎÌäÂ꤬²ò·è¤·¤Þ¤¹¡£




Tags: ¥×¥í¥°¥é¥à¥á¥â¡¡VirtualPC´ØÏ¢¡¡Windows7(x64)´ØÏ¢
author : HUNDREDSOFT | - | -

AndroidÃå¿®²»¤Î¥ë¡¼¥×ºÆÀ¸

ÀΤÎÃå¥á¥í²°¤µ¤ó¤À¤È¡¢Ãå¿®²»¤Î¥ë¡¼¥×Éôʬ¤Ë¤«¤Ê¤ê¤Î¤³¤À¤ï¤ê¤¬¤¢¤ê¡¢
·«¤êÊÖ¤·Éôʬ¤¬¥¹¥à¡¼¥º¤Ë¤Ê¤ë¤è¤¦Ä´Àá¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
¤¤¤ï¤æ¤ë¡¢¥ë¡¼¥×ÁǺà¤È¤¤¤¦¤ä¤Ä¤Ç¤¹¡£

´û¤ËÍÍ¡¹¤Ê¥µ¥¤¥È¤Ç¾Ò²ð¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢
Android·ÈÂӤǤϡ¢MP3,wavÅù¡¢ÍÍ¡¹¤Ê²»³Ú¥Õ¥¡¥¤¥ë¤òÃå¿®²»¤ËÀßÄê¤Ç¤­¤Þ¤¹¡£
¤·¤«¤·¡¢¼«ºî¤ÎÃå¿®²»¤òÀßÄꤹ¤ë¤È¡¢£±²ó¤·¤«ºÆÀ¸¤µ¤ì¤Ê¤¤¤¿¤á¡¢
û¤¤²»À¼¤ÇÃå¿®²»¤òºîÀ®¤¹¤ë¤È¡¢£±²ó¤À¤±ºÆÀ¸¤·¤¿¸å¡¢Ìµ²»¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹¡£

⤷¡¢Ogg¤ÇºîÀ®¤·¤¿²»À¼¥Õ¥¡¥¤¥ë¤Ç¥á¥¿¥¿¥°¡ÖANDROID_LOOP=true¡×¤òÀßÄꤷ¤¿¾ì¹ç¤Ï¥ë¡¼¥×ºÆÀ¸¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£

¤â¤Á¤í¤óAudacityÅù¤ÇOgg¤òºîÀ®¤·¤Æ¤¤¤ì¤Ð¡¢¥á¥¿¥¿¥°ÊÔ½¸¤ÇÆþ¤ì¤é¤ì¤Þ¤¹¤¬¡¢
²»³ÚÊÔ½¸¤Ë¾¤Î¥½¥Õ¥È¤ò»È¤Ã¤Æ¤¤¤¿¤ê¤¹¤ë¤È¡¢ÌÌÅݤǤ¹¡£
³«È¯¤ò»ß¤á¤Æ¤¤¤¿wav2mld¤Ç¤â´Êñ¤ËÄɲäǤ­¤½¤¦¤Ê¤Î¤Ç¡¢ÊýË¡¤ò¹Í¤¨¤Æ¤ß¤Þ¤·¤¿¡£

PC¤Ç¤Î¥×¥í¥°¥é¥à¤È¤·¤Æ¤Ï¡¢OggVorbisɸ½à¤Î http://xiph.org ¤Î¤â¤Î¤ò»È¤Ã¤¿¤È¤·¤Æ
libvorbis-1.x.x\lib\info.c ¤Î vorbis_comment_add_tag¤òCall¤¹¤ì¤ÐÎɤ¤¡£

Î㤨¤Ð¡¢encoder_example.c ¤Ç¤¢¤ì¤Ð¡¢

vorbis_comment_init(&vc);
vorbis_comment_add_tag(&vc,"ENCODER","encoder_example.c");
¤Î¸å¤Ë¡¢
vorbis_comment_add_tag(&vc, "ANDROID_LOOP", "true");
¤òÆþ¤ì¤ì¤Ð¡¢AndroidÍѥ롼¥×²»À¼¤¬ºîÀ®¤Ç¤­¤Þ¤¹¡£

ºîÀ®¤·¤¿ogg¥Õ¥¡¥¤¥ë¤Ï¡¢¤É¤³¤«¤ËUpLoad¤·¤Æ¥À¥¦¥ó¥í¡¼¥É¤·¤Æ¤âÎɤ¤¤·¡¢
Wi-Fi ¤¬»È¤¨¤ë´Ä¶­¤Ê¤é¡¢Es explorer¤Ê¤É¤ÇPC¤«¤éľÀÜ¥³¥Ô¡¼¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£
¥³¥Ô¡¼½ÐÎϾì½ê¤Ï¡¢
/sdcard/media/audio/ringtones
¤Ç¤¹¡£

wav2mld Ver.2.35 ¤Çµ¡Ç½Äɲä·¤Þ¤·¤¿¡£
¤³¤ì¤Ç¡¢¼«ºîÃå¿®²»¤¬Android·ÈÂÓ¾å¤Ç¥ë¡¼¥×ºÆÀ¸¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£


Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

¥Ë¥å¡¼¥È¥óË¡¤ò»È¤Ã¤¿£²¿Ê¿·å¤ÎÀ°¿ô½ü»»(¤½¤Î£²)

Á°²ó¡¢½ü»» x = p / q¡¡¤òNewtonË¡¤ò»È¤Ã¤Æ²ò¤¯¥×¥í¥°¥é¥à¤ò¾Ò²ð¤·¤Þ¤·¤¿¤¬¡¢
ñÆȤνé´üÃͤò»È¤Ã¤¿ÊýË¡¤Ç¤Ï¡¢¤¢¤Þ¤êÁ᤯¤¢¤ê¤Þ¤»¤ó¡£
¿ôËübit¤òĶ¤¨¤ë¿·å±é»»¤Î¾ì¹ç¡¢64bitÀºÅ٤νé´üÃͤò»È¤Ã¤¿¤È¤·¤Æ¤â¡¢¤¢¤Þ¤ê®Å٤˺¹¤¬½Ð¤Þ¤»¤ó¡£
¤½¤³¤ÇÂ礭¤Ê·å(¿ôËübit¤òĶ¤¨¤ë)¤Ç·×»»¤ò³«»Ï¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢½ü¿ô(q)¤ÎÀèƬÉôʬ¤ò»È¤Ã¤¿¾®¤µ¤Ê·å¤Ç·×»»¤ò³«»Ï¤·¤Æ¡¢¤³¤ì¤òNewtonË¡¤Î½é´üÃͤȤ·¡¢¤â¤¦¾¯¤·Â礭¤Ê·å¤ÇNewtonË¡¤ò²ò¤¯¡¢
¤³¤ì¤ò·«¤êÊÖ¤·¤ÆºÇ½ªÅª¤ÊÅú¤¨¤òÆÀ¤ëÊýË¡¤ò¾Ò²ð¤·¤Þ¤¹¡£
¾¯¤·¥³¡¼¥É½¤Àµ¤·¤Þ¤·¤¿(2011.2.11)

Bigint newtondiv(const Bigint& q, const int& n, const Bigint& init){
  Bigint x(init), m(0), c2(2);
  c2 <<= n;
  while(m != x){
    m = x;
    x *= c2 - q * x;
    x >>= n;
  }
  return x;
}

Bigint iDiv(Bigint p, Bigint q){
  int pb = p.length(); // Èï½ü¿ô¤Îbit¿ô
  int qb = q.length(); // ½ü¿ô¤Îbit¿ô
  int n;
  int b = 64;
  int step = qb / 4;

  Bigint d = 1;
  d <<= b;      // NewtonË¡¤Î½é´üÃͤȤ·¤Æ, 1 << b ¤òÍ¿¤¨¤ë¡£

  d = newtondiv(q >> (qb-b), b*2, d);  // 1²óÌÜ
  b += step;
  d <<= step;

  d = newtondiv(q >> (qb-b), b*2, d);  // 2²óÌÜ
  b += step;
  d <<= step;

  d = newtondiv(q >> (qb-b), b*2, d);  // 3²óÌÜ
  d <<= (pb-b);
  n = pb + qb;

  d = newtondiv(q, n, d);  // 4²óÌÜ

  d *= p;        // d = p / q
  d >>= n;

  // ¸íº¹½¤Àµ
  if (p >= (d+1)*q){
      d += 1;
  }
  return d;
}


newtondiv¤Ï¡¢NewtonË¡¤Ç ¡Ê2n / q¡Ë ¤òµá¤á¤ë´Ø¿ô¤Ç¤¹¡£
½é²ó¤ÏÀèƬ64bitÄøÅ٤Ƿ׻»¤·¤Þ¤¹¡£
2²óÌܤϡ¢½é²ó¤Î·×»»·ë²Ì¤ò½é´üÃͤȤ·¤Æ¡¢64+(½ü¿ô¤ÎBit¿ô/4)¤Ç¤Î·×»»¡£
3²óÌܤϡ¢£²²óÌܤη׻»·ë²Ì¤ò½é´üÃͤȤ·¤Æ¡¢64+(½ü¿ô¤ÎBit¿ô/2)¤Ç¤Î·×»»¡£
4²óÌܤϡ¢£³²óÌܤη׻»·ë²Ì¤ò½é´üÃͤȤ·¤Æ¡¢Á´·å¤Ç¤Î·×»»¡£
¤È·×»»·å¤òÁý¤ä¤·¤Æ¤¤¤­¤Þ¤¹¡£

½ü¿ô¡¦Èï½ü¿ô¤Î¤È¤êÊý¤Ë¤â¤è¤ê¤Þ¤¹¤¬¡¢·×»»»þ´Ö¤ÏÌÀ¤é¤«¤Ëû¤¯¤Ê¤ê¤Þ¤¹¡£
¤³¤ÎÊýË¡¤Ï¡¢Bigint¤Î±é»»²ó¿ô¤È¤·¤Æ¤Ï¡¢¸ú²Ì¤Ï¤Ê¤¤¤Î¤Ç¤¹¤¬¡¢
²ÄÊÑŤÎFFT¾è»»¤òÍѤ¤¤ë¾ì¹ç¡¢±é»»Î̤ϣ²¤ÎÑÑ¿ô·åñ°Ì¤ËÁý²Ã¤¹¤ë¤Î¤Ç¡¢
Total¤Î·×»»Î̤Ȥ·¤Æ¤Ï¡¢¤³¤Á¤é¤ÎÊý¤¬Í­Íø¤Ç¤¹¡£

4ʬ³ä¤È¤·¤Æ¤¤¤Þ¤¹¤¬¡¢ÍøÍѤ¹¤ëBigint(¿ÇÜĹÀ°¿ô)¥¯¥é¥¹¤ÇºÇ®¤È¤Ê¤ë¤è¤¦Ä´À᤹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¤³¤ì¤Ë¤Ä¤¤¤Æ¤Ï¡¢¡Ö¹â¶¶ Âç²ð, ¶âÅÄ ¹¯Àµ. "¿ÇÜĹʿÊýº¬¤Î¹â®·×»»Ë¡". ¾ðÊó½èÍý³Ø²ñ¸¦µæÊó¹ð 95-HPC-58, pp.51-56.¡×¤¬¾Ü¤·¤¤¤Ç¤¹¡£
ʸ¸¥¤Ë½¾¤¨¤Ð¡¢½é´üÃͤËÇÜÀºÅÙ·ë²Ì¤ò»È¤¦¡¦£³¡Á£´Ê¬³äÄøÅÙ¡¦FFTºÆÍøÍÑ¡¢¤ò¹Ô¤¨¤ÐºÇÂç¸Â¤Î¹â®²½¤ò˾¤á¤Þ¤¹¤¬¡¢¤³¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ç¤Ï¤½¤³¤Þ¤ÇÂбþ¤Ç¤­¤Æ¤¤¤Þ¤»¤ó¡£

¤³¤³¤Ç¤ÏÀâÌÀ¤ò´Êñ¤Ë¤¹¤ë¤¿¤á½é´üÃͤˡÊ2^64¡Ë¤òÍ¿¤¨¤Æ¤¤¤Þ¤¹¡£
¤è¤êÀµ³Î¤Ê½é´üÃͤΤȤêÊý¤ä¡¢¾ÜºÙ¥¢¥ë¥´¥ê¥º¥à¤Ï¤³¤Á¤é
À°¿ô½ü»»¤Î¾ÜºÙ²òÀâ

½ü¿ô¡¦Èó½ü¿ô¤Î·åº¹¤¬¾®¤µ¤±¤ì¤Ð¡¢¤³¤Î¤è¤¦¤ÊÊýË¡¤â¤¢¤ê¤Þ¤¹¡£
²óÉüË¡¤ò»È¤Ã¤¿£²¿Ê¿·å¤Î½ü»»

ƱÍͤη׻»ÊýË¡¤ò¹Ô¤Ã¤Æ¤¤¤ë¡¢À°¿ôÊ¿Êýº¬²òÀâ¤Ï¤³¤Á¤é
À°¿ôÊ¿Êýº¬¤Ç¤Î¾ÜºÙ²òÀâ

¤³¤Î¥¢¥ë¥´¥ê¥º¥à¤òÍøÍѤ·¤¿16¿Ê¡¦£²¿Ê¡¦10¿ÊÅÅÂî¤Ç¤¹¡£
À°¿ô¤À¤±¤Ç¤¹¤¬¤ª¤è¤½100Ëü·å¤Þ¤Ç·×»»¤Ç¤­¤Þ¤¹¡£


(Ãí)¤³¤³¤Ç¤ÎBigint¥¯¥é¥¹¤Ï¡¢Â¿ÇÜĹÀ°¿ô¤ò³ÊǼ¤¹¤ë²¾ÁۤΥ¯¥é¥¹¤Ç¤¢¤ê¡¢¼Âºß¤¹¤ë¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£


Tags: ¥×¥í¥°¥é¥à¥á¥â
³¤­¤òÆɤà¡ä¡ä
author : HUNDREDSOFT | - | -

¥Ë¥å¡¼¥È¥óË¡¤ò»È¤Ã¤¿£²¿Ê¿·å¤ÎÀ°¿ôÊ¿Êýº¬(¤½¤Î£²)

Á°²ó¡¢Ê¿Êýº¬ ¢ås¡¡¤òNewtonË¡¤ò»È¤Ã¤Æ²ò¤¯¥×¥í¥°¥é¥à¤ò¾Ò²ð¤·¤Þ¤·¤¿¤¬¡¢
ñÆȤνé´üÃͤò»È¤Ã¤¿ÊýË¡¤Ç¤Ï¡¢¤¢¤Þ¤êÁ᤯¤¢¤ê¤Þ¤»¤ó¡£
¿ôËübit¤òĶ¤¨¤ë¿·å±é»»¤Î¾ì¹ç¡¢64bitÀºÅ٤νé´üÃͤò»È¤Ã¤¿¤È¤·¤Æ¤â¡¢¤¢¤Þ¤ê®Å٤˺¹¤¬½Ð¤Þ¤»¤ó¡£
¤½¤³¤ÇÂ礭¤Ê·å(¿ôËübit¤òĶ¤¨¤ë)¤Ç·×»»¤ò³«»Ï¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢(s)¤ÎÀèƬÉôʬ¤ò»È¤Ã¤¿¾®¤µ¤Ê·å¤Ç·×»»¤ò³«»Ï¤·¤Æ¡¢¤³¤ì¤òNewtonË¡¤Î½é´üÃͤȤ·¡¢¤â¤¦¾¯¤·Â礭¤Ê·å¤ÇNewtonË¡¤ò²ò¤¯¡¢
¤³¤ì¤ò·«¤êÊÖ¤·¤ÆºÇ½ªÅª¤ÊÅú¤¨¤òÆÀ¤ëÊýË¡¤ò¾Ò²ð¤·¤Þ¤¹¡£


Bigint newtonsqrt(const Bigint& q, const int& n, const Bigint& init){
  Bigint x(init), m(0), c3(3);
  c3 <<= n;
  while(m != x){
    m = x;
    x *= c3 - ((m * m * q) >> n);
    x >>= n+1;
  }
  return x;
}

Bigint iSqrt(Bigint s){
  int n = s.length(); // bit¿ô
  int b;
  if (n & 1)    b = 65; // ½é´ü±é»»Bit¿ô(n:´ñ¿ô)
  else          b = 64; // ½é´ü±é»»Bit¿ô(n:¶ö¿ô)

  Bigint x = 1;
  x <<= (b / 2);  // NewtonË¡¤Î½é´üÃͤȤ·¤Æ, 1 << (b/2) ¤òÍ¿¤¨¤ë¡£

  Bigint w;
  int m = n / 8;  // 4ʬ³äÄøÅÙ

  while(1){
    w = s >> (n - b);        // (s)ÀèƬ¤«¤é»ØÄêbit¿ô(n-b)ÀÚ¤ê¼è¤ê
    x = newtonsqrt(w, b, x);

    if (b + 2 * m > n)
      break;

    b += 2 * m;
    x <<= m;
  }
  x <<= (n - b) / 2;         // ɬ¤º³ä¤êÀÚ¤ì¤ë
  x = newtonsqrt(s, n, x);

  x *= s;         // x = s * (2^n) / ¢ås = (2^n) * ¢ås
  x >>= n;        // x = ¢ås

  // ¸íº¹½¤Àµ
  w = x + 1;
  if (s >= w * w){
     x = w;
  }
  return x;
}


newtonsqrt¤Ï¡¢NewtonË¡¤Ç ¡Ê2n / ¢åq¡Ë ¤òµá¤á¤ë´Ø¿ô¤Ç¤¹¡£
½é²ó¤ÏÀèƬ64bitÄøÅ٤Ƿ׻»¤·¤Þ¤¹¡£
2²óÌܤϡ¢½é²ó¤Î·×»»·ë²Ì¤ò½é´üÃͤȤ·¤Æ¡¢(n/8)·åÁý¤ä¤·¤Æ·×»»¡£
3²óÌܤϡ¢£²²óÌܤη׻»·ë²Ì¤ò½é´üÃͤȤ·¤Æ¡¢¹¹¤Ë(n/8)·åÁý¤ä¤·¤Æ·×»»¡£
¤È¼¡¡¹¤È·å¤òÁý¤ä¤·¤Æ¤¤¤­¤Þ¤¹¡£

·×»»»þ´Ö¤ÏÌÀ¤é¤«¤Ëû¤¯¤Ê¤ê¤Þ¤¹¡£
¤³¤ÎÊýË¡¤Ï¡¢Bigint¤Î±é»»²ó¿ô¤È¤·¤Æ¤Ï¡¢¸ú²Ì¤Ï¤Ê¤¤¤Î¤Ç¤¹¤¬¡¢
²ÄÊÑŤÎFFT¾è»»¤òÍѤ¤¤ë¾ì¹ç¡¢±é»»Î̤ϣ²¤ÎÑÑ¿ô·åñ°Ì¤ËÁý²Ã¤¹¤ë¤Î¤Ç¡¢
Total¤Î·×»»Î̤Ȥ·¤Æ¤Ï¡¢¤³¤Á¤é¤ÎÊý¤¬Í­Íø¤Ç¤¹¡£

ʬ³ä¿ô¤Ï¡¢ÍøÍѤ¹¤ëBigint(¿ÇÜĹÀ°¿ô)¥¯¥é¥¹¤ÇºÇ®¤ÎÀ­Ç½¤¬½Ð¤ë¤è¤¦¤ËÄ´À᤹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¤³¤ì¤Ë¤Ä¤¤¤Æ¤Ï¡¢¡Ö¹â¶¶ Âç²ð, ¶âÅÄ ¹¯Àµ. "¿ÇÜĹʿÊýº¬¤Î¹â®·×»»Ë¡". ¾ðÊó½èÍý³Ø²ñ¸¦µæÊó¹ð 95-HPC-58, pp.51-56.¡×¤¬¾Ü¤·¤¤¤Ç¤¹¡£
ʸ¸¥¤Ë½¾¤¨¤Ð¡¢½é´üÃͤËÇÜÀºÅÙ·ë²Ì¤ò»È¤¦¡¦£³¡Á£´Ê¬³äÄøÅÙ¡¦FFTºÆÍøÍÑ¡¢¤ò¹Ô¤¨¤ÐºÇÂç¸Â¤Î¹â®²½¤ò˾¤á¤Þ¤¹¤¬¡¢¤³¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ç¤Ï¤½¤³¤Þ¤ÇÂбþ¤Ç¤­¤Æ¤¤¤Þ¤»¤ó¡£

¤Þ¤¿¡¢¤³¤ÎÊýË¡¤ÏÊ¿Êýº¬¤Ë¸Â¤é¤º¡¢NewtonË¡¤ò»È¤Ã¤¿ÍÍ¡¹¤Ê·×»»¤Ë±þÍѤǤ­¤Þ¤¹¡£

À°¿ôÊ¿Êýº¬¤Ç¤Î¾ÜºÙ²òÀâ

À°¿ô½ü»»¤Ç¤Î¾ÜºÙ²òÀâ

¤³¤Î¥¢¥ë¥´¥ê¥º¥à¤òÍøÍѤ·¤¿16¿Ê¡¦£²¿Ê¡¦10¿ÊÅÅÂî¤Ç¤¹¡£
À°¿ô¤À¤±¤Ç¤¹¤¬¤ª¤è¤½100Ëü·å¤Þ¤Ç·×»»¤Ç¤­¤Þ¤¹¡£


(Ãí)¤³¤³¤Ç¤ÎBigint¥¯¥é¥¹¤Ï¡¢Â¿ÇÜĹÀ°¿ô¤ò³ÊǼ¤¹¤ë²¾ÁۤΥ¯¥é¥¹¤Ç¤¢¤ê¡¢¼Âºß¤¹¤ë¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£


Tags: ¥×¥í¥°¥é¥à¥á¥â
³¤­¤òÆɤà¡ä¡ä
author : HUNDREDSOFT | - | -

¥â¥ó¥´¥á¥êÑѾê; ¥µ¥ó¥×¥ë¥³¡¼¥É

Á°²ó¡¢¥â¥ó¥´¥á¥ê¾è»» ¥µ¥ó¥×¥ë¥³¡¼¥É¤ò½ñ¤­¤Þ¤·¤¿¤¬¡¢¤è¤¯»È¤ï¤ì¤ëÑѾê;¤Ë¤Ä¤¤¤Æ¤âC++¥µ¥ó¥×¥ë¤òºÜ¤»¤Æ¤ª¤­¤Þ¤¹¡£


// ¥â¥ó¥´¥á¥êÑѾê;±é»» (a^b) mod n¤òµá¤á¤ë
// gcd(n,r) == 1 ¤È¤Ê¤ë¤³¤È¡£(n¤Ï´ñ¿ô¤Ç¤¢¤ì¤ÐÎɤ¤)
//
#ifndef MONTGOMERY_INCLUDED
#define MONTGOMERY_INCLUDED

#include "Bigint.h"

class montgomery{
public:
    montgomery(const Bigint& n) : m_n(), m_r2(), m_nb(0), m_n2(){
        m_n = n;
        // n ¤òË¡¤È¤¹¤ë
        // BitŤòÄ´¤Ù¤ë(nb)
        m_nb = n.length();

        // r: n¤è¤êÂ礭¤Ê£²¤Î¤Ù¤­
        Bigint r(1);
        r <<= m_nb;

        // r2 = r^2 mod n
        m_r2 = r * r;
        m_r2 %= n;

        // n*n2 ¢á -1 mod r
        m_n2 = 0; /* µá¤á¤ëN' */
        Bigint t = 0;
        Bigint vi = 1;
        int ni = m_nb;
        while (ni--){ /* R¤Î¥È¥Ã¥×¥Ó¥Ã¥È¤ò½ü¤¤¤¿¥Ó¥Ã¥È¿ôʬ·«¤êÊÖ¤¹ */
            if ((t & 1) == 0){
                /* ¥¼¥í¤Ë¤Ê¤Ã¤Æ¤¤¤ë¥Ó¥Ã¥È¤¬¤¢¤Ã¤¿¤é¡¢N'¤Î¤½¤ÎÉôʬ¤ò1¤Ë¤¹¤ë¡ÊN¤ÏR¤È¸ß¤¤¤ËÁǤʤΤÇɬ¤º´ñ¿ô¡Ë*/
                t += n; /* ³Ý¤±»»¤À¤¬¡¢Æó¿Ê¿ô°ì·å¤Î³Ý¤±»»¤Ê¤Î¤Ç¼Â¼Á¤Ï­¤·»» */
                m_n2 += vi; /* N'¤Î¤½¤ÎÉôʬ¤ò1¤Ë¤¹¤ë */
            }
            t >>= 1; /* ɬ¤ºÃ¼¿ô¤¬½Ð¤ë¤¬ÀÚ¤ê¼Î¤Æ¤ë */
            vi <<= 1; /* R¤Ï2¤ÎÑѤʤΤǡ¢ÀäÂÐü¿ô¤Ï½Ð¤Ê¤¤ */
        }
    }

    ~montgomery(){}

    Bigint reduction(const Bigint& t){
        // t¤Î¥â¥ó¥´¥á¥ê¥ê¥À¥¯¥·¥ç¥ó
        Bigint c = t * m_n2;
        c.hibitmask(m_nb); // mod R¤Î°ÕÌ£,(m_nb)bit°Ê¾å¤ò0¥¯¥ê¥¢
        c *= m_n;
        c += t;
        c >>= m_nb; // 1/r ¤Î°ÕÌ£
        if (c >= m_n) c -= m_n;
        return c;
    }

    // ÑѾê; a^b mod n, ¥Ð¥¤¥Ê¥êË¡¤Î²¼°Ì·å¤«¤é·×»»
    Bigint exp(const Bigint& a, const Bigint& b){
        Bigint p = reduction(a * m_r2);
        Bigint x = reduction(m_r2);
        Bigint y(b);
        while (y > 0){
            if (y & 1){
                x = reduction(x * p);
            }
            p = reduction(p * p);
            y >>= 1;
        }
        return reduction(x);
    }

protected:
    montgomery() : m_n(), m_r2(), m_nb(0), m_n2(){}

private:
    Bigint m_n;   // Ë¡(m_n)
    Bigint m_r2;  // r¤ò(m_n)¤è¤êÂ礭¤Ê£²¤Î¤Ù¤­¤È¤·¤Æ¡¢(m_r2)=(r)^2 mod n
    Bigint m_n2;  // (m_n)*(m_n2) ¢á -1 mod r ¤òËþ¤¿¤¹(m_n2)
    int    m_nb;  // (m_n)¤ÎÍ­¸úBit¿ô, Î㤨¤Ð(m_n)=5 ¤Î¤È¤­(m_nb)=3
};

#endif



wikipedia¤ÎÀâÌÀ¤Ë¤¢¤ë¤è¤¦¤Ë¥Ð¥¤¥Ê¥êË¡¤òÍѤ¤¤Æ¤¤¤Þ¤¹¡£
½é¤á¤ËË¡(n)¤È¤¹¤ë¥³¥ó¥¹¥È¥é¥¯¥¿¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹¡£
ÑѾê;¤Ï¡¢exp()¥á¥½¥Ã¥É¤Ç¹Ô¤¤¤Þ¤¹¡£


¤³¤Î¥¢¥ë¥´¥ê¥º¥à¤òÍøÍѤ·¤¿16¿Ê¡¦£²¿Ê¡¦10¿ÊÅÅÂî¤Ç¤¹¡£
À°¿ô¤À¤±¤Ç¤¹¤¬¤ª¤è¤½100Ëü·å¤Þ¤Ç·×»»¤Ç¤­¤Þ¤¹¡£


(Ãí)Bigint¥¯¥é¥¹¤Ï¡¢Â¿ÇÜĹÀ°¿ô¤ò³ÊǼ¤¹¤ë²¾ÁۤΥ¯¥é¥¹¤Ç¤¢¤ê¡¢¼Âºß¤¹¤ë¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£


Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

VC++¤Ç³ÈÄ¥ÇÜÀºÅÙ¤ò¤É¤¦¤·¤Æ¤â»È¤¤¤¿¤¤

VC++¤Ç³ÈÄ¥ÇÜÀºÅÙÉâÆ°¾®¿ôÅÀ·Á¼°¤ò¤É¤¦¤·¤Æ¤â»È¤¤¤¿¤¤

Visual Stdio¤Ç¤Ï³ÈÄ¥ÇÜÀºÅÙÉâÆ°¾®¿ô(80bit)¤¬»È¤¨¤Þ¤»¤ó¡£
long double ¤È½ñ¤¤¤Æ¤â¡¢64bitÀºÅ٤ˤʤê¤Þ¤¹¡£
Ä̾²¾¿ôÉô53bit(°ÅÌÛBit´Þ¤á)¤ÇÉÔ­¤¹¤ë¤³¤È¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤¬¡¢
¤É¤¦¤·¤Æ¤â²¾¿ôÉô64bit¤¬É¬ÍפȤ¤¤¦¾ì¹ç¤Î¥µ¥ó¥×¥ë¥¯¥é¥¹¤Ç¤¹¡£
ÍÍ¡¹¤Ê¥³¥ó¥¹¥È¥é¥¯¥¿¡¢»Í§±é»»¡¦Èæ³Ó¤Î¾¡¢FPU¤Ç¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë»°³Ñ´Ø¿ô¤äÊ¿Êýº¬¤òÆþ¤ì¤Þ¤·¤¿¡£


/* (c) Hundredsoft Corporation 2010 All rights reserved.

	Ldouble.h -  VC ³ÈÄ¥ÇÜÀºÅÙ¥¯¥é¥¹

*/

#ifndef LDOUBLE_INCLUDED
#define LDOUBLE_INCLUDED

#include <memory.h>

typedef struct {
	unsigned char d[12];
} LONG_DOUBLE_STR, *LPLONG_DOUBLE_STR;

void Ldouble_init()
{
	unsigned short fcw=0x033f;	// round to nearest, 64 bits, exceptions disabled
	__asm {
		fldcw     [fcw]
	}
}

class Ldouble
{
public:
	Ldouble() {
		memset(&m_data, 0, sizeof(m_data));
	}
	virtual ~Ldouble(){}

	Ldouble(const Ldouble& v) {
		if (this != &v){
			memcpy(&m_data, &v.m_data, sizeof(m_data));
		}
	}
	Ldouble(const __int64& v) {
		LPLONG_DOUBLE_STR m = &m_data;
		__asm {
			mov  eax, [v]
			fild qword ptr [eax]
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
	}
	Ldouble(const unsigned __int64& v) {
		__int64 t = 0x8000000000000000;
		int i;
		for (i=63; i>=0; i--, t>>=1){
			if (v & t) break;
		}
		if (i < 0){
			memset(&m_data, 0, sizeof(m_data));
		}else{
			t = v;
			t <<= 63-i; // ²¾¿ôÉô
			int ex = i + 16383; // »Ø¿ôÉô
			memcpy(&m_data, &t, sizeof(__int64));
			*(int*)&m_data.d[8] = ex;
		}
	}
	Ldouble(const int& v) {
		LPLONG_DOUBLE_STR m = &m_data;
		__asm {
			mov  eax, [v]
			fild dword ptr [eax]
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
	}
	Ldouble(const unsigned int& v) {
		__int64 i = v;
		LPLONG_DOUBLE_STR m = &m_data;
		__asm {
			lea  eax, [i]
			fild qword ptr [eax]
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
	}
	Ldouble(const short& v) {
		LPLONG_DOUBLE_STR m = &m_data;
		int i = v;
		__asm {
			lea  eax, [i]
			fild dword ptr [eax]
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
	}
	Ldouble(const unsigned short& v) {
		LPLONG_DOUBLE_STR m = &m_data;
		int i = v;
		__asm {
			lea  eax, [i]
			fild dword ptr [eax]
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
	}
	Ldouble(const char& v) {
		LPLONG_DOUBLE_STR m = &m_data;
		int i = v;
		__asm {
			lea  eax, [i]
			fild dword ptr [eax]
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
	}
	Ldouble(const unsigned char& v) {
		LPLONG_DOUBLE_STR m = &m_data;
		int i = v;
		__asm {
			lea  eax, [i]
			fild dword ptr [eax]
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
	}
	Ldouble(const double& v) {
		LPLONG_DOUBLE_STR m = &m_data;
		__asm {
			mov  eax, [v]
			fld  qword ptr [eax]
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
	}
	Ldouble& operator=(const Ldouble& v){
		if (this != &v){
			memcpy(&m_data, &v.m_data, sizeof(m_data));
		}
		return *this;
	}

	// Unary -								
	Ldouble operator-(){
		Ldouble v = *this;
		v.m_data.d[9] ^= 0x80;
		return v;
	}
	Ldouble operator++(){
		LPLONG_DOUBLE_STR m = &m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fld1
			fadd
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
		return *this;
	}
	Ldouble operator++(int){
		Ldouble v = *this;
		LPLONG_DOUBLE_STR m = &m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fld1
			fadd
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
		return v;
	}
	Ldouble operator--(){
		LPLONG_DOUBLE_STR m = &m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fld1
			fsub
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
		return *this;
	}
	Ldouble operator--(int){
		Ldouble v = *this;
		LPLONG_DOUBLE_STR m = &m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fld1
			fsub
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
		return v;
	}

	// Binary operator +=, -=, *=, /=
	Ldouble& operator+=(const Ldouble& v){
		LPLONG_DOUBLE_STR m = &m_data;
		LPLONG_DOUBLE_STR mv = (LPLONG_DOUBLE_STR)&v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			mov  eax, [mv]
			fld  tbyte ptr [eax]
			fadd
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
		return *this;
	}
	Ldouble& operator-=(const Ldouble& v){
		LPLONG_DOUBLE_STR m = &m_data;
		LPLONG_DOUBLE_STR mv = (LPLONG_DOUBLE_STR)&v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			mov  eax, [mv]
			fld  tbyte ptr [eax]
			fsub
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
		return *this;
	}
	Ldouble& operator*=(const Ldouble& v){
		LPLONG_DOUBLE_STR m = &m_data;
		LPLONG_DOUBLE_STR mv = (LPLONG_DOUBLE_STR)&v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			mov  eax, [mv]
			fld  tbyte ptr [eax]
			fmul
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
		return *this;
	}
	Ldouble& operator/=(const Ldouble& v){
		LPLONG_DOUBLE_STR m = &m_data;
		LPLONG_DOUBLE_STR mv = (LPLONG_DOUBLE_STR)&v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			mov  eax, [mv]
			fld  tbyte ptr [eax]
			fdiv
			mov  eax, [m]
			fstp tbyte ptr [eax]
		}
		return *this;
	}

	// compare
	// this <  v: -
	// this == v: 0
	// this >  v: +
	int comp(const Ldouble& v) const{
		LPLONG_DOUBLE_STR m = (LPLONG_DOUBLE_STR)&m_data;
		LPLONG_DOUBLE_STR mv = (LPLONG_DOUBLE_STR)&v.m_data;
		short sts;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			mov  eax, [mv]
			fld  tbyte ptr [eax]
			lea  eax, [sts]
			fcompp
			fnstsw word ptr [eax]
		}
		return ((sts & 0x4100) - 1) ^ 0x3fff;
	}
	bool operator==(const Ldouble& v) const{
		return (comp(v) == 0);
	}
	bool operator!=(const Ldouble& v) const{
		return (comp(v) != 0);
	}
	bool operator<(const Ldouble& v) const{
		return (comp(v) < 0);
	}
	bool operator<=(const Ldouble& v) const{
		return (comp(v) <= 0);
	}
	bool operator>(const Ldouble& v) const{
		return (comp(v) > 0);
	}
	bool operator>=(const Ldouble& v) const{
		return (comp(v) >= 0);
	}

	// cast
	operator double() {
		LPLONG_DOUBLE_STR m = (LPLONG_DOUBLE_STR)&m_data;
		double t;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fstp qword ptr [t]
		}
		return t;
	}
	operator int() {
		LPLONG_DOUBLE_STR m = (LPLONG_DOUBLE_STR)&m_data;
		double t;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fstp qword ptr [t]
		}
		return (int)t;
	}

	//friend Binary operator	 +,-,*,/
	friend  const Ldouble operator+(const  Ldouble&a, const Ldouble&b){
		Ldouble p(a);
		p += b;
		return p;
	}
	friend  const Ldouble operator-(const  Ldouble&a, const Ldouble&b){
		Ldouble p(a);
		p -= b;
		return p;
	}
	friend  const Ldouble operator*(const  Ldouble&a, const Ldouble&b){
		Ldouble p(a);
		p *= b;
		return p;
	}
	friend  const Ldouble operator/(const  Ldouble&a, const Ldouble&b){
		Ldouble p(a);
		p /= b;
		return p;
	}


	LONG_DOUBLE_STR	m_data;
};

namespace LD {
	Ldouble abs(const Ldouble& s){
		Ldouble v(s);
		v.m_data.d[9] &= 0x7f;
		return v;
	}

	Ldouble sin(const Ldouble& s){
		Ldouble v(s);
		LPLONG_DOUBLE_STR m = &v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fsin
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble cos(const Ldouble& s){
		Ldouble v(s);
		LPLONG_DOUBLE_STR m = &v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fcos
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble tan(const Ldouble& s){
		Ldouble v(s);
		double t;
		LPLONG_DOUBLE_STR m = &v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fptan
			lea  ebx, [t]
			fstp qword ptr [ebx]
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble atan(const Ldouble& s){
		Ldouble v(s);
		LPLONG_DOUBLE_STR m = &v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fld1
			fpatan
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble atan2(const Ldouble& x, const Ldouble& y){
		Ldouble v(y);
		LPLONG_DOUBLE_STR xm = (LPLONG_DOUBLE_STR)&x.m_data;
		LPLONG_DOUBLE_STR vm = &v.m_data;
		__asm {
			mov  eax, [xm]
			fld  tbyte ptr [eax]
			mov  eax, [vm]
			fld  tbyte ptr [eax]
			fpatan
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble sqrt(const Ldouble& s){
		Ldouble v(s);
		LPLONG_DOUBLE_STR m = &v.m_data;
		__asm {
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fsqrt
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble pi(){
		Ldouble v;
		LPLONG_DOUBLE_STR m = &v.m_data;
		__asm {
			mov  eax, [m]
			fldpi
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble log(const Ldouble& s){
		Ldouble v(s);
		LPLONG_DOUBLE_STR m = &v.m_data;
		__asm {
			fldln2
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fyl2x
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble log10(const Ldouble& s){
		Ldouble v(s);
		LPLONG_DOUBLE_STR m = &v.m_data;
		__asm {
			fldlg2
			mov  eax, [m]
			fld  tbyte ptr [eax]
			fyl2x
			fstp tbyte ptr [eax]
		}
		return v;
	}

	Ldouble exp(const Ldouble& s){
		Ldouble v(s);
		LPLONG_DOUBLE_STR m = &v.m_data;
		double half = 0.5;
		bool sign = ((m->d[9] & 0x80) != 0);
		m->d[9] &= 0x7f;

		__asm {
			fldl2e                 // log2e
			mov  eax, [m]
			fld  tbyte ptr [eax]   // log2e, v
			fmul                   // log2e*v
			fld  st(0)             // log2e*v, log2e*v
			lea  ebx, [half]
			fld  qword ptr [ebx]   // log2e*v, log2e*v, 0.5
			fsub                   // log2e*v, log2e*v-0.5
			frndint                // log2e*v, (int)(log2e*v-0.5)
			fxch                   // (int)(log2e*v-0.5), log2e*v
			fsub  st(0), st(1)     // (int)(log2e*v-0.5), log2e*v - (int)(log2e*v-0.5)
			f2xm1                  // (int)(log2e*v-0.5), 2^(log2e*v - (int)(log2e*v-0.5))-1
			fld1                   // (int)(log2e*v-0.5), 2^(log2e*v - (int)(log2e*v-0.5))-1, 1
			fadd                   // (int)(log2e*v-0.5), 2^(log2e*v - (int)(log2e*v-0.5))
			fscale                 // (int)(log2e*v-0.5), 2^(log2e*v - (int)(log2e*v-0.5)) * 2^(int)(log2e*v-0.5)
			fstp tbyte ptr [eax]   // (int)(log2e*v-0.5)
			fstp qword ptr [ebx]   // 
		}

		if (sign){
			__asm {
				fld1
				mov  eax, [m]
				fld  tbyte ptr [eax]
				fdiv
				fstp tbyte ptr [eax]
			}
		}
		return v;
	}

	Ldouble pow(const Ldouble& x, const Ldouble& y){
		Ldouble u(x),v(y);
		LPLONG_DOUBLE_STR mx = &u.m_data;
		LPLONG_DOUBLE_STR m = &v.m_data;
		double half = 0.5;
		bool xsign = ((mx->d[9] & 0x80) != 0);
		bool ysign = ((m->d[9] & 0x80) != 0);
		if (xsign){
			int ny = (int)v;
			Ldouble t = ny;
			if (t != y){
				throw "Invalid value.";
			}
			xsign = (ny & 1) ? true : false;
		}
		mx->d[9] &= 0x7f;
		m->d[9] &= 0x7f;

		__asm {
			fld1                   // 1
			mov  eax, [mx]
			fld  tbyte ptr [eax]   // 1, x
			fyl2x                  // log2x
			mov  eax, [m]
			fld  tbyte ptr [eax]   // log2x, v
			fmul                   // log2x*v
			fld  st(0)             // log2x*v, log2x*v
			lea  ebx, [half]
			fld  qword ptr [ebx]   // log2x*v, log2x*v, 0.5
			fsub                   // log2x*v, log2x*v-0.5
			frndint                // log2x*v, (int)(log2x*v-0.5)
			fxch                   // (int)(log2x*v-0.5), log2x*v
			fsub  st(0), st(1)     // (int)(log2x*v-0.5), log2x*v - (int)(log2x*v-0.5)
			f2xm1                  // (int)(log2x*v-0.5), 2^(log2x*v - (int)(log2x*v-0.5))-1
			fld1                   // (int)(log2x*v-0.5), 2^(log2x*v - (int)(log2x*v-0.5))-1, 1
			fadd                   // (int)(log2x*v-0.5), 2^(log2x*v - (int)(log2x*v-0.5))
			fscale                 // (int)(log2x*v-0.5), 2^(log2x*v - (int)(log2x*v-0.5)) * 2^(int)(log2x*v-0.5)
			fstp tbyte ptr [eax]   // (int)(log2x*v-0.5)
			fstp qword ptr [ebx]   // 
		}

		if (ysign){
			__asm {
				fld1
				mov  eax, [m]
				fld  tbyte ptr [eax]
				fdiv
				fstp tbyte ptr [eax]
			}
		}
		if (xsign){
			m->d[9] |= 0x80;
		}
		return v;
	}
} // end of namespace

#endif

Ldouble¥¯¥é¥¹¤ò»È¤¦Á°¤Ë¡¢Ldouble_init()¤ò¸Æ¤Ó½Ð¤·¤Æ¡¢FPU¤Ë³ÈÄ¥ÇÜÀºÅÙ¤ò»Ø¼¨¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¤³¤Î¥³¡¼¥É¤ÏÆ°ºî¤·¤Þ¤¹¤¬¡¢¤¢¤Þ¤ê®¤¯¤¢¤ê¤Þ¤»¤ó¡£
¼Â¹Ô®Å٤ˤĤ¤¤Æ¤Ï¥³¥ó¥Ñ¥¤¥é¤¬³ÈÄ¥ÇÜÀºÅÙ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¯¤ì¤Ê¤¤¤È¡¢¤É¤¦¤Ë¤â¤Ê¤ê¤Þ¤»¤ó¡£
¼Â¹Ô®ÅÙ¤ò¤½¤ì¤Û¤Éµá¤á¤Æ¤¤¤Ê¤¤¤¬¡¢²¾¿ôÉô64bit¤ÎÀºÅÙ¤¬É¬ÍפǤ¢¤ë¤«¡¢
ºÇÂçÃͤ¬10¿Ê¤Ç300·å°Ê¾å¤Ë¤Ê¤ë¾ì¹ç¡Ê³ÈÄ¥ÇÜÀºÅ٤ǤϤª¤è¤½5000·å¤Þ¤Ç²Äǽ¡Ë¤Ë¤Î¤ßÍ­¸ú¤Ç¤¹¡£
Win32¥¢¥×¥ê¤Ç³ÈÄ¥ÇÜÀºÅÙ·×»»¤ò¹Ô¤¤¡¢Æ±»þ¤Ë¼Â¹Ô®ÅÙ¤âµá¤á¤ë¤Ê¤é¡¢VC°Ê³°¤Î¥³¥ó¥Ñ¥¤¥é(C++ BuilderÅù)¤òÍøÍѤ·¤¿Êý¤¬Îɤ¤¤Ç¤·¤ç¤¦¡£




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -

¿ÇÜĹ¥µ¥ó¥×¥ë¥¢¥×¥ê

¿·å¤Î½ü»»¤äÊ¿Êýº¬·×»»¤ò¼ÂÁõ¤·¤¿¥µ¥ó¥×¥ë¤Î16¿Ê¡¦£²¿Ê¡¦10¿ÊÅÅÂî¤Ç¤¹¡£
À°¿ô¤À¤±¤Ç¤¹¤¬¤ª¤è¤½100Ëü·å¤Þ¤Ç·×»»¤Ç¤­¤Þ¤¹¡£




¾è»»¤Ï¡¢¼Â¿ôFFT¤ÈKaratsubaË¡¤òÁȤ߹ç¤ï¤»¤Æ¤¤¤Þ¤¹¡£
¤³¤ÎÆâ¡¢¼Â¿ôFFT¤Ë¤Ï¡¢µþÂç¤ÎÂ籺Çî»Î¤ÎDFT¥³¡¼¥É(fftsg.c)¤Î°ìÉô¤òFPU²½¤·¤Æ»È¤Ã¤Æ¤¤¤Þ¤¹¡£
VC++¤À¤È³ÈÄ¥ÇÜÀºÅ٤Πlong double ¤¬»È¤¨¤Ê¤¤¤¿¤á¡¢¤Ç¤­¤ë¤À¤±FPU¤ò»È¤Ã¤ÆÀºÅÙ¤ò¹â¤á¤Æ¤¤¤Þ¤¹¡£
ÀºÅÙ¤¬¾å¤¬¤ë¤È°ìÅ٤˾軻¤Ç¤­¤ë·å¿ô¤¬¾å¤¬¤ê¡¢±þÅúÀ­¤¬¸þ¾å¤·¤Þ¤¹¡£
¤³¤Î¤È¤­¤ÎÀºÅ٤ˤĤ¤¤Æ¤Ï ¡Ö(*1)FFT¿ÇÜĹ¾è»»´ï¤ÎVLSIÀß·×¡× ¤ò»²¹Í¤Ë¡¢ºÇÂçÃͤɤ¦¤·¤Î¾è»»¤¬ºÇÂç¤Î¸íº¹¤òÍ¿¤¨¤ë¤È²¾Äꤷ¡¢£±Å٤˹Ԥ¨¤ëFFT¾è»»·å¿ô¤ò·èÄꤷ¤Æ¤¤¤Þ¤¹¡£
¤Þ¤¿¡¢£²¿Ê¢ª£±£°¿ÊÊÑ´¹¤Ë¤âFFT¾è»»¤¬É¬Íפˤʤê¤Þ¤¹¡£
¤³¤ì¤Ë¤Ï¿ÀÆàÀ²ÊÂç³Ø Ê¿»³Çî»Î¤Î¡Ö(*2)ʬ³äÅý¼£Ë¡¤Ë¤è¤ë¿ÇÜű黻¤Î¹â®²½¡×¤ò»²¹Í¤Ë¤·¤Þ¤·¤¿¡£


(*1) Ìðºê½Ó»Ö, °¤Éô¸øµ±: ¡ÖFFT ¿ÇÜĹ¾è»»´ï¤ÎVLSI À߷ס×, ÆüËܱþÍÑ¿ôÍý³Ø²ñÏÀʸ»ï, Vol.15, No.3, pp.385-401 (2005-9)

(*2) Ê¿»³¹°: ¡Öʬ³äÅý¼£Ë¡¤Ë¤è¤ë¿ÇÜű黻¤Î¹â®²½ (¿ô¼°½èÍý¤Ë¤ª¤±¤ëÍýÏÀ¤È±þÍѤ覵æ)¡×, ¿ôÍý²òÀϸ¦µæ½ê¹ÖµæÏ¿ (2000), 1138: 247-255





Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -