| 1 |
@c Copyright (c) 2015-2026, The matio contributors |
| 2 |
@c Copyright (c) 2011-2014, Christopher C. Hulbert |
| 3 |
@c All rights reserved. |
| 4 |
@c |
| 5 |
@c Redistribution and use in source and binary forms, with or without |
| 6 |
@c modification, are permitted provided that the following conditions are met: |
| 7 |
@c |
| 8 |
@c 1. Redistributions of source code must retain the above copyright notice, this |
| 9 |
@c list of conditions and the following disclaimer. |
| 10 |
@c |
| 11 |
@c 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 |
@c this list of conditions and the following disclaimer in the documentation |
| 13 |
@c and/or other materials provided with the distribution. |
| 14 |
@c |
| 15 |
@c THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 |
@c AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 |
@c IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 18 |
@c DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 19 |
@c FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 20 |
@c DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 21 |
@c SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 22 |
@c CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 23 |
@c OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 |
@c OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 |
|
| 26 |
@chapter Introduction |
| 27 |
@section About and Licensing |
| 28 |
The @emph{matio} software contains a library for reading and writing MATLAB MAT |
| 29 |
files. The @emph{matio} library (@emph{libmatio}) is the primary interface for |
| 30 |
creating/opening MAT files, and writing/ reading variables. |
| 31 |
|
| 32 |
This @emph{matio} software is provided with the Simplified BSD License |
| 33 |
reproduced below. The license allows for commercial, proprietary, and open |
| 34 |
source derivative works. |
| 35 |
|
| 36 |
@verbatim |
| 37 |
Copyright (c) 2015-2026, The matio contributors |
| 38 |
Copyright (c) 2011-2014, Christopher C. Hulbert |
| 39 |
All rights reserved. |
| 40 |
|
| 41 |
Redistribution and use in source and binary forms, with or without |
| 42 |
modification, are permitted provided that the following conditions are met: |
| 43 |
|
| 44 |
1. Redistributions of source code must retain the above copyright notice, |
| 45 |
this list of conditions and the following disclaimer. |
| 46 |
|
| 47 |
2. Redistributions in binary form must reproduce the above copyright notice, |
| 48 |
this list of conditions and the following disclaimer in the documentation |
| 49 |
and/or other materials provided with the distribution. |
| 50 |
|
| 51 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 52 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 53 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 54 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 55 |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 56 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 57 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 58 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 59 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 60 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 61 |
POSSIBILITY OF SUCH DAMAGE. |
| 62 |
@end verbatim |
| 63 |
|
| 64 |
@section Incompatible Changes from 1.3 |
| 65 |
This version has changes that break compatibility with the 1.3 versions of the |
| 66 |
@emph{matio} software. This section lists these changes and how existing code |
| 67 |
should be modified to handle these changes. |
| 68 |
@enumerate |
| 69 |
@item dims field of matvar_t structure changed to size_t@tie{}* |
| 70 |
@item MEM_CONSERVE preprocessor definition removed |
| 71 |
@item BY_NAME and BY_INDEX renamed |
| 72 |
@item Added @code{MAT_} prefix to enumerations of @code{matio_compression} |
| 73 |
@item Changed name of structure for complex split-format data from |
| 74 |
@code{struct ComplexSplit} to @code{struct mat_complex_split_t} |
| 75 |
@item Changed name of sparse data structure from @code{sparse_t} to |
| 76 |
@code{mat_sparse_t}. |
| 77 |
@item Changed meaning of memory conservation for cell arrays and structures |
| 78 |
@end enumerate |
| 79 |
Each of these changes are described in the remaining sections, and as necessary |
| 80 |
include recommendations to upgrade existing code for compatibility with this |
| 81 |
version. |
| 82 |
|
| 83 |
@subsection Type Change for Dimensions Array |
| 84 |
The existing dims field of the @code{matvar_t} structure was an @code{int@tie{}*} |
| 85 |
which limited the maximum size of a dimension to @math{2^{31}}. In version 1.5, |
| 86 |
the type was changed to @code{size_t@tie{}*} which allows a variable of length |
| 87 |
@math{2^{31}} on 32-bit systems, but @math{2^{64} - 1} on 64-bit system. To |
| 88 |
upgrade to version 1.5, all existing code should ensure the use of @code{dims} |
| 89 |
allows for @code{size_t}, and that any use of the @code{Mat_VarCreate} function |
| 90 |
passes an array of type @code{size_t} and not @code{int}. Not upgrading to |
| 91 |
@code{size_t} is likely to produce segmentation faults on systems where |
| 92 |
@code{sizeof(size_t) != sizeof(int)}. |
| 93 |
|
| 94 |
@subsection Removed Preprocessor Flag to Conserve Memory |
| 95 |
Previous versions of the @emph{matio} library had a preprocessor macro |
| 96 |
@code{MEM_CONSERVE} that was passed as an option to @code{Mat_VarCreate} to tell |
| 97 |
the library to only store a pointer to the data variable instead of creating a |
| 98 |
copy of the data. Copies of scalars or small arrays are not critical, but for |
| 99 |
large arrays is necessary. In version 1.5, this macro has been changed to the |
| 100 |
enumeration value @code{MAT_F_DONT_COPY_DATA}. A quick search/replace can |
| 101 |
quickly upgrade any references to @code{MEM_CONSERVE}. Alternatively, since |
| 102 |
@code{MAT_F_DONT_COPY_DATA} has the same value as @code{MEM_CONSERVE}, software |
| 103 |
using @emph{matio} can simply define @code{MEM_CONSERVE} to 1. |
| 104 |
|
| 105 |
@subsection Renamed Structure Field Lookup Enumerations |
| 106 |
The @code{BY_NAME} and @code{BY_INDEX} enumerations are used by |
| 107 |
@code{Mat_VarGetStructField} to indicate if the field is retrieved by its name, |
| 108 |
or by its index in the list of fields. To bring these into a @emph{matio} |
| 109 |
namespace and hopefully avoid conflicts, these have been renamed to |
| 110 |
@code{MAT_BY_NAME} and @code{MAT_BY_INDEX}. A quick search/replace operation |
| 111 |
should be able to correct existing code that uses the old names. |
| 112 |
|
| 113 |
@subsection Memory Conservation with Cells and Structures |
| 114 |
Previous versions of @emph{matio} would still free fields of structures and |
| 115 |
elements of cell arrays even if created with memory conservation flag set. In |
| 116 |
the latest version of @emph{matio}, the fields/cell elements are not free'd if |
| 117 |
the structure was created with the @code{MAT_F_DONT_COPY_DATA} flag. This is |
| 118 |
useful if the fields/elements are referenced by another variable such as the |
| 119 |
case when they are indices of a larger array (i.e. @code{Mat_VarGetStructs}, |
| 120 |
@code{Mat_VarGetStructsLinear}). |