[f22b43]: ltfatmex.m Maximize Restore History

Download this file

ltfatmex.m    202 lines (143 with data), 4.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
function ltfatmex(optclean)
%LTFATMEX Compile Mex/Oct interfaces
% Usage: ltfatmex;
% ltfatmex('clean');
%
% LTFATMEX compiles certain functions written in C in order to speed
% up the execution of the toolbox.
%
% LTFATMEX('clean') removes the compiled functions.
% AUTHOR : Peter Soendergaard.
% TESTING: NA
% REFERENCE: NA
error(nargchk(0,1,nargin));
global TF_CONF;
% Verify that TF_CONF has been initialized
if numel(TF_CONF)==0
disp('');
disp('--- LTFAT - The Linear Time Frequency Analysis toolbox. ---');
disp('')
disp('To start the toolbox, call LTFATSTART as the first command.');
disp('');
return;
end;
bp=TF_CONF.basepath;
% Remember the current directory.
curdir=pwd;
if (nargin>0) && strcmpi(optclean,'clean')
if isoctave
cd([bp,'oct']);
deletefiles('*.oct');
deletefiles('*.o');
cd(curdir);
else
% Delete files permanently (bypass trashcan on Windows/Mac
% but remember the old state
oldstate = recycle('off');
cd([bp,'mex']);
deletefiles(['*.',mexext]);
recycle(oldstate);
cd(curdir);
end;
return;
end;
if ispc
% FIXME Need to differentiate between Matlab and Octave.
s=[bp,'lib',filesep,'libltfat-nomem.lib'];
else
s=[bp,'lib',filesep,'libltfat-nomem.a'];
end;
if ~exist(s,'file')
error(['The LTFAT C library cannot be found. Please compile as described ' ...
'in the INSTALL file, or download a binary release.']);
end;
if ispc && ~isoctave
if ~exist([bp,'mex\libfftw3-3.dll'],'file')
error(['Please download the FFTW binary release for Windows as ' ...
'described in the INSTALL file.']);
end;
% Create the .lib file for the Matlab FFTW3 lib.
if ~exist([bp,'mex\libfftw3-3.lib'],'file')
system(['"',matlabroot,'\sys\lcc\bin\lcc_implib.exe" -u "',...
bp,'mex\LIBFFTW3-3.DLL"']);
end;
if ~exist([bp,'mex\libfftw3f-3.dll'],'file')
error(['Please download the FFTW binary release for Windows as ' ...
'described in the INSTALL file.']);
end;
if ~exist([bp,'mex\libfftw3f-3.lib'],'file')
system(['"',matlabroot,'\sys\lcc\bin\lcc_implib.exe" -u "',...
bp,'mex\libfftw3f-3.dll"']);
end;
end;
if isoctave
cd([bp,'oct']);
ext='oct';
% Get the list of files.
L=dir('*.cc');
endchar=2;
else
cd([bp,'mex']);
ext=mexext;
% Get the list of files.
L=dir('comp_*.c');
endchar=1;
end;
for ii=1:numel(L)
filename = L(ii).name;
objname = [filename(1:end-endchar),ext];
objdirinfo = dir(objname);
% Make-like behaviour: build only the files where the src file is
% newer than the object file, or the object file is missing.
if isempty(objdirinfo) || (objdirinfo.datenum<L(ii).datenum)
fprintf('Compiling %s\n',filename);
if isoctave
mkoctfile('-c','oct-memalloc.c');
mkoctfile('-I../thirdparty',...
'-I.','-I../src','-L../src','-L../lib',...
filename,'oct-memalloc.o',...
'-lltfat-nomem',...
'-lfftw3',...
'-lfftw3f',...
'-llapack',...
'-lblas');
else
if ispc
mex('-c','mex-memalloc.c');
mex('-I../thirdparty',...
'-I.','-I../src','-L../src',...
filename,'mex-memalloc.obj',...
'../lib/libltfat-nomem.lib',...
'../mex/LIBFFTW3-3.LIB',...
'../mex/LIBFFTW3F-3.LIB',...
[matlabroot '\extern\lib\win32\lcc\libmwlapack.lib'],...
[matlabroot '\extern\lib\win32\lcc\libmwblas.lib']);
else
mex('-c','mex-memalloc.c');
mex('-I../thirdparty',...
'-I.','-I../src','-L../src','-L../lib',...
filename,'mex-memalloc.o',...
'-lltfat-nomem',...
'-lfftw3',...
'-lfftw3f',...
'-llapack',...
'-lblas');
end;
end;
end;
end;
if ~isoctave
if exist([bp,filesep,'thirdparty',filesep,'GPC',filesep,'gpc.c'], ...
'file')
% Compile the PolygonClip interface to GPC for use with mulaclab
cd([bp,filesep,'thirdparty',filesep,'PolygonClip']);
mex('-I../GPC','PolygonClip.c','../GPC/gpc.c');
end;
end;
% Jump back to the original directory.
cd(curdir);
function deletefiles(files)
L=dir(files);
for ii=1:numel(L)
delete(L(ii).name);
end;