Home > atmlab > arts > xml > xmlWriteTensor4.m

xmlWriteTensor4

PURPOSE ^

Writes a Tensor4 to an XML file.

SYNOPSIS ^

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

DESCRIPTION ^

 Writes a Tensor4 to an XML file.

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

 FORMAT   xmlWriteTensor4(fid, fidb, data, precision)

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlWriteTensor4.m

SOURCE CODE ^

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

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