Home > atmlab > arts > xml > xmlWriteTensor3.m

xmlWriteTensor3

PURPOSE ^

Writes a Tensor3 to an XML file.

SYNOPSIS ^

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

DESCRIPTION ^

 Writes a Tensor3 to an XML file.

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

 FORMAT   xmlWriteTensor3(fid, fidb, data, precision)

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlWriteTensor3.m

SOURCE CODE ^

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

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