From d08eeb050b12adae64a067b3f72ace2faa3ab133 Mon Sep 17 00:00:00 2001 From: "J. Daniel Smith" Date: Tue, 13 Jun 2023 16:14:41 -0400 Subject: [PATCH] lay groundwork for removing std::complex (#660) * Squashed commit of the following: commit bb2bb5aaf944040ea5bc42168b846324287dcad8 Merge: bbba5a210 4c146e7d0 Author: Dan Smith Date: Mon Jun 12 13:04:09 2023 -0400 Merge commit '4c146e7d01b14cf408b0e398cba96705df69090c' into develop/sync_externals commit 4c146e7d01b14cf408b0e398cba96705df69090c Author: Dan Smith Date: Mon Jun 12 13:04:09 2023 -0400 Squashed 'externals/coda-oss/' changes from aeec0131c..c88b9c053 c88b9c053 types::complex (#681) d1244a080 don't need our own make_unique in C++14 (#680) git-subtree-dir: externals/coda-oss git-subtree-split: c88b9c05325c802f88a85ddcebb498be4afacad0 commit bbba5a210c0257f622781914e9d228eeca23341c Author: Dan Smith Date: Mon Jun 12 13:04:06 2023 -0400 latest from CODA-OSS commit 370dd8876136755230624ebc955bc67642b1482b Merge: 58ff5a537 ffe1caafd Author: Dan Smith Date: Mon Jun 12 13:03:25 2023 -0400 Merge branch 'main' into develop/sync_externals commit 58ff5a5371d9158910e99613f4ce6e6fc36e543e Author: Dan Smith Date: Thu Jun 8 16:23:08 2023 -0400 latest from CODA-OSS commit 3bfc33a40274fa7a073983d4e4ddd907e45730d2 Author: Dan Smith Date: Thu Jun 8 14:34:45 2023 -0400 latest from CODA-OSS and NITRO commit 389417a983778ba2a07af9c6dbfea80484324b97 Merge: bce7ba0b1 4ad490fe4 Author: Dan Smith Date: Thu Jun 8 14:34:28 2023 -0400 latest from CODA-OSS and NITRO commit 4ad490fe4224df18ce4a437c40a257af0686140e Author: Dan Smith Date: Thu Jun 8 14:34:22 2023 -0400 Squashed 'externals/nitro/' changes from c8ecbe9ae..05dae18a3 05dae18a3 patch to build other projects 8f974e995 NITRO-2.11.3 (#554) 870aa6afd update to coda-oss 2023-06-05 (#553) 2fd7a0bfa latest from coda-oss (#552) 0eecce004 invoke() utility to reduce code duplication (#550) 59fb02fe9 latest from coda-oss (#551) 9fbf2b7b8 Fill out adapter free block which is used for nitf decompression (#549) 089ba0b5b latest from coda-oss 3b52f0025 latest from coda-oss (#547) 90c6263e2 latest from coda-oss (#544) 90d513ac5 latest from coda-oss (#543) git-subtree-dir: externals/nitro git-subtree-split: 05dae18a3a9c5ad70e1ce814c21ca8ec278829be commit 86929db19a438630d531ca0c34bdcd8e8c527ae9 Author: Dan Smith Date: Thu Jun 8 14:34:18 2023 -0400 Squashed 'externals/coda-oss/' changes from e87c32b4d..aeec0131c aeec0131c assert()s for mem::CopyablePtr (#679) 72b0ebd60 add types::complex_short (#678) 932130a58 patch to build other projects c00c1f203 coda-oss release 2023-06-06 (#677) ef54bbcd5 remove more compiler warnings (#676) dadfc5ce6 distinguish between byte-swapping a buffer and single value (#674) 90187f6cd more xml.lite tweaks for SIDD-3.0/ISM (#675) eb9960772 stronger type-checking for byteSwap() (#673) ff4f820ed xml.lite tweaks to support SIDD 3.0 ISM (#672) b1de8c0e5 std::byte should be a unique type (#671) c05bf9a02 allow enums to be byte-swapped too 1f9fd88d6 remove spurious 47684c45b byteSwap now uses byte buffers (#670) cbc659db2 add swapBytes() utility from SIX (#669) 891481b64 simplify byte-swapping (#668) 540ae763e more byteSwap() tweaks 0774c03c4 threaded byteSwap() (#667) d156370d3 swapping a single-byte value makes no sense c120e3255 be sure parameter is used to avoid compiler warning e85ec9331 --output-on-failure for CTest (#666) e80376197 turn off "there is no warning number" warning c5f0a5d15 A C-string may not be NULL-terminated (#665) 0c5eb29ae use platform-specific routines for byteSwap() (#664) 0b7d581fa remove transform_async() (#663) f6489b6be Merge branch 'main' into feature/xml.lite_tweaks 836c426a2 use function-pointers so that isConsoleOutput is only checked once 56e3c45b1 move depthPrint() functionality into non-member function in preparation for future changes ddcd26d97 Merge branch 'main' into feature/xml.lite_tweaks 69cc0e506 use the more rigorous create_and_check_datatype() 9efb87558 Merge branch 'main' into feature/hdf5 4d2f2f417 more HighFive unittests (#662) 14191a844 HighFive::create_datatype() goes from C++ to HighFive 98583473f utility routines to read string attributes 1fa75ce81 use the C API to read a string attribute 71e7b69f5 still can't figure out how to read a string attribute :-( e96f37a69 test reading the file attributes a25244519 getAttribute() unittest 8f12a3000 getDataType() unittest 857ff0af3 HighFive utility routines (#661) 1d687db57 writeDataSet() utility overload 106aa6894 sigh ... H5Easy::dump() fill fails on Windows/WAF :-( 2641b60b2 Merge branch 'main' into feature/hdf5 35c19e7e8 change actions to @v3 (#660) 212bbd3a3 works on local machine, but not build server ... ? 7125118b0 dump of 1D vector doesn't work :-( c704db435 sigh ... WAF build still failing :-( 01aae4616 does dump() of a 1D vector work? 76a53c813 comment-out H5 writing :-( 0f0e19aff test_highfive_dump() cb8f73795 trying to get highfive_dump() unittest working w/Windows-WAF 6584a264a does test_highfive_create() work? cde6147ce tweak HighFive wrappers (#659) 316566854 Revert "trying HighFive "write" unittests again" a9ec24ca4 trying HighFive "write" unittests again 585ad49a5 tweak names of utility routines 4c91a4d97 make it easier to read a std::vector and std::vecotr 0217ffa26 readDataSet() now works for 1D data 95e8973f2 trying to get hdf5::lite::load() working 4d294611d "const" correctness 5e6305c3f fix load_complex() 4a134dc5f start work on utility routines to read complex data from HDF5 9d76a7f41 Merge branch 'main' into feature/hdf5 8f9667a24 whitepsace ebd3fc99e Merge branch 'main' into feature/hdf5 40091b069 comment-out writing tests for now ... need to figure our WAF bulid failure 935aa3459 be sure the dataset has real data 114b9bf33 update release notes bd9c0b26c tweak HighFive utility routines acda1ef57 turn off diagnostics around expected failures 22a748840 readDataSet() utility routine for HighFive bd88a8c25 HighFive writeDataSet() utility to work with our SpanRC 6142f5b33 use HighFive routines to write a HDF5 file 5bbf1abaf Use HiveFive routines to get info about the file 84fbc8378 duplicate unittests with H5Easy f1f054c03 Merge branch 'main' into feature/hdf5 9b63ca470 fix directory names f6f826689 fix directory names 7aeb82c33 Merge branch 'main' into feature/hdf5 d028baaeb hook up HighFive header-only library (#653) 3083b0a31 Revert "HighFive 2.6.2" 246985a7f Revert ""build" HighFive HDF5 library" a8b75a586 Revert "turn off HighFive Boost support" ec68d5f83 Revert "Add HighFive unittests" f1f85b9e7 Revert "get test_high_five_base more-or-less compiling" 5ea634ee1 Revert "more work on getting HighFive unittests to build" ecc45433c more work on getting HighFive unittests to build bb194788a get test_high_five_base more-or-less compiling d42bde000 Add HighFive unittests ddc86bb32 turn off HighFive Boost support b255122d4 "build" HighFive HDF5 library 396cc3ef2 HighFive 2.6.2 5e5f9d9c0 Merge branch 'main' into feature/hdf5 ee938b4a5 changes from SIX bb764df90 Merge branch 'main' into feature/xml.lite_tweaks de2a24380 make derived classes 'final' if possible 14e19bcd2 Change xml lite function to virtual (#645) 8f42ac8e9 Merge branch 'main' into feature/xml.lite_tweaks 18ad90645 hdf5Write unittest 3462e1179 createFile() and writeFile() overloads ecee81d53 fix typos 197eecfa6 sketch-out hdf5::lite::writeFile() bd2311795 use SpanRC for writeFile(), not yet implemented ea9af7510 simple SpanRC to hold a 2D-size and pointer 027c19ee8 createFile() unittest 1f9d07ecb hook up createFile() 8c7e4473f start hooking up HDF5 writing 146e0bea3 Merge branch 'main' into feature/hdf5 88ca9fcb7 Merge branch 'main' into feature/hdf5 42b604b46 Squashed commit of the following: 10ee602c2 Merge branch 'main' into feature/hdf5 67aa42b69 restore changes from "main" 8bbfcbfbf unittests can be simplified to match fewer "view" classes 126bb802e Merge branch 'main' into feature/hdf5 3f8ba7a42 again, don't need a class just to convert from std::vector<> to std::span<> 24c2b489c Squashed commit of the following: 2703c119d Squashed commit of the following: 9d5228a2b don't need an entire class just to convert a std::vector<> into std::span<> 51bc931dc Merge branch 'main' into feature/hdf5 a84f25816 Squashed commit of the following: c4d2ed696 add missing #include guards, fix type in existing #include guard d541525a0 use a single ComplexViewConstIterator for all views 86e6a459f CODA_OSS_disable_warning causes GCC errors :-( 5d4b9c2cb only need an custom iterator for ComplexSpansView d9f0fb128 hook up iterators b9329e4db initial pass at a ComplexViewConstIterator 635238873 remove compiler warning about unused "constexpr" variables b39f6096f use the casing from H5 to make copy/pasting code slightly easier 0887b13eb Merge branch 'main' into feature/hdf5 bd07df1ca Consistent casing for Dataset, Datatype, Dataspace 7acd30ee2 tweak hdf5.lite dependencies 38ab914df Jupyter notebook for creating H5 files 95a040e0b _small.h5 is now (correctly) FLOAT32 107e7c487 make a simple values() member function to avoid template magic e1feca919 use TEST_SPECIFIC_EXCEPTION macro instead of try/catch 738333688 readDatasetT() now throws for the wrong buffer type 6b2cc2529 Merge branch 'feature/hdf5' of github.com:mdaus/coda-oss into feature/hdf5 310f8fd3d can't get template magic right for copy_axis() 86b306d59 stepping through copy ctors in the debugger is annoying f243e92d6 trying to make wrong type of buffer fail 2b10d9652 read in new sample file a28e59d8c help the compiler with type deduction 49bf5e9bc nested_complex_float_data_small.h5 e029325fc utility routines to "deconstruct" and array of std::complex dede3bd39 Merge branch 'main' into feature/hdf5 904b1ef5e tweak class names, make_() and copy() utility routines 8237b9efb make it harder to pass the wrong types to ComplexViews 4d9aeda2c ComplexArrayView and ComplexParallelView utility classes f5e367dfa test std::span> a4a2844f2 read in the nested "i" and "r" data 115615265 sample file has subgroups 8e1b7869a Merge branch 'feature/hdf5' of github.com:mdaus/coda-oss into feature/hdf5 9f4232a1d update sample H5 file 8c55db73a walk through HDF5 sub-groups 7775ed9c4 Update 123_barfoo_catdog_cx.h5 677975d7c Matlab code to create sample H5 file a0e7dfe07 Update test_hdf5info.cpp 0b67e1602 pass __FILE__ and __LINE__ from calling site for a more accurate exception message 86a677321 skeleton for more sample data 85f79b099 Merge branch 'main' into feature/hdf5 18088e942 Merge branch 'main' into feature/hdf5 3a1d17692 Merge branch 'main' into feature/hdf5 1755c69d7 Merge branch 'main' into feature/hdf5 9ad015432 No more "11" suffix on exception names c20d96251 Squashed commit of the following: c88cee999 other values to be filled-in bca4a4ecd incorporation NamedObject from HDF5 docs 61fa68f72 groupInfo() 460e7d766 datasetInfo() 14eb9b764 start filling in DatasetInfo afe5f1c3a start to fill in DatasetInfo 77a968c72 start filling in GroupInfo d81bcdfd9 openGroup() to open groups (loc) a0cd29469 comment-out "dataset" unittest for now 86e006024 begin filling in FileInfo 366dda6ab a return_type_of utility is needed to deduce the return type e21928263 explicitly pass return type to template 4937ccd11 template to reduce boilerplate when calling try_catch_H5Exceptions b3b5ebde7 use new exception utility routines ea1c03ef0 put exception handling/conversion in a utility routine 819a99d39 utility routine for exception handling 6f34eea97 put utilities in a separate file for easier reuse fcbde4f24 break utility routines into smaller pieces for easier reuse 52358ea8a WIN32 no longer automatically defined? 5a4286472 Revert "build HDF5 with C89" 680e599e9 build HDF5 with C89 a87a07121 Merge branch 'main' into feature/hdf5 8447c1a90 Revert "sym-links instead of copying files" db3b5e12b Merge branch 'main' into feature/xml.lite_tweaks fb60b5696 Merge branch 'main' into feature/hdf5 5110a5cc8 Comments about _u and _q 1a937d32c Merge branch 'main' into feature/xml.lite_tweaks fa06f04d7 get ready for hdf5.lite enhancdements b040c7c43 sym-links instead of copying files aa431bb47 use _u for xml::lite::Uri 3d0c6d58c fix case-sensitive #include filename 93dcd0e52 operator() for getElementByName() 75a93af85 more operator[] overloads to make attribute management easier 4ab8216f8 user-defined string literals to remove some noise around xml::lite::QName f82f0b0fc Merge branch 'main' into feature/xml.lite_tweaks ae30e3644 Merge branch 'feature/xml.lite_tweaks' of github.com:mdaus/coda-oss into feature/xml.lite_tweaks ffdd9beb0 simplify attribute creation 9bf5414f5 simplify attribute creation 82d7a4e95 SWIG gets confused about namespaces 7a61d0741 fix bug on Element ctor uncovered by unittest fdd7e58c1 QName is also in the xerces namespace which confuses SWIG bindings a325b7053 operator+=() overload for addChild daf30e6c0 Merge branch 'feature/xml.lite_tweaks' of github.com:mdaus/coda-oss into feature/xml.lite_tweaks b887d2b47 provide overloads for Element& rather than creating new "reference" types 1fa6bba38 rename test_xmleasy.cpp 7c8c9e0f1 += overload 850da6f63 overload for std::string 4547fc5a7 use UIT-8 strings for characterData 4723462a3 convenient addChild() overloads e48720753 copy over ElementReference from xml.easy a4ca30a0d Merge branch 'main' into feature/xml.lite_tweaks 6ae9f0b71 Revert "check-in of new xml.easy (to move code between computers)" f7466a6d7 Revert "simple routines for single element" a5490230d Revert "make some operators simplier ways of calling functions" c9a25630a Revert "get document creation working" 8af8710b0 Revert "free functions instead of member functions" 16c3847cb Revert "ElementReference distinct from Element" 7d68e156f Revert "ElementMutableReference" 00eb2a282 Merge branch 'main' into feature/xml.lite_tweaks a42969c1f ElementMutableReference a20ae9355 ElementReference distinct from Element 14eeeea0b free functions instead of member functions 4aae014b3 get document creation working 883569269 make some operators simplier ways of calling functions 053bd1212 simple routines for single element 8bf701a2e check-in of new xml.easy (to move code between computers) 41f959051 unittests for creating XML documents from scratch 9752d50ae Merge branch 'main' into feature/xml.lite_tweaks 1531d5709 by default, don't validate strings passed to Uri() 46d13d4bf Merge branch 'master' into feature/xml.lite_tweaks 39b547d32 remove more vestiges of Expat and LibXML ec8274d52 remove LibXML and Expat as they're no longer used/supported. 20eeefeef Merge branch 'master' into feature/xml.lite_tweaks 95074b9b1 update for newer Intel compiler 7024f71e1 Merge branch 'master' into feature/xml.lite_tweaks 57b1cbc83 Merge branch 'master' into feature/xml.lite_tweaks 4b67561c3 remove validate() overload that nobody is using fa15f1e5d Squashed commit of the following: 1484a9090 test the new validate() API 470da70fb hookup StringStreamT routines 2cddf2504 begin hooking up validate() overloads 1b5d910f3 overload validate() for UTF-8 and Windows-1252 03309b8c9 Squashed commit of the following: b72c6c5bf older compiler doesn't like our make_unique af8f00307 validate UTF-8 XML on Linux 211188613 unit-test for LEGACY XML validation 3c1169d2b Squashed commit of the following: 3afff19ca std::filesystem::path for FileInputStreamOS 908d452f8 WIP: validate all of our sample XML files 00f9bb16b validate against a XML schema 243d8c356 Merge branch 'master' into feature/xml.lite_tweaks 2815d707d fix to work with SWIG bindings. :-( 460862132 trying (again) to remove vestiages of old code e3c83a858 Revert "new code should use UTF-8" 811207c92 new code should use UTF-8 0ffd835f9 Squashed commit of the following: 1e7e03ded Merge branch 'master' into feature/xml.lite_tweaks c1d806aff Merge branch 'master' into feature/xml.lite_tweaks 850d3c811 str::strip() that can be easier to use than str::trim() 580ba9c8c explicitly =delete move 2b39831a8 Squashed commit of the following: 39eebdc23 Merge branch 'master' into feature/xml.lite_tweaks 9adf86cba force calling new UTF-8 write() routines ea61b6204 Merge branch 'master' into feature/xml.lite_tweaks 8a34583fa overload to take schemaPaths as filesystem::path 8671b442f parse XML embedded in a binary file ec4a902f1 updates from xerces.lite 80dc4d963 updates from xerces.lite 549766d6c Attributes::contains() no longer catches an exception 8a645ceac need "sys/" when building in other environments 36af08269 super-simple URI validation 78ef28a3e SWIG bindings are a PITA! :-( e9cba8491 SWIG needs help with Uri 8a8d8dc07 another routines used by pre-build SWIG bindings 818e1ec5d pre-build SWIG bindings use getElementByTagName() member function 067cac5d8 old compiler gets confused on unadorned QName ba92c0ae7 more use of Uri and QName 446c7d17a use QName in new code d6f8b0c83 more direct use of QName 90fff1c73 use xml::lite::QName instead of tuple 646cbb5ed more direct use of QName and Uri ba589ea3b make QName more robust bab0ee8b5 createElement() -> addNewElement() e3a145747 grab changes from six-library 32285e95c Merge branch 'master' into feature/xml.lite_tweaks 9f79f0bf6 Merge branch 'master' into feature/xml.lite_tweaks a12bbc32c make it easier to create new Elements with a value fc9967f98 make it easy for callers to addChild() keep a reference to the Element 4627766b7 be sure test_xmlparser works in "externals" of other projects bf2276396 "private" is part of the name-mangling fad92bcc8 making sure copy-ctor is implemented f90fdcead consolidate common XML test code 9fc53f2d5 use str:: utility for casting 6da6f794b still trying to find the right macro for SWIG 0c1b86c56 still trying to fix SWIG fdc6fc9bd trying to fix SWIG build error 7835e8c27 SWIG needs copy-ctor 585695942 disable copy/assignment for Element, it's probably almost always wrong 391fed613 fix double-delete caused by copying 61790fe69 retry parsing XML with Windows-1252 if first parse() fails 63cffac59 change string_encoding to match coda-oss style of PascalCase 010479bbe read an XML file we know is wrongly encoded as Windows-1252 9a0505062 more references instead of pointers 2d44b6951 Reading Windows-1252 w/o "encoding" fails 63dc7b076 read Windows-1252 too c9434c9cb test as UIT-8 too f310ccf0c get reading from UTF-8 XML working on Windows 1fa39c2be get testReadUtf8XmlFile working on Linux 1a83cd815 sys::Path is too much trouble right now ed60aa22c unit-test to read XML from a file a9336db7c Squashed commit of the following: 0825beb0d Merge branch 'master' into feature/xml.lite_tweaks c618489be Merge branch 'master' into feature/xml.lite_tweaks e8e4b8fe1 determine string_encoding based on platform 1f43bcfc2 create a new Element by using the platform to determine "characterData" encoding 961bef66b Merge branch 'master' into feature/xml.lite_tweaks e9798a5cb fix static_assert() 6f7772874 Merge branch 'master' into feature/xml.lite_tweaks b98d4f5a9 Merge branch 'master' into feature/xml.lite_tweaks 1b5abba2a The (old) version of SWIG we're using doesn't like certain C++11 features. 53bdeabaf Merge branch 'master' into feature/xml.lite_tweaks 60cf8ae80 "" doesn't work with decltype() in older C++ 97e72477a reduce getValue() overloads by making "key" a template argument 5e6373e55 reduce code duplication f9e7cfeee provide castValue instead of getValue(T&) cbd0bd8f2 castValue throws instead of returning a bool like getValue(T&) 87c7514fc Merge branch 'master' into feature/xml.lite_tweaks 10cc61223 make getElement*() consistent for zero or >1 results f5b137e3c Merge branch 'master' into feature/xml.lite_tweaks 1765efc62 allow clients to specify toType() and toString() for getValue() and setValue() df8b746e1 allow clients to specify their own toType/toString routines 66702726a Merge branch 'master' into feature/xml.lite_tweaks 6956311f1 Merge branch 'master' into feature/xml.lite_tweaks d505f3593 Merge branch 'master' into feature/xml.lite_tweaks fbd106115 catch a BadCastException and return false from getValue() 3a78377b5 use a template to reduce duplicated code 0ad4b8606 Merge branch 'master' into feature/xml.lite_tweaks a848aa3a2 get & set the characer data as a type f3ee1ee12 utility routines to set an attribute value 595227683 templates to get an attribute value convert to a specific type 06639227b miised a change in last commit 1aa458ef8 add getValue() overloads that return true/false rather than throwing faa6d3075 added getElementByTagName() overloads as that's a very common use-case git-subtree-dir: externals/coda-oss git-subtree-split: aeec0131c51497c5d448a39be0d2df608d93bc15 commit bce7ba0b1ae40e9ddcb4f24610e7e4d702272d54 Merge: 646b70e8d 86929db19 Author: Dan Smith Date: Thu Jun 8 14:34:18 2023 -0400 Merge commit '86929db19a438630d531ca0c34bdcd8e8c527ae9' into develop/sync_externals commit 646b70e8d47438211451493837e6b2d76db4e896 Author: Dan Smith Date: Thu Jun 8 14:34:13 2023 -0400 latest from CODA-OSS and NITRO * aliases for std::complex and std::complex * std::complex -> zfloat * std::complex -> zfloat * turn off _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING * begin switching to types::complex for integral T * use types::z* aliases for complex * latest from coda-oss * CPHD aliaes for std::complex * use types::complex for TInteger * Update test_dump_images.cpp * latest from coda-oss * types::complex is std::complex for now * finish (almost) switching to types::complex for integers * std::complex -> six::zfloat --- externals/coda-oss/UnitTest/UnitTest.vcxproj | 2 +- .../UnitTest/UnitTest.vcxproj.filters | 2 +- externals/coda-oss/UnitTest/pch.h | 2 +- externals/coda-oss/UnitTest/types.cpp | 4 +- .../modules/c++/coda-oss-lite.vcxproj | 2 +- .../modules/c++/coda-oss-lite.vcxproj.filters | 2 +- .../modules/c++/types/include/types/complex.h | 145 ++++++++++++++++++ .../c++/types/include/types/complex_short.h | 114 -------------- ...est_complex_short.cpp => test_complex.cpp} | 15 +- six/modules/c++/cphd/framework.h | 4 +- six/modules/c++/cphd/include/cphd/ByteSwap.h | 11 +- .../c++/cphd/include/cphd/CPHDWriter.h | 18 ++- six/modules/c++/cphd/include/cphd/PVPBlock.h | 11 +- six/modules/c++/cphd/include/cphd/Types.h | 18 ++- six/modules/c++/cphd/include/cphd/Wideband.h | 6 +- six/modules/c++/cphd/source/ByteSwap.cpp | 33 ++-- six/modules/c++/cphd/source/CPHDWriter.cpp | 36 ++--- six/modules/c++/cphd/source/PVPBlock.cpp | 12 +- six/modules/c++/cphd/source/Wideband.cpp | 48 +++--- .../c++/cphd/tests/test_compare_cphd.cpp | 6 +- .../c++/cphd/tests/test_round_trip.cpp | 6 +- .../c++/cphd/unittests/test_pvp_block.cpp | 6 +- .../cphd/unittests/test_pvp_block_round.cpp | 16 +- .../unittests/test_signal_block_round.cpp | 36 ++--- .../unittests/test_support_block_round.cpp | 2 +- .../c++/cphd03/include/cphd03/CPHDWriter.h | 12 +- six/modules/c++/cphd03/source/CPHDWriter.cpp | 36 ++--- .../c++/cphd03/tests/test_cphd_compare.cpp | 6 +- .../c++/cphd03/tests/test_cphd_round_trip.cpp | 12 +- .../cphd03/tests/test_cphd_write_simple.cpp | 4 +- .../unittests/test_cphd_read_unscaled_int.cpp | 36 ++--- .../c++/cphd03/unittests/test_cphd_write.cpp | 10 +- six/modules/c++/cpp_pch.h | 7 +- .../c++/samples/project_slant_to_output.cpp | 2 +- six/modules/c++/samples/round_trip_six.cpp | 26 ++-- .../sicd_output_plane_pixel_to_lat_lon.cpp | 2 +- six/modules/c++/samples/test_create_sicd.cpp | 2 +- .../c++/samples/test_create_sicd_from_mem.cpp | 2 +- six/modules/c++/samples/test_dump_images.cpp | 11 +- six/modules/c++/samples/test_large_offset.cpp | 10 +- .../c++/samples/update_sicd_version.cpp | 4 +- .../c++/samples/update_sidd_version.cpp | 6 +- six/modules/c++/scene/include/scene/Types.h | 19 ++- .../six.sicd/include/six/sicd/ComplexData.h | 8 +- .../c++/six.sicd/include/six/sicd/ImageData.h | 4 +- .../include/six/sicd/ImageFormation.h | 12 +- .../six/sicd/NITFReadComplexXMLControl.h | 4 +- .../c++/six.sicd/include/six/sicd/Utilities.h | 24 +-- .../six.sicd/source/ComplexToAMP8IPHS8I.cpp | 2 +- six/modules/c++/six.sicd/source/CropUtils.cpp | 2 +- six/modules/c++/six.sicd/source/ImageData.cpp | 4 +- .../c++/six.sicd/source/ImageFormation.cpp | 12 +- .../source/NITFReadComplexXMLControl.cpp | 6 +- six/modules/c++/six.sicd/source/Utilities.cpp | 42 ++--- .../six.sicd/tests/derive_output_plane.cpp | 2 +- .../tests/test_compare_sicd_meshes.cpp | 2 +- .../tests/test_load_from_input_stream.cpp | 2 +- .../c++/six.sicd/tests/test_read_sicd.cpp | 2 +- .../six.sicd/tests/test_read_sicd_mesh.cpp | 2 +- .../tests/test_sicd_byte_provider.cpp | 8 +- .../six.sicd/tests/test_streaming_write.cpp | 10 +- .../six.sicd/unittests/test_AMP8I_PHS8I.cpp | 94 ++++++------ .../test_projection_polynomial_fitter.cpp | 2 +- .../c++/six.sicd/unittests/test_valid_six.cpp | 18 +-- .../six.sidd/tests/test_check_blocking.cpp | 12 +- six/modules/c++/six/include/six/Adapters.h | 11 +- .../c++/six/include/six/AmplitudeTable.h | 11 +- .../c++/six/include/six/NITFWriteControl.h | 6 +- six/modules/c++/six/include/six/Parameter.h | 16 +- six/modules/c++/six/include/six/Region.h | 7 +- .../c++/six/include/six/SICommonXMLParser.h | 2 +- six/modules/c++/six/include/six/Types.h | 16 +- six/modules/c++/six/include/six/XMLParser.h | 2 +- six/modules/c++/six/include/six/XmlLite.h | 2 +- six/modules/c++/six/source/Adapters.cpp | 16 +- .../c++/six/source/NITFWriteControl.cpp | 8 +- .../c++/six/source/SICommonXMLParser.cpp | 2 +- six/modules/c++/six/source/XMLParser.cpp | 2 +- six/modules/c++/six/source/XmlLite.cpp | 4 +- 79 files changed, 613 insertions(+), 530 deletions(-) create mode 100644 externals/coda-oss/modules/c++/types/include/types/complex.h delete mode 100644 externals/coda-oss/modules/c++/types/include/types/complex_short.h rename externals/coda-oss/modules/c++/types/unittests/{test_complex_short.cpp => test_complex.cpp} (72%) diff --git a/externals/coda-oss/UnitTest/UnitTest.vcxproj b/externals/coda-oss/UnitTest/UnitTest.vcxproj index 532441cbc7..acd9a5bbee 100644 --- a/externals/coda-oss/UnitTest/UnitTest.vcxproj +++ b/externals/coda-oss/UnitTest/UnitTest.vcxproj @@ -321,7 +321,7 @@ true true - + true true diff --git a/externals/coda-oss/UnitTest/UnitTest.vcxproj.filters b/externals/coda-oss/UnitTest/UnitTest.vcxproj.filters index f4e1f33531..fd73449870 100644 --- a/externals/coda-oss/UnitTest/UnitTest.vcxproj.filters +++ b/externals/coda-oss/UnitTest/UnitTest.vcxproj.filters @@ -222,7 +222,7 @@ mt - + types diff --git a/externals/coda-oss/UnitTest/pch.h b/externals/coda-oss/UnitTest/pch.h index bd1dff097b..26d745b783 100644 --- a/externals/coda-oss/UnitTest/pch.h +++ b/externals/coda-oss/UnitTest/pch.h @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/externals/coda-oss/UnitTest/types.cpp b/externals/coda-oss/UnitTest/types.cpp index 9ab942e4ff..3d03155b3f 100644 --- a/externals/coda-oss/UnitTest/types.cpp +++ b/externals/coda-oss/UnitTest/types.cpp @@ -15,8 +15,8 @@ TEST_CLASS(test_range_list){ public: #include "types/unittests/test_range_list.cpp" }; -TEST_CLASS(test_complex_short){ public: -#include "types/unittests/test_complex_short.cpp" +TEST_CLASS(test_complex){ public: +#include "types/unittests/test_complex.cpp" }; } \ No newline at end of file diff --git a/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj b/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj index f7cb974a77..5c5a4b7f51 100644 --- a/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj +++ b/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj @@ -256,7 +256,7 @@ - + diff --git a/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters b/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters index 9f785622bb..f380d7dcd3 100644 --- a/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters +++ b/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters @@ -747,7 +747,7 @@ sys - + types diff --git a/externals/coda-oss/modules/c++/types/include/types/complex.h b/externals/coda-oss/modules/c++/types/include/types/complex.h new file mode 100644 index 0000000000..f6051594c7 --- /dev/null +++ b/externals/coda-oss/modules/c++/types/include/types/complex.h @@ -0,0 +1,145 @@ +/* ========================================================================= + * This file is part of types-c++ + * ========================================================================= + * + * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * (C) Copyright 2023, Maxar Technologies, Inc. + * + * types-c++ is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; If not, + * see . + * + */ + +#pragma once +#ifndef CODA_OSS_types_complex_h_INCLUDED_ +#define CODA_OSS_types_complex_h_INCLUDED_ + +#include + +// TODO: remove this once TIntergers are switched to types::details::complex +// '...': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. +#ifndef _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING +#define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING +#endif + +#include +#include + +#include "config/disable_compiler_warnings.h" +#include "coda_oss/CPlusPlus.h" + +namespace types +{ +namespace details +{ +/*! + * \class complex + * \brief Our own implementation of std::complex for SIX and friends. + * + * `std::complex` is no longer valid C++; provide a (partial) work-around. + * See https://en.cppreference.com/w/cpp/numeric/complex for detals. + * + * SIX (and others) mostly use `std::complex` as a + * convenient package for two values; very little "complex math" is done + * using integers. + */ +template +struct complex final +{ + using value_type = T; + static_assert(!std::is_floating_point::value, "Use std::complex for floating-point."); + static_assert(std::is_signed::value, "T should be a signed integer."); + + complex(value_type re = 0, value_type im = 0) : z{re, im} {} + complex(const complex&) = default; + complex& operator=(const complex&) = default; + complex(complex&&) = default; + complex& operator=(complex&&) = default; + ~complex() = default; + + // If someone already has a std::complex, is there any harm in creating ours? + complex(const std::complex& z_) : complex(z_.real(), z_.imag()) {} + + value_type real() const + { + return z[0]; + } + void real(value_type value) + { + z[0] = value; + } + + value_type imag() const + { + return z[1]; + } + void imag(value_type value) + { + z[1] = value; + } + +private: + value_type z[2]{0, 0}; +}; + +CODA_OSS_disable_warning_push +#ifdef _MSC_VER +#pragma warning(disable: 4996) // '...': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. +#endif + +template +inline const std::complex& cast(const complex& z) +{ + // Getting different results with GCC vs MSVC :-( So just use + // std::complex Assume by the time we're actually using C++23 with a + // compiler that enforces this restriction, "something" will be different. + const void* const pZ_ = &z; + return *static_cast*>(pZ_); +} + +CODA_OSS_disable_warning_pop + +// https://en.cppreference.com/w/cpp/numeric/complex/abs +template +inline auto abs(const complex& z) +{ + return abs(cast(z)); +} + +} + +//// Have the compiler pick between std::complex and details::complex +//template +//using complex = std::conditional_t::value, std::complex, details::complex>; +//static_assert(std::is_same, complex>::value, "should be details::complex"); +template +using complex = std::complex; + +static_assert(std::is_same, complex>::value, "should be std::complex"); +static_assert(sizeof(std::complex) == sizeof(complex), "sizeof(sizeof(std::complex) != sizeof(complex)"); + +// Convenient aliases +using zfloat = complex; // std::complex +using zdouble = complex; // std::complex +//using zlong_double = complex; // std::complex + +// Intentionally using somewhat cumbersome names +// TODO: switch TIntergers to types::details::complex +using zint8_t = complex; // details:complex +using zint16_t = complex; // details:complex +using zint32_t = complex; // details::complex +using zint64_t = complex; // details::complex +} + +#endif // CODA_OSS_types_complex_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/types/include/types/complex_short.h b/externals/coda-oss/modules/c++/types/include/types/complex_short.h deleted file mode 100644 index ab747a83f9..0000000000 --- a/externals/coda-oss/modules/c++/types/include/types/complex_short.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ========================================================================= - * This file is part of types-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * (C) Copyright 2023, Maxar Technologies, Inc. - * - * types-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#pragma once -#ifndef CODA_OSS_types_complex_short_h_INCLUDED_ -#define CODA_OSS_types_complex_short_h_INCLUDED_ - -#include - -#include "config/disable_compiler_warnings.h" -#include "coda_oss/CPlusPlus.h" - -namespace types -{ -namespace details -{ -/*! - * \class complex_short - * \brief std::complex - * - * `std::complex` is no longer valid C++; provide a (partial) work-around. - * See https://en.cppreference.com/w/cpp/numeric/complex for detals. - */ -struct complex_short final -{ - using value_type = short; - - complex_short(value_type re = 0, value_type im = 0) : z{re, im} {} - complex_short(const complex_short&) = default; - complex_short& operator=(const complex_short&) = default; - complex_short(complex_short&&) = default; - complex_short& operator=(complex_short&&) = default; - ~complex_short() = default; - - value_type real() const - { - return z[0]; - } - void real(value_type value) - { - z[0] = value; - } - - value_type imag() const - { - return z[1]; - } - void imag(value_type value) - { - z[1] = value; - } - -private: - value_type z[2]{0, 0}; -}; -static_assert(sizeof(complex_short) == sizeof(float), "sizeof(complex_short) != sizeof(float)"); - -CODA_OSS_disable_warning_push -#ifdef _MSC_VER -#pragma warning(disable: 4996) // '...': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. -#endif - -inline const std::complex& cast(const complex_short& z) -{ - // Getting different results with GCC vs MSVC :-( So just use - // std::complex Assume by the time we're actually using C++23 with a - // compiler that enforces this restriction, "something" will be different. - const void* const pZ_ = &z; - return *static_cast*>(pZ_); -} - -CODA_OSS_disable_warning_pop - -// https://en.cppreference.com/w/cpp/numeric/complex/abs -inline auto abs(const complex_short& z) -{ - return abs(cast(z)); -} - -} - -#if CODA_OSS_cpp23 - using details::complex_short; -#else - // No macro to turn this on/off, want to implement what we need in details::complex_short. - // But keep in `details` in case somebody wants to uncomment. - //using complex_short = std::complex; // not valid in C++23 - using details::complex_short; - - static_assert(sizeof(std::complex) == sizeof(complex_short), "sizeof(sizeof(std::complex) != sizeof(complex_short)"); -#endif -} - -#endif // CODA_OSS_types_complex_short_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/types/unittests/test_complex_short.cpp b/externals/coda-oss/modules/c++/types/unittests/test_complex.cpp similarity index 72% rename from externals/coda-oss/modules/c++/types/unittests/test_complex_short.cpp rename to externals/coda-oss/modules/c++/types/unittests/test_complex.cpp index 43b870a5f7..6410e48f30 100644 --- a/externals/coda-oss/modules/c++/types/unittests/test_complex_short.cpp +++ b/externals/coda-oss/modules/c++/types/unittests/test_complex.cpp @@ -22,7 +22,7 @@ #include "TestCase.h" -#include +#include TEST_CASE(TestCxShort_abs) { @@ -37,8 +37,17 @@ TEST_CASE(TestCxShort_abs) CODA_OSS_disable_warning_pop const auto expected = abs(cx_short); - const types::complex_short types_cx_short(real, imag); - const auto actual = abs(types_cx_short); + CODA_OSS_disable_warning_push + #ifdef _MSC_VER + #pragma warning(disable: 4996) // '...': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. + #endif + const types::zint16_t types_zint16(cx_short); + CODA_OSS_disable_warning_pop + auto actual = abs(types_zint16); + TEST_ASSERT_EQ(actual, expected); + + const types::complex types_cx_int16(cx_short); + actual = abs(types_cx_int16); TEST_ASSERT_EQ(actual, expected); } diff --git a/six/modules/c++/cphd/framework.h b/six/modules/c++/cphd/framework.h index 91b3386d67..b0ff40e149 100644 --- a/six/modules/c++/cphd/framework.h +++ b/six/modules/c++/cphd/framework.h @@ -39,9 +39,7 @@ #pragma warning(disable: 6386) // Buffer overrun while writing to '...': the writable size is '...' bytes, but '...' bytes might be written. #pragma warning(disable: 26812) // The enum type '...' is unscoped. Prefer '...' over '...' (Enum.3). -// error 4996: '...': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. -#define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING -#include +#include #pragma warning(push) #pragma warning(disable: 4464) // relative include path contains '..' diff --git a/six/modules/c++/cphd/include/cphd/ByteSwap.h b/six/modules/c++/cphd/include/cphd/ByteSwap.h index c95403b679..066775bd6a 100644 --- a/six/modules/c++/cphd/include/cphd/ByteSwap.h +++ b/six/modules/c++/cphd/include/cphd/ByteSwap.h @@ -24,11 +24,14 @@ #define __CPHD_BYTE_SWAP_H__ #include -#include -#include +#include #include +#include + +#include "cphd/Types.h" + namespace cphd { /* @@ -66,7 +69,7 @@ void byteSwapAndPromote(const void* input, size_t elementSize, const types::RowCol& dims, size_t numThreads, - std::complex* output); + cphd::zfloat* output); /* * \func byteSwapAndScale @@ -92,7 +95,7 @@ void byteSwapAndScale(const void* input, const types::RowCol& dims, const double* scaleFactors, size_t numThreads, - std::complex* output); + cphd::zfloat* output); } #endif diff --git a/six/modules/c++/cphd/include/cphd/CPHDWriter.h b/six/modules/c++/cphd/include/cphd/CPHDWriter.h index 1341cbb829..67f5cc65bb 100644 --- a/six/modules/c++/cphd/include/cphd/CPHDWriter.h +++ b/six/modules/c++/cphd/include/cphd/CPHDWriter.h @@ -27,10 +27,14 @@ #include #include -#include +#include #include #include #include + +#include + +#include #include #include #include @@ -114,9 +118,9 @@ struct CPHDWriter final * * This only works with valid CPHDWriter data types: * std:: ubyte* (for compressed data) - * std::complex - * std::complex - * std::complex + * cphd::zfloat + * chpd::zint16_t + * cphd::zint8_t * * \param pvpBlock The vector based metadata to write. * \param widebandData .The wideband data to write to disk @@ -207,9 +211,9 @@ struct CPHDWriter final * using this method. This only works with * valid CPHDWriter data types: * std:: ubyte* (for compressed data) - * std::complex - * std::complex - * std::complex + * cphd::zfloat + * chpd::zint16_t + * cphd::zint8_t * * \param data The data to write to disk. * \param numElements The number of elements in data. Treat the data diff --git a/six/modules/c++/cphd/include/cphd/PVPBlock.h b/six/modules/c++/cphd/include/cphd/PVPBlock.h index 8d6f5ce61a..7981e33123 100644 --- a/six/modules/c++/cphd/include/cphd/PVPBlock.h +++ b/six/modules/c++/cphd/include/cphd/PVPBlock.h @@ -23,15 +23,16 @@ #ifndef __CPHD_PVP_BLOCK_H__ #define __CPHD_PVP_BLOCK_H__ +#include + #include #include -#include #include -#include #include - #include +#include + #include #include #include @@ -60,9 +61,9 @@ struct AddedPVP } }; template -struct AddedPVP > +struct AddedPVP > { - std::complex getAddedPVP(const six::Parameter& val) const + types::complex getAddedPVP(const six::Parameter& val) const { return val.getComplex(); } diff --git a/six/modules/c++/cphd/include/cphd/Types.h b/six/modules/c++/cphd/include/cphd/Types.h index 0414f738e4..81873ffcb6 100644 --- a/six/modules/c++/cphd/include/cphd/Types.h +++ b/six/modules/c++/cphd/include/cphd/Types.h @@ -19,12 +19,16 @@ * see . * */ -#ifndef __CPHD_TYPES_H__ -#define __CPHD_TYPES_H__ #pragma once +#ifndef SIX_cphd_Types_h_INCLUDED_ +#define SIX_cphd_Types_h_INCLUDED_ + +#include #include +#include + #include #include #include @@ -36,6 +40,14 @@ namespace cphd { // Use the same types that SIX uses +using zfloat = six::zfloat; +using zdouble = six::zdouble; + +using zint8_t = types::zint8_t; +using zint16_t = types::zint16_t; +using zint32_t = types::zint32_t; +using zint64_t = types::zint64_t; + typedef six::Vector2 Vector2; typedef six::Vector3 Vector3; @@ -86,4 +98,4 @@ typedef six::MatchInformation MatchInformation; } -#endif +#endif // SIX_cphd_Types_h_INCLUDED_ \ No newline at end of file diff --git a/six/modules/c++/cphd/include/cphd/Wideband.h b/six/modules/c++/cphd/include/cphd/Wideband.h index 95ca1ed732..9774ffb96b 100644 --- a/six/modules/c++/cphd/include/cphd/Wideband.h +++ b/six/modules/c++/cphd/include/cphd/Wideband.h @@ -285,7 +285,7 @@ struct Wideband final const std::vector& vectorScaleFactors, size_t numThreads, const mem::BufferView& scratch, - const mem::BufferView>& data) const; + const mem::BufferView& data) const; void read(size_t channel, size_t firstVector, size_t lastVector, @@ -294,10 +294,10 @@ struct Wideband final const std::vector& vectorScaleFactors, size_t numThreads, std::span scratch, - std::span> data) const + std::span data) const { mem::BufferView scratch_(reinterpret_cast(scratch.data()), scratch.size()); - mem::BufferView> data_(data.data(), data.size()); + mem::BufferView data_(data.data(), data.size()); read(channel, firstVector, lastVector, firstSample, lastSample, vectorScaleFactors, numThreads, scratch_, data_); } diff --git a/six/modules/c++/cphd/source/ByteSwap.cpp b/six/modules/c++/cphd/source/ByteSwap.cpp index 4f69666ed6..978e1c98dd 100644 --- a/six/modules/c++/cphd/source/ByteSwap.cpp +++ b/six/modules/c++/cphd/source/ByteSwap.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -62,8 +63,8 @@ struct ByteSwapAndPromoteRunnable final : public sys::Runnable size_t startRow, size_t numRows, size_t numCols, - std::complex* output) : - mInput(calc_offset(input, startRow * numCols * sizeof(std::complex))), + cphd::zfloat* output) : + mInput(calc_offset(input, startRow * numCols * sizeof(types::complex))), mDims(numRows, numCols), mOutput(output + startRow * numCols) { @@ -76,16 +77,16 @@ struct ByteSwapAndPromoteRunnable final : public sys::Runnable for (size_t row = 0, inIdx = 0, outIdx = 0; row < mDims.row; ++row) { - for (size_t col = 0; col < mDims.col; ++col, inIdx += sizeof(std::complex), ++outIdx) + for (size_t col = 0; col < mDims.col; ++col, inIdx += sizeof(types::complex), ++outIdx) { // Have to be careful here - can't treat mInput as a - // std::complex directly in case InT is a float (see + // types::complex directly in case InT is a float (see // explanation in byteSwap() comments) const auto input = calc_offset(mInput, inIdx); byteSwap(input, real); byteSwap(calc_offset(input, sizeof(InT)), imag); - mOutput[outIdx] = std::complex(real, imag); + mOutput[outIdx] = cphd::zfloat(real, imag); } } } @@ -93,7 +94,7 @@ struct ByteSwapAndPromoteRunnable final : public sys::Runnable private: const std::byte* const mInput; const types::RowCol mDims; - std::complex* const mOutput; + cphd::zfloat* const mOutput; }; @@ -105,8 +106,8 @@ struct ByteSwapAndScaleRunnable final : public sys::Runnable size_t numRows, size_t numCols, const double* scaleFactors, - std::complex* output) : - mInput(calc_offset(input, startRow * numCols * sizeof(std::complex))), + cphd::zfloat* output) : + mInput(calc_offset(input, startRow * numCols * sizeof(types::complex))), mDims(numRows, numCols), mScaleFactors(scaleFactors + startRow), mOutput(output + startRow * numCols) @@ -124,16 +125,16 @@ struct ByteSwapAndScaleRunnable final : public sys::Runnable for (size_t col = 0; col < mDims.col; - ++col, inIdx += sizeof(std::complex), ++outIdx) + ++col, inIdx += sizeof(types::complex), ++outIdx) { // Have to be careful here - can't treat mInput as a - // std::complex directly in case InT is a float (see + // types::complex directly in case InT is a float (see // explanation in byteSwap() comments) const auto input = calc_offset(mInput, inIdx); byteSwap(input, real); byteSwap(calc_offset(input, sizeof(InT)), imag); - mOutput[outIdx] = std::complex( + mOutput[outIdx] = cphd::zfloat( static_cast(real * scaleFactor), static_cast(imag * scaleFactor)); } @@ -144,14 +145,14 @@ struct ByteSwapAndScaleRunnable final : public sys::Runnable const std::byte* const mInput; const types::RowCol mDims; const double* const mScaleFactors; - std::complex* const mOutput; + cphd::zfloat* const mOutput; }; template void byteSwapAndPromote(const void* input, const types::RowCol& dims, size_t numThreads, - std::complex* output) + cphd::zfloat* output) { if (numThreads <= 1) { @@ -187,7 +188,7 @@ void byteSwapAndScale(const void* input, const types::RowCol& dims, const double* scaleFactors, size_t numThreads, - std::complex* output) + cphd::zfloat* output) { if (numThreads <= 1) { @@ -232,7 +233,7 @@ void byteSwapAndPromote(const void* input, size_t elementSize, const types::RowCol& dims, size_t numThreads, - std::complex* output) + cphd::zfloat* output) { switch (elementSize) { @@ -256,7 +257,7 @@ void byteSwapAndScale(const void* input, const types::RowCol& dims, const double* scaleFactors, size_t numThreads, - std::complex* output) + cphd::zfloat* output) { switch (elementSize) { diff --git a/six/modules/c++/cphd/source/CPHDWriter.cpp b/six/modules/c++/cphd/source/CPHDWriter.cpp index e80946b0e5..4d8ad2d9a4 100644 --- a/six/modules/c++/cphd/source/CPHDWriter.cpp +++ b/six/modules/c++/cphd/source/CPHDWriter.cpp @@ -178,34 +178,34 @@ template void CPHDWriter::write(const PVPBlock& pvpBlock, const std::byte* widebandData, const std::byte* supportData); -template void CPHDWriter::write>( +template void CPHDWriter::write( const PVPBlock& pvpBlock, - const std::complex* widebandData, + const cphd::zint8_t* widebandData, const sys::ubyte* supportData); -template void CPHDWriter::write>( +template void CPHDWriter::write( const PVPBlock& pvpBlock, - const std::complex* widebandData, + const cphd::zint16_t* widebandData, const sys::ubyte* supportData); -template void CPHDWriter::write>( +template void CPHDWriter::write( const PVPBlock& pvpBlock, - const std::complex* widebandData, + const cphd::zfloat* widebandData, const sys::ubyte* supportData); -template void CPHDWriter::write>( +template void CPHDWriter::write( const PVPBlock& pvpBlock, - const std::complex* widebandData, + const cphd::zint8_t* widebandData, const std::byte* supportData); -template void CPHDWriter::write>( +template void CPHDWriter::write( const PVPBlock& pvpBlock, - const std::complex* widebandData, + const cphd::zint16_t* widebandData, const std::byte* supportData); -template void CPHDWriter::write>( +template void CPHDWriter::write( const PVPBlock& pvpBlock, - const std::complex* widebandData, + const cphd::zfloat* widebandData, const std::byte* supportData); void CPHDWriter::writeMetadata(const PVPBlock& pvpBlock) @@ -298,16 +298,16 @@ template void CPHDWriter::writeCPHDData(const std::byte* data, size_t numElements, size_t channel); -template void CPHDWriter::writeCPHDData>( - const std::complex* data, +template void CPHDWriter::writeCPHDData( + const cphd::zint8_t* data, size_t numElements, size_t channel); -template void CPHDWriter::writeCPHDData>( - const std::complex* data, +template void CPHDWriter::writeCPHDData( + const cphd::zint16_t* data, size_t numElements, size_t channel); -template void CPHDWriter::writeCPHDData>( - const std::complex* data, size_t numElements, size_t channel); +template void CPHDWriter::writeCPHDData( + const cphd::zfloat* data, size_t numElements, size_t channel); } diff --git a/six/modules/c++/cphd/source/PVPBlock.cpp b/six/modules/c++/cphd/source/PVPBlock.cpp index 23b8e2dde3..c94677ab5b 100644 --- a/six/modules/c++/cphd/source/PVPBlock.cpp +++ b/six/modules/c++/cphd/source/PVPBlock.cpp @@ -257,42 +257,42 @@ void PVPBlock::PVPSet::write(const PVPBlock& pvpBlock, const Pvp& p, const sys:: } else if (it->second.getFormat() == "CI2") { - std::complex val; + cphd::zint8_t val; ::setData(input + it->second.getByteOffset(), val); addedPVP[it->first] = six::Parameter(); addedPVP.find(it->first)->second.setValue(val); } else if (it->second.getFormat() == "CI4") { - std::complex val; + cphd::zint16_t val; ::setData(input + it->second.getByteOffset(), val); addedPVP[it->first] = six::Parameter(); addedPVP.find(it->first)->second.setValue(val); } else if (it->second.getFormat() == "CI8") { - std::complex val; + cphd::zint32_t val; ::setData(input + it->second.getByteOffset(), val); addedPVP[it->first] = six::Parameter(); addedPVP.find(it->first)->second.setValue(val); } else if (it->second.getFormat() == "CI16") { - std::complex val; + cphd::zint64_t val; ::setData(input + it->second.getByteOffset(), val); addedPVP[it->first] = six::Parameter(); addedPVP.find(it->first)->second.setValue(val); } else if (it->second.getFormat() == "CF8") { - std::complex val; + cphd::zfloat val; ::setData(input + it->second.getByteOffset(), val); addedPVP[it->first] = six::Parameter(); addedPVP.find(it->first)->second.setValue(val); } else if (it->second.getFormat() == "CF16") { - std::complex val; + cphd::zdouble val; ::setData(input + it->second.getByteOffset(), val); addedPVP[it->first] = six::Parameter(); addedPVP.find(it->first)->second.setValue(val); diff --git a/six/modules/c++/cphd/source/Wideband.cpp b/six/modules/c++/cphd/source/Wideband.cpp index c073ece8e2..a2a50d48b6 100644 --- a/six/modules/c++/cphd/source/Wideband.cpp +++ b/six/modules/c++/cphd/source/Wideband.cpp @@ -24,14 +24,16 @@ #include #include #include -#include +#include -#include +#include #include #include #include #include +#include + #include #include #include @@ -46,11 +48,11 @@ template class PromoteRunnable : public sys::Runnable { public: - PromoteRunnable(const std::complex* input, + PromoteRunnable(const types::complex* input, size_t startRow, size_t numRows, size_t numCols, - std::complex* output) : + cphd::zfloat* output) : mInput(input + startRow * numCols), mDims(numRows, numCols), mOutput(output + startRow * numCols) @@ -63,28 +65,28 @@ class PromoteRunnable : public sys::Runnable { for (size_t col = 0; col < mDims.col; ++col, ++idx) { - const std::complex& input(mInput[idx]); - mOutput[idx] = std::complex(input.real(), input.imag()); + const types::complex& input(mInput[idx]); + mOutput[idx] = cphd::zfloat(input.real(), input.imag()); } } } private: - const std::complex* const mInput; + const types::complex* const mInput; const types::RowCol mDims; - std::complex* const mOutput; + cphd::zfloat* const mOutput; }; template class ScaleRunnable : public sys::Runnable { public: - ScaleRunnable(const std::complex* input, + ScaleRunnable(const types::complex* input, size_t startRow, size_t numRows, size_t numCols, const double* scaleFactors, - std::complex* output) : + cphd::zfloat* output) : mInput(input + startRow * numCols), mDims(numRows, numCols), mScaleFactors(scaleFactors + startRow), @@ -99,29 +101,29 @@ class ScaleRunnable : public sys::Runnable const double scaleFactor(mScaleFactors[row]); for (size_t col = 0; col < mDims.col; ++col, ++idx) { - const std::complex& input(mInput[idx]); - mOutput[idx] = std::complex(static_cast(input.real() * scaleFactor), + const types::complex& input(mInput[idx]); + mOutput[idx] = cphd::zfloat(static_cast(input.real() * scaleFactor), static_cast(input.imag() * scaleFactor)); } } } private: - const std::complex* const mInput; + const types::complex* const mInput; const types::RowCol mDims; const double* const mScaleFactors; - std::complex* const mOutput; + cphd::zfloat* const mOutput; }; template void promote(const void* input, const types::RowCol& dims, size_t numThreads, - std::complex* output) + cphd::zfloat* output) { if (numThreads <= 1) { - PromoteRunnable(static_cast*>(input), + PromoteRunnable(static_cast*>(input), 0, dims.row, dims.col, @@ -139,7 +141,7 @@ void promote(const void* input, while (planner.getThreadInfo(threadNum++, startRow, numRowsThisThread)) { auto scaler = std::make_unique>( - static_cast*>(input), + static_cast*>(input), startRow, numRowsThisThread, dims.col, @@ -155,7 +157,7 @@ void promote(const void* input, size_t elementSize, const types::RowCol& dims, size_t numThreads, - std::complex* output) + cphd::zfloat* output) { switch (elementSize) { @@ -178,11 +180,11 @@ void scale(const void* input, const types::RowCol& dims, const double* scaleFactors, size_t numThreads, - std::complex* output) + cphd::zfloat* output) { if (numThreads <= 1) { - ScaleRunnable(static_cast*>(input), + ScaleRunnable(static_cast*>(input), 0, dims.row, dims.col, @@ -201,7 +203,7 @@ void scale(const void* input, while (planner.getThreadInfo(threadNum++, startRow, numRowsThisThread)) { auto scaler = std::make_unique>( - static_cast*>(input), + static_cast*>(input), startRow, numRowsThisThread, dims.col, @@ -219,7 +221,7 @@ void scale(const void* input, const types::RowCol& dims, const double* scaleFactors, size_t numThreads, - std::complex* output) + cphd::zfloat* output) { switch (elementSize) { @@ -602,7 +604,7 @@ void Wideband::read(size_t channel, const std::vector& vectorScaleFactors, size_t numThreads, const mem::BufferView& scratch, - const mem::BufferView>& data) const + const mem::BufferView& data) const { // Sanity checks types::RowCol dims; diff --git a/six/modules/c++/cphd/tests/test_compare_cphd.cpp b/six/modules/c++/cphd/tests/test_compare_cphd.cpp index 37784695fe..00a072546f 100644 --- a/six/modules/c++/cphd/tests/test_compare_cphd.cpp +++ b/six/modules/c++/cphd/tests/test_compare_cphd.cpp @@ -116,7 +116,7 @@ bool compareWideband(cphd::CPHDReader& reader1, switch (reader1.getMetadata().data.getSampleType()) { case cphd::SampleType::RE08I_IM08I: - if (!compareCPHDData >( + if (!compareCPHDData( cphdData1.get(), cphdData2.get(), dims1.area(), @@ -126,7 +126,7 @@ bool compareWideband(cphd::CPHDReader& reader1, } break; case cphd::SampleType::RE16I_IM16I: - if (!compareCPHDData >( + if (!compareCPHDData( cphdData1.get(), cphdData2.get(), dims1.area(), @@ -136,7 +136,7 @@ bool compareWideband(cphd::CPHDReader& reader1, } break; case cphd::SampleType::RE32F_IM32F: - if (!compareCPHDData >( + if (!compareCPHDData( cphdData1.get(), cphdData2.get(), dims1.area(), diff --git a/six/modules/c++/cphd/tests/test_round_trip.cpp b/six/modules/c++/cphd/tests/test_round_trip.cpp index 35f4804412..f6f43c161f 100644 --- a/six/modules/c++/cphd/tests/test_round_trip.cpp +++ b/six/modules/c++/cphd/tests/test_round_trip.cpp @@ -111,19 +111,19 @@ void testRoundTrip(const std::string& inPathname, const std::string& outPathname case cphd::SignalArrayFormat::CI2: writer.write( pvpBlock, - reinterpret_cast* >(data.get()), + reinterpret_cast(data.get()), readPtr.get()); break; case cphd::SignalArrayFormat::CI4: writer.write( pvpBlock, - reinterpret_cast* >(data.get()), + reinterpret_cast(data.get()), readPtr.get()); break; case cphd::SignalArrayFormat::CF8: writer.write( pvpBlock, - reinterpret_cast* >(data.get()), + reinterpret_cast(data.get()), readPtr.get()); break; } diff --git a/six/modules/c++/cphd/unittests/test_pvp_block.cpp b/six/modules/c++/cphd/unittests/test_pvp_block.cpp index 3bb82cd976..ffba33abfa 100644 --- a/six/modules/c++/cphd/unittests/test_pvp_block.cpp +++ b/six/modules/c++/cphd/unittests/test_pvp_block.cpp @@ -163,7 +163,7 @@ TEST_CASE(testPvpOptional) pvpBlock.setAddedPVP(addedParam1, channel, vector, "Param1"); const std::string addedParam2 = "Parameter2"; pvpBlock.setAddedPVP(addedParam2, channel, vector, "Param2"); - const std::complex addedParam3(3,4); + const cphd::zint32_t addedParam3(3,4); pvpBlock.setAddedPVP(addedParam3, channel, vector, "Param3"); TEST_ASSERT_EQ(ampSF, pvpBlock.getAmpSF(channel, vector)); @@ -171,7 +171,7 @@ TEST_CASE(testPvpOptional) TEST_ASSERT_EQ(fxN2, pvpBlock.getFxN2(channel, vector)); TEST_ASSERT_EQ(addedParam1, pvpBlock.getAddedPVP(channel, vector, "Param1")); TEST_ASSERT_EQ(addedParam2, pvpBlock.getAddedPVP(channel, vector, "Param2")); - TEST_ASSERT_EQ(addedParam3, pvpBlock.getAddedPVP >(channel, vector, "Param3")); + TEST_ASSERT_EQ(addedParam3, pvpBlock.getAddedPVP(channel, vector, "Param3")); } } } @@ -297,7 +297,7 @@ TEST_CASE(testPvpEquality) pvpBlock1.setAddedPVP(addedParam1, channel, vector, "Param1"); pvpBlock2.setAddedPVP(addedParam1, channel, vector, "Param1"); - const std::complex addedParam2(3,4); + const cphd::zint32_t addedParam2(3,4); pvpBlock1.setAddedPVP(addedParam2, channel, vector, "Param2"); pvpBlock2.setAddedPVP(addedParam2, channel, vector, "Param2"); } diff --git a/six/modules/c++/cphd/unittests/test_pvp_block_round.cpp b/six/modules/c++/cphd/unittests/test_pvp_block_round.cpp index 0eed0ba090..026f6c3511 100644 --- a/six/modules/c++/cphd/unittests/test_pvp_block_round.cpp +++ b/six/modules/c++/cphd/unittests/test_pvp_block_round.cpp @@ -43,15 +43,15 @@ #include template -std::vector> generateComplexData(size_t length) +std::vector> generateComplexData(size_t length) { - std::vector> data(length); + std::vector> data(length); srand(0); for (size_t ii = 0; ii < data.size(); ++ii) { float real = static_cast(rand() / 100); float imag = static_cast(rand() / 100); - data[ii] = std::complex(real, imag); + data[ii] = types::complex(real, imag); } return data; } @@ -119,7 +119,7 @@ template void writeCPHD(const std::string& outPathname, size_t numThreads, const types::RowCol dims, - const std::vector>& writeData, + const std::vector>& writeData, cphd::Metadata& metadata, cphd::PVPBlock& pvpBlock) { @@ -157,7 +157,7 @@ bool checkData(const std::string& pathname, template bool runTest(bool /*scale*/, - const std::vector>& writeData, + const std::vector>& writeData, cphd::Metadata& meta, cphd::PVPBlock& pvpBlock, const types::RowCol dims) @@ -171,7 +171,7 @@ bool runTest(bool /*scale*/, TEST_CASE(testPVPBlockSimple) { const types::RowCol dims(128, 256); - const std::vector> writeData = + const std::vector writeData = generateComplexData(dims.area()); const bool scale = false; cphd::Metadata meta = cphd::Metadata(); @@ -195,7 +195,7 @@ TEST_CASE(testPVPBlockSimple) TEST_CASE(testPVPBlockOptional) { const types::RowCol dims(128, 256); - const std::vector> writeData = + const std::vector writeData = generateComplexData(dims.area()); const bool scale = false; cphd::Metadata meta = cphd::Metadata(); @@ -222,7 +222,7 @@ TEST_CASE(testPVPBlockOptional) TEST_CASE(testPVPBlockAdditional) { const types::RowCol dims(128, 256); - const std::vector> writeData = + const std::vector writeData = generateComplexData(dims.area()); const bool scale = false; cphd::Metadata meta = cphd::Metadata(); diff --git a/six/modules/c++/cphd/unittests/test_signal_block_round.cpp b/six/modules/c++/cphd/unittests/test_signal_block_round.cpp index fb55dcd37d..5eaeb9fd70 100644 --- a/six/modules/c++/cphd/unittests/test_signal_block_round.cpp +++ b/six/modules/c++/cphd/unittests/test_signal_block_round.cpp @@ -47,15 +47,15 @@ */ template -std::vector > generateData(size_t length) +std::vector > generateData(size_t length) { - std::vector > data(length); + std::vector > data(length); srand(0); for (size_t ii = 0; ii < data.size(); ++ii) { auto real = static_cast(rand() / 100); auto imag = static_cast(rand() / 100); - data[ii] = std::complex(real, imag); + data[ii] = types::complex(real, imag); } return data; } @@ -76,7 +76,7 @@ inline std::vector generateScaleFactors(size_t length, bool scale) template void writeCPHD(const std::string& outPathname, size_t /*numThreads*/, const types::RowCol dims, - const std::vector >& writeData, + const std::vector >& writeData, cphd::Metadata& metadata, cphd::PVPBlock& pvpBlock) { @@ -100,19 +100,19 @@ void writeCPHD(const std::string& outPathname, size_t /*numThreads*/, } } -std::vector > checkData(const std::string& pathname, +std::vector checkData(const std::string& pathname, size_t numThreads, const std::vector& scaleFactors, const types::RowCol dims) { cphd::CPHDReader reader(pathname, numThreads); const cphd::Wideband& wideband = reader.getWideband(); - std::vector > readData(dims.area()); + std::vector readData(dims.area()); size_t sizeInBytes = readData.size() * sizeof(readData[0]); std::vector scratchData(sizeInBytes); std::span scratch(scratchData.data(), scratchData.size()); - std::span> data(readData.data(), readData.size()); + std::span data(readData.data(), readData.size()); wideband.read(0, 0, cphd::Wideband::ALL, 0, cphd::Wideband::ALL, scaleFactors, numThreads, scratch, data); @@ -121,15 +121,15 @@ std::vector > checkData(const std::string& pathname, } template -bool compareVectors(const std::vector >& readData, - const std::vector >& writeData, +bool compareVectors(const std::vector& readData, + const std::vector >& writeData, const std::vector& scaleFactors, bool scale) { size_t pointsPerScale = readData.size() / scaleFactors.size(); for (size_t ii = 0; ii < readData.size(); ++ii) { - std::complex val(writeData[ii].real(), writeData[ii].imag()); + cphd::zfloat val(writeData[ii].real(), writeData[ii].imag()); if (scale) { val *= scaleFactors[ii / pointsPerScale]; @@ -145,7 +145,7 @@ bool compareVectors(const std::vector >& readData, } template -bool runTest(bool scale, const std::vector >& writeData) +bool runTest(bool scale, const std::vector >& writeData) { io::TempFile tempfile; const size_t numThreads = std::thread::hardware_concurrency(); @@ -158,7 +158,7 @@ bool runTest(bool scale, const std::vector >& writeData) cphd::PVPBlock pvpBlock(meta.pvp, meta.data); writeCPHD(tempfile.pathname(), numThreads, dims, writeData, meta, pvpBlock); - const std::vector > readData = + const std::vector readData = checkData(tempfile.pathname(), numThreads, scaleFactors, dims); return compareVectors(readData, writeData, scaleFactors, scale); @@ -168,7 +168,7 @@ bool runTest(bool scale, const std::vector >& writeData) TEST_CASE(testUnscaledInt8) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT_TRUE(runTest(scale, writeData)); @@ -177,7 +177,7 @@ TEST_CASE(testUnscaledInt8) TEST_CASE(testScaledInt8) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT_TRUE(runTest(scale, writeData)); @@ -186,7 +186,7 @@ TEST_CASE(testScaledInt8) TEST_CASE(testUnscaledInt16) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT_TRUE(runTest(scale, writeData)); @@ -195,7 +195,7 @@ TEST_CASE(testUnscaledInt16) TEST_CASE(testScaledInt16) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT_TRUE(runTest(scale, writeData)); @@ -204,7 +204,7 @@ TEST_CASE(testScaledInt16) TEST_CASE(testUnscaledFloat) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT_TRUE(runTest(scale, writeData)); @@ -213,7 +213,7 @@ TEST_CASE(testUnscaledFloat) TEST_CASE(testScaledFloat) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT_TRUE(runTest(scale, writeData)); diff --git a/six/modules/c++/cphd/unittests/test_support_block_round.cpp b/six/modules/c++/cphd/unittests/test_support_block_round.cpp index 483d9d21c2..8dd52bbd82 100644 --- a/six/modules/c++/cphd/unittests/test_support_block_round.cpp +++ b/six/modules/c++/cphd/unittests/test_support_block_round.cpp @@ -135,7 +135,7 @@ bool runTest(const std::vector& writeData) io::TempFile tempfile; const size_t numThreads = 1; cphd::Metadata meta = cphd::Metadata(); - cphd::setUpData(meta, types::RowCol(128,256), std::vector >()); + cphd::setUpData(meta, types::RowCol(128,256), std::vector()); setSupport(meta.data); cphd::setPVPXML(meta.pvp); cphd::PVPBlock pvpBlock(meta.pvp, meta.data); diff --git a/six/modules/c++/cphd03/include/cphd03/CPHDWriter.h b/six/modules/c++/cphd03/include/cphd03/CPHDWriter.h index e02924c28b..9bbc9ec07a 100644 --- a/six/modules/c++/cphd03/include/cphd03/CPHDWriter.h +++ b/six/modules/c++/cphd03/include/cphd03/CPHDWriter.h @@ -101,9 +101,9 @@ struct CPHDWriter final * \func addImage * \brief Pushes a new image to the file for writing. This only works with * valid CPHDWriter data types: - * std::complex - * std::complex - * std::complex + * cphd::zfloat + * cphd::zint16_t + * cphd::zint8_t * * \param image The image to be added. This should be sized to match the * dims parameter. @@ -147,9 +147,9 @@ struct CPHDWriter final * method. If you do not need to write the data in chunks, * you may instead use addImage and write. This only works with * valid CPHDWriter data types: - * std::complex - * std::complex - * std::complex + * cphd::zfloat + * cphd::zint16_t + * cphd::zint8_t * * \param data The data to write to disk. * \param numElements The number of elements in data. Treat the data diff --git a/six/modules/c++/cphd03/source/CPHDWriter.cpp b/six/modules/c++/cphd03/source/CPHDWriter.cpp index 91d5d93537..564ed5dfc0 100644 --- a/six/modules/c++/cphd03/source/CPHDWriter.cpp +++ b/six/modules/c++/cphd03/source/CPHDWriter.cpp @@ -90,38 +90,38 @@ void CPHDWriter::addImage(const T* image, } template -void CPHDWriter::addImage >( - const std::complex* image, +void CPHDWriter::addImage( + const cphd::zint8_t* image, const types::RowCol& dims, const sys::ubyte* vbmData); template -void CPHDWriter::addImage >( - const std::complex* image, +void CPHDWriter::addImage( + const cphd::zint16_t* image, const types::RowCol& dims, const sys::ubyte* vbmData); template -void CPHDWriter::addImage >( - const std::complex* image, +void CPHDWriter::addImage( + const cphd::zfloat* image, const types::RowCol& dims, const sys::ubyte* vbmData); template -void CPHDWriter::addImage >( - const std::complex* image, +void CPHDWriter::addImage( + const cphd::zint8_t* image, const types::RowCol& dims, const std::byte* vbmData); template -void CPHDWriter::addImage >( - const std::complex* image, +void CPHDWriter::addImage( + const cphd::zint16_t* image, const types::RowCol& dims, const std::byte* vbmData); template -void CPHDWriter::addImage >( - const std::complex* image, +void CPHDWriter::addImage( + const cphd::zfloat* image, const types::RowCol& dims, const std::byte* vbmData); @@ -219,18 +219,18 @@ void CPHDWriter::writeCPHDData(const T* data, } template -void CPHDWriter::writeCPHDData >( - const std::complex* data, +void CPHDWriter::writeCPHDData( + const cphd::zint8_t* data, size_t numElements); template -void CPHDWriter::writeCPHDData >( - const std::complex* data, +void CPHDWriter::writeCPHDData( + const cphd::zint16_t* data, size_t numElements); template -void CPHDWriter::writeCPHDData >( - const std::complex* data, +void CPHDWriter::writeCPHDData( + const cphd::zfloat* data, size_t numElements); void CPHDWriter::write(const std::string& classification, diff --git a/six/modules/c++/cphd03/tests/test_cphd_compare.cpp b/six/modules/c++/cphd03/tests/test_cphd_compare.cpp index 786236e757..c4e965c533 100644 --- a/six/modules/c++/cphd03/tests/test_cphd_compare.cpp +++ b/six/modules/c++/cphd03/tests/test_cphd_compare.cpp @@ -92,7 +92,7 @@ bool compareWideband(cphd03::CPHDReader& reader1, switch (reader1.getMetadata().getSampleType()) { case cphd::SampleType::RE08I_IM08I: - if (!compareCPHDData >( + if (!compareCPHDData( cphd03Data1.get(), cphd03Data2.get(), dims1.area(), @@ -102,7 +102,7 @@ bool compareWideband(cphd03::CPHDReader& reader1, } break; case cphd::SampleType::RE16I_IM16I: - if (!compareCPHDData >( + if (!compareCPHDData( cphd03Data1.get(), cphd03Data2.get(), dims1.area(), @@ -112,7 +112,7 @@ bool compareWideband(cphd03::CPHDReader& reader1, } break; case cphd::SampleType::RE32F_IM32F: - if (!compareCPHDData >( + if (!compareCPHDData( cphd03Data1.get(), cphd03Data2.get(), dims1.area(), diff --git a/six/modules/c++/cphd03/tests/test_cphd_round_trip.cpp b/six/modules/c++/cphd03/tests/test_cphd_round_trip.cpp index 527bb6b584..45e04f4f8c 100644 --- a/six/modules/c++/cphd03/tests/test_cphd_round_trip.cpp +++ b/six/modules/c++/cphd03/tests/test_cphd_round_trip.cpp @@ -81,18 +81,18 @@ int main(int argc, char** argv) switch (sampleType) { case cphd::SampleType::RE08I_IM08I: - writer.writeCPHDData >( - reinterpret_cast* >(data.get()), + writer.writeCPHDData( + reinterpret_cast(data.get()), dims.area()); break; case cphd::SampleType::RE16I_IM16I: - writer.writeCPHDData >( - reinterpret_cast* >(data.get()), + writer.writeCPHDData( + reinterpret_cast(data.get()), dims.area()); break; case cphd::SampleType::RE32F_IM32F: - writer.writeCPHDData >( - reinterpret_cast* >(data.get()), + writer.writeCPHDData( + reinterpret_cast(data.get()), dims.area()); break; } diff --git a/six/modules/c++/cphd03/tests/test_cphd_write_simple.cpp b/six/modules/c++/cphd03/tests/test_cphd_write_simple.cpp index 3c3d436cc3..b363f3ad1b 100644 --- a/six/modules/c++/cphd03/tests/test_cphd_write_simple.cpp +++ b/six/modules/c++/cphd03/tests/test_cphd_write_simple.cpp @@ -76,8 +76,8 @@ int main(int argc, char** argv) const std::string outPathname(options->get("output")); const size_t numThreads(options->get("threads")); - const std::vector > data( - dims.area(), std::complex(0.0f, 0.0f)); + const std::vector data( + dims.area(), cphd::zfloat(0.0f, 0.0f)); cphd03::Metadata metadata; diff --git a/six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp b/six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp index eace4e4f4f..704517da68 100644 --- a/six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp +++ b/six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp @@ -38,15 +38,15 @@ #include "TestCase.h" template -std::vector > generateData(size_t length) +std::vector > generateData(size_t length) { - std::vector > data(length); + std::vector > data(length); srand(0); for (size_t ii = 0; ii < data.size(); ++ii) { float real = static_cast(rand() / 100); float imag = static_cast(rand() / 100); - data[ii] = std::complex(real, imag); + data[ii] = types::complex(real, imag); } return data; } @@ -87,7 +87,7 @@ inline cphd::SampleType getSampleType(size_t writeDataSize) template void writeCPHD(const std::string& outPathname, size_t numThreads, const types::RowCol dims, - const std::vector >& writeData) + const std::vector >& writeData) { const size_t numChannels = 1; const std::vector numVectors(numChannels, dims.row); @@ -143,7 +143,7 @@ void writeCPHD(const std::string& outPathname, size_t numThreads, writer.close(); } -std::vector > checkData(const std::string& pathname, +std::vector checkData(const std::string& pathname, size_t numThreads, const std::vector& scaleFactors, bool /*scale*/, @@ -151,12 +151,12 @@ std::vector > checkData(const std::string& pathname, { cphd03::CPHDReader reader(pathname, numThreads); cphd::Wideband& wideband = reader.getWideband(); - std::vector > readData(dims.area()); + std::vector readData(dims.area()); size_t sizeInBytes = readData.size() * sizeof(readData[0]); std::vector scratchData(sizeInBytes); std::span scratch(scratchData.data(), scratchData.size()); - std::span> data(readData.data(), readData.size()); + std::span data(readData.data(), readData.size()); wideband.read(0, 0, cphd::Wideband::ALL, 0, cphd::Wideband::ALL, scaleFactors, numThreads, scratch, data); @@ -165,15 +165,15 @@ std::vector > checkData(const std::string& pathname, } template -bool compareVectors(const std::vector >& readData, - const std::vector >& writeData, +bool compareVectors(const std::vector& readData, + const std::vector >& writeData, const std::vector& scaleFactors, bool scale) { size_t pointsPerScale = readData.size() / scaleFactors.size(); for (size_t ii = 0; ii < readData.size(); ++ii) { - std::complex val(writeData[ii].real(), writeData[ii].imag()); + cphd::zfloat val(writeData[ii].real(), writeData[ii].imag()); if (scale) { val *= scaleFactors[ii / pointsPerScale]; @@ -189,7 +189,7 @@ bool compareVectors(const std::vector >& readData, } template -bool runTest(bool scale, const std::vector >& writeData) +bool runTest(bool scale, const std::vector >& writeData) { io::TempFile tempfile; const size_t numThreads = std::thread::hardware_concurrency(); @@ -197,7 +197,7 @@ bool runTest(bool scale, const std::vector >& writeData) const std::vector scaleFactors = generateScaleFactors(dims.row, scale); writeCPHD(tempfile.pathname(), numThreads, dims, writeData); - const std::vector > readData = + const std::vector readData = checkData(tempfile.pathname(), numThreads, scaleFactors, scale, dims); return compareVectors(readData, writeData, scaleFactors, scale); @@ -206,7 +206,7 @@ bool runTest(bool scale, const std::vector >& writeData) TEST_CASE(testUnscaledInt8) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT(runTest(scale, writeData)); @@ -215,7 +215,7 @@ TEST_CASE(testUnscaledInt8) TEST_CASE(testScaledInt8) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT(runTest(scale, writeData)); @@ -223,7 +223,7 @@ TEST_CASE(testScaledInt8) TEST_CASE(testUnscaledInt16) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT(runTest(scale, writeData)); @@ -232,7 +232,7 @@ TEST_CASE(testUnscaledInt16) TEST_CASE(testScaledInt16) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT(runTest(scale, writeData)); @@ -241,7 +241,7 @@ TEST_CASE(testScaledInt16) TEST_CASE(testUnscaledFloat) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = false; TEST_ASSERT(runTest(scale, writeData)); @@ -250,7 +250,7 @@ TEST_CASE(testUnscaledFloat) TEST_CASE(testScaledFloat) { const types::RowCol dims(128, 128); - const std::vector > writeData = + const std::vector writeData = generateData(dims.area()); const bool scale = true; TEST_ASSERT(runTest(scale, writeData)); diff --git a/six/modules/c++/cphd03/unittests/test_cphd_write.cpp b/six/modules/c++/cphd03/unittests/test_cphd_write.cpp index 3a253997d8..01089a30af 100644 --- a/six/modules/c++/cphd03/unittests/test_cphd_write.cpp +++ b/six/modules/c++/cphd03/unittests/test_cphd_write.cpp @@ -332,7 +332,7 @@ void addTwoWayParams(cphd03::Metadata& metadata) void writeCPHD( cphd03::VBM& vbm, cphd03::Metadata& metadata, - std::vector > >& data, + std::vector >& data, std::vector >& dims) { cphd03::CPHDWriter writer(metadata, FILE_NAME, NUM_THREADS); @@ -348,7 +348,7 @@ void writeCPHD( data[ii].resize(dims[ii].area()); for (size_t jj = 0; jj < data[ii].size(); ++jj) { - data[ii][jj] = std::complex( + data[ii][jj] = cphd::zfloat( getRandomReal(), getRandomReal()); } @@ -402,7 +402,7 @@ void runCPHDTest(const std::string& testName_, } //std::vector >vbm(NUM_IMAGES); - std::vector > >data(NUM_IMAGES); + std::vector >data(NUM_IMAGES); std::vector > dims(NUM_IMAGES); writeCPHD(vbm, metadata, data, dims); @@ -424,8 +424,8 @@ void runCPHDTest(const std::string& testName_, 0, cphd::Wideband::ALL, NUM_THREADS); - const std::complex* readBuffer = - reinterpret_cast* >(readData.get()); + const cphd::zfloat* readBuffer = + reinterpret_cast(readData.get()); for (size_t jj = 0; jj < dims[ii].area(); ++jj) { diff --git a/six/modules/c++/cpp_pch.h b/six/modules/c++/cpp_pch.h index 7040596567..2d32878ef6 100644 --- a/six/modules/c++/cpp_pch.h +++ b/six/modules/c++/cpp_pch.h @@ -15,9 +15,6 @@ #pragma warning(disable: 4619) // #pragma warning: there is no warning number '...' #pragma warning(disable: 5264) // '...': '...' variable is not used -// error 4996: '...': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. -#define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING - #define _USE_MATH_DEFINES #include #include @@ -45,11 +42,11 @@ #include #include #include -#include - #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #define NOMINMAX #include +#include + #pragma warning(pop) \ No newline at end of file diff --git a/six/modules/c++/samples/project_slant_to_output.cpp b/six/modules/c++/samples/project_slant_to_output.cpp index 013821139f..ebfb39a97b 100644 --- a/six/modules/c++/samples/project_slant_to_output.cpp +++ b/six/modules/c++/samples/project_slant_to_output.cpp @@ -103,7 +103,7 @@ int main(int argc, char** argv) registry.addCreator(); std::unique_ptr complexData; - std::vector > buffer; + std::vector buffer; six::sicd::Utilities::readSicd(sicdPathname, schemaPaths, complexData, buffer); diff --git a/six/modules/c++/samples/round_trip_six.cpp b/six/modules/c++/samples/round_trip_six.cpp index 1945826b2f..c28844a373 100644 --- a/six/modules/c++/samples/round_trip_six.cpp +++ b/six/modules/c++/samples/round_trip_six.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -95,16 +96,16 @@ struct Buffers final // We'll expand to complex starting in the first half of the buffer void expandComplex(size_t numPixels, std::byte* buffer) { - const std::complex* const input = - reinterpret_cast*>( - buffer + numPixels * sizeof(std::complex)); + const types::zint16_t* const input = + reinterpret_cast( + buffer + numPixels * sizeof(types::zint16_t)); - std::complex* const output = - reinterpret_cast*>(buffer); + six::zfloat* const output = + reinterpret_cast(buffer); for (size_t ii = 0; ii < numPixels; ++ii) { - output[ii] = std::complex(input[ii].real(), input[ii].imag()); + output[ii] = six::zfloat(input[ii].real(), input[ii].imag()); } } @@ -118,7 +119,7 @@ void expandComplex(size_t numPixels, std::byte* buffer) // [-32K, 32K]. void compressInteger(size_t numPixels, std::byte* buffer) { - const float* const floatValues = reinterpret_cast(buffer); + auto const floatValues = reinterpret_cast(buffer); // Find the min and max values of either real or imag float min = floatValues[0]; @@ -135,11 +136,8 @@ void compressInteger(size_t numPixels, std::byte* buffer) } } - const std::complex* const input = - reinterpret_cast*>(buffer); - - std::complex* const output = - reinterpret_cast*>(buffer); + auto const input = reinterpret_cast(buffer); + auto const output = reinterpret_cast(buffer); const float diff = max - min; // If diff ends up being zero, we will get a division by 0 error. @@ -147,14 +145,14 @@ void compressInteger(size_t numPixels, std::byte* buffer) // fill it with 0s. if (diff == 0.0f) { - std::fill_n(output, numPixels, std::complex(0, 0)); + std::fill_n(output, numPixels, types::zint16_t(0, 0)); return; } const CompressFloat compressFloat(min, diff); for (size_t ii = 0; ii < numPixels; ++ii) { - output[ii] = std::complex( + output[ii] = types::zint16_t( compressFloat(input[ii].real()), compressFloat(input[ii].imag())); } diff --git a/six/modules/c++/samples/sicd_output_plane_pixel_to_lat_lon.cpp b/six/modules/c++/samples/sicd_output_plane_pixel_to_lat_lon.cpp index 4ee7c87436..2808ca16ea 100644 --- a/six/modules/c++/samples/sicd_output_plane_pixel_to_lat_lon.cpp +++ b/six/modules/c++/samples/sicd_output_plane_pixel_to_lat_lon.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) std::unique_ptr complexData; - std::vector > widebandData; + std::vector widebandData; six::sicd::Utilities::readSicd(sicdPathname, schemaPaths, complexData, widebandData); diff --git a/six/modules/c++/samples/test_create_sicd.cpp b/six/modules/c++/samples/test_create_sicd.cpp index 7a2c4552f3..3f7f416719 100644 --- a/six/modules/c++/samples/test_create_sicd.cpp +++ b/six/modules/c++/samples/test_create_sicd.cpp @@ -137,7 +137,7 @@ int main(int argc, char** argv) != sio::lite::FileHeader::COMPLEX_FLOAT) throw except::Exception(Ctxt("Expected a complex float SIO image!")); - // And that its std::complex-able + // And that its six::zfloat-able if (fileHeader->getElementSize() != 8) throw except::Exception( Ctxt( diff --git a/six/modules/c++/samples/test_create_sicd_from_mem.cpp b/six/modules/c++/samples/test_create_sicd_from_mem.cpp index 42fc0ccf41..f4c2dc6b29 100644 --- a/six/modules/c++/samples/test_create_sicd_from_mem.cpp +++ b/six/modules/c++/samples/test_create_sicd_from_mem.cpp @@ -76,7 +76,7 @@ int main(int argc, char** argv) six::XMLControlFactory::getInstance().addCreator(); - std::vector > image(dims.row * dims.col); + std::vector image(dims.row * dims.col); std::unique_ptr data( six::sicd::Utilities::createFakeComplexData().release()); diff --git a/six/modules/c++/samples/test_dump_images.cpp b/six/modules/c++/samples/test_dump_images.cpp index 0575413ac1..8b279e4b72 100644 --- a/six/modules/c++/samples/test_dump_images.cpp +++ b/six/modules/c++/samples/test_dump_images.cpp @@ -21,16 +21,17 @@ */ #include #include - #include -#include - +#include #include #include #include #include #include + +#include + #include "utils.h" namespace fs = std::filesystem; @@ -48,11 +49,11 @@ void writeSIOFileHeader(size_t numRows, switch (pixelType) { case six::PixelType::RE32F_IM32F: - elementSize = sizeof(std::complex); + elementSize = sizeof(six::zfloat); elementType = sio::lite::FileHeader::COMPLEX_FLOAT; break; case six::PixelType::RE16I_IM16I: - elementSize = sizeof(std::complex); + elementSize = sizeof(types::zint16_t); elementType = sio::lite::FileHeader::COMPLEX_SIGNED; break; case six::PixelType::MONO8I: diff --git a/six/modules/c++/samples/test_large_offset.cpp b/six/modules/c++/samples/test_large_offset.cpp index 92a86113e5..37f3425d5a 100644 --- a/six/modules/c++/samples/test_large_offset.cpp +++ b/six/modules/c++/samples/test_large_offset.cpp @@ -87,12 +87,12 @@ void createNITF(const std::string& outputPathname, std::unique_ptr imageData(new std::byte[imageSize]); if (container->getDataType() == six::DataType::COMPLEX) { - std::complex* complexData = - reinterpret_cast* >(imageData.get()); + six::zfloat* complexData = + reinterpret_cast(imageData.get()); for (size_t ii = 0; ii < elementsInImage; ++ii) { - complexData[ii] = std::complex( + complexData[ii] = six::zfloat( static_cast(ii), static_cast(ii) * -1); } @@ -133,10 +133,10 @@ bool checkNITF(const std::string& pathname) if (data->getDataType() == six::DataType::COMPLEX) { - auto complexBuffer = reinterpret_cast* >(buffer); + auto complexBuffer = reinterpret_cast(buffer); for (size_t ii = skipSize; ii < imageSize; ++ii) { - const std::complex currentElement = + const six::zfloat currentElement = complexBuffer[ii - skipSize]; if (currentElement.real() != static_cast(ii)) { diff --git a/six/modules/c++/samples/update_sicd_version.cpp b/six/modules/c++/samples/update_sicd_version.cpp index 36dc87548b..536f8bec46 100644 --- a/six/modules/c++/samples/update_sicd_version.cpp +++ b/six/modules/c++/samples/update_sicd_version.cpp @@ -37,7 +37,7 @@ namespace { void writeSicd(std::unique_ptr&& complexData, - const std::vector>& widebandData, + const std::vector& widebandData, const std::vector& schemaPaths_, const std::string& pathname) { @@ -87,7 +87,7 @@ int main(int argc, char **argv) } std::unique_ptr complexData; - std::vector> widebandData; + std::vector widebandData; six::sicd::Utilities::readSicd(pathname, schemaPaths, complexData, widebandData); diff --git a/six/modules/c++/samples/update_sidd_version.cpp b/six/modules/c++/samples/update_sidd_version.cpp index 51091f7793..9e2263c1c0 100644 --- a/six/modules/c++/samples/update_sidd_version.cpp +++ b/six/modules/c++/samples/update_sidd_version.cpp @@ -70,9 +70,9 @@ void writeSidd(std::unique_ptr&& derivedData, six::NITFWriteControl writer(container); const void* pWidebandData_ = widebandData_.data(); - auto pWidebandData = static_cast*>(pWidebandData_); - auto size = widebandData_.size() / sizeof(std::complex); - const std::span> widebandData(pWidebandData, size); + auto pWidebandData = static_cast(pWidebandData_); + auto size = widebandData_.size() / sizeof(six::zfloat); + const std::span widebandData(pWidebandData, size); std::vector schemaPaths; std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), [](const std::string& s) { return s; }); writer.save_image(widebandData, pathname, schemaPaths); diff --git a/six/modules/c++/scene/include/scene/Types.h b/six/modules/c++/scene/include/scene/Types.h index 44d7956d81..4cd92ce227 100644 --- a/six/modules/c++/scene/include/scene/Types.h +++ b/six/modules/c++/scene/include/scene/Types.h @@ -19,21 +19,29 @@ * see . * */ -#ifndef __SCENE_COORDINATE_TYPES_H__ -#define __SCENE_COORDINATE_TYPES_H__ +#pragma once +#ifndef SIX_scene_Types_h_INCLUDED_ +#define SIX_scene_Types_h_INCLUDED_ #include -#include "scene/sys_Conf.h" +#include #include #include #include #include #include - #include "math/linear/MatrixMxN.h" #include "math/linear/VectorN.h" +#include "scene/sys_Conf.h" + +namespace scene +{ + using zfloat = types::zfloat; + using zdouble = types::zdouble; +} + namespace scene { typedef math::linear::VectorN<2> Vector2; @@ -251,5 +259,4 @@ template<> template<> std::string toString(const scene::SideOfTrack& value); } -#endif - +#endif // SIX_scene_Types_h_INCLUDED_ diff --git a/six/modules/c++/six.sicd/include/six/sicd/ComplexData.h b/six/modules/c++/six.sicd/include/six/sicd/ComplexData.h index b55a7d150b..48565a4af8 100644 --- a/six/modules/c++/six.sicd/include/six/sicd/ComplexData.h +++ b/six/modules/c++/six.sicd/include/six/sicd/ComplexData.h @@ -400,7 +400,7 @@ struct ComplexData: public Data struct ComplexImageResult final { std::unique_ptr pComplexData; - std::vector> widebandData; + std::vector widebandData; ComplexImageResult() = default; ComplexImageResult(const ComplexImageResult&) = delete; ComplexImageResult& operator=(const ComplexImageResult&) = delete; @@ -410,10 +410,10 @@ struct ComplexImageResult final struct ComplexImage final { const ComplexData& data; - std::span> image; - ComplexImage(const ComplexData& d, std::span> i) : data(d), image(i) {} + std::span image; + ComplexImage(const ComplexData& d, std::span i) : data(d), image(i) {} ComplexImage(const ComplexImageResult& r) - : ComplexImage(*(r.pComplexData), std::span>(r.widebandData.data(), r.widebandData.size())) {} + : ComplexImage(*(r.pComplexData), std::span(r.widebandData.data(), r.widebandData.size())) {} ComplexImage(const ComplexImage&) = delete; ComplexImage& operator=(const ComplexImage&) = delete; }; diff --git a/six/modules/c++/six.sicd/include/six/sicd/ImageData.h b/six/modules/c++/six.sicd/include/six/sicd/ImageData.h index 36e0093949..f2e50a1bda 100644 --- a/six/modules/c++/six.sicd/include/six/sicd/ImageData.h +++ b/six/modules/c++/six.sicd/include/six/sicd/ImageData.h @@ -31,6 +31,8 @@ #include #include "logging/Logger.h" +#include "types/complex.h" + #include "six/Types.h" #include "six/Init.h" #include "six/Parameter.h" @@ -39,7 +41,7 @@ namespace six { namespace sicd { -using cx_float = std::complex; +using cx_float = six::zfloat; class GeoData; /*! diff --git a/six/modules/c++/six.sicd/include/six/sicd/ImageFormation.h b/six/modules/c++/six.sicd/include/six/sicd/ImageFormation.h index e160154a11..fba14193f9 100644 --- a/six/modules/c++/six.sicd/include/six/sicd/ImageFormation.h +++ b/six/modules/c++/six.sicd/include/six/sicd/ImageFormation.h @@ -110,22 +110,22 @@ struct Distortion double a; //! Recv distortion element (2,2) - std::complex f1; + six::zdouble f1; //! Recv distortion element (1,2) - std::complex q1; + six::zdouble q1; //! Recv distortion element (2,1) - std::complex q2; + six::zdouble q2; //! Transmit distortion element (2,2) - std::complex f2; + six::zdouble f2; //! Transmit distortion element (2,1) - std::complex q3; + six::zdouble q3; //! Transmit distortion element (1,2) - std::complex q4; + six::zdouble q4; /*! * (Optional) Gain estimation error standard deviation (in dB) for diff --git a/six/modules/c++/six.sicd/include/six/sicd/NITFReadComplexXMLControl.h b/six/modules/c++/six.sicd/include/six/sicd/NITFReadComplexXMLControl.h index 011d78ce88..97f8ee03fc 100644 --- a/six/modules/c++/six.sicd/include/six/sicd/NITFReadComplexXMLControl.h +++ b/six/modules/c++/six.sicd/include/six/sicd/NITFReadComplexXMLControl.h @@ -89,9 +89,9 @@ namespace six std::unique_ptr getComplexData(); - std::vector> getWidebandData(const ComplexData&); + std::vector getWidebandData(const ComplexData&); void getWidebandData(const ComplexData&, const types::RowCol& offset, const types::RowCol& extent, - std::complex* buffer); + six::zfloat* buffer); void getMeshes(std::unique_ptr&, std::unique_ptr&) const; diff --git a/six/modules/c++/six.sicd/include/six/sicd/Utilities.h b/six/modules/c++/six.sicd/include/six/sicd/Utilities.h index 241866e8f6..7be19acdba 100644 --- a/six/modules/c++/six.sicd/include/six/sicd/Utilities.h +++ b/six/modules/c++/six.sicd/include/six/sicd/Utilities.h @@ -115,11 +115,11 @@ struct Utilities final static void readSicd(const std::string& sicdPathname, const std::vector& schemaPaths, std::unique_ptr& complexData, - std::vector>& widebandData); + std::vector& widebandData); static void readSicd(const std::filesystem::path& sicdPathname, const std::vector& schemaPaths, std::unique_ptr& complexData, - std::vector>& widebandData); + std::vector& widebandData); static ComplexImageResult readSicd(const std::filesystem::path&, const std::vector& schemaPaths); static ComplexImageResult readSicd(const std::filesystem::path& path) { @@ -162,7 +162,7 @@ struct Utilities final size_t orderX, size_t orderY, std::unique_ptr& complexData, - std::vector >& widebandData, + std::vector& widebandData, six::Poly2D& outputRowColToSlantRow, six::Poly2D& outputRowColToSlantCol, std::unique_ptr& noiseMesh, @@ -216,7 +216,7 @@ struct Utilities final */ static void getWidebandData(NITFReadControl& reader, const ComplexData& complexData, - std::complex* buffer); + six::zfloat* buffer); /* * Given a loaded NITFReadControl and a ComplexData object, this @@ -240,7 +240,7 @@ struct Utilities final const ComplexData& complexData, const types::RowCol& offset, const types::RowCol& extent, - std::complex* buffer); + six::zfloat* buffer); /* * Given a loaded NITFReadControl and a ComplexData object, this @@ -259,7 +259,7 @@ struct Utilities final */ static void getWidebandData(NITFReadControl& reader, const ComplexData& complexData, - std::vector >& buffer); + std::vector& buffer); /* * Given a loaded NITFReadControl, a ComplexData object, and an @@ -282,7 +282,7 @@ struct Utilities final const ComplexData& complexData, const types::RowCol& offset, const types::RowCol& extent, - std::vector >& buffer); + std::vector& buffer); template static void getRawData(NITFReadControl& reader, const ComplexData& complexData, @@ -309,7 +309,7 @@ struct Utilities final const std::string& sicdPathname, const std::vector& schemaPaths, const ComplexData& complexData, - std::complex* buffer); + six::zfloat* buffer); /* * Given a SICD pathname, list of schemas, complexData, and a region of interest, @@ -335,7 +335,7 @@ struct Utilities final const ComplexData& complexData, const types::RowCol& offset, const types::RowCol& extent, - std::complex* buffer); + six::zfloat* buffer); /* * Return the unit vector normal to the ground plane. @@ -655,14 +655,14 @@ inline std::vector readFromNITF(const std::filesystem::path& pathname } // c.f. six_sicd.i -extern void writeAsNITF(const std::filesystem::path&, const std::vector& schemaPaths, const ComplexData&, std::span> image); -extern void writeAsNITF(const std::filesystem::path&, const std::vector& schemaPaths, const ComplexData&, std::span> image); +extern void writeAsNITF(const std::filesystem::path&, const std::vector& schemaPaths, const ComplexData&, std::span image); +extern void writeAsNITF(const std::filesystem::path&, const std::vector& schemaPaths, const ComplexData&, std::span image); extern void writeAsNITF(const std::filesystem::path&, const std::vector& schemaPaths, const ComplexImage&); namespace testing { - extern std::vector> make_complex_image(const types::RowCol&); + extern std::vector make_complex_image(const types::RowCol&); extern std::vector toBytes(const ComplexImageResult&); } diff --git a/six/modules/c++/six.sicd/source/ComplexToAMP8IPHS8I.cpp b/six/modules/c++/six.sicd/source/ComplexToAMP8IPHS8I.cpp index 29211eb5bc..a6bb542ce6 100644 --- a/six/modules/c++/six.sicd/source/ComplexToAMP8IPHS8I.cpp +++ b/six/modules/c++/six.sicd/source/ComplexToAMP8IPHS8I.cpp @@ -159,7 +159,7 @@ static inline uint8_t nearest(const std::vector& magnitudes, long d return gsl::narrow(distance); } -six::AMP8I_PHS8I_t six::sicd::details::ComplexToAMP8IPHS8I::nearest_neighbor(const std::complex &v) const +six::AMP8I_PHS8I_t six::sicd::details::ComplexToAMP8IPHS8I::nearest_neighbor(const six::zfloat &v) const { six::AMP8I_PHS8I_t retval; diff --git a/six/modules/c++/six.sicd/source/CropUtils.cpp b/six/modules/c++/six.sicd/source/CropUtils.cpp index f59c127cb2..64b25cd5c6 100644 --- a/six/modules/c++/six.sicd/source/CropUtils.cpp +++ b/six/modules/c++/six.sicd/source/CropUtils.cpp @@ -125,7 +125,7 @@ void cropSICD(six::NITFReadControl& reader, // Write the AOI SICD out six::NITFWriteControl writer(std::move(aoiData)); - const std::span> image(buffer.get(), origDims.area()); + const std::span image(buffer.get(), origDims.area()); std::vector schemaPaths; std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), [](const std::string& s) { return s; }); writer.save_image(image, outPathname, schemaPaths); diff --git a/six/modules/c++/six.sicd/source/ImageData.cpp b/six/modules/c++/six.sicd/source/ImageData.cpp index c92ef781fe..e61fe4430f 100644 --- a/six/modules/c++/six.sicd/source/ImageData.cpp +++ b/six/modules/c++/six.sicd/source/ImageData.cpp @@ -235,7 +235,7 @@ const six::Amp8iPhs8iLookup_t& ImageData::getLookup(const six::AmplitudeTable* p return *pLookup; } -void ImageData::toComplex(const six::Amp8iPhs8iLookup_t& values, std::span inputs, std::span> results) +void ImageData::toComplex(const six::Amp8iPhs8iLookup_t& values, std::span inputs, std::span results) { const auto toComplex_ = [&values](const auto& v) { @@ -243,7 +243,7 @@ void ImageData::toComplex(const six::Amp8iPhs8iLookup_t& values, std::span inputs, std::span> results) const +void ImageData::toComplex(std::span inputs, std::span results) const { if (pixelType != PixelType::AMP8I_PHS8I) { diff --git a/six/modules/c++/six.sicd/source/ImageFormation.cpp b/six/modules/c++/six.sicd/source/ImageFormation.cpp index 47509ba3d4..c2ec181d05 100644 --- a/six/modules/c++/six.sicd/source/ImageFormation.cpp +++ b/six/modules/c++/six.sicd/source/ImageFormation.cpp @@ -29,12 +29,12 @@ using namespace six::sicd; Distortion::Distortion() : calibrationDate(Init::undefined()), a(Init::undefined()), - f1(Init::undefined >()), - q1(Init::undefined >()), - q2(Init::undefined >()), - f2(Init::undefined >()), - q3(Init::undefined >()), - q4(Init::undefined >()), + f1(Init::undefined()), + q1(Init::undefined()), + q2(Init::undefined()), + f2(Init::undefined()), + q3(Init::undefined()), + q4(Init::undefined()), gainErrorA(Init::undefined()), gainErrorF1(Init::undefined()), gainErrorF2(Init::undefined()), diff --git a/six/modules/c++/six.sicd/source/NITFReadComplexXMLControl.cpp b/six/modules/c++/six.sicd/source/NITFReadComplexXMLControl.cpp index cf1805eb66..0f8327f01e 100644 --- a/six/modules/c++/six.sicd/source/NITFReadComplexXMLControl.cpp +++ b/six/modules/c++/six.sicd/source/NITFReadComplexXMLControl.cpp @@ -79,15 +79,15 @@ std::unique_ptr six::sicd::NITFReadComplexXMLControl::ge return std::unique_ptr< six::sicd::ComplexData>(result.release()); } -std::vector> six::sicd::NITFReadComplexXMLControl::getWidebandData(const ComplexData& complexData) +std::vector six::sicd::NITFReadComplexXMLControl::getWidebandData(const ComplexData& complexData) { - std::vector> retval; + std::vector retval; Utilities::getWidebandData(reader, complexData, retval); return retval; } void six::sicd::NITFReadComplexXMLControl::getWidebandData(const ComplexData& complexData, const types::RowCol& offset, const types::RowCol& extent, - std::complex* buffer) + six::zfloat* buffer) { Utilities::getWidebandData(reader, complexData, offset, extent, buffer); } diff --git a/six/modules/c++/six.sicd/source/Utilities.cpp b/six/modules/c++/six.sicd/source/Utilities.cpp index 3bd9c225ae..306b41c553 100644 --- a/six/modules/c++/six.sicd/source/Utilities.cpp +++ b/six/modules/c++/six.sicd/source/Utilities.cpp @@ -214,14 +214,14 @@ class SICD_readerAndConverter final six::sicd::ImageData::toComplex(lookup, input, output); } const types::RowCol& offset; - std::complex* buffer; + six::zfloat* buffer; const six::Amp8iPhs8iLookup_t& lookup; public: SICD_readerAndConverter(six::NITFReadControl& reader, size_t imageNumber, const types::RowCol& offset, const types::RowCol& extent, size_t elementsPerRow, - std::complex* buffer, const six::AmplitudeTable* pAmplitudeTable = nullptr) + six::zfloat* buffer, const six::AmplitudeTable* pAmplitudeTable = nullptr) : offset(offset), buffer(buffer), lookup(six::sicd::ImageData::getLookup(pAmplitudeTable)) { SICDreader(reader, imageNumber, offset, extent, elementsPerRow, @@ -597,7 +597,7 @@ template static void readSicd_(const std::string& sicdPathname, const std::vector& schemaPaths, TComplexDataPtr& complexData, - std::vector>& widebandData) + std::vector& widebandData) { six::sicd::NITFReadComplexXMLControl reader; reader.load(sicdPathname, &schemaPaths); @@ -619,14 +619,14 @@ static void readSicd_(const std::string& sicdPathname, void Utilities::readSicd(const std::string& sicdPathname, const std::vector& schemaPaths, std::unique_ptr& complexData, - std::vector>& widebandData) + std::vector& widebandData) { readSicd_(sicdPathname, schemaPaths, complexData, widebandData); } void Utilities::readSicd(const fs::path& sicdPathname, const std::vector& schemaPaths, std::unique_ptr& complexData, - std::vector>& widebandData) + std::vector& widebandData) { std::vector schemaPaths_; std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(schemaPaths_), [](const fs::path& p) { return p.string(); }); @@ -645,7 +645,7 @@ static void readSicd_(const std::string& sicdPathname, size_t orderX, size_t orderY, TComplexDataPtr& complexData, - std::vector>& widebandData, + std::vector& widebandData, six::Poly2D& outputRowColToSlantRow, six::Poly2D& outputRowColToSlantCol, TNoiseMeshPtr& noiseMesh, @@ -678,7 +678,7 @@ void Utilities::readSicd(const std::string& sicdPathname, size_t orderX, size_t orderY, std::unique_ptr& complexData, - std::vector>& widebandData, + std::vector& widebandData, six::Poly2D& outputRowColToSlantRow, six::Poly2D& outputRowColToSlantCol, std::unique_ptr& noiseMesh, @@ -736,13 +736,13 @@ void Utilities::getWidebandData(NITFReadControl& reader, const ComplexData& complexData, const types::RowCol& offset, const types::RowCol& extent, - std::complex* buffer) + six::zfloat* buffer) { const PixelType pixelType = complexData.getPixelType(); constexpr size_t imageNumber = 0; const size_t requiredBufferBytes = - sizeof(std::complex) * extent.area(); + sizeof(six::zfloat) * extent.area(); if (buffer == nullptr) { @@ -786,7 +786,7 @@ void Utilities::getWidebandData(NITFReadControl& reader, } void Utilities::getWidebandData(NITFReadControl& reader, const ComplexData& complexData, - std::complex* buffer) + six::zfloat* buffer) { const types::RowCol offset(0, 0); const auto extent = getExtent(complexData); @@ -797,7 +797,7 @@ void Utilities::getWidebandData(NITFReadControl& reader, const ComplexData& complexData, const types::RowCol& offset, const types::RowCol& extent, - std::vector>& buffer) + std::vector& buffer) { const size_t requiredNumElements = extent.area(); buffer.resize(requiredNumElements); @@ -810,7 +810,7 @@ void Utilities::getWidebandData(NITFReadControl& reader, void Utilities::getWidebandData(NITFReadControl& reader, const ComplexData& complexData, - std::vector>& buffer) + std::vector& buffer) { const types::RowCol offset{}; const auto extent = getExtent(complexData); @@ -822,7 +822,7 @@ void Utilities::getWidebandData(const std::string& sicdPathname, const ComplexData& complexData, const types::RowCol& offset, const types::RowCol& extent, - std::complex* buffer) + six::zfloat* buffer) { six::sicd::NITFReadComplexXMLControl reader; reader.load(sicdPathname); @@ -832,7 +832,7 @@ void Utilities::getWidebandData(const std::string& sicdPathname, void Utilities::getWidebandData(const std::string& sicdPathname, const std::vector& schemaPaths, const ComplexData& complexData, - std::complex* buffer) + six::zfloat* buffer) { const types::RowCol offset{}; const auto extent = getExtent(complexData); @@ -844,7 +844,7 @@ void Utilities::getRawData(NITFReadControl& reader, const ComplexData& complexData, const types::RowCol& offset, const types::RowCol& extent, - std::vector>& buffer) + std::vector& buffer) { const auto pixelType = complexData.getPixelType(); if (pixelType != PixelType::RE32F_IM32F) @@ -1623,19 +1623,19 @@ std::vector six::sicd::readFromNITF(const fs::path& pathname, const s return reader.interleaved(); } -static void writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths_, const six::sicd::ComplexData& data, const std::complex* image_) +static void writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths_, const six::sicd::ComplexData& data, const six::zfloat* image_) { six::XMLControlFactory::getInstance().addCreator(); six::NITFWriteControl writer(data.unique_clone()); writer.setLogger(logging::setupLogger("out")); - const std::span> image(image_, getExtent(data).area()); + const std::span image(image_, getExtent(data).area()); std::vector schemaPaths; std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), [](const std::string& s) { return s; }); writer.save_image(image, pathname, schemaPaths); } -void six::sicd::writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths, const ComplexData& data, std::span> image) +void six::sicd::writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths, const ComplexData& data, std::span image) { if (image.size() != getExtent(data).area()) { @@ -1643,7 +1643,7 @@ void six::sicd::writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths, const ComplexData& data, std::span> image) +void six::sicd::writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths, const ComplexData& data, std::span image) { std::vector schemaPaths_; std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(schemaPaths_), [](const fs::path& p) { return p.string(); }); @@ -1654,9 +1654,9 @@ void six::sicd::writeAsNITF(const fs::path& pathname, const std::vector> six::sicd::testing::make_complex_image(const types::RowCol& dims) +std::vector six::sicd::testing::make_complex_image(const types::RowCol& dims) { - std::vector> image; + std::vector image; image.reserve(dims.area()); for (size_t r = 0; r < dims.row; r++) { diff --git a/six/modules/c++/six.sicd/tests/derive_output_plane.cpp b/six/modules/c++/six.sicd/tests/derive_output_plane.cpp index 058de34572..09341a4df5 100644 --- a/six/modules/c++/six.sicd/tests/derive_output_plane.cpp +++ b/six/modules/c++/six.sicd/tests/derive_output_plane.cpp @@ -37,7 +37,7 @@ void roundTripNITF(const std::string& sicdPathname, const std::vector& schemaPaths_) { std::unique_ptr complexData; - std::vector > buffer; + std::vector buffer; six::sicd::Utilities::readSicd(sicdPathname, schemaPaths_, complexData, buffer); diff --git a/six/modules/c++/six.sicd/tests/test_compare_sicd_meshes.cpp b/six/modules/c++/six.sicd/tests/test_compare_sicd_meshes.cpp index 895d66db09..eb7ca2c9d3 100644 --- a/six/modules/c++/six.sicd/tests/test_compare_sicd_meshes.cpp +++ b/six/modules/c++/six.sicd/tests/test_compare_sicd_meshes.cpp @@ -235,7 +235,7 @@ void readMeshes(const std::string& sicdPathname, const size_t orderY = 3; std::unique_ptr complexData; - std::vector > widebandData; + std::vector widebandData; six::Poly2D outputRowColToSlantRow; six::Poly2D outputRowColToSlantCol; diff --git a/six/modules/c++/six.sicd/tests/test_load_from_input_stream.cpp b/six/modules/c++/six.sicd/tests/test_load_from_input_stream.cpp index dc5695ac4e..b168ae5bdf 100644 --- a/six/modules/c++/six.sicd/tests/test_load_from_input_stream.cpp +++ b/six/modules/c++/six.sicd/tests/test_load_from_input_stream.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) } std::unique_ptr fileComplexData; - std::vector > fileWidebandData; + std::vector fileWidebandData; six::sicd::Utilities::readSicd(sicdPathname, schemaPaths, fileComplexData, fileWidebandData); diff --git a/six/modules/c++/six.sicd/tests/test_read_sicd.cpp b/six/modules/c++/six.sicd/tests/test_read_sicd.cpp index 5f808b1666..83882e2afd 100644 --- a/six/modules/c++/six.sicd/tests/test_read_sicd.cpp +++ b/six/modules/c++/six.sicd/tests/test_read_sicd.cpp @@ -63,7 +63,7 @@ int main(int argc, char** argv) } std::unique_ptr complexData; - std::vector > widebandData; + std::vector widebandData; six::sicd::Utilities::readSicd(sicdPathname, schemaPaths, complexData, widebandData); diff --git a/six/modules/c++/six.sicd/tests/test_read_sicd_mesh.cpp b/six/modules/c++/six.sicd/tests/test_read_sicd_mesh.cpp index 686097bbb7..2267bc027c 100644 --- a/six/modules/c++/six.sicd/tests/test_read_sicd_mesh.cpp +++ b/six/modules/c++/six.sicd/tests/test_read_sicd_mesh.cpp @@ -27,7 +27,7 @@ int main(int argc, char** argv) const size_t orderX(4); const size_t orderY(4); std::unique_ptr complexData; - std::vector > widebandData; + std::vector widebandData; six::Poly2D outputRowColToSlantRow; six::Poly2D outputRowColToSlantCol; std::unique_ptr noiseMesh; diff --git a/six/modules/c++/six.sicd/tests/test_sicd_byte_provider.cpp b/six/modules/c++/six.sicd/tests/test_sicd_byte_provider.cpp index c2121f0da2..86b94a1e14 100644 --- a/six/modules/c++/six.sicd/tests/test_sicd_byte_provider.cpp +++ b/six/modules/c++/six.sicd/tests/test_sicd_byte_provider.cpp @@ -60,7 +60,7 @@ struct Tester final { for (size_t ii = 0; ii < mImage.size(); ++ii) { - mImage[ii] = std::complex( + mImage[ii] = types::complex( static_cast(ii), static_cast(ii * 10)); } @@ -148,8 +148,8 @@ struct Tester final const types::RowCol mDims; std::unique_ptr mData; - std::vector > mImage; - std::vector > mBigEndianImage; + std::vector > mImage; + std::vector > mBigEndianImage; std::unique_ptr mCompareFiles; const std::string mTestPathname; @@ -334,7 +334,7 @@ bool doTests(const std::vector& schemaPaths, // It would be better to get the logic fixed that forces // segmentation on the number of rows via OPT_MAX_ILOC_ROWS static const size_t APPROX_HEADER_SIZE = 2 * 1024; - const size_t numBytesPerRow = 456 * sizeof(std::complex); + const size_t numBytesPerRow = 456 * sizeof(types::complex); const size_t maxProductSize = numRowsPerSeg * numBytesPerRow + APPROX_HEADER_SIZE; diff --git a/six/modules/c++/six.sicd/tests/test_streaming_write.cpp b/six/modules/c++/six.sicd/tests/test_streaming_write.cpp index 50ceb03d2d..4c61691474 100644 --- a/six/modules/c++/six.sicd/tests/test_streaming_write.cpp +++ b/six/modules/c++/six.sicd/tests/test_streaming_write.cpp @@ -235,7 +235,7 @@ struct Tester final { for (size_t ii = 0; ii < mImage.size(); ++ii) { - mImage[ii] = std::complex( + mImage[ii] = types::complex( static_cast(ii), static_cast(ii * 10)); } @@ -291,8 +291,8 @@ struct Tester final mem::SharedPtr mContainer; const types::RowCol mDims; - std::vector > mImage; - std::complex* const mImagePtr; + std::vector > mImage; + types::complex* const mImagePtr; std::unique_ptr mCompareFiles; const std::string mTestPathname; @@ -402,7 +402,7 @@ void Tester::testMultipleWritesOfPartialRows() // Rows [40, 60) // Cols [400, 456) types::RowCol offset(40, 400); - std::vector > subset; + std::vector > subset; types::RowCol subsetDims(20, 56); subsetData(mImagePtr, mDims.col, offset, subsetDims, subset); sicdWriter.save(subset.data(), offset, subsetDims); @@ -457,7 +457,7 @@ bool doTests(const std::vector& schemaPaths, // It would be better to get the logic fixed that forces // segmentation on the number of rows via OPT_MAX_ILOC_ROWS static const size_t APPROX_HEADER_SIZE = 2 * 1024; - const size_t numBytesPerRow = 456 * sizeof(std::complex); + const size_t numBytesPerRow = 456 * sizeof(types::complex); const size_t maxProductSize = numRowsPerSeg * numBytesPerRow + APPROX_HEADER_SIZE; diff --git a/six/modules/c++/six.sicd/unittests/test_AMP8I_PHS8I.cpp b/six/modules/c++/six.sicd/unittests/test_AMP8I_PHS8I.cpp index 1706424671..8a45d4830c 100644 --- a/six/modules/c++/six.sicd/unittests/test_AMP8I_PHS8I.cpp +++ b/six/modules/c++/six.sicd/unittests/test_AMP8I_PHS8I.cpp @@ -127,31 +127,31 @@ static void test_nitf_image_info(const std::string& testName, } static void test_assert_eq(const std::string& testName, - const std::vector>& actuals, const std::vector& amp8i_phs8i) + const std::vector& actuals, const std::vector& amp8i_phs8i) { TEST_ASSERT_EQ(actuals.size(), amp8i_phs8i.size()); for (size_t i = 0; i < actuals.size(); i++) { const auto& v = amp8i_phs8i[i]; const auto S = six::sicd::Utilities::toComplex(v.amplitude, v.phase); - const std::complex result(gsl::narrow_cast(S.real()), gsl::narrow_cast(S.imag())); + const six::zfloat result(gsl::narrow_cast(S.real()), gsl::narrow_cast(S.imag())); const auto& expected = actuals[i]; TEST_ASSERT_EQ(expected, result); } } static void from_AMP8I_PHS8I(const six::sicd::ImageData& imageData, - const std::vector& inputs_, std::vector>& results_) + const std::vector& inputs_, std::vector& results_) { const std::span inputs(inputs_.data(), inputs_.size()); - const std::span> results(results_.data(), results_.size()); + const std::span results(results_.data(), results_.size()); imageData.toComplex(inputs, results); } static void to_AMP8I_PHS8I(const six::sicd::ImageData& imageData, - const std::vector>& inputs_, std::vector& results_) + const std::vector& inputs_, std::vector& results_) { - const std::span> inputs(inputs_.data(), inputs_.size()); + const std::span inputs(inputs_.data(), inputs_.size()); const std::span results(results_.data(), results_.size()); imageData.fromComplex(inputs, results); } @@ -162,7 +162,7 @@ TEST_CASE(test_8bit_ampphs) imageData.pixelType = six::PixelType::AMP8I_PHS8I; std::vector inputs; - std::vector> expecteds; + std::vector expecteds; for (const auto amplitude : six::sicd::Utilities::iota_0_256()) { for (const auto phase : six::sicd::Utilities::iota_0_256()) @@ -175,7 +175,7 @@ TEST_CASE(test_8bit_ampphs) } } - std::vector> actuals(inputs.size()); + std::vector actuals(inputs.size()); from_AMP8I_PHS8I(imageData, inputs, actuals); TEST_ASSERT(actuals == expecteds); @@ -190,7 +190,7 @@ TEST_CASE(test_8bit_ampphs) test_assert_eq(testName, actuals, amp8i_phs8i); } -static std::vector > read_8bit_ampphs(const std::string& testName, +static std::vector read_8bit_ampphs(const std::string& testName, const std::filesystem::path& inputPathname, std::optional& amplitudeTable, std::unique_ptr& pResultComplexData, std::complex expected_sum) @@ -239,11 +239,11 @@ struct Pair final // std::pair is not trivial copyable T second; }; -static Pair to_AMP8I_PHS8I(const six::sicd::ImageData& imageData, const std::vector>& widebandData) +static Pair to_AMP8I_PHS8I(const six::sicd::ImageData& imageData, const std::vector& widebandData) { // image is far too big to call to_AMP8I_PHS8I() with DEBUG code const auto size = sys::debug ? widebandData.size() / 200 : widebandData.size(); - const std::span> widebandData_(widebandData.data(), size); + const std::span widebandData_(widebandData.data(), size); std::vector results(widebandData_.size()); imageData.fromComplex(widebandData_, std::span< AMP8I_PHS8I_t>(results.data(), results.size())); @@ -354,7 +354,7 @@ static six::sicd::ComplexImageResult readSicd_(const std::filesystem::path& sicd test_assert(*(result.pComplexData), expectedPixelType, expectedNumBytesPerPixel); return result; } -static std::vector> readSicd(const std::filesystem::path& inputPathname) +static std::vector readSicd(const std::filesystem::path& inputPathname) { return readSicd_(inputPathname, six::PixelType::AMP8I_PHS8I, sizeof(AMP8I_PHS8I_t)).widebandData; } @@ -384,8 +384,8 @@ static void adjust_image(TImage& image) } pImageBytes[pImageBytes.size() - 1] = static_cast(']'); } -static std::vector> adjust_image(const six::sicd::ComplexData& complexData, - std::vector>&& image) +static std::vector adjust_image(const six::sicd::ComplexData& complexData, + std::vector&& image) { if (complexData.getPixelType() != six::PixelType::AMP8I_PHS8I) { @@ -400,11 +400,11 @@ static std::vector> adjust_image(const six::sicd::ComplexDat adjust_image(from_); std::span from(from_.data(), from_.size()); - std::vector> retval(from.size()); - complexData.imageData->toComplex(from, std::span>(retval.data(), retval.size())); + std::vector retval(from.size()); + complexData.imageData->toComplex(from, std::span(retval.data(), retval.size())); return retval; } -static std::vector> make_complex_image(const six::sicd::ComplexData& complexData, const types::RowCol& dims) +static std::vector make_complex_image(const six::sicd::ComplexData& complexData, const types::RowCol& dims) { if (complexData.getPixelType() == six::PixelType::AMP8I_PHS8I) { @@ -463,7 +463,7 @@ static void read_raw_data(const std::filesystem::path& path, six::PixelType pixe } static void read_nitf(const std::string& testName, - const std::filesystem::path& path, six::PixelType pixelType, const std::vector>& image) + const std::filesystem::path& path, six::PixelType pixelType, const std::vector& image) { const auto expectedNumBytesPerPixel = pixelType == six::PixelType::RE32F_IM32F ? 8 : (pixelType == six::PixelType::AMP8I_PHS8I ? 2 : -1); const auto result = readSicd_(path, pixelType, expectedNumBytesPerPixel); @@ -473,7 +473,7 @@ static void read_nitf(const std::string& testName, read_raw_data(path, pixelType, std::span(bytes.data(), bytes.size())); } -static void buffer_list_save(const std::filesystem::path& outputName, const std::vector>& image, +static void buffer_list_save(const std::filesystem::path& outputName, const std::vector& image, std::unique_ptr&& pComplexData) { six::XMLControlFactory::getInstance().addCreator(); @@ -483,21 +483,21 @@ static void buffer_list_save(const std::filesystem::path& outputName, const std: six::save(writer, image.data(), outputName.string(), schemaPaths); // API for Python; it uses six::BufferList } -static void save(const std::filesystem::path& outputName, const std::vector>& image, +static void save(const std::filesystem::path& outputName, const std::vector& image, std::unique_ptr&& pComplexData) { static const std::vector fs_schemaPaths; - six::sicd::writeAsNITF(outputName, fs_schemaPaths, *pComplexData, std::span>(image.data(), image.size())); + six::sicd::writeAsNITF(outputName, fs_schemaPaths, *pComplexData, std::span(image.data(), image.size())); } static void test_assert_image_(const std::string& testName, - const std::vector>& image, const six::sicd::ComplexData& complexData) + const std::vector& image, const six::sicd::ComplexData& complexData) { - static const std::vector> expected_cxfloat{ - std::complex(46.7833481f, 78.0533066f), - std::complex(21.5923157f, 36.0246010f), - std::complex(21.5923157f, 36.0246010f), - std::complex(-27.4332600f, 31.8027706f) }; + static const std::vector expected_cxfloat{ + six::zfloat(46.7833481f, 78.0533066f), + six::zfloat(21.5923157f, 36.0246010f), + six::zfloat(21.5923157f, 36.0246010f), + six::zfloat(-27.4332600f, 31.8027706f) }; TEST_ASSERT_EQ(image.size(), expected_cxfloat.size()); for (size_t i = 0; i < image.size(); i++) { @@ -505,7 +505,7 @@ static void test_assert_image_(const std::string& testName, TEST_ASSERT_ALMOST_EQ(image[i].imag(), expected_cxfloat[i].imag()); } - const std::span> input(image.data(), image.size()); + const std::span input(image.data(), image.size()); std::vector result(input.size()); std::span< AMP8I_PHS8I_t> result_(result.data(), result.size()); complexData.imageData->fromComplex(input, result_); @@ -553,8 +553,8 @@ TEST_CASE(test_create_sicd_from_mem_8i) test_create_sicd_from_mem(testName, "test_create_sicd_from_mem_8i_noamp.sicd", six::PixelType::AMP8I_PHS8I, false /*makeAmplitudeTable*/); } -static void test_adjusted_values(const std::string& testName, const std::vector>& values, - const std::vector& expected, std::complex delta) +static void test_adjusted_values(const std::string& testName, const std::vector& values, + const std::vector& expected, six::zfloat delta) { auto adjusted_values = values; for (auto& v : adjusted_values) @@ -563,7 +563,7 @@ static void test_adjusted_values(const std::string& testName, const std::vector< } std::vector actual(expected.size()); std::span actual_(actual.data(), actual.size()); - std::span> values_(adjusted_values.data(), adjusted_values.size()); + std::span values_(adjusted_values.data(), adjusted_values.size()); six::sicd::ImageData::testing_fromComplex_(values_, actual_); for (size_t i = 0; i < expected.size(); i++) { @@ -574,7 +574,7 @@ static void test_adjusted_values(const std::string& testName, const std::vector< TEST_CASE(test_nearest_neighbor) { - const std::vector> values{ + const std::vector values{ {0.0, 0.0}, {1.0, 1.0}, {10.0, -10.0}, {-100.0, 100.0}, {-1000.0, -1000.0} }; const std::vector expected{ @@ -586,7 +586,7 @@ TEST_CASE(test_nearest_neighbor) std::vector actual(expected.size()); std::span actual_(actual.data(), actual.size()); - std::span> values_(values.data(), values.size()); + std::span values_(values.data(), values.size()); six::sicd::ImageData::testing_fromComplex_(values_, actual_); for (size_t i = 0; i < expected.size(); i++) @@ -598,28 +598,28 @@ TEST_CASE(test_nearest_neighbor) auto other_expected = expected; constexpr auto delta = 0.0122f; - test_adjusted_values(testName, values, other_expected, std::complex(delta, 0.0f)); + test_adjusted_values(testName, values, other_expected, six::zfloat(delta, 0.0f)); other_expected[0].phase = 32; - test_adjusted_values(testName, values, other_expected, std::complex(delta, delta)); + test_adjusted_values(testName, values, other_expected, six::zfloat(delta, delta)); other_expected[0].phase += 32; - test_adjusted_values(testName, values, other_expected, std::complex(0.0f, delta)); + test_adjusted_values(testName, values, other_expected, six::zfloat(0.0f, delta)); other_expected[0].phase += 32; - test_adjusted_values(testName, values, other_expected, std::complex(-delta, delta)); + test_adjusted_values(testName, values, other_expected, six::zfloat(-delta, delta)); other_expected[0].phase += 32; - test_adjusted_values(testName, values, other_expected, std::complex(-delta, 0.0f)); + test_adjusted_values(testName, values, other_expected, six::zfloat(-delta, 0.0f)); other_expected[0].phase += 32; - test_adjusted_values(testName, values, other_expected, std::complex(-delta, -delta)); + test_adjusted_values(testName, values, other_expected, six::zfloat(-delta, -delta)); other_expected[0].phase += 32; - test_adjusted_values(testName, values, other_expected, std::complex(0.0f, -delta)); + test_adjusted_values(testName, values, other_expected, six::zfloat(0.0f, -delta)); other_expected[0].phase += 32; - test_adjusted_values(testName, values, other_expected, std::complex(delta, -delta)); + test_adjusted_values(testName, values, other_expected, six::zfloat(delta, -delta)); other_expected[0].phase += 32; TEST_ASSERT_EQ(other_expected[0].phase, expected[0].phase); @@ -651,12 +651,12 @@ TEST_CASE(test_verify_phase_uint8_ordering) struct Pairs final { - std::complex floating; + six::zfloat floating; AMP8I_PHS8I_t integral; }; static void do_test_ComplexToAMP8IPHS8I_(const std::string& testName, const six::sicd::details::ComplexToAMP8IPHS8I& item, - const std::complex& input_dbl, const std::vector& candidates) + const six::zfloat& input_dbl, const std::vector& candidates) { // Calculate the nearest neighbor quickly. const auto test_integral = item.nearest_neighbor(input_dbl); @@ -676,7 +676,7 @@ static void do_test_ComplexToAMP8IPHS8I_(const std::string& testName, TEST_ASSERT_EQ(test_integral.amplitude, best.integral.amplitude); TEST_ASSERT_EQ(test_integral.phase, best.integral.phase); } -using it_t = std::vector>::const_iterator; +using it_t = std::vector::const_iterator; static void test_ComplexToAMP8IPHS8I_(const std::string& testName, const six::sicd::details::ComplexToAMP8IPHS8I& item, it_t beg, it_t end, const std::vector& candidates) @@ -730,14 +730,14 @@ TEST_CASE(test_ComplexToAMP8IPHS8I) // These are simple cases that don't necessarily exercise the nearest neighbor property. for(auto& i : candidates) { auto truth = i.integral; - auto test = item.nearest_neighbor(std::complex(i.floating.real(), i.floating.imag())); + auto test = item.nearest_neighbor(six::zfloat(i.floating.real(), i.floating.imag())); TEST_ASSERT_EQ(truth.amplitude, test.amplitude); TEST_ASSERT_EQ(truth.phase, test.phase); } // Run an edge case that's very close to a phase of 2PI. // The phase should have wrapped back around to 0. - std::complex problem { + six::zfloat problem { 1.0f, -1e-4f }; TEST_ASSERT_EQ(item.nearest_neighbor(problem).phase, 0); @@ -753,7 +753,7 @@ TEST_CASE(test_ComplexToAMP8IPHS8I) //size_t bad_first = 0; //size_t bad_second = 0; //double worst_error = 0; - std::vector> inputs; + std::vector inputs; for(size_t k = 0; k < kTests; k++) { double x = dist(eng); diff --git a/six/modules/c++/six.sicd/unittests/test_projection_polynomial_fitter.cpp b/six/modules/c++/six.sicd/unittests/test_projection_polynomial_fitter.cpp index 52256692bc..df6d18eef1 100644 --- a/six/modules/c++/six.sicd/unittests/test_projection_polynomial_fitter.cpp +++ b/six/modules/c++/six.sicd/unittests/test_projection_polynomial_fitter.cpp @@ -20,7 +20,7 @@ loadPolynomialFitter() std::vector schemaPaths; std::unique_ptr complexData; - std::vector > buffer; + std::vector buffer; six::sicd::Utilities::readSicd(sicdPathname.string(), schemaPaths, complexData, buffer); return six::sicd::Utilities::getPolynomialFitter(*complexData); } diff --git a/six/modules/c++/six.sicd/unittests/test_valid_six.cpp b/six/modules/c++/six.sicd/unittests/test_valid_six.cpp index aaf8f79855..0996727fcf 100644 --- a/six/modules/c++/six.sicd/unittests/test_valid_six.cpp +++ b/six/modules/c++/six.sicd/unittests/test_valid_six.cpp @@ -271,7 +271,7 @@ static std::vector readFromNITF(const std::filesystem::path& inputPat std::unique_ptr pComplexData; auto image = six::sicd::readFromNITF(inputPathname, pComplexData); - test_assert(*pComplexData, six::PixelType::RE32F_IM32F, sizeof(std::complex)); + test_assert(*pComplexData, six::PixelType::RE32F_IM32F, sizeof(six::zfloat)); return image; @@ -298,9 +298,9 @@ static six::sicd::ComplexImageResult readSicd_(const std::filesystem::path& sicd test_assert(*(result.pComplexData), expectedPixelType, expectedNumBytesPerPixel); return result; } -static std::vector> readSicd(const std::filesystem::path& inputPathname) +static std::vector readSicd(const std::filesystem::path& inputPathname) { - return readSicd_(inputPathname, six::PixelType::RE32F_IM32F, sizeof(std::complex)).widebandData; + return readSicd_(inputPathname, six::PixelType::RE32F_IM32F, sizeof(six::zfloat)).widebandData; } TEST_CASE(test_read_sicd_50x50) { @@ -308,7 +308,7 @@ TEST_CASE(test_read_sicd_50x50) auto widebandData = readSicd(inputPathname); } -static std::vector> make_complex_image(const six::sicd::ComplexData& complexData, const types::RowCol& dims) +static std::vector make_complex_image(const six::sicd::ComplexData& complexData, const types::RowCol& dims) { if (complexData.getPixelType() == six::PixelType::RE32F_IM32F) { @@ -360,7 +360,7 @@ static void read_raw_data(const std::filesystem::path& path, six::PixelType pixe if (pixelType == six::PixelType::RE32F_IM32F) { - std::vector> rawData; + std::vector rawData; six::sicd::Utilities::getRawData(reader.NITFReadControl(), complexData, offset, extent, rawData); test_assert_eq(bytes, rawData); test_assert_eq(expectedBytes, rawData); @@ -368,7 +368,7 @@ static void read_raw_data(const std::filesystem::path& path, six::PixelType pixe } static void read_nitf(const std::string& testName, - const std::filesystem::path& path, six::PixelType pixelType, const std::vector>& image) + const std::filesystem::path& path, six::PixelType pixelType, const std::vector& image) { const auto expectedNumBytesPerPixel = pixelType == six::PixelType::RE32F_IM32F ? 8 : (pixelType == six::PixelType::AMP8I_PHS8I ? 2 : -1); const auto result = readSicd_(path, pixelType, expectedNumBytesPerPixel); @@ -378,7 +378,7 @@ static void read_nitf(const std::string& testName, read_raw_data(path, pixelType, std::span(bytes.data(), bytes.size())); } -static void buffer_list_save(const std::filesystem::path& outputName, const std::vector>& image, +static void buffer_list_save(const std::filesystem::path& outputName, const std::vector& image, std::unique_ptr&& pComplexData) { six::XMLControlFactory::getInstance().addCreator(); @@ -388,11 +388,11 @@ static void buffer_list_save(const std::filesystem::path& outputName, const std: six::save(writer, image.data(), outputName.string(), schemaPaths); // API for Python; it uses six::BufferList } -static void save(const std::filesystem::path& outputName, const std::vector>& image, +static void save(const std::filesystem::path& outputName, const std::vector& image, std::unique_ptr&& pComplexData) { static const std::vector fs_schemaPaths; - six::sicd::writeAsNITF(outputName, fs_schemaPaths, *pComplexData, std::span>(image.data(), image.size())); + six::sicd::writeAsNITF(outputName, fs_schemaPaths, *pComplexData, std::span(image.data(), image.size())); } template diff --git a/six/modules/c++/six.sidd/tests/test_check_blocking.cpp b/six/modules/c++/six.sidd/tests/test_check_blocking.cpp index a7de002594..7928d70637 100644 --- a/six/modules/c++/six.sidd/tests/test_check_blocking.cpp +++ b/six/modules/c++/six.sidd/tests/test_check_blocking.cpp @@ -33,12 +33,12 @@ namespace { -void generateData(const six::Data& data, std::vector>& buffer) +void generateData(const six::Data& data, std::vector& buffer) { buffer.resize(getExtent(data).area()); for (size_t ii = 0; ii < buffer.size(); ++ii) { - buffer[ii] = std::complex(ii % 100); + buffer[ii] = six::zfloat(ii % 100); } } @@ -73,7 +73,7 @@ void writeSingleImage(const six::Data& data, const std::string& pathname, workingData->setNumRows(imageSideSize); workingData->setNumCols(imageSideSize); - std::vector> buffer; + std::vector buffer; generateData(*workingData, buffer); mem::SharedPtr container(new six::Container( @@ -93,7 +93,7 @@ void writeSingleImage(const six::Data& data, const std::string& pathname, } -inline const six::UByte* cast(const std::vector>& buffer) +inline const six::UByte* cast(const std::vector& buffer) { const void* pBuffer = buffer.data(); return static_cast(pBuffer); @@ -115,8 +115,8 @@ void writeTwoImages(const six::Data& data, const std::string& pathname, const std::string productSize = computeProductSize(blockSize, largeImageSize, data.getNumBytesPerPixel()); - std::vector> firstBuffer; - std::vector> secondBuffer; + std::vector firstBuffer; + std::vector secondBuffer; generateData(*firstData, firstBuffer); generateData(*secondData, secondBuffer); diff --git a/six/modules/c++/six/include/six/Adapters.h b/six/modules/c++/six/include/six/Adapters.h index 7c15a9bbc2..2d359c1216 100644 --- a/six/modules/c++/six/include/six/Adapters.h +++ b/six/modules/c++/six/include/six/Adapters.h @@ -30,10 +30,13 @@ #include #include -#include +#include +#include #include #include -#include + +#include + #include "six/Types.h" #include "six/NITFSegmentInfo.h" #include "six/Utilities.h" @@ -164,10 +167,10 @@ class NewMemoryWriteHandler final : public nitf::WriteHandler // all of our code std::span buffer, size_t firstRow, const Data& data, bool doByteSwap); NewMemoryWriteHandler(const NITFSegmentInfo& info, - std::span> buffer, + std::span buffer, size_t firstRow, const Data& data, bool doByteSwap); NewMemoryWriteHandler(const NITFSegmentInfo& info, - std::span> buffer, + std::span buffer, size_t firstRow, const Data& data, bool doByteSwap); NewMemoryWriteHandler(const NITFSegmentInfo& info, std::span> buffer, diff --git a/six/modules/c++/six/include/six/AmplitudeTable.h b/six/modules/c++/six/include/six/AmplitudeTable.h index 5f4e0e1fed..5ea0e750fa 100644 --- a/six/modules/c++/six/include/six/AmplitudeTable.h +++ b/six/modules/c++/six/include/six/AmplitudeTable.h @@ -33,11 +33,14 @@ #include #include +#include +#include + #include #include -#include #include "six/Enums.h" +#include "six/Types.h" namespace six { @@ -156,10 +159,10 @@ struct LUT * double precision amplitude value */ -// Store the computed `std::complex` for every possible +// Store the computed `six::zfloat` for every possible // amp/phs pair, a total of 256*256 values. //! Fixed size 256 element array of complex values. -using phase_values_t = std::array, UINT8_MAX + 1>; +using phase_values_t = std::array; //! Fixed size 256 x 256 matrix of complex values. using Amp8iPhs8iLookup_t = std::array; @@ -202,7 +205,7 @@ class ComplexToAMP8IPHS8I final * @param v complex value to query with * @return nearest amplitude and phase value */ - AMP8I_PHS8I_t nearest_neighbor(const std::complex& v) const; + AMP8I_PHS8I_t nearest_neighbor(const six::zfloat& v) const; private: //! The sorted set of possible magnitudes order from small to large. diff --git a/six/modules/c++/six/include/six/NITFWriteControl.h b/six/modules/c++/six/include/six/NITFWriteControl.h index a46ec1b9af..a4a0e6f146 100644 --- a/six/modules/c++/six/include/six/NITFWriteControl.h +++ b/six/modules/c++/six/include/six/NITFWriteControl.h @@ -299,8 +299,8 @@ class NITFWriteControl : public WriteControl } // Be explicit about the types of images that can be saved; templates are provided below. - void save_image(std::span>, nitf::IOInterface&, const std::vector&); - void save_image(std::span>, nitf::IOInterface&, const std::vector&); + void save_image(std::span, nitf::IOInterface&, const std::vector&); + void save_image(std::span, nitf::IOInterface&, const std::vector&); void save_image(std::span>, nitf::IOInterface&, const std::vector&); void save_image(std::span, nitf::IOInterface&, const std::vector&); void save_image(std::span, nitf::IOInterface&, const std::vector&); @@ -560,7 +560,7 @@ class NITFWriteControl : public WriteControl }; // Help out the compiler with overloads, and keep the class smaller. -extern void save(NITFWriteControl&, const std::complex*, const std::string&, const std::vector&); +extern void save(NITFWriteControl&, const six::zfloat*, const std::string&, const std::vector&); template inline void save(NITFWriteControl& writeControl, diff --git a/six/modules/c++/six/include/six/Parameter.h b/six/modules/c++/six/include/six/Parameter.h index aafc188b9f..1f001529aa 100644 --- a/six/modules/c++/six/include/six/Parameter.h +++ b/six/modules/c++/six/include/six/Parameter.h @@ -22,9 +22,11 @@ #ifndef __SIX_PARAMETER_H__ #define __SIX_PARAMETER_H__ -#include "six/Types.h" +#include #include +#include "six/Types.h" + namespace six { /*! @@ -59,9 +61,9 @@ class Parameter } template - Parameter(std::complex value) + Parameter(types::complex value) { - mValue = str::toString >(mValue); + mValue = str::toString >(mValue); } /*! @@ -88,9 +90,9 @@ class Parameter //! Get complex parameter template - inline std::complex getComplex() const + inline types::complex getComplex() const { - return str::toType >(mValue); + return str::toType >(mValue); } //! Set the parameters' name @@ -108,9 +110,9 @@ class Parameter //! Overload templated setValue function template - void setValue(const std::complex& value) + void setValue(const types::complex& value) { - mValue = str::toString >(value); + mValue = str::toString >(value); } //! Get back const char* diff --git a/six/modules/c++/six/include/six/Region.h b/six/modules/c++/six/include/six/Region.h index c2772563ae..a6f6de7f1d 100644 --- a/six/modules/c++/six/include/six/Region.h +++ b/six/modules/c++/six/include/six/Region.h @@ -29,6 +29,7 @@ #include #include +#include #include @@ -177,7 +178,7 @@ class Region final void* buffer_ = buffer; mBuffer = static_cast(buffer_); } - void setComplexBuffer(std::complex* buffer) noexcept + void setComplexBuffer(six::zfloat* buffer) noexcept { assert(buffer != nullptr); void* buffer_ = buffer; @@ -195,11 +196,11 @@ class Region final setBuffer(retval.get()); return retval; } - std::unique_ptr[]> setComplexBuffer(size_t size) + std::unique_ptr setComplexBuffer(size_t size) { assert(getBuffer() == nullptr); - auto retval = std::make_unique[]>(size); + auto retval = std::make_unique(size); setComplexBuffer(retval.get()); return retval; } diff --git a/six/modules/c++/six/include/six/SICommonXMLParser.h b/six/modules/c++/six/include/six/SICommonXMLParser.h index 7553f7fcce..4da3276e75 100644 --- a/six/modules/c++/six/include/six/SICommonXMLParser.h +++ b/six/modules/c++/six/include/six/SICommonXMLParser.h @@ -55,7 +55,7 @@ struct SICommonXMLParser : public XMLParser return mSICommonURI; } - XMLElem createComplex(const std::string& name, std::complex c, + XMLElem createComplex(const std::string& name, six::zdouble c, XMLElem parent = nullptr) const; XMLElem createVector2D(const std::string& name, const std::string& uri, Vector2 p = 0.0, XMLElem parent = nullptr) const; diff --git a/six/modules/c++/six/include/six/Types.h b/six/modules/c++/six/include/six/Types.h index 9b83b98414..c2c6736021 100644 --- a/six/modules/c++/six/include/six/Types.h +++ b/six/modules/c++/six/include/six/Types.h @@ -32,19 +32,27 @@ #include #include -#include +#include #include #include #include #include #include #include -#include #include +#include + +#include #include "scene/Types.h" #include "scene/FrameType.h" #include "six/Enums.h" + +namespace six +{ + using zfloat = scene::zfloat; + using zdouble = scene::zdouble; +} #include "six/AmplitudeTable.h" namespace six @@ -181,7 +189,7 @@ struct Constants // Each pixel is stored as a pair of numbers that represent the realand imaginary // components. Each component is stored in a 32-bit IEEE floating point format (4 // bytes per component, 8 bytes per pixel). - static_assert(sizeof(std::complex) == 8, "RE32F_IM32F should be two floats"); + static_assert(sizeof(six::zfloat) == 8, "RE32F_IM32F should be two floats"); return 8; } @@ -190,7 +198,7 @@ struct Constants // Each pixel is stored as a pair of numbers that represent the real and imaginary // components. Each component is stored in a 16-bit signed integer in 2's // complement format (2 bytes per component, 4 bytes per pixel). - static_assert(sizeof(std::complex) == 4, "RE16I_IM16I should be two 16-bit integers"); + static_assert(sizeof(types::zint16_t) == 4, "RE16I_IM16I should be two 16-bit integers"); return 4; } diff --git a/six/modules/c++/six/include/six/XMLParser.h b/six/modules/c++/six/include/six/XMLParser.h index 7408a9a028..f931e8dbe1 100644 --- a/six/modules/c++/six/include/six/XMLParser.h +++ b/six/modules/c++/six/include/six/XMLParser.h @@ -249,7 +249,7 @@ struct XMLParser void parseDouble(const xml::lite::Element* element, std::optional& value) const; bool parseOptionalDouble(const xml::lite::Element* parent, const std::string& tag, double& value) const; bool parseOptionalDouble(const xml::lite::Element* parent, const std::string& tag, std::optional& value) const; - void parseComplex(const xml::lite::Element* element, std::complex& value) const; + void parseComplex(const xml::lite::Element* element, six::zdouble& value) const; void parseString(const xml::lite::Element* element, std::string& value) const; void parseString(const xml::lite::Element&, std::string&) const; bool parseString(const xml::lite::Element&, std::u8string&) const; diff --git a/six/modules/c++/six/include/six/XmlLite.h b/six/modules/c++/six/include/six/XmlLite.h index 6030647c45..9d1af8d818 100644 --- a/six/modules/c++/six/include/six/XmlLite.h +++ b/six/modules/c++/six/include/six/XmlLite.h @@ -228,7 +228,7 @@ struct XmlLite final void parseDouble(const xml::lite::Element& element, std::optional& value) const; bool parseOptionalDouble(const xml::lite::Element& parent, const std::string& tag, double& value) const; bool parseOptionalDouble(const xml::lite::Element& parent, const std::string& tag, std::optional& value) const; - void parseComplex(const xml::lite::Element& element, std::complex& value) const; + void parseComplex(const xml::lite::Element& element, six::zdouble& value) const; void parseString(const xml::lite::Element* element, std::string& value) const; void parseString(const xml::lite::Element&, std::string&) const; void parseBooleanType(const xml::lite::Element& element, BooleanType& value) const; diff --git a/six/modules/c++/six/source/Adapters.cpp b/six/modules/c++/six/source/Adapters.cpp index 642081ebda..790809dee0 100644 --- a/six/modules/c++/six/source/Adapters.cpp +++ b/six/modules/c++/six/source/Adapters.cpp @@ -174,7 +174,7 @@ inline void validate_bandSize(std::span buffer, const NITFSegmentInfo& info, if (buffer.size() * sizeof(buffer[0]) != size_in_bytes) { // This is not always correct: the sizes are computed using the values in NITFSegmentInfo/Data - // but we may be working with other data. This is the case when we have std::complex + // but we may be working with other data. This is the case when we have six::zfloat // data that will be converted to AMP8I_PHS8I when written to disk. //throw std::invalid_argument("buffer.size()!"); } } @@ -197,7 +197,7 @@ struct NewMemoryWriteHandler::Impl final // This needs to persist beyhond the constructor std::vector> ampi8i_phs8i; - void convertPixels(NewMemoryWriteHandler& instance, const NITFSegmentInfo& info, std::span> buffer, const Data& data) + void convertPixels(NewMemoryWriteHandler& instance, const NITFSegmentInfo& info, std::span buffer, const Data& data) { ampi8i_phs8i.resize(buffer.size()); const std::span> ampi8i_phs8i_(ampi8i_phs8i.data(), ampi8i_phs8i.size()); @@ -252,19 +252,19 @@ NewMemoryWriteHandler::NewMemoryWriteHandler(const NITFSegmentInfo& info, if (data.getPixelType() == six::PixelType::AMP8I_PHS8I) { - // Assume that buffer is really std::complex. If it is something else + // Assume that buffer is really six::zfloat. If it is something else // (e.g., std::pair -- already converted) a different // overload should be used. Since we've lost the actual buffer type, // there not much else to do except hope for the best. const void* pBuffer_ = buffer.data(); - const auto pBuffer = static_cast*>(pBuffer_); - const std::span> buffer_(pBuffer, buffer.size() / sizeof(std::complex)); + const auto pBuffer = static_cast(pBuffer_); + const std::span buffer_(pBuffer, buffer.size() / sizeof(six::zfloat)); m_pImpl->convertPixels(*this, info, buffer_, data); } } NewMemoryWriteHandler::NewMemoryWriteHandler(const NITFSegmentInfo& info, - std::span> buffer, size_t firstRow, const Data& data, bool doByteSwap) + std::span buffer, size_t firstRow, const Data& data, bool doByteSwap) : NewMemoryWriteHandler(info, cast(buffer), firstRow, data, doByteSwap) { if (data.getPixelType() == six::PixelType::AMP8I_PHS8I) @@ -285,7 +285,7 @@ NewMemoryWriteHandler::NewMemoryWriteHandler(const NITFSegmentInfo& info, std::span> buffer, size_t firstRow, const Data& data, bool doByteSwap) : NewMemoryWriteHandler(info, cast(buffer), firstRow, data, doByteSwap) { - // This is for the uncommon case where the data is already in this format; normally, it is std::complex. + // This is for the uncommon case where the data is already in this format; normally, it is six::zfloat. if (data.getPixelType() != six::PixelType::AMP8I_PHS8I) { throw std::invalid_argument("pixelType is wrong."); @@ -294,7 +294,7 @@ NewMemoryWriteHandler::NewMemoryWriteHandler(const NITFSegmentInfo& info, } NewMemoryWriteHandler::NewMemoryWriteHandler(const NITFSegmentInfo& info, - std::span> buffer, size_t firstRow, const Data& data, bool doByteSwap) + std::span buffer, size_t firstRow, const Data& data, bool doByteSwap) : NewMemoryWriteHandler(info, cast(buffer), firstRow, data, doByteSwap) { // Each pixel is stored as a pair of numbers that represent the real and imaginary diff --git a/six/modules/c++/six/source/NITFWriteControl.cpp b/six/modules/c++/six/source/NITFWriteControl.cpp index b4557d9423..d96406281d 100644 --- a/six/modules/c++/six/source/NITFWriteControl.cpp +++ b/six/modules/c++/six/source/NITFWriteControl.cpp @@ -209,7 +209,7 @@ static auto asBytes(BufferList::value_type pImageData, // At this point, we've lost information about the ACTUAL size of the buffer. Normally, the computation above will be correct. // But in the case of AMP8I_PHS8I (now supported), the buffer is actually RE32F_IM32F as the data is converted to - // std::complex when read-in, and converted to std::pair when written-out. + // six::zfloat when read-in, and converted to std::pair when written-out. if (data.getPixelType() == six::PixelType::AMP8I_PHS8I) { size_in_bytes *= sizeof(float); @@ -518,13 +518,13 @@ static std::vector convert_paths( const std::vector> imageData, +void NITFWriteControl::save_image(std::span imageData, nitf::IOInterface& outputFile, const std::vector& schemaPaths) { do_save(imageData, outputFile, convert_paths(schemaPaths)); } -void NITFWriteControl::save_image(std::span> imageData, +void NITFWriteControl::save_image(std::span imageData, nitf::IOInterface& outputFile, const std::vector& schemaPaths) { @@ -548,7 +548,7 @@ void NITFWriteControl::save(const BufferList& list, const std::string& outputFil save_buffer_list_to_file(list, outputFile, schemaPaths); } -void save(NITFWriteControl& writeControl, const std::complex* image, const std::string& outputFile, const std::vector& schemaPaths) +void save(NITFWriteControl& writeControl, const six::zfloat* image, const std::string& outputFile, const std::vector& schemaPaths) { // Keeping this code-path in place as it's an easy way to test legacy BufferList functionality. const void* pImage = image; diff --git a/six/modules/c++/six/source/SICommonXMLParser.cpp b/six/modules/c++/six/source/SICommonXMLParser.cpp index 023bb32cfa..93ef38b68f 100644 --- a/six/modules/c++/six/source/SICommonXMLParser.cpp +++ b/six/modules/c++/six/source/SICommonXMLParser.cpp @@ -423,7 +423,7 @@ XMLElem SICommonXMLParser::createPoly2D(const std::string& name, XMLElem SICommonXMLParser::createComplex(const std::string& name, - std::complex c, XMLElem parent) const + six::zdouble c, XMLElem parent) const { XMLElem e = newElement(name, getDefaultURI(), parent); createDouble("Real", getSICommonURI(), c.real(), e); diff --git a/six/modules/c++/six/source/XMLParser.cpp b/six/modules/c++/six/source/XMLParser.cpp index 43b11596f0..d71c88a216 100644 --- a/six/modules/c++/six/source/XMLParser.cpp +++ b/six/modules/c++/six/source/XMLParser.cpp @@ -232,7 +232,7 @@ bool XMLParser::parseOptionalDouble(const xml::lite::Element* parent, const std: return mXmlLite.parseOptionalDouble(*parent, tag, value); } -void XMLParser::parseComplex(const xml::lite::Element* element, std::complex& value) const +void XMLParser::parseComplex(const xml::lite::Element* element, six::zdouble& value) const { assert(element != nullptr); mXmlLite.parseComplex(*element, value); diff --git a/six/modules/c++/six/source/XmlLite.cpp b/six/modules/c++/six/source/XmlLite.cpp index 6030c31858..1bd0bd1f39 100644 --- a/six/modules/c++/six/source/XmlLite.cpp +++ b/six/modules/c++/six/source/XmlLite.cpp @@ -401,14 +401,14 @@ bool XmlLite::parseOptionalDouble(const xml::lite::Element& parent, const std::s return false; } -void XmlLite::parseComplex(const xml::lite::Element& element, std::complex& value) const +void XmlLite::parseComplex(const xml::lite::Element& element, six::zdouble& value) const { double r, i; parseDouble(getFirstAndOnly(element, "Real"), r); parseDouble(getFirstAndOnly(element, "Imag"), i); - value = std::complex(r, i); + value = six::zdouble(r, i); } void XmlLite::parseString(const xml::lite::Element& element, std::string& value) const