📄 matlab2fmex.m
字号:
if count==0 dummy=[keywords' inoutother{1}' inoutother{2}' inoutother{3}' inoutother{4}' mxwords' fortranfunwords']';%%% if any(strcmp('i',funstrwords{i}))%%% 'wqord',funstr{i},funstrwords{i}{j},kb%%% end if ((length(find(strcmpi(funstrwords{i}(j),dummy)))==0)&~(inastring(funstrwords_b{i}(j),funstr{i}))&(~strcmpi(funstrwords{i}(1),'call'))&(~strcmpi(funstrwords{i}(1),'rhs')))%%% if any(strcmp('prod',funstrwords{i}{j}))%%% 'wqord',funstr{i},funstrwords{i}{j},kb%%% end foo=1; if strcmpi(funstrwords{i}(j),'j') if ~(length(find(strcmpi('j',inoutother3)))) funstr{i}=[funstr{i}(1:funstrwords_b{i}(j)-1),'cmplx(0.0,1.0)',funstr{i}(funstrwords_e{i}(j)+1:end)]; foo=0; updatefunstr(i); count=1;gotto=i; end end if strcmpi(funstrwords{i}(j),'i') if ~(length(find(strcmpi('i',inoutother3)))) funstr{i}=[funstr{i}(1:funstrwords_b{i}(j)-1),'cmplx(0.0,1.0)',funstr{i}(funstrwords_e{i}(j)+1:end)]; foo=0; updatefunstr(i); count=1;gotto=i; end end if strcmpi(funstrwords{i}(j),'pi') if ~(length(find(strcmpi('pi',inoutother3)))) needpi=1; foo=0; end end if strcmpi(funstrwords{i}(j),'eps') if ~(length(find(strcmpi('eps',inoutother3)))) needeps=1; foo=0; end end if foo foo3=0; if any(strcmp(funstrwords{i}{j},'dot1f')) foo3=1,funstr{i},kb end [tempflag,temp2,suborfun]=wordconverter(i,j,suborfun);%%% if foo3%%% zzz=1;%%% tempflag,funstr{i},funstrwords{i}{j},'converter',kb%%% end if tempflag(3)==1 %Newer interface by call if ==1 updatefunstr(i); [howmany,subscripts,centercomma,parens]=hassubscript(i,j); %'before',funstr{i},funstrwords{i}{j},kb tempstr=makeMATLABcallstring(howmany,subscripts,centercomma,parens,i,j); temp3=cell(1,3);%%% if any(strcmp(funstrwords{i}{j},'diagf'))%%% funstr{i},howmany,subscripts,centercomma,parens,tempstr,kb%%% end try eval(['[temp3{1},temp3{2},temp3{3}]=',funstrwords{i}{j}(1:length(funstrwords{i}{j})-1),'_make(''',tempstr,''');']); catch 'caught after wordconverter',funstr{i},kb end tempstr2=tempstr; for m=1:length(tempstr) temp=any(strcmp(tempstr2(m),{'d','m'})); if temp,tempstr2(m)='c';end temp=any(strcmp(tempstr2(m),{'e','n'})); if temp,tempstr2(m)='r';end temp=any(strcmp(tempstr2(m),{'f','o'})); if temp,tempstr2(m)='i';end temp=any(strcmp(tempstr2(m),{'g','p'})); if temp,tempstr2(m)='l';end end if length(find(strcmpi(funstrwords{i}(j),needed_interfaces{1,1})))==0 temp5=length(needed_interfaces{1,1})+1; needed_interfaces{1,1}{temp5}=funstrwords{i}{j}; needed_interfaces{1,2}{temp5}{1,1}=tempstr2; needed_interfaces{1,2}{temp5}{1,2}=temp3{3}{1}; needed_interfaces{1,2}{temp5}{1,3}=temp3{3}{2}; else temp2=find(strcmpi(funstrwords{i}(j),needed_interfaces{1,1})); if length(find(strcmpi(tempstr2,needed_interfaces{1,2}{temp2}(:,1))))==0 temp5=size(needed_interfaces{1,2}{temp2},1)+1; needed_interfaces{1,2}{temp2}{temp5,1}=tempstr2; needed_interfaces{1,2}{temp2}{temp5,2}=temp3{3}{1}; needed_interfaces{1,2}{temp2}{temp5,3}=temp3{3}{2}; end end %needed_interfaces{1,1},kb%%% if strcmpi(funstrwords{i}(j),'findf')%%% funstr{i},needed_interfaces{1,1},needed_interfaces{1,2}{4},kb%%% end if temp3{3}{1}==1 %Here we have to remake a few lines with the mxTR# and mxTC# %First, what is the highest count of mxTRC# on this line if strcmp(funstrwords{i-1}{1},'deallocate') temp1=gethighesttemp(funstr{i},temp3{3}{2}); else temp1=gethighesttemp([funstr{i-1},funstr{i}],temp3{3}{2}); end for k=size(funstr,1)+2:-1:i+2 funstr{k}=funstr{k-2}; end maxTRC=updatetemp(maxTRC,temp1+1,temp3{3}{2}); funstr{i}=['call ',funstr{i+2}(funstrwords_b{i}(j):parens(1)),'mxT',upper(temp3{3}{2}),num2str(temp1+1),',',funstr{i+2}(parens(1)+1:parens(2)),';']; if length(find(strcmp(keywordsbegin,funstrwords{i}{j})))==0 funstr{i+1}=[funstr{i+2}(1:funstrwords_b{i}(j)-1),'mxT',upper(temp3{3}{2}),num2str(temp1+1),funstr{i+2}(parens(2)+1:length(funstr{i+2}))]; else funstr{i+1}=[funstr{i+2}(1:funstrwords_b{i}(j)-1),'mxs(mxT',upper(temp3{3}{2}),num2str(temp1+1),')',funstr{i+2}(parens(2)+1:length(funstr{i+2}))]; end funstr{i+2}=['deallocate(mxT',upper(temp3{3}{2}),num2str(temp1+1),');']; updatefunstr; end else if length(temp2{1})>0 if length(findstr(temp2{1},mexoperatorinterfaces{1}))==0 mexoperatorinterfaces{1}=[mexoperatorinterfaces{1} temp2{1}]; mexoperatorinterfaces{2}=[mexoperatorinterfaces{2} temp2{2}]; end end end if ~tempflag(1) [howmany,subscripts,centercomma,parens]=hassubscript(i,j); [howmany2,subscripts2,centercomma2,parens2]=hasoutput(i,j); temp3=0;%%% funstr{i},howmany2,kb switch howmany2 case 0 temp='call mlcall0('; tempstr=makeMATLABcallstring(howmany,subscripts,centercomma,parens,i,j); if length(find(strcmp(maxmxinputs0,tempstr)))==0 maxmxinputs0{length(maxmxinputs0)+1}=tempstr; end count=1;gotto=i; case 1 tempstr=makeMATLABcallstring(howmany,subscripts,centercomma,parens,i,j); if length(find(strcmp(maxmxinputs,tempstr)))==0 maxmxinputs{length(maxmxinputs)+1}=tempstr; end %Here we have to remake a few lines with the mxTR# and mxTC# %First, what is the highest count of mxTRC# on this line temp4='r';if sum(length(find(tempstr=='c'))+length(find(tempstr=='t')))>0, temp4='c'; end if i>1 if strcmp(funstrwords{i-1}{1},'deallocate') temp1=gethighesttemp(funstr{i},temp4); else temp1=gethighesttemp([funstr{i-1},funstr{i}],temp4); end else temp1=0; end for k=size(funstr,1)+2:-1:i+2 funstr{k}=funstr{k-2}; end maxTRC=updatetemp(maxTRC,temp1+1,temp4); try funstr{i}=['call mlcall(mxT',upper(temp4),num2str(temp1+1),',',funstr{i+2}(parens(1)+1:parens(2)-1),',''',funstrwords{i}{j},''');']; catch %catch this disp([r,'Here are the contents of ',filename,'_save.m. Is ',funstrwords{i}{j},' here?']) cw disp(['You may have a variable in ',filename,'.m file which is not in ',filename,'_save.m file.']); funstr{i},keyboard end if length(find(strcmp(keywordsbegin,funstrwords{i}{j})))==0 funstr{i+1}=[funstr{i+2}(1:funstrwords_b{i}(j)-1),'mxT',upper(temp4),num2str(temp1+1),funstr{i+2}(parens(2)+1:length(funstr{i+2}))]; else funstr{i+1}=[funstr{i+2}(1:funstrwords_b{i}(j)-1),'mxs(mxT',upper(temp4),num2str(temp1+1),')',funstr{i+2}(parens(2)+1:length(funstr{i+2}))]; end funstr{i+2}=['deallocate(mxT',upper(temp4),num2str(temp1+1),');']; updatefunstr; count=1;gotto=i; temp3=2; otherwise %multioutput temp=['call mlcallm',num2str(multinum),'(']; temp2=makemultioutput(i,j,funstr,funstrnumbers,funstrnumbers_b,funstrnumbers_e,funstrwords,funstrwords_b,funstrwords_e,funwords,inoutother,keywords,localvartype,needed_interfaces,filename_al,make_words,cw,multinum,howmany,subscripts,centercomma,parens,howmany2,subscripts2,centercomma2,parens2); if length(temp2{1})>0 if length(findstr(temp2{1},mexoperatorinterfaces{1}))==0 mexoperatorinterfaces{1}=[mexoperatorinterfaces{1} temp2{1}]; mexoperatorinterfaces{2}=[mexoperatorinterfaces{2} temp2{2}]; end end multinum=multinum+1; temp3=1; end if temp3==0 tempstr=makeMATLABcallstring(howmany,subscripts,centercomma,parens,i,j); if ~isempty(tempstr) if length(find(strcmp(maxmxinputs,tempstr)))==0 maxmxinputs{length(maxmxinputs)+1}=tempstr; end end if howmany==0 temp=[temp,'''',funstrwords{i}{j},''')']; else for k=1:howmany if k==howmany, temp=[temp,subscripts{k},',''',funstrwords{i}{j},''')']; else temp=[temp,subscripts{k},',']; end end end if funstrwords_b{i}(j)==1 if howmany==0 funstr{i}=[temp,funstr{i}((funstrwords_e{i}(j)+1):end)]; else funstr{i}=[temp,funstr{i}(parens(2)+1:end)]; end else try %This catches some common mistakes funstr{i}=[funstr{i}(1:(funstrwords_b{i}(j)-1)),temp,funstr{i}((parens(2)+1):end)];% end catch%Finish try block disp(['Do you have a string someplace it shouldnlt be?',r,'Are all variables saved in ',filename,'.mat?']); funstr{i} kb end end %showall(funstr),i,j,'Either you left the keyboard command there, or you haven't saved some variable in the workspace file.',keyboard updatefunstr(i); count=1;gotto=i; elseif temp3==1 %0 output mlcall0 case for k=1:howmany, temp=[temp,subscripts{k},',']; end for k=1:howmany2 if k==howmany2, rightside=parens2(2);leftside=centercomma2(k-1); fid=find((funstrwords_b{i}<rightside)&(funstrwords_b{i}>leftside)); [howmany3,subscripts3,centercomma3,parens3]=hassubscript(i,fid(1)); if howmany3==2 temp=[temp,funstrwords{i}{fid(1)},',[',subscripts3{1},'],[',subscripts3{2},'],''',funstrwords{i}{j},''')']; else temp=[temp,subscripts2{k},',''',funstrwords{i}{j},''')']; end elseif k==1 rightside=centercomma2(1);leftside=parens2(1); fid=find((funstrwords_b{i}<rightside)&(funstrwords_b{i}>leftside)); [howmany3,subscripts3,centercomma3,parens3]=hassubscript(i,fid(1)); if howmany3==2 temp=[temp,funstrwords{i}{fid(1)},',[',subscripts3{1},'],[',subscripts3{2},'],']; else temp=[temp,subscripts2{k},',']; end else rightside=centercomma2(k);leftside=centercomma2(k-1); fid=find((funstrwords_b{i}<rightside)&(funstrwords_b{i}>leftside)); [howmany3,subscripts3,centercomma3,parens3]=hassubscript(i,fid(1)); if howmany3==2 temp=[temp,funstrwords{i}{fid(1)},',[',subscripts3{1},'],[',subscripts3{2},'],']; else temp=[temp,subscripts2{k},',']; end end end funstr{i}=[temp,';']; updatefunstr(i); count=1;gotto=i; end else updatefunstr(i); if tempflag(2), count=1;gotto=i+tempflag(2)-1; end end end%%% else%%% if ~any(strcmpi(funstrwords{i}(1),{'print';'deallocate';'call';'error'}))%%% goon=1;%%% temp=findstr('=',funstr{i});%%% if ~isempty(temp)%%% for fid=1:length(temp)%%% if inwhichlast(i,temp(fid))==0%%% goon=0;%%% end%%% end%%% end%%% if (goon&(length(find(strcmp(funstrwords{i}{1},keywords)))==0)&(length(find(strcmp(funstrwords{i}{1},funwords)))==0))%%% funstr{i}=['print *,',funstr{i}];%%% updatefunstr(i);%%% count=1;gotto=i;%%% if length(find(strcmp('print',fortranfunwords)))==0%%% fortranfunwords{length(fortranfunwords)+1}='print';%%% end%%% end%%% end end end end end if count==1, break; end end end if want_kb,disp('finished word conversions'),disp(r),showall(funstr),disp(r),keyboard,end if want_fb&(~want_kb),fprintf(1,' finished \n');end%%%catch%%% disp(r);disp(funstr{i});disp(['line number ',num2str(i)]);disp(lasterr);disp(r);%%% disp('Conversion error in preceeding line.');%%% disp('Try to continue? [y,<return>]');%%% tempans=input('or enter keyboard mode? [n,k]','s');%%% if ~isempty(tempans), if ((tempans=='n')|(tempans=='k')), keyboard, end, end%%%end%We need to change = assignments.%try fprintf(1,' ');pticker=pticker+1; if want_fb&(~want_kb),fprintf(1,' fixing assignments ................................ 1');end count=1;gotto=1; while count==1 count=0; for i=gotto:s fprintf(1,b);fprintf(1,ticker{tickercount}); tickercount=tickercount+1;if tickercount>11, tickercount=1; end if i==s, fprintf(1,b);fprintf(1,ticker{pticker}); end if count==0; dummy=findstr('=',funstr{i}); fid=1; if count==0 if ~isempty(dummy) for j=1:length(dummy) temp=dummy(j); if inwhichlast(i,temp)==0 fid=0; if length(find(strcmp(funstrwords{i}{1},keywordsbegin)))==0 if (length(find(strcmp(funstrwords{i}(1),inoutother3)))>0) %'got1111111111111a',funstr{i},funstr{i}(1:temp) tempstr=''; tempstr(2)=makeMATLABcallstring(1,{funstr{i}(temp:length(funstr{i}))},[],[temp length(f
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -