YALL1 下载、安装以及运行

任务在身,碰一下这个,没有搞过Matlab外部库安装的我,这次亲自写个小白一样的心路历程也不错。
电脑版本:Microsoft Windows [版本 10.0.17134.165] 64位
Matlab版本:R2016b

官网下载:https://www.caam.rice.edu//~optimization/L1/YALL1/.download.html
一般是下两个东西:
1. 工具箱本体
2. 说明书

在工具箱本体有个Readme.txt,打开之后,发现:
First run "Run_me_1st" from this directory
老老实实打开matlab,然后运行
这里写图片描述
遇到一个这样的提示,简单查了一下,按照两个网页都提到的,这里选择“添加到路径”试试。
https://blog.csdn.net/cckit/article/details/41500513
https://blog.csdn.net/RobertChenGuangzhi/article/details/50604560
好,出来的结果正式我们想要的
这里写图片描述
然后在运行Demo文件之前,Readme中仍然提示:SPGl1 and l1_ls两个第三方codes需要安装。
去到官网:https://www.cs.ubc.ca/~mpf/spgl1/download.html,选择下载Version 1.9
按照官网提示的步骤走,如果路径名中含有空格,在该文件夹名字左右添加引号,应该就可以解决问题,如:addpath D:/'Computer Science'/matlab/spgl1-1.9
然后遇到错误:

>> spgsetup
Could not compile oneProjector.You can still use the slower ".m" version 错误使用 rethrow
输入必须为结构体。

出错 spgsetup (line 39)
    rethrow(lasterr);

查看了一下代码:

try
    cd('private')
    mex oneProjectorMex.c oneProjectorCore.c heap.c -output oneProjectorMex -DNDEBUG
    fprintf('Successfully compiled oneProjector.\n');
    cd(root)
catch
    cd(root)
    fprintf('Could not compile oneProjector.');
    fprintf('You can still use the slower ".m" version.');
    rethrow(lasterr);
end

亲自操作了一下,在mex这步的时候遇到了一个错误信息:

错误使用 mex
未找到支持的编译器或 SDK。您可以安装免费提供的 MinGW-w64 C/C++ 编译器;请参阅安装 MinGW-w64 编译器。有关更多选项,请访问
http://www.mathworks.com/support/compilers/R2016b/win64.html

所以应该是我没有个给我的matlab配置一个编译器,虽然之前有下过Qt,但是感觉如果引那里的编译器太复杂了,所以这里直接从网上下载:http://tdm-gcc.tdragon.net/download
按照网页:https://blog.csdn.net/fan_pgm_v/article/details/79538528的提示

编译器配置完成之后,再次运行,就成功了:

>> cd(root)
>> spgsetup
使用 'MinGW64 Compiler (C)' 编译。
MEX 已成功完成。
Successfully compiled oneProjector.

spgdemo运行起来也没有问题了

然后是l1_ls,这个也是直接去官网,然后下载运行程序就行了。
https://web.stanford.edu/~boyd/l1_ls/,竟然是boyd编的,呀厉害了。


运行无误之后,开始看YALL1的demo,然后上来就是一个错误:

未定义函数或变量 'pdct_operator'。

出错 demo_1d (line 32)
        A = feval(op_A,picks,perm);

pdct_operator应该是这个子文件夹Utilities的一个文件,如果没有找到的话,应该是path没有添加,重新把YALL1这个文件及其子文件夹都添加了,然后错误继续报:

未定义函数或变量 'fWHtrans'。

出错 pdwht_operator>pfwht_n2m (line 28)
tx = fWHtrans(x(perm))*sqrt(n);

出错 pdwht_operator>@(x)pfwht_n2m(x,picks,perm) (line 13)
A.times = @(x) pfwht_n2m(x,picks,perm);

出错 demo_1d (line 33)
        b = A.times(xs) + noise;

怀疑是这个fWHtrans的文件没有进行编译,然后cd进去之后用mex命令编译一下
果然,编译完成之后,运行结果无错误信息

>> demo_1d

Size [n,m,k] = [2048,256,51]
YALL1 is solving the basis pursuit problem.
 PDCT: iter   62  Rel_err = 1.40e-02
YALL1 is solving the basis pursuit problem.
PDWHT: iter   80  Rel_err = 1.21e-02
YALL1 is solving the basis pursuit problem.
 PDFT: iter   46  Rel_err = 1.40e-02
  rho = 0.0e+00,  CPU   0.41 sec.

YALL1 is solving the unconstrained L1L2 problem.
 PDCT: iter   62  Rel_err = 1.39e-02
YALL1 is solving the unconstrained L1L2 problem.
PDWHT: iter   80  Rel_err = 1.20e-02
YALL1 is solving the unconstrained L1L2 problem.
 PDFT: iter   46  Rel_err = 1.40e-02
  rho = 5.0e-04,  CPU   0.48 sec.

这是运行demo_2d时候的图像:
这里写图片描述
complex时候的图像:
这里写图片描述
L1L2时候的图像:
这里写图片描述

好的,所有demo都运行没有任何错误,那么本期文章也就到这里,之后不定期更新相关内容

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值