Search Comments and Ratings

go

   
Date File Comment by Comment Rating
03 Mar 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Daniel

Daniel (view profile)

It works ! Awesome !

Comment only
23 Feb 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

I just verified the new C version compiles on 64-bit windows, so I have updated the description above to link to the new github code. I will no longer support this versinon of the code, but I will attempt to support the github version

Comment only
22 Feb 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

I have a new version that is all in C and should compile MUCH easier, especially on Windows. Please let me know if you have comments. I haven't yet tried compiling on Windows so that may need some fine-tuning.

See https://github.com/stephenbeckr/L-BFGS-B-C

Comment only
12 Feb 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Daniel

Daniel (view profile)

@Marcin, I think the wrapper works well in Yosemite (this is also my current OS I am using most). You have to make sure you have the updated Xcode and the fortran form http://hpc.sourceforge.net. Also install the OpenBlas libraries (you will find many guides online) After that, you open MATLAB and set up mex, i.e. mex -setup C++ and mex -setup FORTRAN.

Make sure you have
LINKEXPORT="-Wl,-exported_symbols_list,"$MATLABROOT/extern/lib/maci64/mexFunction.map""
in your "mex_FORTRAN_maci64.xml" file. Also make sure you copy the downloaded (with gfortran) libgfortran libraries in the folder :
/Applications/MATLAB_R2014b.app/sys/os/maci64/

After this, in MATLAB, type

mex -v -c lbfgsb_wrapper.c -largeArrayDims -UDEBUG CFLAGS="\$CFLAGS -O3"

and then,

mex -v -output lbfgsb_wrapper lbfgsb_wrapper.o Lbfgsb.3.0/lbfgsb.f Lbfgsb.3.0/linpack.f Lbfgsb.3.0/timer.f -lm -lopenblas

Good luck !

Comment only
02 Feb 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Dan Scholnik

Luckily the fix should not measurably affect speed in the most-common case where x is not aliased to another variable. (I'm actually quite fond of writing in-place mex files myself, often to call LAPACK routines directly that matlab does not expose. But of course then I know to be careful. This one took a while to hunt down since it didn't occur to me for a while.)

Comment only
01 Feb 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

@Dan, good observation and I will include the fix when I next update. For now, the code is true to it's C/Fortran style origins where this practice was commonplace, as it's more efficient for largescale problems. (Back when you told LAPACK how much extra memory you could afford, and saving the entire history of variables was only possible for tiny problems).

Comment only
01 Feb 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Dan Scholnik

The in-place modification of the current iterate x can cause some nasty hair-pulling bugs. If (for example) one is saving x off in a global variable within the objective function, then due to Matlab's copy-on-write optimization the global version will be silently changed as well since Matlab is not aware of the in-place changes. This can be avoided by adding the line

extern bool mxUnshareArray(mxArray *array_ptr, bool noDeepCopy);

at the top of lbfgsb_wrapper.c to declare the undocumented mxUnshareArray function, and then adding the line

mxUnshareArray((mxArray *)prhs[N_x], true);

at the top of mexFunction() before x is overwritten. This forces matlab to perform any delayed copies. Here's a good link with more info:

http://undocumentedmatlab.com/blog/matlab-mex-in-place-editing

Comment only
06 Jan 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

@v, I'm sorry but I can't really give you the help you need to install the 64-bit windows version.

Comment only
01 Jan 2015 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Marcin

Marcin (view profile)

I'm having a hard time compiling this for Max OS X Yosemite. I have MATLAB R2014b. When I run the 'compile_ex' script, I'm getting the following:

Error using mex
Cannot compile both C and FORTRAN source files in a single call to MEX.

Following the advice I was able to find, I then tried:

mex -v -c lbfgsb_wrapper.c -largeArrayDims -UDEBUG CFLAGS="\$CFLAGS -O3" ;

which runs ok, and then:

mex -v -output lbfgsb_wrapper lbfgsb_wrapper.o Lbfgsb.3.0/lbfgsb.f Lbfgsb.3.0/linpack.f Lbfgsb.3.0/timer.f FC="gfortran" -lm -lmwblascompat32 LINKEXPORT='Wl,--version-script,/usr/local/MATLAB/R2014a/extern/lib/glnxa64/mexFunction.map'

which fails:

Error using mex
clang: error: no such file or directory: 'Wl,--version-script,/usr/local/MATLAB/R2014a/extern/lib/glnxa64/mexFunction.map'

Can anyone help?

Comment only
30 Dec 2014 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

fatemeh nj

I just have a bit problem, I receive this warning and my audio signal has not been recovered well, my warning is:
Warning: did not reach target size of residual

I also increase the number of 'K' but at the end the error was repeated!

my first question is that I know the k determined sparsity but how can i know the sparsity of unknown signal?

second question, could you also mention which paper you use for writing omp function?

Comment only
20 Dec 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

v

v (view profile)

compiled the 64-bit version - when it ran the tests in compile_mex_forWindows.m, it caused an internal error crashing matlab. The crash happens in lbfgsb_wrapper.c at the point it calls setulb

1
22 Oct 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Daniel

Daniel (view profile)

Hi Thomas,

Please download (it's free) the Dependency Walker 64 program and use it to analyze the mex file you created. Dependency Walker will tell you what dll's are missing and causing the "Attempt to access invalid address".
This problem can be solved if you are using Windows 7 64bit. In the case of Windows 8.1 I could not get it to work as the dylib libraries from the cygwin fortran make use of some dll's that are no longer available in Windows 8.1

Daniel

Comment only
21 Oct 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Thomas Humphries

So I was happily using this code on my 32-bit workstation and now am enjoying trying to get it to work on my 64-bit laptop... I have followed Daniel's instructions below and have managed to get the .mexw64 file to compile, but when I try to run the example I get

Invalid MEX-file 'C:\Users\...\lbfgsb.3.0_1.2\lbfgsb_wrapper.mexw64': Attempt to access invalid address.

Error in lbfgsb (line 179)
[f, task, csave, lsave, isave, dsave] = ...

Error in example_NNLS (line 100)
[xk, ~, info] = lbfgsb(fun, l, u, opts );

Probably a longshot, but does anyone have any suggestion what could be causing this? I am guessing some kind of library linking issue but nothing comes up during the compilation process...

-TH

Comment only
21 Oct 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Daniel

Daniel (view profile)

Hi Lucas,

Sorry for my late reply, I haven't checked the posts in a while. I think the problem you describe is quite simple, namely you have to add in the PATH variable in Windows the path to the "lib" command from the Visual Studio folder.

Comment only
13 Oct 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Alexandre

I have received a couple of email asking me how to compile. Here how I proceeds in 2 steps on Linux (Mint 17 distro)

mex -v -c lbfgsb_wrapper.c -largeArrayDims -UDEBUG CFLAGS="\$CFLAGS -O3" ;

mex -v -output lbfgsb_wrapper lbfgsb_wrapper.o Lbfgsb.3.0/lbfgsb32.f Lbfgsb.3.0/linpack32.f Lbfgsb.3.0/timer.f FC="gfortran" -lm -lmwblascompat32 LINKEXPORT='Wl,--version-script,/usr/local/MATLAB/R2014a/extern/lib/glnxa64/mexFunction.map'

It is a colleague of mine who found out how to compile, therefore I am afraid I cannot explain why it works.

Comment only
12 Oct 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

wenbin

wenbin (view profile)

I have the same problem as Alexandre. When I try to compile it under Linux with matlab R2014a, I get the following error:
Error using mex
Cannot compile both C and FORTRAN source files in a single call to MEX.

Error in compile_mex (line 61)
mex -v lbfgsb_wrapper.c -largeArrayDims -UDEBUG ...

Anyone had meet this problem? Please kindly show me the solution, I'm really in trouble.

Comment only
15 Jul 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Alexandre

Problem sloved. It seems that Matlab R2014a does not allow to compile Fortran and C in a single MEX call. I believe that it allowed to link the files automatically.

I had to compile the Fortran code to .o objects and link them to the .c files manually.

Comment only
15 Jul 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Alexandre

Hi Stephen,

I managed to compile the Fortran part by splitting into 2 MEX calls:

mex Lbfgsb.3.0/lbfgsb.f Lbfgsb.3.0/linpack.f Lbfgsb.3.0/timer.f -lm -lmwblas CFLAGS="\$CFLAGS -O3"FC="gfortran"

mex -v lbfgsb_wrapper.c -largeArrayDims -UDEBUG ;

The Fortran part is fine, but not the C compilation. I get the following error message:

Error using mex
/tmp/mex_29407351995475_5199/lbfgsb_wrapper.o: In function `mexFunction':
lbfgsb_wrapper.c:(.text+0x738): undefined reference to `setulb_'
collect2: error: ld returned 1 exit status

I have tried to play with the -DNOUNDERSCORE -UUPPERCASE_FORTRAN flags but none of them seem to help.

How can I fix this issue?

Thank you very much

Comment only
03 Jul 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

Hi Alexandre,
I've never seen that error either. Maybe ask the mathworks help about it.
-Stephen

Comment only
03 Jul 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Alexandre

I have tried to compile it under Linux Mint 17, with Matlab 2014a. I got the following error message:

Error using mex
Cannot compile both C and FORTRAN source files in a single call to MEX.

Error in compile_mex (line 61)
mex -v lbfgsb_wrapper.c -largeArrayDims -UDEBUG ...

I've tried to find out about this error but it is nowhere to be found, as if it is an issue related to Matlab 2014 only.

Any suggestion?
Cheers

Comment only
05 May 2014 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

Yang

Yang (view profile)

Thanks for this source code

5
17 Apr 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Lucas

Lucas (view profile)

Hi everyone,

As I'm trying to compile the mex file on a W7 x64 with Matlab R2013a, I follow the tutorial of Daniel, and I would need some specification (thanks by the way for sharing this) :
- the line "lib /def:liblbfgsb.def /machine:x64" gives me
>>>
$ lib /def:liblbfgsb.def /machine:x64
-bash: lib: command not found
<<<

-I tried to run the compilation anyway, and it gives me this :
>>>
/cygdrive/c/Progra~1/MATLAB/R2013a/bin

$ mex.bat -O -largeArrayDims -UDEBUG lbfgsb_wrapper.c liblbfgsb.lib -lmex -lmx -lopenblas

C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: 'lbfgsb_wrapper.c' not found.
<<<

I'm not a great expert on bash's command, and I can't figure out what's the real problem behind these.

-LS

Comment only
09 Apr 2014 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

TDJIO

TDJIO (view profile)

Thanks for sharing!

5
08 Apr 2014 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

sheng

sheng (view profile)

Thank you very much for your share.

5
06 Jan 2014 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Daniel

Daniel (view profile)

Hi,

I succeded to compile and test the mex module for Windows 7 x64 (Sp1) linking with the multithreded OpenBlas. In this way one can take advantage of the multicore architecture of the available CPU. For the Windows operating system the process is rather convoluted and delicate (one can easily get into the so called "dll hell" problem). The solution is indeed based on creating a dll file. I got it working following a script from Roland, so many thanks to him who pioneered a way to compile using Cygwin and gracefully shared his own script.
The idea is the following:
1) install Openblas and add its lib folder to the $Path$ Environment variable.
2) install Cygwin64 (the Devel package)
3) make sure you have SDK 7.1 installed along with Visual Studio 10.0 (it's free) and all the updates for Win7.
4) add to the $Path$ environment variable "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"
5) find and copy the x64 version of IESHIMS.dll into a folder added to $Path$ environment variable. (I know, this is counterintuitive and seems esoteric but if you don't it may not work) To check that this is needed one can use "Dependency Walker".
6) open the Cygwin64 terminal and go to the "lbfgsb3.0_mex1.2" folder and make sure the "Lbfgsb.3.0" subfolder with all its files is inside (if not download it).
7) Type (or creat a .sh script to run at once):
cd Lbfgsb.3.0
rm *.o
rm *.dll
rm *.lib
rm *.dll.a

x86_64-w64-mingw32-gfortran.exe -c -Wall -Wno-uninitialized lbfgsb.f linpack.f blas.f timer.f
echo EXPORTS > liblbfgsb.def
echo setulb_ >> liblbfgsb.def
echo _setulb_=setulb_ >> liblbfgsb.def

dlltool -D liblbfgsb.dll -d liblbfgsb.def -e liblbfgsb.o -l liblbfgsb.dll.a lbfgsb.o linpack.o blas.o timer.o
lib /def:liblbfgsb.def /machine:x64

x86_64-w64-mingw32-gfortran.exe -mdll -static-libgfortran -o liblbfgsb.dll liblbfgsb.o lbfgsb.o linpack.o timer.o blas.o

cp liblbfgsb.dll liblbfgsb.dll.a liblbfgsb.lib .
cp liblbfgsb.dll liblbfgsb.dll.a liblbfgsb.lib ..
cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libgcc_s_seh-1.dll ..
cd ..

/cygdrive/c/Progra~1/MATLAB/R2013b/bin/mex.bat -O -largeArrayDims -UDEBUG lbfgsb_wrapper.c liblbfgsb.lib -lmex -lmx -lopenblas

8) Test example_NNLS.m

Good Luck!

5
27 Nov 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Robert

Robert (view profile)

Dear Chenchen Tong,

I got the same error, when running compile_mex.m on Ubuntu 12.04, gcc-4.6 and MATLAB R2013a:

=== lbfgsb "driver1" test problem, 2D ===
Invalid MEX-file
'.../lbfgsb.3.0_1.2/lbfgsb3.0_mex1.2/lbfgsb_wrapper.mexa64':'.../matlabR2013a/bin/glnxa64/../../sys/os/glnxa64/libgfortran.so.3: version
`GFORTRAN_1.4' not found (required by
.../lbfgsb.3.0_1.2/lbfgsb3.0_mex1.2/lbfgsb_wrapper.mexa64)

For me the problem was solved by running MATLAB with LD_PRELOAD and LD_LIBRARY_PATH, pointing to the system libraries:

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgfortran.so.3 LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu matlab

Comment only
29 Oct 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Ryan Muir

5
25 Sep 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Daniel

Daniel (view profile)

Hi Roland,

Could you please post detailed instructions for how to compile the lbfgsb_wrapper in Windows 7 64bit?
I was only able to compile in Linux and Mac OS X so far . I also linked with the OpenBlas library which is very fast ( if you have a multi-core cpu).

Thank you very much.

Daniel

5
06 Sep 2013 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

Jason

Jason (view profile)

How to estimate sparsity?

Works great if I know the sparse size exactly (by creating test data, for example), otherwise not such a great improvement over least squares (for my particular problem).

Comment only
06 Sep 2013 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

Jason

Jason (view profile)

5
05 Aug 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

Hi Roland,
That's great it works! If you wouldn't mind, can you post detailed instructions here? I think many others would find them useful.

You're right about the typo in the nrhs. I'll fix that in the next update.

Right now, the gradient is necessary. The Python and R versions use large packages to get around this. They might have a finite-differences gradient approximation mode, but I suspect they are really doing automatic differentiation (the good news is that this is the exact gradient, no approximation. The bad news is that it can be sometimes slow). There are automatic differentiation packages for Matlab, but none that seem to be very "mature". So you could try some of those, but if you can work out an explicit function to compute the gradient, that is usually the simplest (no automatic differentiation packages to get working) and the fastest for computation.
Best, Stephen

Comment only
30 Jul 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Roland

Roland (view profile)

I finally managed to run it on Win7 64 with mingw fortran and msvc c compilers.

Stephan, is it necessary to give the gradient in any case? I know that the Python and R versions can use numerical approximations to the gradient. Do you know of a function that does that for me?

Comment only
29 Jul 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Roland

Roland (view profile)

Thanks Steven, I'm still trying to get this to work. At the moment I got it compiled but it crashes when I run it with no expressive error messages. Still debugging... but on a different not, in line 266:

if (nrhs < N_g-1 ) {

shouldn't it read "nrhs < N_g+1", so a "+" instead of "-"?

Cheers

Comment only
24 Jul 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

Hi Roland,
I think that's with trying the f2c'd version of the code. It might be that your C compiler is stricter than the f2c code. Maybe you can tell the compiler to allow a newer standard? In gcc, it would be something like -std=gnu99 or -ansi. You can probably look up the equivalent for MSVC.
Or, if you can get a fortran compiler, then use the original fortran code and don't mess with the f2c version.
Either way, I'm afraid I can't help much because I work with a Windows computer. Judging from the other comments here, it is quite difficult to get this code to work with 64 it Windows. We really need a pure C version of the code; if you want to do this (you can use the f2c version as a base), please let me know!
Best,
Stephen

Comment only
24 Jul 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Roland

Roland (view profile)

Dear Stephen,

Thanks for all your efforts. I would love to use your script but it doesn't compile. I have Matlab R2012b on Win 7 64bit. I use the compile_for_windows script and get the following error:

>>>>>>>>>>>>>>>>>>>>

>> compile_mex_forWindows
Sorry
Compiling abort_.c
Compiling arithchk.c
Compiling backspac.c
Compiling c_abs.c
Compiling c_cos.c
c_cos.c
c_cos.c(14) : error C2143: syntax error : missing ')' before '*'
c_cos.c(14) : error C2143: syntax error : missing '{' before '*'
c_cos.c(14) : error C2143: syntax error : missing ';' before '*'
c_cos.c(14) : error C2059: syntax error : ')'
c_cos.c(16) : error C2054: expected '(' to follow 'z'

C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: Compile of 'c_cos.c' failed.

Error using mex (line 206)
Unable to complete successfully.

Error in compile_mex_forWindows (line 116)
mex('-largeArrayDims','-I./','-c','-DMSDOS','-DNOUNDERSCORE','-DNO_ISATTY',src_file);

<<<<<<<<<<<<<<<<<<<<<<<<<

Any suggestions how to fix that would be very much appreciated.

Thanks,

Roland

Comment only
23 Jul 2013 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

Israa, I'm not exactly sure what you want to do, but if you wish to work with 2D images, then use vectorize (e.g. use vec = @(x) x(:) ) and reshape operators, so that the code only sees vectors. If done right, it will work just fine. Hope that helps a bit.
-Stephen

Comment only
23 Jul 2013 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

israa tawfic

can i use this source code with an image,

3
30 Jun 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

Hi Xin,
You are using the f2c version I included, so this adds more complication. The problem is almost surely that your BLAS requires integers of different lengths. So try two things:
First, define _BLAS64_ when you compile. You can do this by adding -D_BLAS64_ to the mex compilation command. Hopefully this will fix it.
Second, try a different BLAS. You can install another version (e.g. ATLAS) and use that. If there are still problems, use the netlib source code (for CBLAS) and link with this source; this way your compiler will give you errors if there are incompatibilities and they will be easy to fix.
Best, Stephen

Comment only
24 Jun 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

xin yu

xin yu (view profile)

Hi, Stephen
Thank you for the wrapper, which can work pretty well on my windows7 32bit.
But when compiling the wrapper on my desktop, win7 64bit, I met some problems.
I can compile the wrapper, but when running the examples, matlab will crash. I debug the problem. In the loop, when calling the lbfgsb.c at the first time, it is ok, but the second iteration, a breakpoint is triggered. When calling dcopy, matlab will crash down. I have no idea how can I solve the problem. My BLAS is 10.3.11. My matlab version is R2013a.
Thanks!

5
08 Jun 2013 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

Robin, that's a typo. It's an unimportant default value that doesn't affect the code, so I will change it the next time I have a major update.

Comment only
07 Jun 2013 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

Robin Longstride

Why do you use round with 2 nargin in CoSaMP line 97?

It doesn't work.

Thanks for this source code.

4
13 May 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

I'm not sure what's going on. It's odd that it compiles if it can't find the symbol. It could be an issue with a run-time library. On linux, I had the option of using either g95 or gfortran, and I use g95, so maybe try that if it's easy on the mac. Otherwise, I'm afraid I can't be of much help. You could also try following the basic ideas outline in the compile_mex_forWindows (i.e. convert fortran to C). Best of luck!

Comment only
13 May 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Tim

Tim (view profile)

My apologies for the numerous replies. I had to manually update dcopy dscal and daxpy as you suggested. The mex file is generated ("lbfgsb_wrapper.mexmaci64") but it crashes matlab. The error report says: "I should have added that the error report listed "Symbol not found: __gfortran_transfer_real_write""

Comment only
13 May 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Tim

Tim (view profile)

I should have added that the error report listed "Symbol not found: __gfortran_transfer_real_write"

Comment only
13 May 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

Hi Tim,
The crash, the fact that the mwblas seemed to work (for compilation), and the fact that it was looking for _daxpy_ and not _daxpy32_, all suggest that maybe the ddot's and so on were not replaced by ddot32. The C files should be OK, so check the fortran files. You can try running the script from the shell yourself, or just edit the .f files with an editor and do find-replace.

If you verify that the ddot/dcopy/dscal/daxpy are replaced with their ddot32/dcopy32/dscal32/daxpy32 and it still fails, then we have a different problem on our hands. Try compiling with -v and let me know the output.

Comment only
13 May 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Tim

Tim (view profile)

Hi,
Thank you for writing this code. I hope to be able to use it, but I am having some compilation problems. I am running a 64 bit mac, OS 10.6.8, running Matlab v. R2010b.

I get the error "script failed, try running script by hand perhaps?," though the files are still generated with ddot32 replacing dot. It does not, however, compile when using the subsequent mex command ("can't find "_daxpy_" etc). It did compile using the previous, commented out mex command using lmwblas, and generated a mexmaci64 file. If I try running the example code calling lfbgs, Matlab crashes.

The libblas version is 10.2.3 for R2010b. If you could offer any solutions I would be grateful,

Comment only
17 Apr 2013 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

Bo

Bo (view profile)

Hi,
I just get it work.
Sorry for the 4 stars. It should be a five stars.
Thank you,
Bo Yuan

Comment only
16 Apr 2013 CoSaMP and OMP for sparse recovery Orthogonal Matching Pursuit (OMP) and Compressive Sampling Matched Pursuit (CoSaMP). Author: Stephen Becker

Stephen Becker (view profile)

Bo

Bo (view profile)

Hi Stephan,

It seems your functions can only accept A which is square matrix? Do I miss anything or this function will not work for overcomplete frames?

Thank you!
Bo Yuan

4
14 Feb 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Stephen Becker

Stephen Becker (view profile)

Hi Xunkai, I can't help much because I don't have access to Intel's compiler. But if you adapt the gfortran lines to work with the intel fortran compiler, then the rest of the compilation (the C code) should be similar.

Comment only
13 Feb 2013 LBFGSB (L-BFGS-B) mex wrapper Mex wrapper for lbfgsb v3.0 fortan library. L-bfgs-b solves box-constrained optimization. Author: Stephen Becker

Stephen Becker (view profile)

Xunkai Wei

Xunkai Wei (view profile)

Win 7, 64bit system, I have intel fortran compiler and vs 2012 C++ compiler, could you show me how to compile the source code ?

5

Contact us