{"id":1279,"date":"2017-09-03T15:46:40","date_gmt":"2017-09-03T06:46:40","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=1279"},"modified":"2018-02-25T12:13:01","modified_gmt":"2018-02-25T03:13:01","slug":"numpy%e5%85%a5%e9%96%80-%e5%9f%ba%e6%9c%ac%e7%9a%84%e3%81%aa%e7%b7%9a%e5%bd%a2%e4%bb%a3%e6%95%b0%e8%a8%88%e7%ae%97-%e3%81%9d%e3%81%ae1-%e3%83%8e%e3%83%ab%e3%83%a0%e3%83%bb%e6%ad%a3%e8%a6%8f%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/1279","title":{"rendered":"NumPy\u5165\u9580 \u57fa\u672c\u7684\u306a\u7dda\u5f62\u4ee3\u6570\u8a08\u7b97 \u305d\u306e1 \u30ce\u30eb\u30e0\u30fb\u6b63\u898f\u5316\u30fb\u6b63\u898f\u76f4\u4ea4\u5316"},"content":{"rendered":"<p>\u3053\u306e\u30da\u30fc\u30b8\u3067\u306fNumPy\u3067\u884c\u3046\u57fa\u672c\u7684\u306a\u7dda\u5f62\u4ee3\u6570\u8a08\u7b97\u3068\u3057\u3066\u30ce\u30eb\u30e0\u30fb\u6b63\u898f\u5316\u30fb\u6b63\u898f\u76f4\u4ea4\u5316\u3092\u5b66\u7fd2\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30ce\u30eb\u30e0\u3068\u6b63\u898f\u5316<\/h2>\n<h3>\u30ce\u30eb\u30e0<\/h3>\n<p>numpy.linalg.norm\u3092\u4f7f\u7528\u3059\u308b\u3068\u30d9\u30af\u30c8\u30eb\u306e\u30ce\u30eb\u30e0\u3092\u6c42\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30d4\u30bf\u30b4\u30e9\u30b9\u6570\u306e\u5c0f\u3055\u3044\uff12\u6570\u3092\u4f7f\u7528\u3057\u305f\uff12\u6b21\u5143\u30d9\u30af\u30c8\u30eb\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport numpy as np\r\n\r\nx = np.array([3, 4])\r\nnp.linalg.norm(x)\r\n# 5.0\r\n\r\ny = np.array([33, 56])\r\nnp.linalg.norm(y)\r\n# 65.0\r\n# \r\n<\/pre>\n<p>\u659c\u8fba\u306e\u9577\u3055\u3068\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002\uff13\u6b21\u5143\u4ee5\u4e0a\u3067\u3082\u540c\u69d8\u3067\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport numpy as np\r\nx = np.array([2, 4, 4])\r\nnp.linalg.norm(x)\r\n# 6.0\r\n# \r\n<\/pre>\n<h3>\u6b63\u898f\u5316<\/h3>\n<p>numpy.linalg.norm\u3067\u30ce\u30eb\u30e0\u304c\u6c42\u307e\u308a\u307e\u3057\u305f\u3002\u9577\u3055\u3067\u5272\u308a\u7b97\u3059\u308b\u3068\u6b63\u898f\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5148\u307b\u3069\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u3055\u3089\u306b\u6b63\u898f\u5316\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport numpy as np\r\nx = np.array([2, 4, 4])\r\nnorm = np.linalg.norm(x)\r\n# 6.0\r\n\r\n# \u30ce\u30eb\u30e0\u3067\u9664\u7b97\u3057\u6b63\u898f\u5316\u3059\u308b\r\ne = x \/ norm \r\n#  array([ 0.33333333,  0.66666667,  0.66666667])\r\n\r\n# \u6b63\u898f\u5316\u3092\u78ba\u8a8d\u3059\u308b\r\nnp.linalg.norm(e)\r\n# 1.0\r\n# \r\n<\/pre>\n<p>\u6700\u7d42\u7684\u306b\u30ce\u30eb\u30e0\u304c1\u306e\u6b63\u898f\u5316\u3055\u308c\u305f\u30d9\u30af\u30c8\u30eb\u3092\u7b97\u51fa\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>\u6b63\u898f\u76f4\u4ea4\u5316<\/h2>\n<p>\u6b21\u306b\uff12\u3064\u306e\u57fa\u5e95\u30d9\u30af\u30c8\u30eb\u304c\u5f35\u308b\u30d9\u30af\u30c8\u30eb\u7a7a\u9593\u306b\u5bfe\u3057\u3001\u57fa\u5e95\u3092\u6b63\u898f\u76f4\u4ea4\u5316\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u7dda\u5f62\u4ee3\u6570\u306e\u6388\u696d\u306a\u3069\u3067\u306f\u30b0\u30e9\u30e0\u30b7\u30e5\u30df\u30c3\u30c8\u306e\u6b63\u898f\u76f4\u4ea4\u5316\u3092\u5229\u7528\u3057\u305f\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u79c1\u3082\u542b\u3081\u96e3\u5100\u3055\u308c\u305f\u65b9\u304c\u591a\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\uff1fnp.linalg.qr\u3092\u4f7f\u7528\u3059\u308b\u3068QR\u5206\u89e3\u3055\u308c\u305f\u3082\u306e\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002\u3059\u306a\u308f\u3061\u3001\u4efb\u610f\u306e\u6b63\u5247\u884c\u5217A\u304c\u76f4\u4ea4\u884c\u5217Q\u3068\u4e0a\u4e09\u89d2\u884c\u5217R\u306e\u7a4d\u306b\u5206\u89e3\u3055\u308c\u3066\u5024\u304c\u8fd4\u3055\u308c\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>3\u6b21\u5143\u30d9\u30af\u30c8\u30eb\u7a7a\u9593\u5185\u306b\u57fa\u5e95(1, 1, 0)\u3001(0, -1, 0)\u304c\u5f35\u308b\u90e8\u5206\u7a7a\u9593\uff08\u3064\u307e\u308a\uff13\u6b21\u5143\u7a7a\u9593\u4e2d\u306eXY\u5e73\u9762\uff09\u304c\u3042\u3063\u305f\u3068\u3057\u307e\u3059\u3002\u3053\u306e\u57fa\u5e95\u3092\u6b63\u898f\u76f4\u4ea4\u5316\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport numpy as np\r\n\r\n# \u57fa\u5e95(1, 1, 0)\u3001(0, -1, 0)\r\na = np.array([[1, 1], [1, -1], [0, 0]])\r\n# array([[ 1,  1],\r\n#        [ 1, -1],\r\n#        [ 0,  0]])\r\n\r\nq, r = np.linalg.qr(a)\r\nq\r\n# array([[-0.70710678, -0.70710678],\r\n#        [-0.70710678,  0.70710678],\r\n#        [-0.        , -0.        ]])\r\n\r\nr\r\n# array([[ -1.41421356e+00,   3.33066907e-16],\r\n#        [  0.00000000e+00,  -1.41421356e+00]])\r\n\r\n<\/pre>\n<p>QR\u5206\u89e3\u3055\u308c\u305f\u5024\u304c\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u3001\u5b9f\u969b\u306b\u6b63\u898f\u76f4\u4ea4\u306a\u306e\u304b\u3092\u5185\u7a4d\u3068\u30ce\u30eb\u30e0\u3092\u8a08\u7b97\u3057\u3066\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# \u4e0a\u30b5\u30f3\u30d7\u30eb\u7d9a\u304d\r\n\r\n# \u5185\u7a4d\u3092\u8a08\u7b97\u3059\u308b\r\nip = np.dot(q[0], q[1])\r\n\r\n&quot;%.10f&quot; % ip\r\n# '-0.0000000000'\r\n\r\n# \u30ce\u30eb\u30e0\u3092\u78ba\u8a8d\u3059\u308b\r\nnp.linalg.norm(q[0])\r\n# 0.99999999999999978\r\n\r\nnp.linalg.norm(q[1])\r\n# 1.0\r\n# \r\n<\/pre>\n<p>\u8aa4\u5dee\u306b\u3088\u308a\u53b3\u5bc6\u306b\u306f0\u306b\u306a\u308a\u307e\u305b\u3093\u306e\u3067\u3001\u5185\u7a4d\u306e\u65b9\u306f\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u3088\u308a\u5c0f\u6570\u70b9\u8868\u793a\u3067\u4e38\u3081\u3066\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u30da\u30fc\u30b8\u3067\u306fNumPy\u3067\u884c\u3046\u57fa\u672c\u7684\u306a\u7dda\u5f62\u4ee3\u6570\u8a08\u7b97\u3068\u3057\u3066\u30ce\u30eb\u30e0\u30fb\u6b63\u898f\u5316\u30fb\u6b63\u898f\u76f4\u4ea4\u5316\u3092\u5b66\u7fd2\u3057\u307e\u3059\u3002 \u30ce\u30eb\u30e0\u3068\u6b63\u898f\u5316 \u30ce\u30eb\u30e0 numpy.linalg.norm\u3092\u4f7f\u7528\u3059\u308b\u3068\u30d9\u30af\u30c8\u30eb\u306e\u30ce\u30eb\u30e0\u3092\u6c42\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30d4\u30bf\u30b4\u30e9\u30b9\u6570...<\/p>\n","protected":false},"author":1,"featured_media":1607,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[168],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1279"}],"collection":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/comments?post=1279"}],"version-history":[{"count":2,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1279\/revisions"}],"predecessor-version":[{"id":3517,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1279\/revisions\/3517"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/1607"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=1279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=1279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=1279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}