{"id":3980,"date":"2018-04-17T07:04:24","date_gmt":"2018-04-17T05:04:24","guid":{"rendered":"http:\/\/www.glc.us.es\/~jalonso\/exercitium\/?p=3980"},"modified":"2021-04-25T16:05:16","modified_gmt":"2021-04-25T14:05:16","slug":"matrices-de-hadamard-2018","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/matrices-de-hadamard-2018\/","title":{"rendered":"Matrices de Hadamard"},"content":{"rendered":"<p>Las <a href=\"http:\/\/bit.ly\/2vhsoGG\">matrices de Hadamard<\/a> se definen recursivamente como sigue<\/p>\n<pre lang=\"text\">\n   \u03bb> hadamard 0\n   ( 1 )\n   \n   \u03bb> hadamard 1\n   (  1  1 )\n   (  1 -1 )\n   \n   \u03bb> hadamard 2\n   (  1  1  1  1 )\n   (  1 -1  1 -1 )\n   (  1  1 -1 -1 )\n   (  1 -1 -1  1 )\n   \n   \u03bb> hadamard 3\n   (  1  1  1  1  1  1  1  1 )\n   (  1 -1  1 -1  1 -1  1 -1 )\n   (  1  1 -1 -1  1  1 -1 -1 )\n   (  1 -1 -1  1  1 -1 -1  1 )\n   (  1  1  1  1 -1 -1 -1 -1 )\n   (  1 -1  1 -1 -1  1 -1  1 )\n   (  1  1 -1 -1 -1 -1  1  1 )\n   (  1 -1 -1  1 -1  1  1 -1 )\n<\/pre>\n<p>En general, la n-\u00e9sima matriz de Hadamard, H(n), es<\/p>\n<pre lang=\"text\">\n   ( H(n-1)  H(n-1) )\n   ( H(n-1) -H(n-1) )\n<\/pre>\n<p>Definir la funci\u00f3n<\/p>\n<pre lang=\"text\">\n   hadamard :: Int -> Matrix Int\n<\/pre>\n<p>tal que (hadamard n) es la n-\u00e9sima matriz de Hadamard.<\/p>\n<p>Comprobar con QuickCheck que para todo n\u00famero natural n, el producto de la n-\u00e9sima matriz de Hadamard y su traspuesta es igual al producto de 2^n por la matriz identidad de orden 2^n.<\/p>\n<h4>Soluciones<\/h4>\n<pre lang=\"haskell\">\nimport Data.Matrix (Matrix, identity, joinBlocks, scaleMatrix, transpose)\nimport Test.QuickCheck \n\nhadamard :: Int -> Matrix Int\nhadamard 0 = identity 1\nhadamard n = joinBlocks (a, a, a, b)\n  where a = hadamard (n-1)\n        b = scaleMatrix (-1) a\n\n-- La propiedad es\nprop_Hadamard :: (Positive Int) -> Bool\nprop_Hadamard (Positive n) =\n  h * transpose h == scaleMatrix (2^n) (identity (2^n))\n  where h = hadamard n\n\n-- La comprobaci\u00f3n es\n--    \u03bb> quickCheckWith (stdArgs {maxSize=7}) prop_Hadamard\n--    +++ OK, passed 100 tests.\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Las matrices de Hadamard se definen recursivamente como sigue \u03bb> hadamard 0 ( 1 ) \u03bb> hadamard 1 ( 1 1 ) ( 1 -1 ) \u03bb> hadamard 2 ( 1 1 1 1 ) ( 1 -1 1 -1 ) ( 1 1 -1 -1 ) ( 1 -1 -1 1 ) \u03bb> hadamard&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[4],"tags":[446,447,42,448,68],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/3980"}],"collection":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/comments?post=3980"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/3980\/revisions"}],"predecessor-version":[{"id":4003,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/3980\/revisions\/4003"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/media?parent=3980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/categories?post=3980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/tags?post=3980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}