diff --git a/HDF5Examples/JAVA/H5T/H5Ex_T_Commit.java b/HDF5Examples/JAVA/H5T/H5Ex_T_Commit.java index cd26a96e25b..db46cf38663 100644 --- a/HDF5Examples/JAVA/H5T/H5Ex_T_Commit.java +++ b/HDF5Examples/JAVA/H5T/H5Ex_T_Commit.java @@ -47,7 +47,8 @@ enum H5T_class { H5T_ENUM(HDF5Constants.H5T_ENUM), // enumeration types H5T_VLEN(HDF5Constants.H5T_VLEN), // Variable-Length types H5T_ARRAY(HDF5Constants.H5T_ARRAY), // Array types - H5T_NCLASSES(11); // this must be last + H5T_COMPLEX(HDF5Constants.H5T_COMPLEX), // Complex number types + H5T_NCLASSES(12); // this must be last private static final Map lookup = new HashMap(); diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 5135e0c7fa7..0d5281f65ca 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -632,7 +632,7 @@ test_attr_compound_write(FileAccPropList &fapl) hsize_t dims2[] = {ATTR4_DIM1, ATTR4_DIM2}; DataSpace sid2(ATTR4_RANK, dims2); - // Create complex attribute for the dataset + // Create compound attribute for the dataset Attribute attr = dataset.createAttribute(ATTR4_NAME, comp_type, sid2); // Try to create the same attribute again (should fail) @@ -643,7 +643,7 @@ test_attr_compound_write(FileAccPropList &fapl) { } // do nothing, exception expected - // Write complex attribute data + // Write compound attribute data attr.write(comp_type, attr_data4); PASSED(); @@ -2001,8 +2001,8 @@ test_attr() test_attr_rename(curr_fapl); // Test renaming attribute test_attr_basic_read(curr_fapl); // Test basic H5A reading code - test_attr_compound_write(curr_fapl); // Test complex datatype H5A writing code - test_attr_compound_read(curr_fapl); // Test complex datatype H5A reading code + test_attr_compound_write(curr_fapl); // Test compound datatype H5A writing code + test_attr_compound_read(curr_fapl); // Test compound datatype H5A reading code test_attr_scalar_write(curr_fapl); // Test scalar dataspace H5A writing code test_attr_scalar_read(curr_fapl); // Test scalar dataspace H5A reading code diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index af2d13e5180..20e077ad64e 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -816,6 +816,31 @@ macro (H5ConversionTests TEST def msg) endif () endmacro () +#----------------------------------------------------------------------------- +# Check for complex number support +#----------------------------------------------------------------------------- +message (STATUS "Checking if complex number support is available") +HDF_CHECK_TYPE_SIZE ("float _Complex" ${HDF_PREFIX}_SIZEOF_FLOAT_COMPLEX) +HDF_CHECK_TYPE_SIZE ("double _Complex" ${HDF_PREFIX}_SIZEOF_DOUBLE_COMPLEX) +HDF_CHECK_TYPE_SIZE ("long double _Complex" ${HDF_PREFIX}_SIZEOF_LONG_DOUBLE_COMPLEX) + +if (${HDF_PREFIX}_SIZEOF_FLOAT_COMPLEX AND ${HDF_PREFIX}_SIZEOF_DOUBLE_COMPLEX AND + ${HDF_PREFIX}_SIZEOF_LONG_DOUBLE_COMPLEX) + # Check if __STDC_NO_COMPLEX__ macro is defined, in which case complex number + # support is not available + HDF_FUNCTION_TEST (HAVE_STDC_NO_COMPLEX) + + if (NOT H5_HAVE_STDC_NO_COMPLEX) + # TODO: imaginary number support + + set (${HDF_PREFIX}_HAVE_COMPLEX_NUMBERS 1) + else () + message (STATUS "Complex number support has been disabled since __STDC_NO_COMPLEX__ is defined") + endif () +else () + message (STATUS "Complex number support has been disabled since the C types were not found") +endif () + #----------------------------------------------------------------------------- # Check various conversion capabilities #----------------------------------------------------------------------------- diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index c6e3a619162..8f07ea18e4b 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -110,6 +110,9 @@ /* Define to 1 if CLOCK_MONOTONIC_COARSE is available */ #cmakedefine H5_HAVE_CLOCK_MONOTONIC_COARSE @H5_HAVE_CLOCK_MONOTONIC_COARSE@ +/* Define if complex number support is available */ +#cmakedefine H5_HAVE_COMPLEX_NUMBERS @H5_HAVE_COMPLEX_NUMBERS@ + /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_CURL_CURL_H @H5_HAVE_CURL_H@ @@ -445,9 +448,15 @@ /* The size of `double', as computed by sizeof. */ #cmakedefine H5_SIZEOF_DOUBLE @H5_SIZEOF_DOUBLE@ +/* The size of `double _Complex', as computed by sizeof. */ +#cmakedefine H5_SIZEOF_DOUBLE_COMPLEX @H5_SIZEOF_DOUBLE_COMPLEX@ + /* The size of `float', as computed by sizeof. */ #cmakedefine H5_SIZEOF_FLOAT @H5_SIZEOF_FLOAT@ +/* The size of `float _Complex', as computed by sizeof. */ +#cmakedefine H5_SIZEOF_FLOAT_COMPLEX @H5_SIZEOF_FLOAT_COMPLEX@ + /* The size of `int', as computed by sizeof. */ #cmakedefine H5_SIZEOF_INT @H5_SIZEOF_INT@ @@ -501,6 +510,9 @@ /* The size of `long double', as computed by sizeof. */ #cmakedefine H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@ +/* The size of `long double _Complex', as computed by sizeof. */ +#cmakedefine H5_SIZEOF_LONG_DOUBLE_COMPLEX @H5_SIZEOF_LONG_DOUBLE_COMPLEX@ + #else /* On Apple, to support Universal Binaries (where multiple CPU @@ -520,10 +532,13 @@ # if defined(__i386__) || defined(__x86_64__) #define H5_SIZEOF_LONG_DOUBLE 16 + #define H5_SIZEOF_LONG_DOUBLE_COMPLEX 32 # elif defined(__aarch64__) #define H5_SIZEOF_LONG_DOUBLE 8 + #define H5_SIZEOF_LONG_DOUBLE_COMPLEX 16 # else #cmakedefine H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@ + #cmakedefine H5_SIZEOF_LONG_DOUBLE_COMPLEX @H5_SIZEOF_LONG_DOUBLE_COMPLEX@ # endif #endif diff --git a/config/cmake/HDFTests.c b/config/cmake/HDFTests.c index 8d0e78f46b7..7f9ca7684c1 100644 --- a/config/cmake/HDFTests.c +++ b/config/cmake/HDFTests.c @@ -118,3 +118,34 @@ main(void) #endif } #endif + +#ifdef HAVE_STDC_NO_COMPLEX +#ifndef __STDC_NO_COMPLEX__ +#error "__STDC_NO_COMPLEX__ not defined" +#else +int +main(void) +{ + return 0; +} +#endif +#endif + +#ifdef HAVE_COMPLEX_NUMBERS +#include + +int +main(void) +{ + float _Complex z1 = 1.0f + 3.0f * I; + double _Complex z2 = 2.0 + 4.0 * I; + long double _Complex z3 = 3.0L + 5.0L * I; + float r1 = creal(z1); + float i1 = cimag(z1); + double r2 = creal(z2); + double i2 = cimage(z2); + long double r3 = creal(z3); + long double i3 = cimag(z3); + return 0; +} +#endif diff --git a/doxygen/aliases b/doxygen/aliases index e3ec6438021..d6c244ff0a6 100644 --- a/doxygen/aliases +++ b/doxygen/aliases @@ -370,7 +370,7 @@ ALIASES += ref_rfc20040811="Conve ALIASES += click4more="(Click on a enumerator, field, or type for more information.)" ALIASES += csets="
#H5T_CSET_ASCIIUS ASCII
#H5T_CSET_UTF8UTF-8 Unicode encoding
" -ALIASES += datatype_class=" \li #H5T_INTEGER \li #H5T_FLOAT \li #H5T_STRING \li #H5T_BITFIELD \li #H5T_OPAQUE \li #H5T_COMPOUND \li #H5T_REFERENCE \li #H5T_ENUM \li #H5T_VLEN \li #H5T_ARRAY" +ALIASES += datatype_class=" \li #H5T_INTEGER \li #H5T_FLOAT \li #H5T_STRING \li #H5T_BITFIELD \li #H5T_OPAQUE \li #H5T_COMPOUND \li #H5T_REFERENCE \li #H5T_ENUM \li #H5T_VLEN \li #H5T_ARRAY \li #H5T_COMPLEX" ALIASES += file_access="
#H5F_ACC_RDWRFile was opened with read/write access.
#H5F_ACC_RDONLYFile was opened with read-only access.
#H5F_ACC_SWMR_WRITEFile was opened with read/write access for a single-writer/multiple-reader (SWMR) scenario. Note that the writer process must also open the file with the #H5F_ACC_RDWR flag.
#H5F_ACC_SWMR_READFile was opened with read-only access for a single-writer/multiple-reader (SWMR) scenario. Note that the reader process must also open the file with the #H5F_ACC_RDONLY flag.
" ALIASES += id_types="
#H5I_FILEFile
#H5I_GROUPGroup
#H5I_DATATYPEDatatype
#H5I_DATASPACEDataspace
#H5I_DATASETDataset
#H5I_ATTRAttribute
" ALIASES += indexes="
#H5_INDEX_NAMELexicographic order on name
#H5_INDEX_CRT_ORDERIndex on creation order
" diff --git a/doxygen/dox/DDLBNF114.dox b/doxygen/dox/DDLBNF114.dox index 61e9157e560..d7914d71f1a 100644 --- a/doxygen/dox/DDLBNF114.dox +++ b/doxygen/dox/DDLBNF114.dox @@ -1,4 +1,4 @@ -/** \page DDLBNF114 DDL in BNF for HDF5 1.14.4 and above +/** \page DDLBNF114 DDL in BNF for HDF5 1.14.5 and above \todo Revise this & break it up! @@ -63,7 +63,8 @@ This section contains a brief explanation of the symbols used in the DDL. * } - ::= | | | + ::= | | | | + ::= DATATYPE { @@ -169,6 +170,15 @@ This section contains a brief explanation of the symbols used in the DDL. ::= + ::= H5T_COMPLEX { } | + H5T_NATIVE_FLOAT_COMPLEX | H5T_NATIVE_DOUBLE_COMPLEX | + H5T_NATIVE_LDOUBLE_COMPLEX + + ::= +// Currently complex number datatypes can only hold homogeneous floating-point +// type data, but they may be expanded in the future to hold heterogeneous +// floating-point type data or even non-floating-point type data + ::= + ::= / diff --git a/doxygen/examples/tables/predefinedDatatypes.dox b/doxygen/examples/tables/predefinedDatatypes.dox index 6cf044af5d4..1743532bc22 100644 --- a/doxygen/examples/tables/predefinedDatatypes.dox +++ b/doxygen/examples/tables/predefinedDatatypes.dox @@ -489,6 +489,18 @@ C-style long double +#H5T_NATIVE_FLOAT_COMPLEX +C-style float _Complex (May be H5I_INVALID_HID if platform doesn't support float _Complex type) + + +#H5T_NATIVE_DOUBLE_COMPLEX +C-style double _Complex (May be H5I_INVALID_HID if platform doesn't support double _Complex type) + + +#H5T_NATIVE_LDOUBLE_COMPLEX +C-style long double _Complex (May be H5I_INVALID_HID if platform doesn't support long double _Complex type) + + #H5T_NATIVE_B8 8-bit bitfield based on native types diff --git a/fortran/src/H5Tf.c b/fortran/src/H5Tf.c index 393873e110b..746c21deb19 100644 --- a/fortran/src/H5Tf.c +++ b/fortran/src/H5Tf.c @@ -212,11 +212,12 @@ h5tequal_c(hid_t_f *type1_id, hid_t_f *type2_id, int_f *c_flag) * H5T_STRING_F (3) * H5T_BITFIELD_F (4) * H5T_OPAQUE_F (5) - * H5T_COMPOUNDF (6) + * H5T_COMPOUND_F (6) * H5T_REFERENCE_F (7) * H5T_ENUM_F (8) * H5T_VLEN_F (9) * H5T_ARRAY_F (10) + * H5T_COMPLEX_F (11) * RETURNS * 0 on success, -1 on failure * SOURCE @@ -239,17 +240,7 @@ h5tget_class_c(hid_t_f *type_id, int_f *classtype) return ret_value; } *classtype = c_classtype; - /* - if (c_classtype == H5T_INTEGER) *classtype = H5T_INTEGER_F; - if (c_classtype == H5T_FLOAT) *classtype = H5T_FLOAT_F; - if (c_classtype == H5T_TIME) *classtype = H5T_TIME_F; - if (c_classtype == H5T_STRING) *classtype = H5T_STRING_F; - if (c_classtype == H5T_BITFIELD) *classtype = H5T_BITFIELD_F; - if (c_classtype == H5T_OPAQUE) *classtype = H5T_OPAQUE_F; - if (c_classtype == H5T_COMPOUND) *classtype = H5T_COMPOUND_F; - if (c_classtype == H5T_REFERENCE) *classtype = H5T_REFERENCE_F; - if (c_classtype == H5T_ENUM) *classtype = H5T_ENUM_F; - */ + return ret_value; } diff --git a/fortran/src/H5Tff.F90 b/fortran/src/H5Tff.F90 index b93e3c3a03c..7c1e84a60e7 100644 --- a/fortran/src/H5Tff.F90 +++ b/fortran/src/H5Tff.F90 @@ -267,6 +267,7 @@ END SUBROUTINE h5tclose_f !! \li H5T_ENUM_F !! \li H5T_VLEN_F !! \li H5T_ARRAY_F +!! \li H5T_COMPLEX_F !! \param hdferr \fortran_error !! !! See C API: @ref H5Tget_class() @@ -1726,9 +1727,9 @@ END SUBROUTINE h5tis_variable_str_f !! !! \brief Returns datatype class of compound datatype member. !! -!! \param type_id Datartpe identifier. +!! \param type_id Datatype identifier. !! \param member_no Index of compound datatype member. -!! \param class Class type for compound dadtype member. Valid classes: +!! \param class Class type for compound datatype member. Valid classes: !! \li H5T_NO_CLASS_F (error) !! \li H5T_INTEGER_F !! \li H5T_FLOAT_F @@ -1741,6 +1742,7 @@ END SUBROUTINE h5tis_variable_str_f !! \li H5T_ENUM_F !! \li H5T_VLEN_F !! \li H5T_ARRAY_F +!! \li H5T_COMPLEX_F !! \param hdferr \fortran_error !! !! See C API: @ref H5Tget_member_class() diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index 530068ba880..2f8351f7545 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -847,6 +847,7 @@ h5init_flags_c(int_f *h5d_flags, size_t_f *h5d_size_flags, int_f *h5e_flags, hid h5t_flags[32] = (int_f)H5T_ARRAY; h5t_flags[33] = (int_f)H5T_DIR_ASCEND; h5t_flags[34] = (int_f)H5T_DIR_DESCEND; + h5t_flags[35] = (int_f)H5T_COMPLEX; /* * H5VL flags diff --git a/fortran/src/H5_ff.F90 b/fortran/src/H5_ff.F90 index fb3bba67198..1b819af9c87 100644 --- a/fortran/src/H5_ff.F90 +++ b/fortran/src/H5_ff.F90 @@ -144,7 +144,7 @@ MODULE H5LIB ! ! H5T flags declaration ! - INTEGER, PARAMETER :: H5T_FLAGS_LEN = 35 + INTEGER, PARAMETER :: H5T_FLAGS_LEN = 36 INTEGER, DIMENSION(1:H5T_FLAGS_LEN) :: H5T_flags ! ! H5VL flags declaration @@ -704,6 +704,7 @@ END FUNCTION h5init1_flags_c H5T_ARRAY_F = H5T_flags(33) H5T_DIR_ASCEND_F = H5T_flags(34) H5T_DIR_DESCEND_F = H5T_flags(35) + H5T_COMPLEX_F = H5T_flags(36) ! ! H5VL flags ! diff --git a/fortran/src/H5f90global.F90 b/fortran/src/H5f90global.F90 index 4794bdc83c8..ececaa8ddab 100644 --- a/fortran/src/H5f90global.F90 +++ b/fortran/src/H5f90global.F90 @@ -861,6 +861,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5T_ENUM_F !DEC$ATTRIBUTES DLLEXPORT :: H5T_VLEN_F !DEC$ATTRIBUTES DLLEXPORT :: H5T_ARRAY_F + !DEC$ATTRIBUTES DLLEXPORT :: H5T_COMPLEX_F !DEC$ATTRIBUTES DLLEXPORT :: H5T_ORDER_LE_F !DEC$ATTRIBUTES DLLEXPORT :: H5T_ORDER_BE_F !DEC$ATTRIBUTES DLLEXPORT :: H5T_ORDER_VAX_F @@ -899,6 +900,7 @@ MODULE H5GLOBAL INTEGER :: H5T_ENUM_F !< H5T_ENUM INTEGER :: H5T_VLEN_F !< H5T_VLEN INTEGER :: H5T_ARRAY_F !< H5T_ARRAY + INTEGER :: H5T_COMPLEX_F !< H5T_COMPLEX INTEGER :: H5T_ORDER_LE_F !< H5T_ORDER_LE INTEGER :: H5T_ORDER_BE_F !< H5T_ORDER_BE INTEGER :: H5T_ORDER_VAX_F !< H5T_ORDER_VAX diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 7d44792fbc0..311b348920b 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -2753,6 +2753,13 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bo break; } + case H5T_COMPLEX: + snprintf(dt_str, *slen, "H5T_COMPLEX {"); + + /* TODO */ + + break; + case H5T_TIME: snprintf(dt_str, *slen, "H5T_TIME: not yet implemented"); break; diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l index a573f8137f3..99418c5b0ad 100644 --- a/hl/src/H5LTanalyze.l +++ b/hl/src/H5LTanalyze.l @@ -93,6 +93,10 @@ H5T_NATIVE_FLOAT {return hid(H5T_NATIVE_FLOAT_TOKEN);} H5T_NATIVE_DOUBLE {return hid(H5T_NATIVE_DOUBLE_TOKEN);} H5T_NATIVE_LDOUBLE {return hid(H5T_NATIVE_LDOUBLE_TOKEN);} +H5T_NATIVE_FLOAT_COMPLEX {return hid(H5T_NATIVE_FLOAT_COMPLEX_TOKEN);} +H5T_NATIVE_DOUBLE_COMPLEX {return hid(H5T_NATIVE_DOUBLE_COMPLEX_TOKEN);} +H5T_NATIVE_LDOUBLE_COMPLEX {return hid(H5T_NATIVE_LDOUBLE_COMPLEX_TOKEN);} + H5T_STRING {return token(H5T_STRING_TOKEN);} STRSIZE {return token(STRSIZE_TOKEN);} STRPAD {return token(STRPAD_TOKEN);} @@ -111,6 +115,7 @@ H5T_COMPOUND {return token(H5T_COMPOUND_TOKEN);} H5T_ENUM {return token(H5T_ENUM_TOKEN);} H5T_ARRAY {return token(H5T_ARRAY_TOKEN);} H5T_VLEN {return token(H5T_VLEN_TOKEN);} +H5T_COMPLEX {return token(H5T_COMPLEX_TOKEN);} H5T_OPAQUE {return token(H5T_OPAQUE_TOKEN);} OPQ_SIZE {return token(OPQ_SIZE_TOKEN);} diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y index 3a14e769419..844d8998cc3 100644 --- a/hl/src/H5LTparse.y +++ b/hl/src/H5LTparse.y @@ -83,6 +83,8 @@ static char* enum_memb_symbol; /*enum member symbol string*/ %token H5T_IEEE_F32BE_TOKEN H5T_IEEE_F32LE_TOKEN H5T_IEEE_F64BE_TOKEN H5T_IEEE_F64LE_TOKEN %token H5T_NATIVE_FLOAT16_TOKEN H5T_NATIVE_FLOAT_TOKEN H5T_NATIVE_DOUBLE_TOKEN H5T_NATIVE_LDOUBLE_TOKEN +%token H5T_NATIVE_FLOAT_COMPLEX_TOKEN H5T_NATIVE_DOUBLE_COMPLEX_TOKEN H5T_NATIVE_LDOUBLE_COMPLEX_TOKEN + %token H5T_STRING_TOKEN STRSIZE_TOKEN STRPAD_TOKEN CSET_TOKEN CTYPE_TOKEN H5T_VARIABLE_TOKEN %token H5T_STR_NULLTERM_TOKEN H5T_STR_NULLPAD_TOKEN H5T_STR_SPACEPAD_TOKEN %token H5T_CSET_ASCII_TOKEN H5T_CSET_UTF8_TOKEN H5T_C_S1_TOKEN H5T_FORTRAN_S1_TOKEN @@ -93,6 +95,7 @@ static char* enum_memb_symbol; /*enum member symbol string*/ %token H5T_ENUM_TOKEN %token H5T_ARRAY_TOKEN %token H5T_VLEN_TOKEN +%token H5T_COMPLEX_TOKEN %token STRING %token NUMBER @@ -106,6 +109,7 @@ ddl_type : atomic_type | compound_type | array_type | vlen_type + | complex_type ; atomic_type : integer_type | fp_type diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c index b4dd62fd70c..d3178bdc1a0 100644 --- a/hl/tools/h5watch/h5watch.c +++ b/hl/tools/h5watch/h5watch.c @@ -176,6 +176,8 @@ doprint(hid_t did, const hsize_t *start, const hsize_t *block, int rank) snprintf(fmt_double, sizeof(fmt_double), "%%1.%dg", DBL_DIG); info.fmt_double = fmt_double; + /* TODO: set complex number format here */ + info.dset_format = "DSET-%s "; info.dset_hidefileno = 0; diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 388ba18f87a..25fa61d7284 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -14250,6 +14250,8 @@ else if (HDF5Constants.H5T_VLEN == class_id) /* Variable-Length types */ retValue = "H5T_VLEN"; else if (HDF5Constants.H5T_ARRAY == class_id) /* Array types */ retValue = "H5T_ARRAY"; + else if (HDF5Constants.H5T_COMPLEX == class_id) /* Complex number types */ + retValue = "H5T_COMPLEX"; else retValue = "H5T_NO_CLASS"; diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index 55b6f4be913..b62fee46713 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -1041,6 +1041,8 @@ public class HDF5Constants { /** */ public static final long H5T_C_S1 = H5T_C_S1(); /** */ + public static final int H5T_COMPLEX = H5T_COMPLEX(); + /** */ public static final int H5T_COMPOUND = H5T_COMPOUND(); /** */ public static final int H5T_CONV_CONV = H5T_CONV_CONV(); @@ -1177,10 +1179,14 @@ public class HDF5Constants { /** */ public static final long H5T_NATIVE_DOUBLE = H5T_NATIVE_DOUBLE(); /** */ + public static final long H5T_NATIVE_DOUBLE_COMPLEX = H5T_NATIVE_DOUBLE_COMPLEX(); + /** */ public static final long H5T_NATIVE_FLOAT = H5T_NATIVE_FLOAT(); /** */ public static final long H5T_NATIVE_FLOAT16 = H5T_NATIVE_FLOAT16(); /** */ + public static final long H5T_NATIVE_FLOAT_COMPLEX = H5T_NATIVE_FLOAT_COMPLEX(); + /** */ public static final long H5T_NATIVE_HADDR = H5T_NATIVE_HADDR(); /** */ public static final long H5T_NATIVE_HBOOL = H5T_NATIVE_HBOOL(); @@ -1223,6 +1229,8 @@ public class HDF5Constants { /** */ public static final long H5T_NATIVE_LONG = H5T_NATIVE_LONG(); /** */ + public static final long H5T_NATIVE_LDOUBLE_COMPLEX = H5T_NATIVE_LDOUBLE_COMPLEX(); + /** */ public static final long H5T_NATIVE_OPAQUE = H5T_NATIVE_OPAQUE(); /** */ public static final long H5T_NATIVE_SCHAR = H5T_NATIVE_SCHAR(); @@ -2532,6 +2540,8 @@ public class HDF5Constants { private static native final long H5T_C_S1(); + private static native final int H5T_COMPLEX(); + private static native final int H5T_COMPOUND(); private static native final int H5T_CONV_CONV(); @@ -2668,10 +2678,14 @@ public class HDF5Constants { private static native final long H5T_NATIVE_DOUBLE(); + private static native final long H5T_NATIVE_DOUBLE_COMPLEX(); + private static native final long H5T_NATIVE_FLOAT(); private static native final long H5T_NATIVE_FLOAT16(); + private static native final long H5T_NATIVE_FLOAT_COMPLEX(); + private static native final long H5T_NATIVE_HADDR(); private static native final long H5T_NATIVE_HBOOL(); @@ -2714,6 +2728,8 @@ public class HDF5Constants { private static native final long H5T_NATIVE_LONG(); + private static native final long H5T_NATIVE_LDOUBLE_COMPLEX(); + private static native final long H5T_NATIVE_OPAQUE(); private static native final long H5T_NATIVE_SCHAR(); diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index 41395a4413f..8e958e55a04 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -2543,6 +2543,11 @@ Java_hdf_hdf5lib_HDF5Constants_H5T_1C_1S1(JNIEnv *env, jclass cls) return H5T_C_S1; } JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5T_1COMPLEX(JNIEnv *env, jclass cls) +{ + return H5T_COMPLEX; +} +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1COMPOUND(JNIEnv *env, jclass cls) { return H5T_COMPOUND; @@ -2883,6 +2888,11 @@ Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1DOUBLE(JNIEnv *env, jclass cls) return H5T_NATIVE_DOUBLE; } JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1DOUBLE_1COMPLEX(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_DOUBLE_COMPLEX; +} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1FLOAT(JNIEnv *env, jclass cls) { return H5T_NATIVE_FLOAT; @@ -2893,6 +2903,11 @@ Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1FLOAT16(JNIEnv *env, jclass cls) return H5T_NATIVE_FLOAT16; } JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1FLOAT_1COMPLEX(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_FLOAT_COMPLEX; +} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HADDR(JNIEnv *env, jclass cls) { return H5T_NATIVE_HADDR; @@ -2998,6 +3013,11 @@ Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LONG(JNIEnv *env, jclass cls) return H5T_NATIVE_LONG; } JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LDOUBLE_1COMPLEX(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_LDOUBLE_COMPLEX; +} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1OPAQUE(JNIEnv *env, jclass cls) { return H5T_NATIVE_OPAQUE; diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index 54c862eff6c..73b4d0fef18 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -1243,12 +1243,13 @@ Java_hdf_hdf5lib_H5_H5Aread_1VLStrings(JNIEnv *env, jclass clss, jlong attr_id, jobjectArray buf) { H5T_class_t type_class; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; - htri_t isComplex2 = 0; - hid_t nested_tid = H5I_INVALID_HID; - herr_t status = FAIL; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isCompound = 0; + htri_t isVlen = 0; + hid_t nested_tid = H5I_INVALID_HID; + bool isComposite = false; + herr_t status = FAIL; UNUSED(clss); @@ -1272,13 +1273,13 @@ Java_hdf_hdf5lib_H5_H5Aread_1VLStrings(JNIEnv *env, jclass clss, jlong attr_id, if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if ((isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) + if ((isCompound = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if ((isComplex2 = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) + if ((isVlen = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) H5_LIBRARY_ERROR(ENVONLY); - isComplex = isComplex || isComplex2; + isComposite = isCompound || isVlen; if (H5Tclose(nested_tid) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1289,7 +1290,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1VLStrings(JNIEnv *env, jclass clss, jlong attr_id, isVlenStr = 1; /* Strings created by H5Tvlen_create(H5T_C_S1) */ } - if (!isStr || isComplex || isVlenStr) { + if (!isStr || isComposite || isVlenStr) { if ((status = H5AreadVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } @@ -1447,12 +1448,13 @@ Java_hdf_hdf5lib_H5_H5Awrite_1VLStrings(JNIEnv *env, jclass clss, jlong attr_id, jobjectArray buf) { H5T_class_t type_class; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; - htri_t isComplex2 = 0; - hid_t nested_tid = H5I_INVALID_HID; - herr_t status = FAIL; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isCompound = 0; + htri_t isVlen = 0; + hid_t nested_tid = H5I_INVALID_HID; + bool isComposite = false; + herr_t status = FAIL; UNUSED(clss); @@ -1476,13 +1478,13 @@ Java_hdf_hdf5lib_H5_H5Awrite_1VLStrings(JNIEnv *env, jclass clss, jlong attr_id, if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if ((isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) + if ((isCompound = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if ((isComplex2 = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) + if ((isVlen = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) H5_LIBRARY_ERROR(ENVONLY); - isComplex = isComplex || isComplex2; + isComposite = isCompound || isVlen; if (H5Tclose(nested_tid) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1493,7 +1495,7 @@ Java_hdf_hdf5lib_H5_H5Awrite_1VLStrings(JNIEnv *env, jclass clss, jlong attr_id, isVlenStr = 1; /* Strings created by H5Tvlen_create(H5T_C_S1) */ } - if (!isStr || isComplex || isVlenStr) { + if (!isStr || isComposite || isVlenStr) { if ((status = H5AwriteVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index f6318b222d4..7447eca2e88 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -1259,12 +1259,13 @@ Java_hdf_hdf5lib_H5_H5Dread_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_i jobjectArray buf) { H5T_class_t type_class; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; - htri_t isComplex2 = 0; - hid_t nested_tid = H5I_INVALID_HID; - herr_t status = FAIL; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isCompound = 0; + htri_t isVlen = 0; + hid_t nested_tid = H5I_INVALID_HID; + bool isComposite = false; + herr_t status = FAIL; UNUSED(clss); @@ -1288,13 +1289,13 @@ Java_hdf_hdf5lib_H5_H5Dread_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_i if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if ((isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) + if ((isCompound = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if ((isComplex2 = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) + if ((isVlen = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) H5_LIBRARY_ERROR(ENVONLY); - isComplex = isComplex || isComplex2; + isComposite = isCompound || isVlen; if (H5Tclose(nested_tid) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1305,7 +1306,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_i isVlenStr = 1; /* Strings created by H5Tvlen_create(H5T_C_S1) */ } - if (!isStr || isComplex || isVlenStr) { + if (!isStr || isComposite || isVlenStr) { if ((status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1484,12 +1485,13 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_ jobjectArray buf) { H5T_class_t type_class; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; - htri_t isComplex2 = 0; - hid_t nested_tid = H5I_INVALID_HID; - herr_t status = FAIL; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isCompound = 0; + htri_t isVlen = 0; + hid_t nested_tid = H5I_INVALID_HID; + bool isComposite = false; + herr_t status = FAIL; UNUSED(clss); @@ -1513,13 +1515,13 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_ if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if ((isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) + if ((isCompound = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if ((isComplex2 = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) + if ((isVlen = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) H5_LIBRARY_ERROR(ENVONLY); - isComplex = isComplex || isComplex2; + isComposite = isCompound || isVlen; if (H5Tclose(nested_tid) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1530,7 +1532,7 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_ isVlenStr = 1; /* Strings created by H5Tvlen_create(H5T_C_S1) */ } - if (!isStr || isComplex || isVlenStr) { + if (!isStr || isComposite || isVlenStr) { if ((status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 9c441729a39..90fc92cefbd 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -620,6 +620,10 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_ break; } + case H5T_COMPLEX: + /* TODO */ + break; + case H5T_NCLASSES: case H5T_NO_CLASS: { H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_convert: invalid datatype class"); @@ -1482,6 +1486,10 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i break; } + case H5T_COMPLEX: + /* TODO */ + break; + case H5T_NO_CLASS: case H5T_NCLASSES: { H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: invalid datatype class"); @@ -2116,6 +2124,10 @@ h5str_get_little_endian_type(hid_t tid) break; } + case H5T_COMPLEX: + /* TODO */ + break; + case H5T_NO_CLASS: case H5T_NCLASSES: { goto done; @@ -2212,6 +2224,10 @@ h5str_get_big_endian_type(hid_t tid) break; } + case H5T_COMPLEX: + /* TODO */ + break; + case H5T_NO_CLASS: case H5T_NCLASSES: { goto done; @@ -2468,6 +2484,10 @@ h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hs break; } + case H5T_COMPLEX: + /* TODO */ + break; + case H5T_NO_CLASS: case H5T_NCLASSES: { ret_value = FAIL; @@ -4312,6 +4332,9 @@ translate_atomic_rbuf(JNIEnv *env, jlong mem_type_id, H5T_class_t type_class, vo break; } /* H5T_STRING */ + case H5T_COMPLEX: + /* TODO */ + break; case H5T_TIME: case H5T_NO_CLASS: case H5T_NCLASSES: @@ -4536,6 +4559,9 @@ translate_atomic_wbuf(JNIEnv *env, jobject in_obj, jlong mem_type_id, H5T_class_ } break; } /* H5T_STRING */ + case H5T_COMPLEX: + /* TODO */ + break; case H5T_TIME: case H5T_NO_CLASS: case H5T_NCLASSES: @@ -4758,6 +4784,9 @@ translate_rbuf(JNIEnv *env, jobjectArray ret_buf, jlong mem_type_id, H5T_class_t } break; } + case H5T_COMPLEX: + /* TODO */ + break; case H5T_TIME: case H5T_NO_CLASS: case H5T_NCLASSES: @@ -4920,6 +4949,9 @@ translate_wbuf(JNIEnv *env, jobjectArray in_buf, jlong mem_type_id, H5T_class_t } break; } + case H5T_COMPLEX: + /* TODO */ + break; case H5T_TIME: case H5T_NO_CLASS: case H5T_NCLASSES: diff --git a/java/test/TestH5T.java b/java/test/TestH5T.java index 0121cc24297..ba76a613e6d 100644 --- a/java/test/TestH5T.java +++ b/java/test/TestH5T.java @@ -171,6 +171,8 @@ public void testH5Tarray_create() } } + /* TODO: add complex number support */ + @Test public void testH5Tget_array_ndims() { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6743a85ff7..6c47ed9c90d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -600,17 +600,19 @@ set (H5T_SOURCES ${HDF5_SRC_DIR}/H5Tarray.c ${HDF5_SRC_DIR}/H5Tbit.c ${HDF5_SRC_DIR}/H5Tcommit.c + ${HDF5_SRC_DIR}/H5Tcomplex.c ${HDF5_SRC_DIR}/H5Tcompound.c ${HDF5_SRC_DIR}/H5Tconv.c - ${HDF5_SRC_DIR}/H5Tconv_integer.c - ${HDF5_SRC_DIR}/H5Tconv_float.c - ${HDF5_SRC_DIR}/H5Tconv_string.c + ${HDF5_SRC_DIR}/H5Tconv_array.c ${HDF5_SRC_DIR}/H5Tconv_bitfield.c + ${HDF5_SRC_DIR}/H5Tconv_complex.c ${HDF5_SRC_DIR}/H5Tconv_compound.c - ${HDF5_SRC_DIR}/H5Tconv_reference.c ${HDF5_SRC_DIR}/H5Tconv_enum.c + ${HDF5_SRC_DIR}/H5Tconv_float.c + ${HDF5_SRC_DIR}/H5Tconv_integer.c + ${HDF5_SRC_DIR}/H5Tconv_reference.c + ${HDF5_SRC_DIR}/H5Tconv_string.c ${HDF5_SRC_DIR}/H5Tconv_vlen.c - ${HDF5_SRC_DIR}/H5Tconv_array.c ${HDF5_SRC_DIR}/H5Tcset.c ${HDF5_SRC_DIR}/H5Tdbg.c ${HDF5_SRC_DIR}/H5Tdeprec.c @@ -958,6 +960,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5Tconv.h ${HDF5_SRC_DIR}/H5Tconv_array.h ${HDF5_SRC_DIR}/H5Tconv_bitfield.h + ${HDF5_SRC_DIR}/H5Tconv_complex.h ${HDF5_SRC_DIR}/H5Tconv_compound.h ${HDF5_SRC_DIR}/H5Tconv_enum.h ${HDF5_SRC_DIR}/H5Tconv_float.h diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 24671b02107..d1a085cc05f 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -830,6 +830,35 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t dt->shared->force_conv = true; break; + case H5T_COMPLEX: + /* + * Complex number datatypes... + */ + + /* Set whether the complex number datatype is homogeneous */ + dt->shared->u.complex.homogeneous = (bool)(flags & 0x01); + + if (!dt->shared->u.complex.homogeneous) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "heterogeneous complex number datatypes are currently unsupported"); + + /* Set the form of the complex number datatype */ + dt->shared->u.complex.form = (H5T_complex_form_t)((flags >> 1) & 0x03); + + if (dt->shared->u.complex.form != H5T_COMPLEX_RECTANGULAR) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "only complex number datatypes in rectangular form are currently supported"); + + /* Decode the base datatype of the complex number */ + if (NULL == (dt->shared->parent = H5T__alloc())) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, + "unable to allocate complex number base datatype"); + if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent, skip, p_end) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, + "unable to decode complex number base datatype"); + + break; + case H5T_NO_CLASS: case H5T_NCLASSES: default: @@ -1347,6 +1376,28 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type"); break; + case H5T_COMPLEX: + if (!dt->shared->u.complex.homogeneous) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, + "heterogeneous complex number datatypes are currently unsupported"); + if (dt->shared->u.complex.form != H5T_COMPLEX_RECTANGULAR) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, + "complex number datatypes not in rectangular form are currently unsupported"); + + /* Store whether complex number is homogeneous in first flag bit */ + if (dt->shared->u.complex.homogeneous) + flags |= 0x01; + + /* Store complex number form in next two bits */ + flags = (unsigned)(flags | (((unsigned)dt->shared->u.complex.form & 0x03) << 1)); + + /* Encode the base datatype of the complex number */ + if (H5O__dtype_encode_helper(pp, dt->shared->parent) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, + "unable to encode complex number base datatype"); + + break; + case H5T_NO_CLASS: case H5T_NCLASSES: default: @@ -1644,6 +1695,13 @@ H5O__dtype_size(const H5F_t *f, const void *_mesg) ret_value += H5O__dtype_size(f, dt->shared->parent); break; + case H5T_COMPLEX: + if (dt->shared->u.complex.homogeneous) + ret_value += H5O__dtype_size(f, dt->shared->parent); + else + ret_value = 0; + break; + case H5T_NO_CLASS: case H5T_STRING: case H5T_REFERENCE: @@ -2001,6 +2059,10 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt s = "vlen"; break; + case H5T_COMPLEX: + s = "complex number"; + break; + case H5T_NO_CLASS: case H5T_NCLASSES: default: @@ -2244,6 +2306,26 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt fprintf(stream, "%*s%s\n", indent, "", "Base type:"); H5O__dtype_debug(f, dt->shared->parent, stream, indent + 3, MAX(0, fwidth - 3)); } /* end else if */ + else if (H5T_COMPLEX == dt->shared->type) { + switch (dt->shared->u.complex.form) { + case H5T_COMPLEX_RECTANGULAR: + fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Form:", "rectangular"); + break; + case H5T_COMPLEX_POLAR: + fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Form:", "polar"); + break; + case H5T_COMPLEX_EXPONENTIAL: + fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Form:", "exponential"); + break; + default: + fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Form:", "invalid"); + break; + } + if (dt->shared->u.complex.homogeneous) { + fprintf(stream, "%*s%s\n", indent, "", "Base type:"); + H5O__dtype_debug(f, dt->shared->parent, stream, indent + 3, MAX(0, fwidth - 3)); + } + } else { switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 3d4ca8b69eb..18b477f35cd 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -1461,14 +1461,14 @@ H5Pget_driver(hid_t plist_id) H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list"); /* Get the driver */ if ((ret_value = H5P_peek_driver(plist)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get driver"); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 64cd2996fc4..460d0842cca 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -1035,14 +1035,14 @@ H5Pget_elink_fapl(hid_t lapl_id) H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) /* Get the plist structure */ if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) - HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); + HGOTO_ERROR(H5E_ID, H5E_BADID, H5I_INVALID_HID, "can't find object for ID"); if (H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &ret_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get fapl for links"); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5S.c b/src/H5S.c index 3b8a825ee8c..08000fff3da 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -328,23 +328,23 @@ H5Screate(H5S_class_t type) H5S_t *new_ds = NULL; /* New dataspace structure */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) /* Check args */ if (type <= H5S_NO_CLASS || type > H5S_NULL) /* don't allow complex dataspace yet */ - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dataspace type"); if (NULL == (new_ds = H5S_create(type))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace"); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create dataspace"); /* Register */ if ((ret_value = H5I_register(H5I_DATASPACE, new_ds, true)) < 0) - HGOTO_ERROR(H5E_ID, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID"); + HGOTO_ERROR(H5E_ID, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace ID"); done: if (ret_value < 0) if (new_ds && H5S_close(new_ds) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace"); FUNC_LEAVE_API(ret_value) } /* end H5Screate() */ diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 3697374d49c..9d6fe6a226d 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -251,10 +251,10 @@ H5_DLL hid_t H5Scopy(hid_t space_id); * Further dataspace types may be added later. * * A scalar dataspace, #H5S_SCALAR, has a single element, though that - * element may be of a complex datatype, such as a compound or array + * element may be of a composite datatype, such as a compound or array * datatype. By convention, the rank of a scalar dataspace is always \p 0 * (zero); think of it geometrically as a single, dimensionless point, - * though that point can be complex. + * though that point can be composite. * * A simple dataspace, #H5S_SIMPLE, consists of a regular array of elements. * diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 5625de3aab4..651f73b6c03 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -2655,39 +2655,39 @@ H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, hid_t src H5S_t *proj_space = NULL; /* Output dataspace */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) /* Check args */ if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace"); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace"); if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace"); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace"); if (NULL == (src_intersect_space = (H5S_t *)H5I_object_verify(src_intersect_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace"); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace"); /* Check numbers of points selected matches in source and destination */ if (H5S_GET_SELECT_NPOINTS(src_space) != H5S_GET_SELECT_NPOINTS(dst_space)) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "number of points selected in source space does not match that in destination space"); /* Check numbers of dimensions matches in source and source intersect spaces */ if (H5S_GET_EXTENT_NDIMS(src_space) != H5S_GET_EXTENT_NDIMS(src_intersect_space)) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "rank of source space does not match rank of source intersect space"); /* Perform operation */ if (H5S_select_project_intersection(src_space, dst_space, src_intersect_space, &proj_space, false) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project dataspace intersection"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, H5I_INVALID_HID, "can't project dataspace intersection"); /* Register */ if ((ret_value = H5I_register(H5I_DATASPACE, proj_space, true)) < 0) - HGOTO_ERROR(H5E_ID, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID"); + HGOTO_ERROR(H5E_ID, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace ID"); done: if (ret_value < 0) if (proj_space && H5S_close(proj_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace"); FUNC_LEAVE_API(ret_value) } /* end H5Sselect_project_intersection() */ diff --git a/src/H5T.c b/src/H5T.c index 23993b3d639..635365c8d97 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -469,30 +469,33 @@ hid_t H5T_C_S1_g = H5I_INVALID_HID; hid_t H5T_FORTRAN_S1_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_SCHAR_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_UCHAR_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_SHORT_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_USHORT_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_INT_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_UINT_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_LONG_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_ULONG_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_LLONG_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_ULLONG_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_FLOAT16_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_FLOAT_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_DOUBLE_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_LDOUBLE_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_B8_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_B16_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_B32_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_B64_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_OPAQUE_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_HADDR_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_HSIZE_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_HSSIZE_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_HERR_g = H5I_INVALID_HID; -hid_t H5T_NATIVE_HBOOL_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_SCHAR_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_UCHAR_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_SHORT_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_USHORT_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_INT_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_UINT_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_LONG_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_ULONG_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_LLONG_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_ULLONG_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_FLOAT16_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_FLOAT_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_DOUBLE_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_LDOUBLE_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_FLOAT_COMPLEX_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_DOUBLE_COMPLEX_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_LDOUBLE_COMPLEX_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_B8_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_B16_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_B32_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_B64_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_OPAQUE_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_HADDR_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_HSIZE_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_HSSIZE_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_HERR_g = H5I_INVALID_HID; +hid_t H5T_NATIVE_HBOOL_g = H5I_INVALID_HID; hid_t H5T_NATIVE_INT8_g = H5I_INVALID_HID; hid_t H5T_NATIVE_UINT8_g = H5I_INVALID_HID; @@ -538,20 +541,23 @@ size_t H5T_HOBJREF_ALIGN_g = 0; size_t H5T_HDSETREGREF_ALIGN_g = 0; size_t H5T_REF_ALIGN_g = 0; -size_t H5T_NATIVE_SCHAR_ALIGN_g = 0; -size_t H5T_NATIVE_UCHAR_ALIGN_g = 0; -size_t H5T_NATIVE_SHORT_ALIGN_g = 0; -size_t H5T_NATIVE_USHORT_ALIGN_g = 0; -size_t H5T_NATIVE_INT_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_ALIGN_g = 0; -size_t H5T_NATIVE_LONG_ALIGN_g = 0; -size_t H5T_NATIVE_ULONG_ALIGN_g = 0; -size_t H5T_NATIVE_LLONG_ALIGN_g = 0; -size_t H5T_NATIVE_ULLONG_ALIGN_g = 0; -size_t H5T_NATIVE_FLOAT16_ALIGN_g = 0; -size_t H5T_NATIVE_FLOAT_ALIGN_g = 0; -size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0; -size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; +size_t H5T_NATIVE_SCHAR_ALIGN_g = 0; +size_t H5T_NATIVE_UCHAR_ALIGN_g = 0; +size_t H5T_NATIVE_SHORT_ALIGN_g = 0; +size_t H5T_NATIVE_USHORT_ALIGN_g = 0; +size_t H5T_NATIVE_INT_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_ALIGN_g = 0; +size_t H5T_NATIVE_LONG_ALIGN_g = 0; +size_t H5T_NATIVE_ULONG_ALIGN_g = 0; +size_t H5T_NATIVE_LLONG_ALIGN_g = 0; +size_t H5T_NATIVE_ULLONG_ALIGN_g = 0; +size_t H5T_NATIVE_FLOAT16_ALIGN_g = 0; +size_t H5T_NATIVE_FLOAT_ALIGN_g = 0; +size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0; +size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; +size_t H5T_NATIVE_FLOAT_COMPLEX_ALIGN_g = 0; +size_t H5T_NATIVE_DOUBLE_COMPLEX_ALIGN_g = 0; +size_t H5T_NATIVE_LDOUBLE_COMPLEX_ALIGN_g = 0; /* Alignment constraints for C99 types */ size_t H5T_NATIVE_INT8_ALIGN_g = 0; @@ -843,6 +849,11 @@ H5T_init(void) true; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ #ifdef H5_HAVE__FLOAT16 H5T_t *native_float16 = NULL; /* Datatype structure for native _Float16 type */ +#endif +#ifdef H5_HAVE_COMPLEX_NUMBERS + H5T_t *native_float_complex = NULL; /* Datatype structure for native float _Complex type */ + H5T_t *native_double_complex = NULL; /* Datatype structure for native double _Complex type */ + H5T_t *native_ldouble_complex = NULL; /* Datatype structure for native long double _Complex type */ #endif herr_t ret_value = SUCCEED; /* Return value */ @@ -860,6 +871,12 @@ H5T_init(void) if (H5T__init_native_float_types() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize floating-point types"); +#ifdef H5_HAVE_COMPLEX_NUMBERS + /* Initialize native complex number datatypes */ + if (H5T__init_native_complex_types() < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize complex number types"); +#endif + /* Initialize all other native types */ if (H5T__init_native_internal() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize integers"); @@ -895,6 +912,14 @@ H5T_init(void) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL == (native_ldouble = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); +#ifdef H5_HAVE_COMPLEX_NUMBERS + if (NULL == (native_float_complex = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_COMPLEX_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); + if (NULL == (native_double_complex = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_COMPLEX_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); + if (NULL == (native_ldouble_complex = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE_COMPLEX_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); +#endif /*------------------------------------------------------------ * Derived native types @@ -1155,7 +1180,8 @@ H5T_init(void) status |= H5T__register_int(H5T_PERS_SOFT, "regref", regref, regref, H5T__conv_noop); status |= H5T__register_int(H5T_PERS_SOFT, "ref", ref, ref, H5T__conv_ref); status |= H5T__register_int(H5T_PERS_SOFT, "objref_ref", objref, ref, H5T__conv_ref); - status |= H5T__register_int(H5T_PERS_SOFT, "regref_ref", regref, ref, H5T__conv_ref); + status |= H5T__register_int(H5T_PERS_SOFT, "regref_ref", regref, ref, + H5T__conv_ref); /* TODO: complex number conversions */ /* * Native conversions should be listed last since we can use hardware to @@ -1765,30 +1791,33 @@ H5T_top_term_package(void) H5T_FORTRAN_S1_g = H5I_INVALID_HID; - H5T_NATIVE_SCHAR_g = H5I_INVALID_HID; - H5T_NATIVE_UCHAR_g = H5I_INVALID_HID; - H5T_NATIVE_SHORT_g = H5I_INVALID_HID; - H5T_NATIVE_USHORT_g = H5I_INVALID_HID; - H5T_NATIVE_INT_g = H5I_INVALID_HID; - H5T_NATIVE_UINT_g = H5I_INVALID_HID; - H5T_NATIVE_LONG_g = H5I_INVALID_HID; - H5T_NATIVE_ULONG_g = H5I_INVALID_HID; - H5T_NATIVE_LLONG_g = H5I_INVALID_HID; - H5T_NATIVE_ULLONG_g = H5I_INVALID_HID; - H5T_NATIVE_FLOAT16_g = H5I_INVALID_HID; - H5T_NATIVE_FLOAT_g = H5I_INVALID_HID; - H5T_NATIVE_DOUBLE_g = H5I_INVALID_HID; - H5T_NATIVE_LDOUBLE_g = H5I_INVALID_HID; - H5T_NATIVE_B8_g = H5I_INVALID_HID; - H5T_NATIVE_B16_g = H5I_INVALID_HID; - H5T_NATIVE_B32_g = H5I_INVALID_HID; - H5T_NATIVE_B64_g = H5I_INVALID_HID; - H5T_NATIVE_OPAQUE_g = H5I_INVALID_HID; - H5T_NATIVE_HADDR_g = H5I_INVALID_HID; - H5T_NATIVE_HSIZE_g = H5I_INVALID_HID; - H5T_NATIVE_HSSIZE_g = H5I_INVALID_HID; - H5T_NATIVE_HERR_g = H5I_INVALID_HID; - H5T_NATIVE_HBOOL_g = H5I_INVALID_HID; + H5T_NATIVE_SCHAR_g = H5I_INVALID_HID; + H5T_NATIVE_UCHAR_g = H5I_INVALID_HID; + H5T_NATIVE_SHORT_g = H5I_INVALID_HID; + H5T_NATIVE_USHORT_g = H5I_INVALID_HID; + H5T_NATIVE_INT_g = H5I_INVALID_HID; + H5T_NATIVE_UINT_g = H5I_INVALID_HID; + H5T_NATIVE_LONG_g = H5I_INVALID_HID; + H5T_NATIVE_ULONG_g = H5I_INVALID_HID; + H5T_NATIVE_LLONG_g = H5I_INVALID_HID; + H5T_NATIVE_ULLONG_g = H5I_INVALID_HID; + H5T_NATIVE_FLOAT16_g = H5I_INVALID_HID; + H5T_NATIVE_FLOAT_g = H5I_INVALID_HID; + H5T_NATIVE_DOUBLE_g = H5I_INVALID_HID; + H5T_NATIVE_LDOUBLE_g = H5I_INVALID_HID; + H5T_NATIVE_FLOAT_COMPLEX_g = H5I_INVALID_HID; + H5T_NATIVE_DOUBLE_COMPLEX_g = H5I_INVALID_HID; + H5T_NATIVE_LDOUBLE_COMPLEX_g = H5I_INVALID_HID; + H5T_NATIVE_B8_g = H5I_INVALID_HID; + H5T_NATIVE_B16_g = H5I_INVALID_HID; + H5T_NATIVE_B32_g = H5I_INVALID_HID; + H5T_NATIVE_B64_g = H5I_INVALID_HID; + H5T_NATIVE_OPAQUE_g = H5I_INVALID_HID; + H5T_NATIVE_HADDR_g = H5I_INVALID_HID; + H5T_NATIVE_HSIZE_g = H5I_INVALID_HID; + H5T_NATIVE_HSSIZE_g = H5I_INVALID_HID; + H5T_NATIVE_HERR_g = H5I_INVALID_HID; + H5T_NATIVE_HBOOL_g = H5I_INVALID_HID; H5T_NATIVE_INT8_g = H5I_INVALID_HID; H5T_NATIVE_UINT8_g = H5I_INVALID_HID; @@ -1919,19 +1948,19 @@ H5Tcreate(H5T_class_t type, size_t size) H5T_t *dt = NULL; /* New datatype constructed */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) /* check args. We support string (fixed-size or variable-length) now. */ if (size <= 0 && size != H5T_VARIABLE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "size must be positive"); /* create the type */ if (NULL == (dt = H5T__create(type, size))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to create type"); /* Get an ID for the datatype */ if ((ret_value = H5I_register(H5I_DATATYPE, dt, true)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype ID"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype ID"); done: FUNC_LEAVE_API(ret_value) @@ -2340,7 +2369,7 @@ H5T_detect_class(const H5T_t *dt, H5T_class_t cls, bool from_api) HGOTO_DONE(true); /* Recurse if it's VL, compound, enum or array */ - if (H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) + if (H5T_IS_COMPOSITE(dt->shared->u.compnd.memb[i].type->shared->type)) if ((nested_ret = H5T_detect_class(dt->shared->u.compnd.memb[i].type, cls, from_api)) != false) HGOTO_DONE(nested_ret); @@ -2352,6 +2381,10 @@ H5T_detect_class(const H5T_t *dt, H5T_class_t cls, bool from_api) case H5T_ENUM: HGOTO_DONE(H5T_detect_class(dt->shared->parent, cls, from_api)); break; + case H5T_COMPLEX: + assert(dt->shared->u.complex.homogeneous); + HGOTO_DONE(H5T_detect_class(dt->shared->parent, cls, from_api)); + break; case H5T_NO_CLASS: case H5T_INTEGER: case H5T_FLOAT: @@ -3219,11 +3252,11 @@ H5Tdecode(const void *buf) H5T_t *dt; hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) /* Check args */ if (buf == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "empty buffer"); /* Create datatype by decoding buffer * There is no way to get the size of the buffer, so we pass in @@ -3232,11 +3265,11 @@ H5Tdecode(const void *buf) * takes a size parameter. */ if (NULL == (dt = H5T_decode(SIZE_MAX, (const unsigned char *)buf))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "can't decode object"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, H5I_INVALID_HID, "can't decode object"); /* Register the type and return the ID */ if ((ret_value = H5I_register(H5I_DATATYPE, dt, true)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register data type"); done: FUNC_LEAVE_API(ret_value) @@ -3442,6 +3475,9 @@ H5T__create(H5T_class_t type, size_t size) case H5T_ARRAY: /* Array datatype */ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tarray_create2()"); + case H5T_COMPLEX: /* Complex number datatype */ + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tcomplex_create()"); + case H5T_NO_CLASS: case H5T_REFERENCE: case H5T_NCLASSES: @@ -3743,6 +3779,7 @@ H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo case H5T_TIME: case H5T_STRING: case H5T_BITFIELD: + case H5T_COMPLEX: case H5T_NCLASSES: default: break; @@ -4111,6 +4148,7 @@ H5T__free(H5T_t *dt) case H5T_REFERENCE: case H5T_VLEN: case H5T_ARRAY: + case H5T_COMPLEX: case H5T_NCLASSES: default: break; @@ -4293,12 +4331,28 @@ H5T__set_size(H5T_t *dt, size_t size) assert(!(H5T_ENUM == dt->shared->type && 0 == dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { - if (H5T__set_size(dt->shared->parent, size) < 0) + size_t new_size = size; + + if (dt->shared->type == H5T_COMPLEX) { + if (!dt->shared->u.complex.homogeneous) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, + "heterogeneous complex number datatypes are currently unsupported"); + + if ((new_size % 2) != 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, + "new datatype size is not evenly divisible by 2"); + + new_size /= 2; + } + + if (H5T__set_size(dt->shared->parent, new_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type"); /* Adjust size of datatype appropriately */ if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; + else if (dt->shared->type == H5T_COMPLEX) + dt->shared->size = 2 * dt->shared->parent->shared->size; else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } @@ -4422,6 +4476,7 @@ H5T__set_size(H5T_t *dt, size_t size) case H5T_VLEN: case H5T_ARRAY: case H5T_REFERENCE: + case H5T_COMPLEX: assert("can't happen" && 0); break; @@ -4810,6 +4865,38 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, bool superset) HGOTO_DONE(1); break; + case H5T_COMPLEX: + /* Make sure the complex number datatypes are both homogeneous or + * both heterogeneous + */ + tmp = (dt1->shared->u.complex.homogeneous > dt2->shared->u.complex.homogeneous) - + (dt1->shared->u.complex.homogeneous < dt2->shared->u.complex.homogeneous); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); + + /* Make sure the complex number datatypes are both in the same form */ + tmp = (dt1->shared->u.complex.form > dt2->shared->u.complex.form) - + (dt1->shared->u.complex.form < dt2->shared->u.complex.form); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); + + if (dt1->shared->u.complex.homogeneous) { + tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); + } + else + /* Heterogeneous complex number datatypes are currently unsupported */ + HGOTO_DONE(-1); + + break; + case H5T_NO_CLASS: case H5T_INTEGER: case H5T_FLOAT: @@ -4940,6 +5027,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, bool superset) case H5T_ENUM: case H5T_VLEN: case H5T_ARRAY: + case H5T_COMPLEX: case H5T_NCLASSES: default: assert("not implemented yet" && 0); @@ -5640,6 +5728,7 @@ H5T_path_match_find_type_with_volobj(const H5T_t *datatype, const H5VL_object_t case H5T_OPAQUE: case H5T_REFERENCE: /* Should have been determined by above check */ case H5T_ENUM: + case H5T_COMPLEX: case H5T_NO_CLASS: /* Error value, but simplify logic for a true/false return value */ case H5T_NCLASSES: /* Error value, but simplify logic for a true/false return value */ default: @@ -6187,6 +6276,7 @@ H5T_is_sensible(const H5T_t *dt) case H5T_REFERENCE: case H5T_VLEN: case H5T_ARRAY: + case H5T_COMPLEX: case H5T_NCLASSES: default: /* Assume all other datatype are sensible to store on disk */ @@ -6239,7 +6329,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ if (dt->shared->parent->shared->force_conv && - H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + H5T_IS_COMPOSITE(dt->shared->parent->shared->type)) { /* Keep the old base element size for later */ old_size = dt->shared->parent->shared->size; @@ -6280,7 +6370,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if (memb_type->shared->force_conv && H5T_IS_COMPLEX(memb_type->shared->type)) { + if (memb_type->shared->force_conv && H5T_IS_COMPOSITE(memb_type->shared->type)) { /* Keep the old field size for later */ old_size = memb_type->shared->size; @@ -6322,7 +6412,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) * them as part of the same blob)*/ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ if (dt->shared->parent->shared->force_conv && - H5T_IS_COMPLEX(dt->shared->parent->shared->type) && + H5T_IS_COMPOSITE(dt->shared->parent->shared->type) && (dt->shared->parent->shared->type != H5T_REFERENCE)) { if ((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); @@ -6351,6 +6441,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) case H5T_BITFIELD: case H5T_OPAQUE: case H5T_ENUM: + case H5T_COMPLEX: case H5T_NCLASSES: default: break; @@ -6446,6 +6537,7 @@ H5T__detect_vlen_ref(const H5T_t *dt) case H5T_BITFIELD: case H5T_OPAQUE: case H5T_REFERENCE: + case H5T_COMPLEX: case H5T_NCLASSES: default: break; @@ -6538,6 +6630,7 @@ H5T__upgrade_version_cb(H5T_t *dt, void *op_value) case H5T_BITFIELD: case H5T_OPAQUE: case H5T_REFERENCE: + case H5T_COMPLEX: case H5T_NCLASSES: default: break; @@ -6568,7 +6661,7 @@ H5T__upgrade_version(H5T_t *dt, unsigned new_version) assert(dt); /* Iterate over entire datatype, upgrading the version of components, if it's useful */ - if (H5T__visit(dt, (H5T_VISIT_SIMPLE | H5T_VISIT_COMPLEX_LAST), H5T__upgrade_version_cb, &new_version) < + if (H5T__visit(dt, (H5T_VISIT_SIMPLE | H5T_VISIT_COMPOSITE_LAST), H5T__upgrade_version_cb, &new_version) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "iteration to upgrade datatype encoding version failed"); diff --git a/src/H5Tcomplex.c b/src/H5Tcomplex.c new file mode 100644 index 00000000000..4b0f74ef53d --- /dev/null +++ b/src/H5Tcomplex.c @@ -0,0 +1,153 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Module Info: This module contains the functionality for complex number + * datatypes in the H5T interface. + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Public Variables */ +/*********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5Tcomplex_create + * + * Purpose: Create a new complex number datatype based on the specified + * base datatype ID. + * + * Return: Success: ID of new complex number datatype + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Tcomplex_create(hid_t base_type_id) +{ + H5T_t *base = NULL; /* base datatype */ + H5T_t *dt = NULL; /* new datatype */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + + if (NULL == (base = (H5T_t *)H5I_object_verify(base_type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid base datatype ID"); + + if (NULL == (dt = H5T__complex_create(base))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, + "can't create complex number datatype from base datatype"); + + if ((ret_value = H5I_register(H5I_DATATYPE, dt, true)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype"); + +done: + FUNC_LEAVE_API(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5T__complex_create + * + * Purpose: Create a new complex number datatype based on the specified + * base datatype. + * + * Return: Success: new complex number datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5T_t * +H5T__complex_create(const H5T_t *base) +{ + H5T_t *dt = NULL; /* New complex number datatype */ + H5T_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check args */ + assert(base); + + /* Currently, only floating-point base datatypes are supported. */ + if (base->shared->type != H5T_FLOAT) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "base datatype is not a H5T_FLOAT datatype"); + if (base->shared->size == 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid base datatype size"); + if (base->shared->size > SIZE_MAX / 2) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, + "base datatype size too large - new datatype size would overflow"); + + /* Build new type */ + if (NULL == (dt = H5T__alloc())) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "memory allocation failed"); + dt->shared->type = H5T_COMPLEX; + dt->shared->size = 2 * base->shared->size; + + if (NULL == (dt->shared->parent = H5T_copy(base, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy base datatype"); + + /* Inherit encoding version from base type */ + dt->shared->version = base->shared->version; + + /* Set complex number-specific fields */ + dt->shared->u.complex.form = H5T_COMPLEX_RECTANGULAR; /* Only rectangular form is currently supported */ + dt->shared->u.complex.homogeneous = true; + + ret_value = dt; + +done: + if (!ret_value) + if (dt && H5T_close(dt) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "can't close datatype"); + + FUNC_LEAVE_NOAPI(ret_value) +} diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index eb39dd4e98a..1e1986b01e2 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -503,6 +503,13 @@ H5T__pack(const H5T_t *dt) /* Adjust size of datatype appropriately */ if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; + else if (dt->shared->type == H5T_COMPLEX) { + if (dt->shared->u.complex.homogeneous) + dt->shared->size = 2 * dt->shared->parent->shared->size; + else + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, + "heterogeneous complex number datatypes are currently unsupported"); + } else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } /* end if */ diff --git a/src/H5Tconv_complex.c b/src/H5Tconv_complex.c new file mode 100644 index 00000000000..4bc37ee88d6 --- /dev/null +++ b/src/H5Tconv_complex.c @@ -0,0 +1,789 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Datatype conversion functions for complex number datatypes + */ + +/****************/ +/* Module Setup */ +/****************/ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5Eprivate.h" +#include "H5Tconv.h" +#include "H5Tconv_macros.h" +#include "H5Tconv_complex.h" + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*------------------------------------------------------------------------- + * Function: H5T__conv_complex + * + * Purpose: Convert one complex number type to another. This is the + * catch-all function for complex number conversions and is + * probably not particularly fast. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_complex(const H5T_t *src, const H5T_t *dst, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_complex_struct + * + * Purpose: Convert a complex number type to the equivalent compound + * type representation. A compound type must match one of the + * the following representations exactly to be considered + * equivalent. + * + * H5T_COMPOUND { + * "r"; OFFSET 0 + * "i"; OFFSET SIZEOF("r") + * } + * + * H5T_COMPOUND { + * "re"; OFFSET 0 + * "im"; OFFSET SIZEOF("re") + * } + * + * H5T_COMPOUND { + * "real"; OFFSET 0 + * "imag"; OFFSET SIZEOF("real") + * } + * + * H5T_COMPOUND { + * "real"; OFFSET 0 + * "imaginary"; OFFSET SIZEOF("real") + * } + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_complex_struct(const H5T_t *src, const H5T_t *dst, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *_buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +#ifdef H5_HAVE_COMPLEX_NUMBERS +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_schar + * + * Purpose: Converts `float _Complex' to `signed char' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_schar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ /* H5T_CONV_su(FLOAT_COMPLEX, SCHAR, float _Complex, signed char, -, -); */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_uchar + * + * Purpose: Converts `float _Complex' to `unsigned char' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_uchar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_short + * + * Purpose: Converts `float _Complex' to `short' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_short(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_ushort + * + * Purpose: Converts `float _Complex' to `unsigned short' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_ushort(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_int + * + * Purpose: Converts `float _Complex' to `int' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_int(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_uint + * + * Purpose: Converts `float _Complex' to `unsigned int' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_uint(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_long + * + * Purpose: Converts `float _Complex' to `long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_long(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_ulong + * + * Purpose: Converts `float _Complex' to `unsigned long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_ulong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_llong + * + * Purpose: Converts `float _Complex' to `long long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_llong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_ullong + * + * Purpose: Converts `float _Complex' to `unsigned long long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_ullong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +#ifdef H5_HAVE__FLOAT16 +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex__Float16 + * + * Purpose: Converts `float _Complex' to `_Float16' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex__Float16(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} +#endif + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_float + * + * Purpose: Converts `float _Complex' to `float' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_float(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_double + * + * Purpose: Converts `float _Complex' to `double' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_double(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_fcomplex_ldouble + * + * Purpose: Converts `float _Complex' to `long double' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_fcomplex_ldouble(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_schar + * + * Purpose: Converts `double _Complex' to `signed char' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_schar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_uchar + * + * Purpose: Converts `double _Complex' to `unsigned char' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_uchar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_short + * + * Purpose: Converts `double _Complex' to `short' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_short(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_ushort + * + * Purpose: Converts `double _Complex' to `unsigned short' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_ushort(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_int + * + * Purpose: Converts `double _Complex' to `int' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_int(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_uint + * + * Purpose: Converts `double _Complex' to `unsigned int' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_uint(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_long + * + * Purpose: Converts `double _Complex' to `long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_long(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_ulong + * + * Purpose: Converts `double _Complex' to `unsigned long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_ulong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_llong + * + * Purpose: Converts `double _Complex' to `long long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_llong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_ullong + * + * Purpose: Converts `double _Complex' to `unsigned long long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_ullong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +#ifdef H5_HAVE__FLOAT16 +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex__Float16 + * + * Purpose: Converts `double _Complex' to `_Float16' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex__Float16(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} +#endif + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_float + * + * Purpose: Converts `double _Complex' to `float' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_float(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_double + * + * Purpose: Converts `double _Complex' to `double' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_double(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_dcomplex_ldouble + * + * Purpose: Converts `double _Complex' to `long double' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_dcomplex_ldouble(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_schar + * + * Purpose: Converts `long double _Complex' to `signed char' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_schar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_uchar + * + * Purpose: Converts `long double _Complex' to `unsigned char' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_uchar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_short + * + * Purpose: Converts `long double _Complex' to `short' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_short(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_ushort + * + * Purpose: Converts `long double _Complex' to `unsigned short' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_ushort(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_int + * + * Purpose: Converts `long double _Complex' to `int' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_int(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_uint + * + * Purpose: Converts `long double _Complex' to `unsigned int' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_uint(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_long + * + * Purpose: Converts `long double _Complex' to `long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_long(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_ulong + * + * Purpose: Converts `long double _Complex' to `unsigned long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_ulong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_llong + * + * Purpose: Converts `long double _Complex' to `long long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_llong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_ullong + * + * Purpose: Converts `long double _Complex' to `unsigned long long' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_ullong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +#ifdef H5_HAVE__FLOAT16 +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex__Float16 + * + * Purpose: Converts `long double _Complex' to `_Float16' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex__Float16(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} +#endif + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_float + * + * Purpose: Converts `long double _Complex' to `float' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_float(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx, + size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_double + * + * Purpose: Converts `long double _Complex' to `double' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_double(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} + +/*------------------------------------------------------------------------- + * Function: H5T__conv_lcomplex_ldouble + * + * Purpose: Converts `long double _Complex' to `long double' + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__conv_lcomplex_ldouble(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) +{ + return FAIL; /* TODO */ +} +#endif /* H5_HAVE_COMPLEX_NUMBERS */ diff --git a/src/H5Tconv_complex.h b/src/H5Tconv_complex.h new file mode 100644 index 00000000000..be82b2cce11 --- /dev/null +++ b/src/H5Tconv_complex.h @@ -0,0 +1,181 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef H5Tconv_complex_H +#define H5Tconv_complex_H + +/* Private headers needed by this file */ +#include "H5Tpkg.h" + +/***********************/ +/* Function Prototypes */ +/***********************/ + +/****************************************/ +/* Soft (emulated) conversion functions */ +/****************************************/ + +/* Conversion functions between complex number datatypes */ +H5_DLL herr_t H5T__conv_complex(const H5T_t *src, const H5T_t *dst, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *_buf, void *bkg); + +/* Conversion functions from complex number datatype to another datatype class */ +H5_DLL herr_t H5T__conv_complex_struct(const H5T_t *src, const H5T_t *dst, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *_buf, void *bkg); + +/*********************************************/ +/* Hard (compiler cast) conversion functions */ +/*********************************************/ + +#ifdef H5_HAVE_COMPLEX_NUMBERS +/* Conversion functions for 'float _Complex' */ +H5_DLL herr_t H5T__conv_fcomplex_schar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_uchar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_short(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_ushort(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_int(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_uint(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_long(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_ulong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_llong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_ullong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +#ifdef H5_HAVE__FLOAT16 +H5_DLL herr_t H5T__conv_fcomplex__Float16(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +#endif +H5_DLL herr_t H5T__conv_fcomplex_float(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_double(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_fcomplex_ldouble(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); + +/* Conversion functions for 'double _Complex' */ +H5_DLL herr_t H5T__conv_dcomplex_schar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_uchar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_short(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_ushort(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_int(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_uint(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_long(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_ulong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_llong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_ullong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +#ifdef H5_HAVE__FLOAT16 +H5_DLL herr_t H5T__conv_dcomplex__Float16(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +#endif +H5_DLL herr_t H5T__conv_dcomplex_float(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_double(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_dcomplex_ldouble(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); + +/* Conversion functions for 'long double _Complex' */ +H5_DLL herr_t H5T__conv_lcomplex_schar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_uchar(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_short(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_ushort(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_int(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_uint(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_long(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_ulong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_llong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_ullong(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +#ifdef H5_HAVE__FLOAT16 +H5_DLL herr_t H5T__conv_lcomplex__Float16(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +#endif +H5_DLL herr_t H5T__conv_lcomplex_float(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_double(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_lcomplex_ldouble(const H5T_t *st, const H5T_t *dt, H5T_cdata_t *cdata, + const H5T_conv_ctx_t *conv_ctx, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +#endif /* H5_HAVE_COMPLEX_NUMBERS */ + +#endif /* H5Tconv_complex_H */ diff --git a/src/H5Tconv_macros.h b/src/H5Tconv_macros.h index c2876670f5e..5f86d2351c4 100644 --- a/src/H5Tconv_macros.h +++ b/src/H5Tconv_macros.h @@ -804,6 +804,13 @@ typedef struct H5T_conv_hw_t { H5T_CONV(H5T_CONV_Xf, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ } while (0) +/* TODO */ +#define H5T_CONV_Zs(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + do { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Zs, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ + } while (0) + /* Since all "no exception" cores do the same thing (assign the value in the * source location to the destination location, using casting), use one "core" * to do them all. diff --git a/src/H5Tconv_vlen.c b/src/H5Tconv_vlen.c index ab6f5fc2d59..6c73563644e 100644 --- a/src/H5Tconv_vlen.c +++ b/src/H5Tconv_vlen.c @@ -56,7 +56,7 @@ H5FL_BLK_DEFINE_STATIC(vlen_seq); * Function: H5T__conv_vlen_nested_free * * Purpose: Recursively locates and frees any nested VLEN components of - * complex data types (including COMPOUND). + * composite data types (including COMPOUND). * * Return: Non-negative on success/Negative on failure. * @@ -100,6 +100,7 @@ H5T__conv_vlen_nested_free(uint8_t *buf, H5T_t *dt) case H5T_OPAQUE: case H5T_REFERENCE: case H5T_ENUM: + case H5T_COMPLEX: /* These types cannot contain vl data */ break; diff --git a/src/H5Tdbg.c b/src/H5Tdbg.c index b1de7708b8f..e72128a536c 100644 --- a/src/H5Tdbg.c +++ b/src/H5Tdbg.c @@ -182,6 +182,31 @@ H5T_debug(const H5T_t *dt, FILE *stream) s1 = "struct"; break; + case H5T_REFERENCE: + switch (dt->shared->u.atomic.u.r.rtype) { + case H5R_OBJECT1: + s1 = "object reference (old)"; + break; + case H5R_OBJECT2: + s1 = "object reference (new)"; + break; + case H5R_DATASET_REGION1: + s1 = "region reference (old)"; + break; + case H5R_DATASET_REGION2: + s1 = "region reference (new)"; + break; + case H5R_ATTR: + s1 = "attribute reference"; + break; + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + s1 = "invalid reference"; + break; + } + break; + case H5T_ENUM: s1 = "enum"; break; @@ -193,8 +218,14 @@ H5T_debug(const H5T_t *dt, FILE *stream) s1 = "vlen"; break; - case H5T_REFERENCE: case H5T_ARRAY: + s1 = "array"; + break; + + case H5T_COMPLEX: + s1 = "complex number"; + break; + case H5T_NCLASSES: default: s1 = ""; @@ -342,6 +373,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) case H5T_ENUM: case H5T_VLEN: case H5T_ARRAY: + case H5T_COMPLEX: case H5T_NCLASSES: default: /* No additional info */ @@ -407,6 +439,23 @@ H5T_debug(const H5T_t *dt, FILE *stream) else if (H5T_OPAQUE == dt->shared->type) { fprintf(stream, ", tag=\"%s\"", dt->shared->u.opaque.tag); } + else if (H5T_COMPLEX == dt->shared->type) { + fprintf(stream, ", %s", dt->shared->u.complex.homogeneous ? "homogeneous" : "heterogeneous"); + switch (dt->shared->u.complex.form) { + case H5T_COMPLEX_RECTANGULAR: + fprintf(stream, ", rectangular form"); + break; + case H5T_COMPLEX_POLAR: + fprintf(stream, ", polar form"); + break; + case H5T_COMPLEX_EXPONENTIAL: + fprintf(stream, ", exponential form"); + break; + default: + fprintf(stream, ", invalid form"); + break; + } + } else { /* Unknown */ fprintf(stream, "unknown class %d\n", (int)(dt->shared->type)); diff --git a/src/H5Tfields.c b/src/H5Tfields.c index 86c9e1eb51b..336d016476d 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -172,6 +172,7 @@ H5T__get_member_name(H5T_t const *dt, unsigned membno) case H5T_REFERENCE: case H5T_VLEN: case H5T_ARRAY: + case H5T_COMPLEX: case H5T_NCLASSES: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "operation not supported for type class"); @@ -231,6 +232,7 @@ H5Tget_member_index(hid_t type_id, const char *name) case H5T_REFERENCE: case H5T_VLEN: case H5T_ARRAY: + case H5T_COMPLEX: case H5T_NCLASSES: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for this type"); diff --git a/src/H5Tfixed.c b/src/H5Tfixed.c index 178a0271fb4..b4495ddc465 100644 --- a/src/H5Tfixed.c +++ b/src/H5Tfixed.c @@ -23,13 +23,12 @@ #include "H5Tpkg.h" /*data-type functions */ /*------------------------------------------------------------------------- - * Function: H5Tget_sign + * Function: H5Tget_sign * - * Purpose: Retrieves the sign type for an integer type. + * Purpose: Retrieves the sign type for an integer type. * - * Return: Success: The sign type. - * - * Failure: H5T_SGN_ERROR (Negative) + * Return: Success: The sign type. + * Failure: H5T_SGN_ERROR (Negative) * *------------------------------------------------------------------------- */ @@ -52,14 +51,13 @@ H5Tget_sign(hid_t type_id) } /*------------------------------------------------------------------------- - * Function: H5T_get_sign + * Function: H5T_get_sign * - * Purpose: Private function for H5Tget_sign. Retrieves the sign type + * Purpose: Private function for H5Tget_sign. Retrieves the sign type * for an integer type. * - * Return: Success: The sign type. - * - * Failure: H5T_SGN_ERROR (Negative) + * Return: Success: The sign type. + * Failure: H5T_SGN_ERROR (Negative) * *------------------------------------------------------------------------- */ @@ -88,11 +86,11 @@ H5T_get_sign(H5T_t const *dt) } /*------------------------------------------------------------------------- - * Function: H5Tset_sign + * Function: H5Tset_sign * - * Purpose: Sets the sign property for an integer. + * Purpose: Sets the sign property for an integer. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ diff --git a/src/H5Tmodule.h b/src/H5Tmodule.h index 35e748bac3f..33837247fdc 100644 --- a/src/H5Tmodule.h +++ b/src/H5Tmodule.h @@ -1114,7 +1114,7 @@ * * * The datatype class: #H5T_INTEGER, #H5T_FLOAT, #H5T_STRING, #H5T_BITFIELD, #H5T_OPAQUE, #H5T_COMPOUND, - * #H5T_REFERENCE, #H5T_ENUM, #H5T_VLEN, #H5T_ARRAY + * #H5T_REFERENCE, #H5T_ENUM, #H5T_VLEN, #H5T_ARRAY, #H5T_COMPLEX * * * @@ -2404,7 +2404,8 @@ filled according to the value of this property. The padding can be: *
  • #H5T_REFERENCE
  • *
  • #H5T_ENUM
  • *
  • #H5T_VLEN
  • - *
  • #H5T_ARRAY
  • + *
  • #H5T_ARRAY
  • + *
  • #H5T_COMPLEX
  • * *
  • If class is #H5T_COMPOUND, then go to step 2 and repeat all steps under step 3. If * class is not #H5T_COMPOUND, then a member is of an atomic class and can be read @@ -3744,7 +3745,8 @@ filled according to the value of this property. The padding can be: * \ref DDLBNF114 that defines HDF5 datatypes appears below. * The definition of HDF5 datatypes from the HDF5 DDL * \code - * ::= | | | + * ::= | | | | + * * * ::= | |