/usr/share/sdpa/mex/gensdpafile.m is in sdpam 7.3.9+dfsg-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | function gensdpafile(filename,mDIM,nBLOCK,bLOCKsTRUCT,c,F)
%
% Generate SDP data file with SDPA Sparse format
%
% gensdpafile(filename,mDIM,nBLOCK,bLOCKsTRUCT,c,F)
%
% <INPUT>
% - filename : string ; generated filename
% - mDIM : integer ; number of decision variables
% - nBLOCK : integer ; number of blocks of F
% - bLOCKsTRUCT: vector ; represetns the block structure of F
% - c : vector ; coefficient vector
% - F : cell array; coefficient matrices
%
% This file is a component of SDPA
% Copyright (C) 2004-2013 SDPA Project
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
%
% SDPA-M: $Revision: 6.2 $
% $Id: gensdpafile.m,v 6.2 2005/05/28 02:36:40 drophead Exp $
% check the validity of arguments
if nargin ~= 6
error('input arguments must be 6.');
elseif ~ischar(filename)
error('1st argument must be a filename.');
end
% open file
fid=fopen(filename, 'w');
if fid == -1
error(sprintf('Failed to open %s.', filename));
end
% comment
stamp=clock;
fprintf(fid,...
'"Generated by gensdpafile() %04d/%02d/%02d %02d:%02d:%02d"\n',...
stamp(1),stamp(2),stamp(3),stamp(4),stamp(5),fix(stamp(6)));
% mDIM
fprintf(fid, '%d\n', mDIM);
% nBLOCK
fprintf(fid, '%d\n', nBLOCK);
% bLOCKsTRUCT
for l=1:nBLOCK
if l~= nBLOCK
fprintf(fid,'%d,', bLOCKsTRUCT(l));
else
fprintf(fid,'%d\n', bLOCKsTRUCT(l));
end
end
% cost vector c
for k=1:mDIM
if k ~= mDIM
fprintf(fid,'%g,', c(k));
else
fprintf(fid,'%g\n', c(k));
end
end
% coefficient matrices F => Sparse format
for k=1:mDIM+1
for l=1:nBLOCK
dim=abs(bLOCKsTRUCT(l));
tmpF=F{l,k};
if isempty(tmpF)
continue;
end
[m,n]=size(tmpF);
if m == dim & n == dim & bLOCKsTRUCT(l) > 0
% normal block
for i=1:dim
for j=1:dim
if (i <= j & tmpF(i,j) ~= 0)
% upper triangle part only
fprintf(fid, '%d,%d,%d,%d,%g\n',k-1,l,i,j,tmpF(i,j));
end
end
end
elseif ( m==1 | n==1 ) & m*n==dim & bLOCKsTRUCT(l) < 0
% diagonal block with vector
for i=1:dim
if tmpF(i) ~= 0
fprintf(fid, '%d,%d,%d,%d,%g\n',k-1,l,i,i,tmpF(i));
end
end
elseif m == dim & n == dim & bLOCKsTRUCT(l) < 0
% diagonal block with matrix
for i=1:dim
if tmpF(i,i) ~= 0
fprintf(fid, '%d,%d,%d,%d,%g\n',k-1,l,i,i,tmpF(i,i));
end
end
else
error(sprintf('Inconsistent data at F{%d,%d}',l,k));
fclose(fid);
return;
end
end
end
% close file
fclose(fid);
% End of File
|