Page 18 - Demo
P. 18
Interface to C/C++%uf09f %uf09f RCP Consult 2023-2025 Page 1810.Built-in Access to binary data containerThe C/C++ interface provides a set of built-in procedures for binding of external data, usually a binary container with a specific organisation. The most popular is MAT-file created by Matlab. Files with the %u201c. mat%u201d extension are files in the binary data container format that Matlab uses. The extension was developed by Mathworks and MAT files are categorized as data files that include variables, functions, arrays and other information. Also, the HDF5-filecreated by The HDF Group gets more popular now. The HDF5 technology is designed to organize, store, discover, access, analyse, share, and preserve diverse, complex data in continuously evolving heterogeneous computing and storage environments. The basic organisation of both binary formats is a directory of symbolic names given for a specific kind of corresponding linked data.The list of accessible functions/subroutines for binding of binary datalong long OpenBinaryDataFileInit(datafile)Open a MAT/HDF5 binary file and read all data fromdatafile (char *) %u2013 filename having extension *.mat or *.h5Returns identifier (long long) of opened data file or 0 if error.void *GetBinaryDataFileVariable(fid, variable, m1, m2, bytes)Returns identifier of variable data, dimensions and bytes of typefid (long long) %u2013 identifier of data filevariable (char *) %u2013 name of variable in directory of data filem1, m2 (longs) %u2013 dimension of variable data arraybytes (long) %u2013 size in bytes of variable data elementvoid CloseBinaryDataFile(fid)Close a MAT/HDF5 binary filefid (long long) %u2013 identifier of data fileThe invoking of binary data file in the source file is very straightforward. First the data file must be opened and becomes an unique identifier. For example long long fid=OpenBinaryDataFile(\or long long fid=OpenBinaryDataFile(\Next a pointer to data array and corresponding dimensions and size in bytes for a variable of interest should be defined. long m1, m2, nb; double *mc=(double *)GetBinaryDataFileVariable(fid,\Now it is possible to reshape an array of variable to a real shape as is stored in data file double (&ar)[m2][m1]=*reinterpret cast(mc);%uf046 The cl compiler does not allow usage of variables in reinterpret_cast statement. Therefore it is necessary to get these values first using Data File Viewer of STRUREL. For example, m1=25 and m2=9. After it is possible to reshape an array of variable to a real shape as is stored in data file double (&ar)[9][25]=*reinterpret_cast(mc);Finally, after loading data from binary file it must be closed by CloseBinaryDataFile(fid);