Home > atmlab > arts > xml > xmlWriteTensor6.m

xmlWriteTensor6

PURPOSE ^

Writes a Tensor6 to an XML file.

SYNOPSIS ^

function xmlWriteTensor6(fid, fidb, data, precision, attrlist)

DESCRIPTION ^

 Writes a Tensor6 to an XML file.

    Internal function that should never be called directly.
    Use *xmlStore* instead.

 FORMAT   xmlWriteTensor6(fid, fidb, data, precision)

 IN    fid    File descriptor
 IN    fidb       File descriptor for binary file
 IN    data   Tensor6
 IN    precision  Precision for floats

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlWriteTensor6.m

SOURCE CODE ^

0001 % Writes a Tensor6 to an XML file.
0002 %
0003 %    Internal function that should never be called directly.
0004 %    Use *xmlStore* instead.
0005 %
0006 % FORMAT   xmlWriteTensor6(fid, fidb, data, precision)
0007 %
0008 % IN    fid    File descriptor
0009 % IN    fidb       File descriptor for binary file
0010 % IN    data   Tensor6
0011 % IN    precision  Precision for floats
0012 
0013 % 2002-12-13  Created by Oliver Lemke.
0014 
0015 function xmlWriteTensor6(fid, fidb, data, precision, attrlist)
0016 
0017 if nargin < 5
0018   attrlist = [];
0019 end
0020 
0021 s = size (data);
0022 
0023 for i = (ndims (data)+1):6
0024   s(i) = 1;
0025 end
0026 
0027 nv = s(1);
0028 ns = s(2);
0029 nb = s(3);
0030 np = s(4);
0031 nr = s(5);
0032 nc = s(6);
0033 
0034 attrlist = xmlAddAttribute (attrlist, 'nvitrines', sprintf ('%d', nv));
0035 attrlist = xmlAddAttribute (attrlist, 'nshelves', sprintf ('%d', ns));
0036 attrlist = xmlAddAttribute (attrlist, 'nbooks', sprintf ('%d', nb));
0037 attrlist = xmlAddAttribute (attrlist, 'npages', sprintf ('%d', np));
0038 attrlist = xmlAddAttribute (attrlist, 'nrows', sprintf ('%d', nr));
0039 attrlist = xmlAddAttribute (attrlist, 'ncols', sprintf ('%d', nc));
0040 
0041 xmlWriteTag (fid, 'Tensor6', attrlist);
0042 
0043 data = permute (data, [6 5 4 3 2 1]);
0044 
0045 if (strcmp(precision, 'BINARY'))
0046     fwrite (fidb, data, 'double');
0047 else
0048     format=xmlGetPrecisionFormatString (precision);
0049     form=format;
0050     for i = 1:(nc-1)
0051         form = sprintf ('%s %s', form, format);
0052     end
0053     form = [form '\n'];
0054     fprintf (fid, form, data);
0055 end
0056 
0057 xmlWriteCloseTag (fid, 'Tensor6');
0058

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005