This file is indexed.

/usr/lib/petscdir/3.7.5/x86_64-linux-gnu-real-debug/share/petsc/matlab/PetscBinaryWrite.m is in libpetsc3.7.5-dbg 3.7.5+dfsg1-4+b1.

This file is owned by root:root, with mode 0o755.

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
function PetscBinaryWrite(inarg,varargin)
%
%  Writes in PETSc binary file sparse matrices and vectors.
%  If the array is multidimensional and dense it is saved
%  as a one dimensional PETSc Vec. If you want to save the multidimensional
%  array as a matrix that MatLoad() will read you must first convert it to 
%  a sparse matrix: for example PetscBinaryWrite('myfile',sparse(A));
%
%
%   PetscBinaryWrite(inarg,args to write,['indices','int32' or 'int64'],['precision','float64' or 'float32'],['complex',true,false])
%   inarg may be:
%      filename 
%      socket number (0 for PETSc default)
%      the object returned from PetscOpenSocket or PetscOpenFile
%
if ischar(inarg) 
  fd = PetscOpenFile(inarg,'w');
else if isnumeric(inarg)
  if inarg == 0
    fd = PetscOpenSocket;
  else 
    fd = PetscOpenSocket(inarg);
  end
else 
  fd = inarg;
end
end

indices = 'int32';
precision = 'float64';
ispetsccomplex = false;
tnargin = nargin;
for l=1:nargin-2
  if ischar(varargin{l}) && strcmpi(varargin{l},'indices')
    tnargin = min(l,tnargin-1);
    indices = varargin{l+1};
  end
  if ischar(varargin{l}) && strcmpi(varargin{l},'precision')
    tnargin = min(l,tnargin-1);
    precision = varargin{l+1};
  end
  if ischar(varargin{l}) && strcmpi(varargin{l},'complex')
    tnargin = min(l,tnargin-1);
    ispetsccomplex = varargin{l+1};
  end
end

for l=1:nargin-1
  A = varargin{l};
  if issparse(A) || min(size(A)) > 1
    % save sparse matrix in special Matlab format
    if ~issparse(A)
        A = sparse(A);
    end
    [m,n] = size(A);

    if min(size(A)) == 1     %a one-rank matrix will be compressed to a
                             %scalar instead of a vectory by sum
      n_nz = full(A' ~= 0);
    else
      n_nz = full(sum(A' ~= 0));
    end
    nz   = sum(n_nz);
    write(fd,[1211216,m,n,nz],indices);

    write(fd,n_nz,indices);   %nonzeros per row
    [i,j,s] = find(A');
    write(fd,i-1,indices);
    if ~isreal(s) || ispetsccomplex
      s = conj(s);
      ll = length(s);
      sr = real(s);
      si = imag(s);
      s(1:2:2*ll) = sr;
      s(2:2:2*ll) = si;
    end
    write(fd,s,precision);
  else
    [m,n] = size(A);
    write(fd,[1211214,m*n],indices);
    if ~isreal(A) || ispetsccomplex
      ll = length(A);
      sr = real(A);
      si = imag(A);
      A(1:2:2*ll) = sr;
      A(2:2:2*ll) = si;
    end
    write(fd,A,precision);
  end
end
if ischar(inarg) || isinteger(inarg)
    close(fd)
end