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