Home > atmlab > arts > xml > xmlWriteTensor7.m

xmlWriteTensor7

PURPOSE ^

Writes a Tensor7 to an XML file.

SYNOPSIS ^

function xmlWriteTensor7(fid, fidb, data, precision)

DESCRIPTION ^

 Writes a Tensor7 to an XML file.

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

 FORMAT   xmlWriteTensor7(fid, fidb, data, precision)

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlWriteTensor7.m

SOURCE CODE ^

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

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