2012-01-01ãã1å¹´éã®è¨äºä¸è¦§
ä»åã¯gihyo.jpã®é£è¼"ã¯ãããã æ©æ¢°å¦ç¿"ã®ç¬¬11å "ç·å½¢å帰ãå®è£ ãã¦ã¿ãã"(http://gihyo.jp/dev/serial/01/machine-learning/0011)ããã£ã¦ã¿ã¾ãããhttp://uhiaha888.com/machine_learnings/linear_regression.htmlç¹åãä¸ããããã¨ãã«ãå¤é å¼â¦
æè¿ã¯æ©æ¢°å¦ç¿ã¨ãããªãã ä½ã£ãWebãµã¤ãããããããã¨ã«ã¯ã¾ã£ã¦ããã®ã§ããµã¤ãä¸ã§æ©æ¢°å¦ç¿ã®ãµã³ãã«ãåããã¦ã¿ã¾ãããhttp://uhiaha888.com/machine_learnings/bayesian_filter.htmlã¨ãã£ã¦ãgihyo.jpã®é£è¼ http://gihyo.jp/dev/serial/01/maâ¦
http://uhiaha888.com/ã¾ã ä½ãç¡ãã§ããããªããããä½æã«å¿ è¦ã ã£ãã»ã¨ãã©ã®ç¥èã¯ãããã¤ã³ã¹ãã¼ã«ããå¦ã¹ãã®ãé©ãã§ããã
Linuxã使ã£ã¦ããã¨ãã¯xmonadã使ã£ã¦ãã¾ããã"Windowsã«ã¯ã¿ã¤ã«åã¦ã£ã³ãã¦ããã¼ã¸ã£ã¯ãªããï¼"ã£ã¦ããæ å ±ãã©ã£ãã§ã¿ãã®ãéµåã¿ã«ãã¦"ãã£ãã¼ãªãã®ãã¼"ã¨æã£ã¦ããã¼ãªãã§ãã®ã¾ã¾ä½¿ã£ã¦ãã¾ããããæ¨æ¥ä½¿ããããªãã®ãè¦ã¤ããã®ã§â¦
ä»åã¯algorithmã®ï¼åç®ã§ãã ä»æ¥ã®ãµã³ãã«ã§ä½¿ã£ã¦ãã¡ã½ããã¯ã©ãã使ã£ããã¨ç¡ãã£ãã§ãã æ®æ®µã®éçºã§ã"ããï¼ãããåºæ¥ãé¢æ°ãalgorithmã«å ¥ã£ã¦ãã¯ãã ï¼"ã£ã¦ãªããã¨ãç®æ¨ãªã®ã§ããã®èª¿åã§ã©ãã©ããã£ã¦ããããè¯ãã§ããã #incluâ¦
ä»åããalgorithmãæ°åã«åãã¦ãã£ã¦ããããã¨æãã¾ããå人çã«ã¯for_eachã¨ã©ã ãå¼ã®çµåãã大好ãã§ãçµæ§è¯ã使ãã®ã§ããsearchã¨ãsort以å¤ã¯ãããªã«ä½¿ã£ããã¨ããªãã®ã§ãããã試ãã¦ããããã¨æãã¾ãã #include <iostream> #include <algorithm> #include <vector> #</vector></algorithm></iostream>â¦
ä»åã¯listã§ãã #include <iostream> #include <list> int main() { std::list<int> l; // vectoråæ§push_back()ã§è¦ç´ ã追å ã§ãã l.push_back(1); l.push_back(2); // push_front()ã§ã追å å¯è½ l.push_front(3); l.push_front(4); std::cout << "è¦ç´ ã追å " << std::endl;</int></list></iostream>â¦
ä»æ¥ãvectorã§ãã #include <iostream> #include <vector> int main() { std::vector<int> v; for(int i = 0; i < 5; ++i) v.push_back(i); v.erase(v.begin() + 1); // å é ã®æ¬¡ã®è¦ç´ ãåé¤ãã std::cout << "å é ã®æ¬¡ãåé¤" << std::endl; for(std::vector<int>::iterator it = v.</int></int></vector></iostream>â¦
第ä¸åã¯vectorãåãä¸ãããã¨æãã¾ããã¾ãã¯åºæ¬çãªä½¿ãæ¹ã #include <iostream> #include <vector> int main() { std::vector<int> v; v.push_back(1); // push_backã§è¦ç´ ãæ«å°¾ã«è¿½å v.push_back(2); v.push_back(3); std::cout << std::endl << "ã¤ãã¬ã¼ã¿ã§ã¢ã¯ã»ã¹" <</int></vector></iostream>â¦
ååã®ãã¶ã¤ã³ãã¿ã¼ã³ä¼ç»ã§ãæ¯æ¥å°ããã¤ã§ããªããæ¸ãã£ã¦ã®ã¯ãããªãã¨æã£ãã®ã§ç¶ãã¾ããä»æ¥ããã¯STLã®ç°¡åãªãµã³ãã«ãæ¸ãã¦ä½¿ãæ¹ãå¦ãã§ãããã¨ãããã¾ããæ®æ®µvectorãä¸é¨ã®algorithmã®é¢æ°ã¯ä½¿ã£ãããã¾ããã"list? deque? ãããâ¦
ã¤ãã«ä»åã§ãã®ä¼ç»ãæå¾ã§ãããæå¾ã¯Iteratorãã¿ã¼ã³ã§ãããªããçç±ããã£ã¦Iteratorãæå¾ã«æã£ã¦ãããã¨ããã¨ãããããããã§ããªãã¦ããªãããã§ããªãã¦ãããã¨ããã®ã¯ãIteratorãã¿ã¼ã³ãC++ã§å®è£ ããã¨ããã§ã»ã¼æå³ãç¡ãã¨ãããâ¦
èå³æ·±ãã¯ããããå¦ãã§ããã£ãã¨ã¯æãããã©â¦ãèªåãå人çã«ä½ãã½ããã«æ¡å¼µç¨ã®ã¹ã¯ãªããçãªã®ãã¤ãããã¨ãããã http://code.google.com/p/chibi-scheme/ ãã®è¾ºã®ããããã使ããªããã£ã¦ã¾ãèãããã èªåã§ã¡ããã¨ä½ããªããã£ã¨ããâ¦
ã³ãã³ããã¿ã¼ã³ã§ããã¢ã³ãã¥ãªãã¥ã«ã¤ããã¾ããã¨ããããå¼ã³åºãæã¨å¥ã®ã¿ã¤ãã³ã°ã§å¿ è¦ãªãã©ã¡ã¿ã渡ãã¦ããã¦ã使ãã¨ãã¯ä½ãç¥ããã§ãExecute()ãå¼ã³åºãã°ãªãã¸ã§ã¯ãå´ã§è¯ãæãã«å®è¡ãã¦ãããã£ã¦ã®ãããã£ã¦ã¯ãªãã§ãããhttp:/â¦
ä»åã¯Proxyãã¿ã¼ã³ã§ããä»åã®ãµã³ãã«ã ã¨ãªããã¡ãªãããç¡ãæãã§ããããªãããä¸æç®ããã¶ãããã¨ã«ãã£ã¦ãªãã¸ã§ã¯ãã®çæã®ã¿ã¤ãã³ã°ãé ãããããã¢ã¯ã»ã¹æ¨©ãè¨å®ãããã¨ãããããã§ãããã£ã¦ãã¨ã¿ããã§ããæ±ç¨çãªåæ½è±¡çã§ããâ¦
ä»åã¯FlyWeightãã¿ã¼ã³ã§ãã ã¨ã£ã¦ãSingletonã£ã½ãã§ããããã ãä¸åº¦çæããã¤ã³ã¹ã¿ã³ã¹ãSingletonã§ã¯ã¤ã³ã¹ã¿ã³ã¹ãã®ãã®ãstaticã¨ãã¦æã£ã¦ããã®ã«å¯¾ããFlyWeightã§ã¯ä»åã®ãµã³ãã«ã ã¨CharacterFactoryãã³ã¬ã¯ã·ã§ã³ã¨ãã¦æã£ã¦ãã¾ãâ¦
C#ã®ã³ã¼ãã ã¨.hã¨.cppã«åããã¿ãããªãã¨ã¯ãªãã£ã½ãã®ã§ãã¨ããããããªãã¨ããµã³ãã«ã³ã¼ãã§ã¯ãããããã¨ã¯ãªãã®ã§ãªãã¨ãªãããã£ã½ãC++ã§æ¸ãã¦ãã¦ããã¾ã¾ã§ã»ã¼åé¡ãªãã£ãã®ã§ãã®ã¾ã¾ã ã£ããã§ãããä»åã¯ãããã¨åããã»ããããâ¦
ãªãã¸ã§ã¯ãã®ç¶æ ãä¿åãããã£ã¦ãã¤ã§ãããä»åã®ãµã³ãã«ã§å¾®å¦ãªã®ã¯name_ã¨ãphone_ã¨ãããã¶ã£ã¡ãã£ã¦ãã¨ããã§ãããä»åã®å ´åMementoã¯ã©ã¹ããã ã®ãã¼ã¿ãã«ãã¯ã©ã¹ãªãã ãããSalesProspectã¯ã©ã¹ã®ã¡ã³ãã¨ãã¦Mementoãªãã¸ã§ã¯ãã®â¦
ãã®ä¼ç»ã®è¯ãç¹ã¯ãããã¾ãèããªãã¦ãã³ã¼ããC++ã«æ¸ãç´ãã¦ããã¡ã«ãªãã¨ãªã"ãã¼ãããããã¨ã"ã£ã¦ãªãã®ã§ãä»äºãçµãã£ã¦ããå¯ãåã«ãã£ã£ã¦ãã£ã¦ãã¾ããç¹ã§ããè¯ããªãç¹ã¯ããã¾ãèããªããããããããããã調ã¹ãã»ã©ã«ã¯å æ°ãâ¦
C++ã§ãã¶ã¤ã³ãã¿ã¼ã³ãå®è£ ãã¦ãããã 第15å ChainOfResponsibilityãã¿ã¼ã³
ä»åã¯ChainOfResponsibilityãã¿ã¼ã³ã§ãããããã¾ããçãªãã¨ã§ããããï¼ã¾ããApproverã¯ã©ã¹ã®åãSetSuccessor()ã¡ã½ããã§éç¶ã«ã¤ãªãã¾ããããããããã®éã«å¯¾ãã¦ã²ã¨ã¤ãã¤å¼æ°ã¨ãã¦æ¸¡ãããPurchaseãªãã¸ã§ã¯ããåãå ¥ãããå¦ããProcesâ¦
ä»åã¯ãVisitorãã¿ã¼ã³ã§ãã åãã¦è¦ãã¨ãã¯å®å ¨ã«"?"ã§ããããä»è¦ãã¨å°ãé¢ç½ãã§ããã訪åããããªãã¸ã§ã¯ã(ä¾ã§ã¯Elementã¤ã³ã¿ãã§ã¼ã¹ã®å®è£ ã§ããEmployeeã¨ã)ã®ã³ã¬ã¯ã·ã§ã³(Employees)ã«ã訪åãããªãã¸ã§ã¯ã(IVisitorã¤ã³ã¿ãã§ã¼ã¹â¦
ä»åã¯Compositeãã¿ã¼ã³ã§ããè¦ã¯ã"ãã©ã«ãã¯ãã©ã«ãããã¡ã¤ã«ãä¸ç·ããã«æ ¼ç´ã§ããã"çãªãã¨ã§ãããä»åã¯PrimitiveElementã¯ç´ç·ã¨ãåã¨ãã®åç´ãªå³å½¢ã§ãCompositeElementã¯ãããã®åç´ãªå³å½¢ããããçµã¿åãããCompositeElementãçµã¿åâ¦
ãã£ã¨ååãã¾ããããä»åã¯Builderãã¿ã¼ã³ã§ãããªãã¸ã§ã¯ãã®çæã«é¢ãããã¿ã¼ã³ã¨ãã¦ããã§ã«AbstractFactoryãã¿ã¼ã³ãFactoryMethodãã¿ã¼ã³ãæ±ãã¾ããããããããã©ã£ã¡ãã¨ããã¨ã"ããã¤ã³ã¿ãã§ã¼ã¹ã®ã©ã®å®è£ ãå®ä½åããã"çãªãã¨ã«â¦
Prototypeãã¿ã¼ã³ã¯ãåãã¦ç¥ã£ãã¨ããã´ãã¨ãã¾ããã§ãããããã¾èªã¿ç´ãã¦ãã´ãã¨ãã¾ããã§ãããä»åã®ä¾ã§è¨ãã°ãColorPrototypeã¤ã³ã¿ãã§ã¼ã¹ã®ä»»æã®åã¯ã©ã¹ã®ã³ãã¼ã³ã³ã¹ãã©ã¯ã¿ããåã¯ã©ã¹ã®ç¨®é¡ãç¥ããªãã¦ãclone()ã¡ã½ããããå¼â¦
é©åãªå®è£ ã®éåãå®ä½åããã¨ããç®çã®ãã¿ã¼ã³ã§ãAbstractFactoryã¨ããã¾ãå¤ããã¾ãããAbstractFactoryã¯å§è²ã§è¡ã£ã¦ãããã¨ããFactoryMethodãã¿ã¼ã³ã§ã¯ç¶æ¿ã使ã£ã¦è¡ã£ã¦ãããã¨èãã¦è¯ããã ã¨æãã¾ãããããã¯AbstractFactory!ãã£ã¡â¦
Singletonãã¿ã¼ã³ã¯é常ã«ããããããããããªãã§ãããããModern C++ Designã«ã¯å¥ã®æ¹æ³ã使ã£ãæ¸ãæ¹ã¿ãããªã®ãã®ã£ã¦ã¾ããããhttp://www.dofactory.com/Patterns/PatternSingleton.aspx#_self2ä»åã¯æ®éã«staticãªã¡ã³ãã使ã£ãå®è£ ã§ããhttâ¦
åãã¦ãã¶ã¤ã³ãã¿ã¼ã³ãå¦ãã ã¨ããä¸çªç解ããããã¨æããã®ãTemplateMethodãã¿ã¼ã³ã§ãããä»åã®ä¾ã¯ http://www.dofactory.com/Patterns/PatternTemplate.aspx#_self2 ããã§ãããªãããã¼ã¿ãã¼ã¹ã¸ã®ã¢ã¯ã»ã¹ããã¦ã¾ãããæ¸ãç´ãããã¼ã¸ã§â¦
http://www.dofactory.com/Patterns/PatternObserver.aspx#_self2 ä»åã®ãé¡ã¯ä»ã¾ã§ã®ä¸ã§ã¯ä¸çªè¯ãæãããªã¨æãã¾ããæ ªä¾¡(Stock::price_)ãå¤ããã¨æè³å®¶(Investor)ã«éç¥(Notify)ãè¡ãã¾ãã"æ ªä¾¡ãå¤ãã£ããéç¥ããã"ã£ã¦ã®ã¯æè¬å ±éæ§ã§ããâ¦
ã¾ãä»åã®ãé¡ã§ãã http://www.dofactory.com/Patterns/PatternDecorator.aspx#_self2å³æ¸é¤¨ã§åãããããã®ã¨ããLibraryItemã¯ã©ã¹ããæ´¾çãã¦ããBookã¯ã©ã¹ã¨Videoã¯ã©ã¹ããã£ã¦ãããã«Decoratorãã¿ã¼ã³ã使ã£ã¦Borrowable(åãããã)ã¨ããæ§â¦
"å®è£ ã§ã¯ãªããã¤ã³ã¿ãã§ã¼ã¹ã«å¯¾ãã¦ããã°ã©ãã³ã°ãã" ã£ã¦ããã¨ãããã¤ã³ã¿ãã§ã¼ã¹Aã®å®è£ ãï¼ç¨®é¡ãã£ã¦ãå¥ã®ã¤ã³ã¿ãã§ã¼ã¹Bã®å®è£ ãï¼ç¨®é¡ãããã©ãä¸é¨ã®çµåãã®ã¿ã«ããæå³ããªãã¿ãããªãã¨ãå¤ããªãã¾ãããã®çµåããé½åº¦æå®ãããâ¦
"ãªãã¸ã§ã¯ãæåã®ããã"ã§ï¼ã¤ç®ã¯Strategyãã¿ã¼ã³ã§ããããå¥ã«ãã®é ã«ããªãããªããªãããã§ã¯ãªãã®ã§ãããã¨ããããä»åã¯Strategyãã¿ã¼ã³ã«ãã¾ããä»åã®ãé¡ã¯ http://www.dofactory.com/Patterns/PatternStrategy.aspx#_self2 ã§ããC++â¦