Home > atmlab > arts > xml > xmlWriteTensor5.m

xmlWriteTensor5

PURPOSE ^

Writes a Tensor5 to an XML file.

SYNOPSIS ^

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

DESCRIPTION ^

 Writes a Tensor5 to an XML file.

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

 FORMAT   xmlWriteTensor5(fid, fidb, data, precision)

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlWriteTensor5.m

SOURCE CODE ^

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

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