{"id":353,"date":"2016-12-26T18:11:18","date_gmt":"2016-12-27T02:11:18","guid":{"rendered":"http:\/\/wonghoi.humgar.com\/blog\/?p=353"},"modified":"2017-07-14T23:29:09","modified_gmt":"2017-07-15T07:29:09","slug":"switch-between-32-bit-and-64-bit-user-written-software-like-cvx","status":"publish","type":"post","link":"https:\/\/wonghoi.humgar.com\/blog\/2016\/12\/26\/switch-between-32-bit-and-64-bit-user-written-software-like-cvx\/","title":{"rendered":"Switch between 32-bit and 64-bit user written software like CVX"},"content":{"rendered":"<p><a href=\"http:\/\/cvxr.com\/\">CVX<\/a> is a very convenient convex optimization package that allows the user to specify the optimization objective and constraints directly instead of manually manipulating them\u00a0(by various transformations) into forms that are accepted by commonly available software like <a href=\"https:\/\/www.mathworks.com\/help\/optim\/ug\/quadprog.html\">quadprog<\/a>().<\/p>\n<p>What I want to show today is not CVX, but a technique to handle the\u00a0many different versions of the same program targeted at each system architecture (32\/64-bit, Windows\/Mac\/Linux).\u00a0Here&#8217;s a snapshot of what&#8217;s available with cvx:<\/p>\n<table width=\"321\">\n<tbody>\n<tr style=\"font-style: inherit; font-weight: inherit;\">\n<td style=\"text-align: center;\" width=\"80\">OS<\/td>\n<td style=\"text-align: center;\" width=\"49\">32\/64<\/td>\n<td style=\"text-align: center;\" width=\"63\"><span style=\"text-decoration: underline;\">mexext<\/span><\/td>\n<td style=\"text-align: center;\" width=\"129\">Download links<\/td>\n<\/tr>\n<tr style=\"font-style: inherit; font-weight: inherit;\">\n<td style=\"font-style: inherit; font-weight: inherit;\" rowspan=\"2\" width=\"80\">Linux<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"49\">32-bit<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"63\">mexglx<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"129\"><a style=\"font-style: inherit; font-weight: inherit;\" href=\"http:\/\/web.cvxr.com\/cvx\/cvx-glx.zip\">cvx-glx.zip<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"49\">64-bit<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"63\">mexa64<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"129\"><a style=\"font-style: inherit; font-weight: inherit;\" href=\"http:\/\/web.cvxr.com\/cvx\/cvx-a64.zip\">cvx-a64.zip<\/a><\/td>\n<\/tr>\n<tr style=\"font-style: inherit; font-weight: inherit;\">\n<td style=\"font-style: inherit; font-weight: inherit;\" rowspan=\"2\" width=\"80\">Mac<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"49\">32-bit<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"63\">mexmaci<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"129\"><a style=\"font-style: inherit; font-weight: inherit;\" href=\"http:\/\/web.cvxr.com\/cvx\/cvx-maci.zip\">cvx-maci.zip<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"49\">64-bit<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"63\">mexmaci64<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"129\"><a style=\"font-style: inherit; font-weight: inherit;\" href=\"http:\/\/web.cvxr.com\/cvx\/cvx-maci64.zip\">cvx-maci64.zip<\/a><\/td>\n<\/tr>\n<tr style=\"font-style: inherit; font-weight: inherit;\">\n<td style=\"font-style: inherit; font-weight: inherit;\" rowspan=\"2\" width=\"80\">Windows<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"49\">32-bit<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"63\">mexw32<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"129\"><a style=\"font-style: inherit; font-weight: inherit;\" href=\"http:\/\/web.cvxr.com\/cvx\/cvx-w32.zip\">cvx-w32.zip<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"49\">64-bit<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"63\">mexw64<\/td>\n<td style=\"font-style: inherit; font-weight: inherit;\" width=\"129\"><a style=\"font-style: inherit; font-weight: inherit;\" href=\"http:\/\/web.cvxr.com\/cvx\/cvx-w64.zip\">cvx-w64.zip<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You can download all packages for different architectures, but make a folder for each of them by their <span style=\"text-decoration: underline;\">mexext<\/span>() name. For example, 32-bit Windows&#8217;\u00a0implementation\u00a0can go under \/<span style=\"text-decoration: underline;\">mexw32<\/span>\/cvx. Then you can\u00a0programmatically initialize\u00a0the right package for say, your startup.m file:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"matlab\">run( fullfile(yourLibrary, mexext(), 'cvx', 'cvx_startup.m') );<\/pre>\n<p>I intentionally put the \/[mexext()] above \/cvx, not the other way round because if you have many different software packages and want to include them in the path, you can do it in one shot without filtering for the platform names:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"matlab\">addpath( genpath( fullfile(yourLibrary, mexext()) ) );<\/pre>\n<p>You can consider using computer(&#8216;arch&#8217;) in place of mexext(), but the names are different and you have to name your folders accordingly. For CVX, it happens to go by mexext(), so I naturally used mexext() instead.<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_353\" class=\"pvc_stats all  \" data-element-id=\"353\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>CVX is a very convenient convex optimization package that allows the user to specify the optimization objective and constraints directly instead of manually manipulating them\u00a0(by various transformations) into forms that are accepted by commonly available software like quadprog(). What I &hellip; <a href=\"https:\/\/wonghoi.humgar.com\/blog\/2016\/12\/26\/switch-between-32-bit-and-64-bit-user-written-software-like-cvx\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_353\" class=\"pvc_stats all  \" data-element-id=\"353\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[10],"tags":[],"class_list":["post-353","post","type-post","status-publish","format-standard","hentry","category-matlab"],"_links":{"self":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":3,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":563,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions\/563"}],"wp:attachment":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}