1
function xmlmatrix(filename, A)
3
% XMLMATRIX - SAVE MATRIX TO DOLFIN IN XML FORMAT
5
% Usage: xmlmatrix(filename, A)
9
% Copyright (C) 2004 Georgios Foufas.
10
% Licensed under the GNU LGPL Version 2.1.
12
% Modified by Anders Logg 2004-2005.
14
% First added: 2004-02-10
17
% Tolerance for sparse matrix
21
fp = fopen(filename,'w');
28
fprintf(fp,'<?xml version="1.0" encoding="UTF-8"?>\n\n');
29
fprintf(fp,'<dolfin xmlns:dolfin="http://www.phi.chalmers.se/dolfin/">\n');
32
disp('Writing matrix...')
33
fprintf(fp,' <sparsematrix rows="%d" columns="%d">\n',nrows,ncols);
38
size = round(length(find(abs(A(i,:)) > tol)));
40
fprintf(fp,' <row row="%d" size="%d"/>\n', i-1, size);
45
fprintf(fp,' <element column="%d" value="%f"/>\n', j-1, A(i,j));
49
fprintf(fp,' </row>\n');
53
fprintf(fp,' </sparsematrix>\n');
54
fprintf(fp,'</dolfin>\n');