diff --git a/.github/license_header.txt b/.github/license_header.txt
new file mode 100644
index 0000000..7719530
--- /dev/null
+++ b/.github/license_header.txt
@@ -0,0 +1,3 @@
+Copyright (C) 2024 Analog Devices, Inc.
+
+SPDX short identifier: ADIBSD OR GPL-2.0-or-later
diff --git a/.github/workflows/.pre-commit-config.yaml b/.github/workflows/.pre-commit-config.yaml
deleted file mode 100644
index 2e5f622..0000000
--- a/.github/workflows/.pre-commit-config.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-repos:
-- repo: https://github.com/Lucas-C/pre-commit-hooks
- rev: v1.5.1
- hooks:
- - id: insert-license
- files: bindings\/python\/genalyzer\/.*\.py$
- args:
- - --license-filepath
- - .github/license_header.txt
- - --use-current-year
- - --no-extra-eol
- - --detect-license-in-X-top-lines=3
\ No newline at end of file
diff --git a/.github/workflows/license_header.txt b/.github/workflows/license_header.txt
deleted file mode 100644
index f3eb502..0000000
--- a/.github/workflows/license_header.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Copyright (C) 2024 Analog Devices, Inc.
-
-SPDX short identifier: ADIBSD
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..9f85750
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,33 @@
+repos:
+- repo: https://github.com/Lucas-C/pre-commit-hooks
+ rev: v1.5.1
+ hooks:
+ - id: insert-license
+ files: bindings\/python\/genalyzer\/.*\.py$
+ args:
+ - --license-filepath
+ - .github/license_header.txt
+ - --use-current-year
+ - --no-extra-eol
+ - --detect-license-in-X-top-lines=3
+ - id: insert-license
+ files: ^(?!tests\/|examples\/).*\.((hpp|h|cpp|c))$
+ args:
+ - --comment-style
+ - //
+ - --license-filepath
+ - .github/license_header.txt
+ - --use-current-year
+ - --no-extra-eol
+ - --detect-license-in-X-top-lines=3
+- repo: https://github.com/cmake-lint/cmake-lint
+ rev: 1.4.3
+ hooks:
+ - id: cmakelint
+ args:
+ - --linelength=200
+ - --filter=-readability/mixedcase,-package/consistency
+- repo: https://github.com/pre-commit/mirrors-clang-format
+ rev: v19.1.5
+ hooks:
+ - id: clang-format
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0cc5f6..f5645b2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,7 +74,7 @@ if(BUILD_TESTS_EXAMPLES)
# Add custom target to run tests with coverage
add_custom_target(
coverage
- COMMAND ${CMAKE_CTEST_COMMAND} --progress && lcov -c -d bindings/c/src -o main_coverage.info && genhtml main_coverage.info -o coverage
+ COMMAND ${CMAKE_CTEST_COMMAND} --progress && lcov -c -d bindings/c/src -o main_coverage.info && genhtml main_coverage.info -o coverage
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
message(STATUS "Coverage flags enabled")
diff --git a/bindings/c/include/cgenalyzer.h b/bindings/c/include/cgenalyzer.h
index 4881829..036941f 100644
--- a/bindings/c/include/cgenalyzer.h
+++ b/bindings/c/include/cgenalyzer.h
@@ -1,24 +1,6 @@
-/*
- * cgenalyzer - genalyzer API header file
- *
- * Copyright (C) 2022 Analog Devices, Inc.
- * Author: Peter Derounian
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * */
-
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef CGENALYZER_H
#define CGENALYZER_H
@@ -30,10 +12,11 @@
/**
* \mainpage Genalyzer Library API Documentation
* \section Overview
- * The Genalyzer Library provides analysis routines for data converter testing. The
- * library contains routines that analyze waveforms, FFTs, and the output of the traditional code
- * density tests: histogram, DNL, and INL. In addition, the library provides basic signal
- * generation and processing utilties.
+ * The Genalyzer Library provides analysis routines for data converter testing.
+ * The library contains routines that analyze waveforms, FFTs, and the output
+ * of the traditional code density tests: histogram, DNL, and INL. In
+ * addition, the library provides basic signal generation and processing
+ * utilties.
* \section AnalysisRoutines Analysis Routines
* The library provides the following types of analysis:
* \li \ref gn_dnl_analysis "DNL Analysis"
@@ -41,121 +24,134 @@
* \li \ref gn_hist_analysis "Histogram Analysis"
* \li \ref gn_inl_analysis "INL Analysis"
* \li \ref gn_wf_analysis "Waveform Analysis"
- *
- * Each analysis routine returns results by filling a Keys array (rkeys) and a corresponding Values
- * array (rvalues). Together, rkeys and rvalues represent a set of key-value result pairs:
- * rkeys[0] corresponds to rvalues[0], rkeys[1] to rvalues[1], and so on.
+ *
+ * Each analysis routine returns results by filling a Keys array (rkeys) and a
+ * corresponding Values array (rvalues). Together, rkeys and rvalues represent
+ * a set of key-value result pairs: rkeys[0] corresponds to rvalues[0],
+ * rkeys[1] to rvalues[1], and so on.
*/
/* Enumerations */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup Enumerations Enumerations
- * @{
- */
+ /**
+ * \defgroup Enumerations Enumerations
+ * @{
+ */
-/**
- * @brief GnAnalysisType enumerates analysis types
- */
-typedef enum GnAnalysisType {
- GnAnalysisTypeDNL, ///< DNL (differential nonlinearity)
- GnAnalysisTypeFourier, ///< Fourier (FFT)
- GnAnalysisTypeHistogram, ///< Histogram
- GnAnalysisTypeINL, ///< INL (integral nonlinearity)
- GnAnalysisTypeWaveform ///< Waveform
- } GnAnalysisType;
+ /**
+ * @brief GnAnalysisType enumerates analysis types
+ */
+ typedef enum GnAnalysisType
+ {
+ GnAnalysisTypeDNL, ///< DNL (differential nonlinearity)
+ GnAnalysisTypeFourier, ///< Fourier (FFT)
+ GnAnalysisTypeHistogram, ///< Histogram
+ GnAnalysisTypeINL, ///< INL (integral nonlinearity)
+ GnAnalysisTypeWaveform ///< Waveform
+ } GnAnalysisType;
-/**
- * @brief GnCodeFormat enumerates binary code formats
- */
-typedef enum GnCodeFormat {
- GnCodeFormatOffsetBinary, ///< Offset Binary
- GnCodeFormatTwosComplement ///< Two's Complement
- } GnCodeFormat;
+ /**
+ * @brief GnCodeFormat enumerates binary code formats
+ */
+ typedef enum GnCodeFormat
+ {
+ GnCodeFormatOffsetBinary, ///< Offset Binary
+ GnCodeFormatTwosComplement ///< Two's Complement
+ } GnCodeFormat;
-/**
- * @brief GnDnlSignal enumerates signal types for which DNL can be computed
- */
-typedef enum GnDnlSignal {
- GnDnlSignalRamp, ///< Ramp
- GnDnlSignalTone ///< Tone (Sinusoid)
- } GnDnlSignal;
+ /**
+ * @brief GnDnlSignal enumerates signal types for which DNL can be computed
+ */
+ typedef enum GnDnlSignal
+ {
+ GnDnlSignalRamp, ///< Ramp
+ GnDnlSignalTone ///< Tone (Sinusoid)
+ } GnDnlSignal;
-/**
- * @brief GnFACompTag enumerates Fourier analysis component tags
- */
-typedef enum GnFACompTag {
- GnFACompTagDC, ///< DC component (always Bin 0)
- GnFACompTagSignal, ///< Signal component
- GnFACompTagHD, ///< Harmonic distortion
- GnFACompTagIMD, ///< Intermodulation distortion
- GnFACompTagILOS, ///< Interleaving offset component
- GnFACompTagILGT, ///< Interleaving gain/timing/BW component
- GnFACompTagCLK, ///< Clock component
- GnFACompTagUserDist, ///< User-designated distortion
- GnFACompTagNoise ///< Noise component (e.g. WorstOther)
- } GnFACompTag;
+ /**
+ * @brief GnFACompTag enumerates Fourier analysis component tags
+ */
+ typedef enum GnFACompTag
+ {
+ GnFACompTagDC, ///< DC component (always Bin 0)
+ GnFACompTagSignal, ///< Signal component
+ GnFACompTagHD, ///< Harmonic distortion
+ GnFACompTagIMD, ///< Intermodulation distortion
+ GnFACompTagILOS, ///< Interleaving offset component
+ GnFACompTagILGT, ///< Interleaving gain/timing/BW component
+ GnFACompTagCLK, ///< Clock component
+ GnFACompTagUserDist, ///< User-designated distortion
+ GnFACompTagNoise ///< Noise component (e.g. WorstOther)
+ } GnFACompTag;
-/**
- * @brief GnFASsb enumerates the component categories for which the number of single side bins
- * (SSB) can be set
- */
-typedef enum GnFASsb {
- GnFASsbDefault, ///< Default SSB (applies to auto-generated components)
- GnFASsbDC, ///< SSB for DC component
- GnFASsbSignal, ///< SSB for Signal components
- GnFASsbWO, ///< SSB for WorstOther components
- } GnFASsb;
+ /**
+ * @brief GnFASsb enumerates the component categories for which the number of
+ * single side bins (SSB) can be set
+ */
+ typedef enum GnFASsb
+ {
+ GnFASsbDefault, ///< Default SSB (applies to auto-generated components)
+ GnFASsbDC, ///< SSB for DC component
+ GnFASsbSignal, ///< SSB for Signal components
+ GnFASsbWO, ///< SSB for WorstOther components
+ } GnFASsb;
-/**
- * @brief GnFreqAxisFormat enumerates frequency axis formats
- */
-typedef enum GnFreqAxisFormat {
- GnFreqAxisFormatBins, ///< Bins
- GnFreqAxisFormatFreq, ///< Frequency
- GnFreqAxisFormatNorm ///< Normalized
- } GnFreqAxisFormat;
+ /**
+ * @brief GnFreqAxisFormat enumerates frequency axis formats
+ */
+ typedef enum GnFreqAxisFormat
+ {
+ GnFreqAxisFormatBins, ///< Bins
+ GnFreqAxisFormatFreq, ///< Frequency
+ GnFreqAxisFormatNorm ///< Normalized
+ } GnFreqAxisFormat;
-/**
- * @brief GnFreqAxisType enumerates frequency axis types
- */
-typedef enum GnFreqAxisType {
- GnFreqAxisTypeDcCenter, ///< DC centered, e.g. [-fs/2, fs/2) (complex FFT only)
- GnFreqAxisTypeDcLeft, ///< DC on left, e.g. [0, fs) (complex FFT only)
- GnFreqAxisTypeReal ///< Real axis, e.g. [0, fs/2] (real FFT only)
- } GnFreqAxisType;
+ /**
+ * @brief GnFreqAxisType enumerates frequency axis types
+ */
+ typedef enum GnFreqAxisType
+ {
+ GnFreqAxisTypeDcCenter, ///< DC centered, e.g. [-fs/2, fs/2) (complex FFT
+ ///< only)
+ GnFreqAxisTypeDcLeft, ///< DC on left, e.g. [0, fs) (complex FFT only)
+ GnFreqAxisTypeReal ///< Real axis, e.g. [0, fs/2] (real FFT only)
+ } GnFreqAxisType;
-/**
- * @brief GnInlLineFit enumerates INL line fitting options
- */
-typedef enum GnInlLineFit {
- GnInlLineFitBestFit, ///< Best fit
- GnInlLineFitEndFit, ///< End fit
- GnInlLineFitNoFit ///< No fit
- } GnInlLineFit;
+ /**
+ * @brief GnInlLineFit enumerates INL line fitting options
+ */
+ typedef enum GnInlLineFit
+ {
+ GnInlLineFitBestFit, ///< Best fit
+ GnInlLineFitEndFit, ///< End fit
+ GnInlLineFitNoFit ///< No fit
+ } GnInlLineFit;
-/**
- * @brief GnRfftScale enumerates real FFT scaling options
- */
-typedef enum GnRfftScale {
- GnRfftScaleDbfsDc, ///< Full-scale sinusoid measures -3 dBFS
- GnRfftScaleDbfsSin, ///< Full-scale sinusoid measures 0 dBFS
- GnRfftScaleNative ///< Full-scale sinusoid measures -6 dBFS
- } GnRfftScale;
+ /**
+ * @brief GnRfftScale enumerates real FFT scaling options
+ */
+ typedef enum GnRfftScale
+ {
+ GnRfftScaleDbfsDc, ///< Full-scale sinusoid measures -3 dBFS
+ GnRfftScaleDbfsSin, ///< Full-scale sinusoid measures 0 dBFS
+ GnRfftScaleNative ///< Full-scale sinusoid measures -6 dBFS
+ } GnRfftScale;
-/**
- * @brief GnWindow enumerates window functions
- */
-typedef enum GnWindow {
- GnWindowBlackmanHarris, ///< Blackman-Harris
- GnWindowHann, ///< Hann ("Hanning")
- GnWindowNoWindow ///< No window (Rectangular)
- } GnWindow;
+ /**
+ * @brief GnWindow enumerates window functions
+ */
+ typedef enum GnWindow
+ {
+ GnWindowBlackmanHarris, ///< Blackman-Harris
+ GnWindowHann, ///< Hann ("Hanning")
+ GnWindowNoWindow ///< No window (Rectangular)
+ } GnWindow;
-/** @} Enumerations */
+ /** @} Enumerations */
#ifdef __cplusplus
} // extern "C"
@@ -163,14 +159,15 @@ typedef enum GnWindow {
/* API Utilities */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
#ifdef _WIN32
#ifdef GENALYZER_EXPORTS
-#define __api __declspec(dllexport)
+#define __api __declspec (dllexport)
#else
-#define __api __declspec(dllimport)
+#define __api __declspec (dllimport)
#endif
#elif __GNUC__ >= 4 && !defined(MATLAB_MEX_FILE) \
&& !defined(MATLAB_LOADLIBRARY)
@@ -179,115 +176,118 @@ extern "C" {
#define __api
#endif
-/**
- * \defgroup APIUtilities API Utilities
- * @{
- */
+ /**
+ * \defgroup APIUtilities API Utilities
+ * @{
+ */
-/**
- * @brief gn_analysis_results_key_sizes
- * @return 0 on success, non-zero otherwise
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the key sizes. See \ref gn_set_string_termination.
- */
-__api int gn_analysis_results_key_sizes(
- size_t* key_sizes, ///< [out] Key size array pointer
- size_t key_sizes_size, ///< [in] Key size array size
- GnAnalysisType type ///< [in] Analysis type
- );
+ /**
+ * @brief gn_analysis_results_key_sizes
+ * @return 0 on success, non-zero otherwise
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the key sizes. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_analysis_results_key_sizes (
+ size_t *key_sizes, ///< [out] Key size array pointer
+ size_t key_sizes_size, ///< [in] Key size array size
+ GnAnalysisType type ///< [in] Analysis type
+ );
-/**
- * @brief gn_analysis_results_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_analysis_results_size(
- size_t* size, ///< [out] Number of key-value result pairs
- GnAnalysisType type ///< [in] Analysis type
- );
+ /**
+ * @brief gn_analysis_results_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_analysis_results_size (
+ size_t *size, ///< [out] Number of key-value result pairs
+ GnAnalysisType type ///< [in] Analysis type
+ );
-/**
- * @brief gn_enum_value
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_enum_value(
- int* value, ///< [out] Underlying value of enumeration::enumerator
- const char* enumeration, ///< [in] Enumeration name
- const char* enumerator ///< [in] Enumerator name
- );
+ /**
+ * @brief gn_enum_value
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_enum_value (
+ int *value, ///< [out] Underlying value of enumeration::enumerator
+ const char *enumeration, ///< [in] Enumeration name
+ const char *enumerator ///< [in] Enumerator name
+ );
-/**
- * @brief gn_error_check
- * @return Always returns 0
- */
-__api int gn_error_check(
- bool* error ///< [out] true if an error has occurred; false otherwise
-);
+ /**
+ * @brief gn_error_check
+ * @return Always returns 0
+ */
+ __api int gn_error_check (
+ bool *error ///< [out] true if an error has occurred; false otherwise
+ );
-/**
- * @brief gn_error_clear
- * @return Always returns 0
- */
-__api int gn_error_clear();
+ /**
+ * @brief gn_error_clear
+ * @return Always returns 0
+ */
+ __api int gn_error_clear ();
-/**
- * @brief gn_error_string
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_error_string(
- char* buf, ///< [out] Pointer to character array
- size_t size ///< [in] Size of character array
- );
+ /**
+ * @brief gn_error_string
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_error_string (char *buf, ///< [out] Pointer to character array
+ size_t size ///< [in] Size of character array
+ );
-/**
- * @brief gn_set_string_termination
- * @return Always returns 0
- * @details Some functions in this library return strings by filling character buffers (arrays)
- * provided by the caller. This function sets a global library setting that determines whether or
- * not strings should be null-terminated. If set to true, functions that return strings will
- * write a '\0' as the last character. In addition, functions that return the size of a string
- * will include the null terminator in the size.
- */
-__api int gn_set_string_termination(
- bool null_terminated ///< [in] If true, strings are terminated with '\0'
-);
+ /**
+ * @brief gn_set_string_termination
+ * @return Always returns 0
+ * @details Some functions in this library return strings by filling
+ * character buffers (arrays) provided by the caller. This function sets a
+ * global library setting that determines whether or not strings should be
+ * null-terminated. If set to true, functions that return strings will write
+ * a '\0' as the last character. In addition, functions that return the size
+ * of a string will include the null terminator in the size.
+ */
+ __api int gn_set_string_termination (
+ bool null_terminated ///< [in] If true, strings are terminated with '\0'
+ );
-/**
- * @brief gn_version_string
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_version_string(
- char* buf, ///< [in,out] Pointer to character array
- size_t size ///< [in] Size of character array
- );
+ /**
+ * @brief gn_version_string
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_version_string (char *buf, ///< [in,out] Pointer to character array
+ size_t size ///< [in] Size of character array
+ );
-/**
- * \defgroup APIUtilityHelpers Helpers
- * @{
- */
+ /**
+ * \defgroup APIUtilityHelpers Helpers
+ * @{
+ */
-/**
- * @brief gn_error_string_size
- * @return Always returns 0
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the size. See \ref gn_set_string_termination.
- */
-__api int gn_error_string_size(
- size_t* size ///< [out] Number of characters in error string
-);
+ /**
+ * @brief gn_error_string_size
+ * @return Always returns 0
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the size. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_error_string_size (
+ size_t *size ///< [out] Number of characters in error string
+ );
-/**
- * @brief gn_version_string_size
- * @return Always returns 0
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the size. See \ref gn_set_string_termination.
- */
-__api int gn_version_string_size(
- size_t* size ///< [out] Number of characters in version string
-);
+ /**
+ * @brief gn_version_string_size
+ * @return Always returns 0
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the size. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_version_string_size (
+ size_t *size ///< [out] Number of characters in version string
+ );
-/** @} APIUtilityHelpers */
+ /** @} APIUtilityHelpers */
-/** @} APIUtilities */
+ /** @} APIUtilities */
#ifdef __cplusplus
} // extern "C"
@@ -295,81 +295,76 @@ __api int gn_version_string_size(
/* Array Operations */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup ArrayOperations Array Operations
- * @{
- */
+ /**
+ * \defgroup ArrayOperations Array Operations
+ * @{
+ */
-/**
- * @brief gn_abs
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_abs(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_abs
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_abs (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size ///< [in] Input array size
+ );
-/**
- * @brief gn_angle
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_angle(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_angle
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_angle (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size ///< [in] Input array size
+ );
-/**
- * @brief gn_db
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_db(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_db
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_db (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size ///< [in] Input array size
+ );
-/**
- * @brief gn_db10
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_db10(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_db10
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_db10 (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size ///< [in] Input array size
+ );
-/**
- * @brief gn_db20
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_db20(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_db20
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_db20 (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size ///< [in] Input array size
+ );
-/**
- * @brief gn_norm
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_norm(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_norm
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_norm (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size ///< [in] Input array size
+ );
-/** @} ArrayOperations */
+ /** @} ArrayOperations */
#ifdef __cplusplus
} // extern "C"
@@ -377,243 +372,244 @@ __api int gn_norm(
/* Code Density */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup CodeDensity Code Density
- * @{
- */
+ /**
+ * \defgroup CodeDensity Code Density
+ * @{
+ */
-/**
- * @brief gn_code_axis
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_code_axis(
- double* out, ///< [out] Array pointer
- size_t size, ///< [in] Array size
- int n, ///< [in] Resolution
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_code_axis
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_code_axis (double *out, ///< [out] Array pointer
+ size_t size, ///< [in] Array size
+ int n, ///< [in] Resolution
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_code_axisx
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_code_axisx(
- double* out, ///< [out] Array pointer
- size_t size, ///< [in] Array size
- int64_t min, ///< [in] Min code
- int64_t max ///< [in] Max code
- );
+ /**
+ * @brief gn_code_axisx
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_code_axisx (double *out, ///< [out] Array pointer
+ size_t size, ///< [in] Array size
+ int64_t min, ///< [in] Min code
+ int64_t max ///< [in] Max code
+ );
-/**
- * @brief gn_dnl
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_dnl(
- double* dnl, ///< [out] Output array pointer
- size_t dnl_size, ///< [in] Output array size
- const uint64_t* hist, ///< [in] Input array pointer
- size_t hist_size, ///< [in] Input array size
- GnDnlSignal type ///< [in] Signal type
- );
+ /**
+ * @brief gn_dnl
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_dnl (double *dnl, ///< [out] Output array pointer
+ size_t dnl_size, ///< [in] Output array size
+ const uint64_t *hist, ///< [in] Input array pointer
+ size_t hist_size, ///< [in] Input array size
+ GnDnlSignal type ///< [in] Signal type
+ );
-/**
- * @brief gn_dnl_analysis
- * @return 0 on success, non-zero otherwise
- * @details The results contain the following key-value pairs (see general description of
- * \ref AnalysisRoutines "Analysis Routines").
- *
- * Key | Description
- * |
---|
min | Minumum value
- * |
max | Maximum value
- * |
avg | Average value
- * |
rms | RMS value
- * |
min_index | Index of first occurence of minimum value
- * |
max_index | Index of first occurence of maximum value
- * |
first_nm_index | Index of first non-missing code
- * |
last_nm_index | Index of last non-missing code
- * |
nm_range | Non-missing code range (1 + (last_nm_index - first_nm_index))
- * |
- */
-__api int gn_dnl_analysis(
- char** rkeys, ///< [out] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const double* dnl, ///< [in] Input array pointer
- size_t dnl_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_dnl_analysis
+ * @return 0 on success, non-zero otherwise
+ * @details The results contain the following key-value pairs (see general
+ * description of
+ * \ref AnalysisRoutines "Analysis Routines").
+ *
+ * Key | Description
+ * |
---|
min | Minumum value
+ * |
max | Maximum value
+ * |
avg | Average value
+ * |
rms | RMS value
+ * |
min_index | Index of first occurence of minimum value
+ * |
max_index | Index of first occurence of maximum value
+ * |
first_nm_index | Index of first non-missing code
+ * |
last_nm_index | Index of last non-missing code
+ * |
nm_range | Non-missing code range (1 + (last_nm_index
+ * - first_nm_index))
+ * |
+ */
+ __api int
+ gn_dnl_analysis (char **rkeys, ///< [out] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const double *dnl, ///< [in] Input array pointer
+ size_t dnl_size ///< [in] Input array size
+ );
-/**
- * @brief gn_hist16
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_hist16(
- uint64_t* hist, ///< [out] Histogram array pointer
- size_t hist_size, ///< [in] Histogram array size
- const int16_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Code width (i.e. ADC resolution)
- GnCodeFormat format, ///< [in] Code format
- bool preserve ///< [in] If true, hist is not cleared before computing the histogram
- );
+ /**
+ * @brief gn_hist16
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_hist16 (uint64_t *hist, ///< [out] Histogram array pointer
+ size_t hist_size, ///< [in] Histogram array size
+ const int16_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Code width (i.e. ADC resolution)
+ GnCodeFormat format, ///< [in] Code format
+ bool preserve ///< [in] If true, hist is not cleared
+ ///< before computing the histogram
+ );
-/**
- * @brief gn_hist32
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_hist32(
- uint64_t* hist, ///< [out] Histogram array pointer
- size_t hist_size, ///< [in] Histogram array size
- const int32_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Code width (i.e. ADC resolution)
- GnCodeFormat format, ///< [in] Code format
- bool preserve ///< [in] If true, hist is not cleared before computing the histogram
- );
+ /**
+ * @brief gn_hist32
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_hist32 (uint64_t *hist, ///< [out] Histogram array pointer
+ size_t hist_size, ///< [in] Histogram array size
+ const int32_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Code width (i.e. ADC resolution)
+ GnCodeFormat format, ///< [in] Code format
+ bool preserve ///< [in] If true, hist is not cleared
+ ///< before computing the histogram
+ );
-/**
- * @brief gn_hist64
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_hist64(
- uint64_t* hist, ///< [out] Histogram array pointer
- size_t hist_size, ///< [in] Histogram array size
- const int64_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Code width (i.e. ADC resolution)
- GnCodeFormat format, ///< [in] Code format
- bool preserve ///< [in] If true, hist is not cleared before computing the histogram
- );
+ /**
+ * @brief gn_hist64
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_hist64 (uint64_t *hist, ///< [out] Histogram array pointer
+ size_t hist_size, ///< [in] Histogram array size
+ const int64_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Code width (i.e. ADC resolution)
+ GnCodeFormat format, ///< [in] Code format
+ bool preserve ///< [in] If true, hist is not cleared
+ ///< before computing the histogram
+ );
-/**
- * @brief gn_histx16
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_histx16(
- uint64_t* hist, ///< [out] Histogram array pointer
- size_t hist_size, ///< [in] Histogram array size
- const int16_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int64_t min, ///< [in] Min code
- int64_t max, ///< [in] Max code
- bool preserve ///< [in] If true, hist is not cleared before computing the histogram
- );
+ /**
+ * @brief gn_histx16
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_histx16 (uint64_t *hist, ///< [out] Histogram array pointer
+ size_t hist_size, ///< [in] Histogram array size
+ const int16_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int64_t min, ///< [in] Min code
+ int64_t max, ///< [in] Max code
+ bool preserve ///< [in] If true, hist is not cleared
+ ///< before computing the histogram
+ );
-/**
- * @brief gn_histx32
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_histx32(
- uint64_t* hist, ///< [out] Histogram array pointer
- size_t hist_size, ///< [in] Histogram array size
- const int32_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int64_t min, ///< [in] Min code
- int64_t max, ///< [in] Max code
- bool preserve ///< [in] If true, hist is not cleared before computing the histogram
- );
+ /**
+ * @brief gn_histx32
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_histx32 (uint64_t *hist, ///< [out] Histogram array pointer
+ size_t hist_size, ///< [in] Histogram array size
+ const int32_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int64_t min, ///< [in] Min code
+ int64_t max, ///< [in] Max code
+ bool preserve ///< [in] If true, hist is not cleared
+ ///< before computing the histogram
+ );
-/**
- * @brief gn_histx64
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_histx64(
- uint64_t* hist, ///< [out] Histogram array pointer
- size_t hist_size, ///< [in] Histogram array size
- const int64_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int64_t min, ///< [in] Min code
- int64_t max, ///< [in] Max code
- bool preserve ///< [in] If true, hist is not cleared before computing the histogram
- );
+ /**
+ * @brief gn_histx64
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_histx64 (uint64_t *hist, ///< [out] Histogram array pointer
+ size_t hist_size, ///< [in] Histogram array size
+ const int64_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int64_t min, ///< [in] Min code
+ int64_t max, ///< [in] Max code
+ bool preserve ///< [in] If true, hist is not cleared
+ ///< before computing the histogram
+ );
-/**
- * @brief gn_hist_analysis
- * @return 0 on success, non-zero otherwise
- * @details The results contain the following key-value pairs (see general description of
- * \ref AnalysisRoutines "Analysis Routines").
- *
- * Key | Description
- * |
---|
sum | Sum of all histogram bins
- * |
first_nz_index | First non-zero bin
- * |
last_nz_index | Last non-zero bin
- * |
nz_range | Non-zero bin range (1 + (last_nz_index - first_nz_index))
- * |
- */
-__api int gn_hist_analysis(
- char** rkeys, ///< [out] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const uint64_t* hist, ///< [in] Input array pointer
- size_t hist_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_hist_analysis
+ * @return 0 on success, non-zero otherwise
+ * @details The results contain the following key-value pairs (see general
+ * description of
+ * \ref AnalysisRoutines "Analysis Routines").
+ *
+ * Key | Description
+ * |
---|
sum | Sum of all histogram bins
+ * |
first_nz_index | First non-zero bin
+ * |
last_nz_index | Last non-zero bin
+ * |
nz_range | Non-zero bin range (1 + (last_nz_index -
+ * first_nz_index))
+ * |
+ */
+ __api int
+ gn_hist_analysis (char **rkeys, ///< [out] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const uint64_t *hist, ///< [in] Input array pointer
+ size_t hist_size ///< [in] Input array size
+ );
-/**
- * @brief gn_inl
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_inl(
- double* inl, ///< [out] Output array pointer
- size_t inl_size, ///< [in] Output array size
- const double* dnl, ///< [in] Input array pointer
- size_t dnl_size, ///< [in] Input array size
- GnInlLineFit fit ///< [in] Line fit type
- );
+ /**
+ * @brief gn_inl
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_inl (double *inl, ///< [out] Output array pointer
+ size_t inl_size, ///< [in] Output array size
+ const double *dnl, ///< [in] Input array pointer
+ size_t dnl_size, ///< [in] Input array size
+ GnInlLineFit fit ///< [in] Line fit type
+ );
-/**
- * @brief gn_inl_analysis
- * @return 0 on success, non-zero otherwise
- * @details The results contain the following key-value pairs (see general description of
- * \ref AnalysisRoutines "Analysis Routines").
- *
- * Key | Description
- * |
---|
min | Minumum value
- * |
max | Maximum value
- * |
min_index | Index of first occurence of minimum value
- * |
max_index | Index of first occurence of maximum value
- * |
- */
-__api int gn_inl_analysis(
- char** rkeys, ///< [out] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const double* inl, ///< [in] Input array pointer
- size_t inl_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_inl_analysis
+ * @return 0 on success, non-zero otherwise
+ * @details The results contain the following key-value pairs (see general
+ * description of
+ * \ref AnalysisRoutines "Analysis Routines").
+ *
+ * Key | Description
+ * |
---|
min | Minumum value
+ * |
max | Maximum value
+ * |
min_index | Index of first occurence of minimum value
+ * |
max_index | Index of first occurence of maximum value
+ * |
+ */
+ __api int
+ gn_inl_analysis (char **rkeys, ///< [out] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const double *inl, ///< [in] Input array pointer
+ size_t inl_size ///< [in] Input array size
+ );
-/**
- * \defgroup CodeDensityHelpers Helpers
- * @{
- */
+ /**
+ * \defgroup CodeDensityHelpers Helpers
+ * @{
+ */
-/**
- * @brief gn_code_density_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_code_density_size(
- size_t* size, ///< [out] Output array size
- int n, ///< [in] Code width (i.e. ADC resolution)
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_code_density_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_code_density_size (size_t *size, ///< [out] Output array size
+ int n, ///< [in] Code width (i.e. ADC resolution)
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_code_densityx_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_code_densityx_size(
- size_t* size, ///< [out] Output array size
- int64_t min, ///< [in] Min code
- int64_t max ///< [in] Max code
- );
+ /**
+ * @brief gn_code_densityx_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_code_densityx_size (size_t *size, ///< [out] Output array size
+ int64_t min, ///< [in] Min code
+ int64_t max ///< [in] Max code
+ );
-/** @} CodeDensityHelpers */
+ /** @} CodeDensityHelpers */
-/** @} CodeDensity */
+ /** @} CodeDensity */
#ifdef __cplusplus
} // extern "C"
@@ -621,473 +617,468 @@ __api int gn_code_densityx_size(
/* Fourier Analysis */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup FourierAnalysis Fourier Analysis
- * @{
- */
+ /**
+ * \defgroup FourierAnalysis Fourier Analysis
+ * @{
+ */
-/**
- * @brief gn_fft_analysis returns all Fourier analysis results
- * @return 0 on success, non-zero otherwise
- * @details The results contain the following key-value pairs (see general description of
- * \ref AnalysisRoutines "Analysis Routines").
- *
- * Key | Description | Units
- * |
---|
signaltype | Signal type: 0=Real, 1=Complex |
- * |
nfft | FFT size |
- * |
datasize | Data size |
- * |
fbin | Frequency bin size | Hz
- * |
fdata | Data rate | S/s
- * |
fsample | Sample rate | S/s
- * |
fshift | Shift frequency | Hz
- * |
fsnr | Full-scale-to-noise ratio (a.k.a. "SNRFS") | dB
- * |
snr | Signal-to-noise ratio | dB
- * |
sinad | Signal-to-noise-and-distortion ratio | dB
- * |
sfdr | Spurious-free dynamic range | dB
- * |
abn | Average bin noise | dBFS
- * |
nsd | Noise spectral density | dBFS/Hz
- * |
carrierindex | Order index of the Carrier tone |
- * |
maxspurindex | Order index of the MaxSpur tone |
- * |
ab_width | Analysis band width | Hz
- * |
ab_i1 | Analysis band first index |
- * |
ab_i2 | Analysis band last index |
- * |
{PREFIX}_nbins | Number of bins associated with PREFIX |
- * |
{PREFIX}_rss | Root-sum-square associated with PREFIX |
- * |
{TONEKEY}:orderindex | Tone order index |
- * |
{TONEKEY}:freq | Tone frequency | Hz
- * |
{TONEKEY}:ffinal | Tone final frequency | Hz
- * |
{TONEKEY}:fwavg | Tone weighted-average frequency | Hz
- * |
{TONEKEY}:i1 | Tone first index |
- * |
{TONEKEY}:i2 | Tone last index |
- * |
{TONEKEY}:nbins | Tone number of bins |
- * |
{TONEKEY}:inband | 0: tone is in-band; 1: tone is out-of-band |
- * |
{TONEKEY}:mag | Tone magnitude |
- * |
{TONEKEY}:mag_dbfs | Tone magnitude relative to full-scale | dBFS
- * |
{TONEKEY}:mag_dbc | Tone magnitude relative to carrier | dBc
- * |
{TONEKEY}:phase | Tone phase | rad
- * |
{TONEKEY}:phase_c | Tone phase relative to carrier | rad
- * |
- */
-__api int gn_fft_analysis(
- char** rkeys, ///< [out] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const char* cfg_id, ///< [in] Configuration identifier (filename or object key)
- const double* in, ///< [in] Interleaved Re/Im input array pointer
- size_t in_size, ///< [in] Input array size
- size_t nfft, ///< [in] FFT size
- GnFreqAxisType axis_type ///< [in] Frequency axis type
- );
+ /**
+ * @brief gn_fft_analysis returns all Fourier analysis results
+ * @return 0 on success, non-zero otherwise
+ * @details The results contain the following key-value pairs (see general
+ * description of
+ * \ref AnalysisRoutines "Analysis Routines").
+ *
+ * Key | Description | Units |
---|
+ * signaltype | Signal type: 0=Real, 1=Complex | |
+ * nfft | FFT size | |
datasize |
+ * Data size | |
fbin |
+ * Frequency bin size | Hz |
fdata |
+ * Data rate | S/s |
fsample
+ * | Sample rate | S/s |
+ * fshift | Shift frequency | Hz |
fsnr |
+ * Full-scale-to-noise ratio (a.k.a. "SNRFS") | dB |
snr |
+ * Signal-to-noise ratio | dB |
sinad |
+ * Signal-to-noise-and-distortion ratio | dB |
sfdr |
+ * Spurious-free dynamic range | dB |
abn |
+ * Average bin noise | dBFS |
nsd |
+ * Noise spectral density | dBFS/Hz |
+ * carrierindex | Order index of the Carrier tone | |
+ * maxspurindex | Order index of the MaxSpur tone | |
+ * ab_width | Analysis band width | Hz |
ab_i1 |
+ * Analysis band first index | |
ab_i2 |
+ * Analysis band last index | |
{PREFIX}_nbins
+ * | Number of bins associated with PREFIX | |
+ * {PREFIX}_rss | Root-sum-square associated with PREFIX |
+ * |
{TONEKEY}:orderindex | Tone order index | |
+ * {TONEKEY}:freq | Tone frequency | Hz |
{TONEKEY}:ffinal
+ * | Tone final frequency | Hz |
+ * {TONEKEY}:fwavg | Tone weighted-average frequency | Hz |
+ * {TONEKEY}:i1 | Tone first index | |
{TONEKEY}:i2 |
+ * Tone last index | |
+ * {TONEKEY}:nbins | Tone number of bins | |
+ * {TONEKEY}:inband | 0: tone is in-band; 1: tone is out-of-band |
+ * |
{TONEKEY}:mag | Tone magnitude | |
+ * {TONEKEY}:mag_dbfs | Tone magnitude relative to full-scale | dBFS
+ * |
{TONEKEY}:mag_dbc | Tone magnitude relative to carrier
+ * | dBc |
{TONEKEY}:phase | Tone phase | rad |
+ * {TONEKEY}:phase_c | Tone phase relative to carrier | rad
+ * |
+ */
+ __api int gn_fft_analysis (
+ char **rkeys, ///< [out] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const char
+ *cfg_id, ///< [in] Configuration identifier (filename or object key)
+ const double *in, ///< [in] Interleaved Re/Im input array pointer
+ size_t in_size, ///< [in] Input array size
+ size_t nfft, ///< [in] FFT size
+ GnFreqAxisType axis_type ///< [in] Frequency axis type
+ );
-/**
- * @brief gn_fft_analysis_select returns select Fourier analysis results
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fft_analysis_select(
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const char* cfg_id, ///< [in] Configuration identifier (filename or object key)
- const char** rkeys, ///< [in] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- const double* in, ///< [in] Interleaved Re/Im input array pointer
- size_t in_size, ///< [in] Input array size
- size_t nfft, ///< [in] FFT size
- GnFreqAxisType axis_type ///< [in] Frequency axis type
- );
+ /**
+ * @brief gn_fft_analysis_select returns select Fourier analysis results
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fft_analysis_select (
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const char
+ *cfg_id, ///< [in] Configuration identifier (filename or object key)
+ const char **rkeys, ///< [in] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ const double *in, ///< [in] Interleaved Re/Im input array pointer
+ size_t in_size, ///< [in] Input array size
+ size_t nfft, ///< [in] FFT size
+ GnFreqAxisType axis_type ///< [in] Frequency axis type
+ );
-/**
- * @brief gn_fft_analysis_single returns a single Fourier analysis result
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fft_analysis_single(
- double* rvalue, ///< [out] Result value
- const char* cfg_id, ///< [in] Configuration identifier (filename or object key)
- const char* rkey, ///< [in] Result key
- const double* in, ///< [in] Interleaved Re/Im input array pointer
- size_t in_size, ///< [in] Input array size
- size_t nfft, ///< [in] FFT size
- GnFreqAxisType axis_type ///< [in] Frequency axis type
- );
+ /**
+ * @brief gn_fft_analysis_single returns a single Fourier analysis result
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fft_analysis_single (
+ double *rvalue, ///< [out] Result value
+ const char
+ *cfg_id, ///< [in] Configuration identifier (filename or object key)
+ const char *rkey, ///< [in] Result key
+ const double *in, ///< [in] Interleaved Re/Im input array pointer
+ size_t in_size, ///< [in] Input array size
+ size_t nfft, ///< [in] FFT size
+ GnFreqAxisType axis_type ///< [in] Frequency axis type
+ );
-/**
- * \defgroup FourierAnalysisConfiguration Configuration
- * @{
- */
+ /**
+ * \defgroup FourierAnalysisConfiguration Configuration
+ * @{
+ */
-/**
- * @brief gn_fa_analysis_band
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_analysis_band(
- const char* obj_key, ///< [in] Object key
- double center, ///< [in] Analysis band center
- double width ///< [in] Analysis band width
- );
+ /**
+ * @brief gn_fa_analysis_band
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_analysis_band (const char *obj_key, ///< [in] Object key
+ double center, ///< [in] Analysis band center
+ double width ///< [in] Analysis band width
+ );
-/**
- * @brief gn_fa_analysis_band_e
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_analysis_band_e(
- const char* obj_key, ///< [in] Object key
- const char* center, ///< [in] Analysis band center expression
- const char* width ///< [in] Analysis band width expression
- );
+ /**
+ * @brief gn_fa_analysis_band_e
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_analysis_band_e (
+ const char *obj_key, ///< [in] Object key
+ const char *center, ///< [in] Analysis band center expression
+ const char *width ///< [in] Analysis band width expression
+ );
-/**
- * @brief gn_fa_clk
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_clk(
- const char* obj_key, ///< [in] Object key
- const int* clk, ///< [in] Pointer to array of clock divisors
- size_t clk_size, ///< [in] Size of array of clock divisors
- bool as_noise ///< [in] If true, CLK components will be treated as noise
- );
+ /**
+ * @brief gn_fa_clk
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_clk (
+ const char *obj_key, ///< [in] Object key
+ const int *clk, ///< [in] Pointer to array of clock divisors
+ size_t clk_size, ///< [in] Size of array of clock divisors
+ bool as_noise ///< [in] If true, CLK components will be treated as noise
+ );
-/**
- * @brief gn_fa_conv_offset
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_conv_offset(
- const char* obj_key, ///< [in] Object key
- bool enable ///< [in] If true, enable converter offset
- );
+ /**
+ * @brief gn_fa_conv_offset
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fa_conv_offset (const char *obj_key, ///< [in] Object key
+ bool enable ///< [in] If true, enable converter offset
+ );
-/**
- * @brief gn_fa_create
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_create(
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_fa_create
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_create (const char *obj_key ///< [in] Object key
+ );
-/**
- * @brief gn_fa_dc
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_dc(
- const char* obj_key, ///< [in] Object key
- bool as_dist ///< [in] If true, treat DC as distortion
- );
+ /**
+ * @brief gn_fa_dc
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_dc (const char *obj_key, ///< [in] Object key
+ bool as_dist ///< [in] If true, treat DC as distortion
+ );
-/**
- * @brief gn_fa_fdata
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fdata(
- const char* obj_key, ///< [in] Object key
- double f ///< [in] fdata
- );
+ /**
+ * @brief gn_fa_fdata
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_fdata (const char *obj_key, ///< [in] Object key
+ double f ///< [in] fdata
+ );
-/**
- * @brief gn_fa_fdata_e
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fdata_e(
- const char* obj_key, ///< [in] Object key
- const char* f ///< [in] fdata expression
- );
+ /**
+ * @brief gn_fa_fdata_e
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_fdata_e (const char *obj_key, ///< [in] Object key
+ const char *f ///< [in] fdata expression
+ );
-/**
- * @brief gn_fa_fixed_tone
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fixed_tone(
- const char* obj_key, ///< [in] Object key
- const char* comp_key, ///< [in] Component key
- GnFACompTag tag, ///< [in] Tag
- double freq, ///< [in] Frequency
- int ssb ///< [in] Number of single-side bins
- );
+ /**
+ * @brief gn_fa_fixed_tone
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_fixed_tone (const char *obj_key, ///< [in] Object key
+ const char *comp_key, ///< [in] Component key
+ GnFACompTag tag, ///< [in] Tag
+ double freq, ///< [in] Frequency
+ int ssb ///< [in] Number of single-side bins
+ );
-/**
- * @brief gn_fa_fixed_tone_e
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fixed_tone_e(
- const char* obj_key, ///< [in] Object key
- const char* comp_key, ///< [in] Component key
- GnFACompTag tag, ///< [in] Tag
- const char* freq, ///< [in] Frequency expression
- int ssb ///< [in] Number of single-side bins
- );
+ /**
+ * @brief gn_fa_fixed_tone_e
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fa_fixed_tone_e (const char *obj_key, ///< [in] Object key
+ const char *comp_key, ///< [in] Component key
+ GnFACompTag tag, ///< [in] Tag
+ const char *freq, ///< [in] Frequency expression
+ int ssb ///< [in] Number of single-side bins
+ );
-/**
- * @brief gn_fa_fsample
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fsample(
- const char* obj_key, ///< [in] Object key
- double f ///< [in] fsample
- );
+ /**
+ * @brief gn_fa_fsample
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_fsample (const char *obj_key, ///< [in] Object key
+ double f ///< [in] fsample
+ );
-/**
- * @brief gn_fa_fsample_e
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fsample_e(
- const char* obj_key, ///< [in] Object key
- const char* f ///< [in] fsample expression
- );
+ /**
+ * @brief gn_fa_fsample_e
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_fsample_e (const char *obj_key, ///< [in] Object key
+ const char *f ///< [in] fsample expression
+ );
-/**
- * @brief gn_fa_fshift
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fshift(
- const char* obj_key, ///< [in] Object key
- double f ///< [in] fshift
- );
+ /**
+ * @brief gn_fa_fshift
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_fshift (const char *obj_key, ///< [in] Object key
+ double f ///< [in] fshift
+ );
-/**
- * @brief gn_fa_fshift_e
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fshift_e(
- const char* obj_key, ///< [in] Object key
- const char* f ///< [in] fshift expression
- );
+ /**
+ * @brief gn_fa_fshift_e
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_fshift_e (const char *obj_key, ///< [in] Object key
+ const char *f ///< [in] fshift expression
+ );
-/**
- * @brief gn_fa_fund_images
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_fund_images(
- const char* obj_key, ///< [in] Object key
- bool enable ///< [in] If true, enable fundamental images
- );
+ /**
+ * @brief gn_fa_fund_images
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fa_fund_images (const char *obj_key, ///< [in] Object key
+ bool enable ///< [in] If true, enable fundamental images
+ );
-/**
- * @brief gn_fa_hd
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_hd(
- const char* obj_key, ///< [in] Object key
- int n ///< [in] Order of harmonic distortion, i.e., the maximum harmonic
- );
+ /**
+ * @brief gn_fa_hd
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_hd (
+ const char *obj_key, ///< [in] Object key
+ int n ///< [in] Order of harmonic distortion, i.e., the maximum harmonic
+ );
-/**
- * @brief gn_fa_ilv
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_ilv(
- const char* obj_key, ///< [in] Object key
- const int* ilv, ///< [in] Pointer to array of interleaving factors
- size_t ilv_size, ///< [in] Size of array of interleaving factors
- bool as_noise ///< [in] If true, ILV components will be treated as noise
- );
+ /**
+ * @brief gn_fa_ilv
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_ilv (
+ const char *obj_key, ///< [in] Object key
+ const int *ilv, ///< [in] Pointer to array of interleaving factors
+ size_t ilv_size, ///< [in] Size of array of interleaving factors
+ bool as_noise ///< [in] If true, ILV components will be treated as noise
+ );
-/**
- * @brief gn_fa_imd
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_imd(
- const char* obj_key, ///< [in] Object key
- int n ///< [in] Order of intermodulation distortion
- );
+ /**
+ * @brief gn_fa_imd
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_imd (const char *obj_key, ///< [in] Object key
+ int n ///< [in] Order of intermodulation distortion
+ );
-/**
- * @brief gn_fa_load
- * @return 0 on success, non-zero otherwise
- * @details If obj_key is empty, the object key is derived from filename.
- */
-__api int gn_fa_load(
- char* buf, ///< [out] Pointer to character array
- size_t size, ///< [in] Size of character array
- const char* filename, ///< [in] Filename
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_fa_load
+ * @return 0 on success, non-zero otherwise
+ * @details If obj_key is empty, the object key is derived from filename.
+ */
+ __api int gn_fa_load (char *buf, ///< [out] Pointer to character array
+ size_t size, ///< [in] Size of character array
+ const char *filename, ///< [in] Filename
+ const char *obj_key ///< [in] Object key
+ );
-/**
- * @brief gn_fa_max_tone
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_max_tone(
- const char* obj_key, ///< [in] Object key
- const char* comp_key, ///< [in] Component key
- GnFACompTag tag, ///< [in] Tag
- int ssb ///< [in] Number of single-side bins
- );
+ /**
+ * @brief gn_fa_max_tone
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_max_tone (const char *obj_key, ///< [in] Object key
+ const char *comp_key, ///< [in] Component key
+ GnFACompTag tag, ///< [in] Tag
+ int ssb ///< [in] Number of single-side bins
+ );
-/**
- * @brief gn_fa_preview
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_preview(
- char* buf, ///< [out] Pointer to character array
- size_t size, ///< [in] Size of character array
- const char* cfg_id, ///< [in] Configuration identifier (filename or object key)
- bool cplx ///< [in] If true, preview will include complex components
- );
+ /**
+ * @brief gn_fa_preview
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_preview (
+ char *buf, ///< [out] Pointer to character array
+ size_t size, ///< [in] Size of character array
+ const char
+ *cfg_id, ///< [in] Configuration identifier (filename or object key)
+ bool cplx ///< [in] If true, preview will include complex components
+ );
-/**
- * @brief gn_fa_quad_errors
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_quad_errors(
- const char* obj_key, ///< [in] Object key
- bool enable ///< [in] If true, enable quadrature errors
- );
+ /**
+ * @brief gn_fa_quad_errors
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fa_quad_errors (const char *obj_key, ///< [in] Object key
+ bool enable ///< [in] If true, enable quadrature errors
+ );
-/**
- * @brief gn_fa_remove_comp
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_remove_comp(
- const char* obj_key, ///< [in] Object key
- const char* comp_key ///< [in] Component key
- );
+ /**
+ * @brief gn_fa_remove_comp
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_remove_comp (const char *obj_key, ///< [in] Object key
+ const char *comp_key ///< [in] Component key
+ );
-/**
- * @brief gn_fa_reset
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_reset(
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_fa_reset
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_reset (const char *obj_key ///< [in] Object key
+ );
-/**
- * @brief gn_fa_ssb
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_ssb(
- const char* obj_key, ///< [in] Object key
- GnFASsb group, ///< [in] SSB group
- int ssb ///< [in] Number of single-side bins
- );
+ /**
+ * @brief gn_fa_ssb
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_ssb (const char *obj_key, ///< [in] Object key
+ GnFASsb group, ///< [in] SSB group
+ int ssb ///< [in] Number of single-side bins
+ );
-/**
- * @brief gn_fa_var
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_var(
- const char* obj_key, ///< [in] Object key
- const char* name, ///< [in] Variable name
- double value ///< [in] Variable value
- );
+ /**
+ * @brief gn_fa_var
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_var (const char *obj_key, ///< [in] Object key
+ const char *name, ///< [in] Variable name
+ double value ///< [in] Variable value
+ );
-/**
- * @brief gn_fa_wo
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_wo(
- const char* obj_key, ///< [in] Object key
- int n ///< [in] Number of worst others
- );
+ /**
+ * @brief gn_fa_wo
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_wo (const char *obj_key, ///< [in] Object key
+ int n ///< [in] Number of worst others
+ );
-/** @} FourierAnalysisConfiguration */
+ /** @} FourierAnalysisConfiguration */
-/**
- * \defgroup FourierAnalysisResults Results
- * @{
- */
+ /**
+ * \defgroup FourierAnalysisResults Results
+ * @{
+ */
-/**
- * @brief gn_fa_result
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_result(
- double* result, ///< [out] Result associated with rkey
- const char** rkeys, ///< [in] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- const double* rvalues, ///< [in] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const char* rkey ///< [in] Key of desired result
-);
+ /**
+ * @brief gn_fa_result
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fa_result (double *result, ///< [out] Result associated with rkey
+ const char **rkeys, ///< [in] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ const double *rvalues, ///< [in] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const char *rkey ///< [in] Key of desired result
+ );
-/**
- * @brief gn_fa_result_string
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fa_result_string(
- char* result, ///< [out] Result string associated with rkey
- size_t result_size, ///< [in] Size of result string
- const char** rkeys, ///< [in] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- const double* rvalues, ///< [in] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const char* rkey ///< [in] Key of desired result
-);
-
-/** @} FourierAnalysisResults */
+ /**
+ * @brief gn_fa_result_string
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fa_result_string (
+ char *result, ///< [out] Result string associated with rkey
+ size_t result_size, ///< [in] Size of result string
+ const char **rkeys, ///< [in] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ const double *rvalues, ///< [in] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const char *rkey ///< [in] Key of desired result
+ );
+
+ /** @} FourierAnalysisResults */
-/**
- * \defgroup FourierAnalysisHelpers Helpers
- * @{
- */
+ /**
+ * \defgroup FourierAnalysisHelpers Helpers
+ * @{
+ */
-/**
- * @brief gn_fa_load_key_size
- * @return 0 on success, non-zero otherwise
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the size. See \ref gn_set_string_termination.
- */
-__api int gn_fa_load_key_size(
- size_t* size, ///< [out] Number of characters in key
- const char* filename, ///< [in] Filename
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_fa_load_key_size
+ * @return 0 on success, non-zero otherwise
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the size. See \ref
+ * gn_set_string_termination.
+ */
+ __api int
+ gn_fa_load_key_size (size_t *size, ///< [out] Number of characters in key
+ const char *filename, ///< [in] Filename
+ const char *obj_key ///< [in] Object key
+ );
-/**
- * @brief gn_fa_preview_size
- * @return 0 on success, non-zero otherwise
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the size. See \ref gn_set_string_termination.
- */
-__api int gn_fa_preview_size(
- size_t* size, ///< [out] Number of characters in compenent list string
- const char* cfg_id, ///< [in] Configuration identifier (filename or object key)
- bool cplx ///< [in] If true, list will include complex components
- );
+ /**
+ * @brief gn_fa_preview_size
+ * @return 0 on success, non-zero otherwise
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the size. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_fa_preview_size (
+ size_t *size, ///< [out] Number of characters in compenent list string
+ const char
+ *cfg_id, ///< [in] Configuration identifier (filename or object key)
+ bool cplx ///< [in] If true, list will include complex components
+ );
-/**
- * @brief gn_fa_result_string_size
- * @return 0 on success, non-zero otherwise
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the size. See \ref gn_set_string_termination.
- */
-__api int gn_fa_result_string_size(
- size_t* size, ///< [out] Number of characters result string
- const char** rkeys, ///< [in] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- const double* rvalues, ///< [in] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const char* rkey ///< [in] Key of desired result
- );
+ /**
+ * @brief gn_fa_result_string_size
+ * @return 0 on success, non-zero otherwise
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the size. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_fa_result_string_size (
+ size_t *size, ///< [out] Number of characters result string
+ const char **rkeys, ///< [in] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ const double *rvalues, ///< [in] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const char *rkey ///< [in] Key of desired result
+ );
-/**
- * @brief gn_fft_analysis_results_key_sizes
- * @return 0 on success, non-zero otherwise
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the key sizes. See \ref gn_set_string_termination.
- */
-__api int gn_fft_analysis_results_key_sizes(
- size_t* key_sizes, ///< [out] Key size array pointer
- size_t key_sizes_size, ///< [in] Key size array size
- const char* cfg_id, ///< [in] Configuration identifier (filename or object key)
- size_t in_size, ///< [in] Input array size
- size_t nfft ///< [in] FFT size
- );
+ /**
+ * @brief gn_fft_analysis_results_key_sizes
+ * @return 0 on success, non-zero otherwise
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the key sizes. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_fft_analysis_results_key_sizes (
+ size_t *key_sizes, ///< [out] Key size array pointer
+ size_t key_sizes_size, ///< [in] Key size array size
+ const char
+ *cfg_id, ///< [in] Configuration identifier (filename or object key)
+ size_t in_size, ///< [in] Input array size
+ size_t nfft ///< [in] FFT size
+ );
-/**
- * @brief gn_fft_analysis_results_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fft_analysis_results_size(
- size_t* size, ///< [out] Number of key-value result pairs
- const char* cfg_id, ///< [in] Configuration identifier (filename or object key)
- size_t in_size, ///< [in] Input array size
- size_t nfft ///< [in] FFT size
- );
+ /**
+ * @brief gn_fft_analysis_results_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fft_analysis_results_size (
+ size_t *size, ///< [out] Number of key-value result pairs
+ const char
+ *cfg_id, ///< [in] Configuration identifier (filename or object key)
+ size_t in_size, ///< [in] Input array size
+ size_t nfft ///< [in] FFT size
+ );
-/** @} FourierAnalysisHelpers */
+ /** @} FourierAnalysisHelpers */
-/** @} FourierAnalysis */
+ /** @} FourierAnalysis */
#ifdef __cplusplus
} // extern "C"
@@ -1095,182 +1086,181 @@ __api int gn_fft_analysis_results_size(
/* Fourier Transforms */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup FourierTransforms Fourier Transforms
- * @{
- */
+ /**
+ * \defgroup FourierTransforms Fourier Transforms
+ * @{
+ */
/**
- * @brief gn_fft
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fft(
- double* out, ///< [out] Interleaved Re/Im output array pointer
- size_t out_size, ///< [in] Output array size
- const double* i, ///< [in] In-phase input array pointer
- size_t i_size, ///< [in] In-phase input array size
- const double* q, ///< [in] Quadrature input array pointer
- size_t q_size, ///< [in] Quadrature input array size
- size_t navg, ///< [in] FFT averaging number
- size_t nfft, ///< [in] FFT size
- GnWindow window ///< [in] Window
- );
+ * @brief gn_fft
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fft (double *out, ///< [out] Interleaved Re/Im output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *i, ///< [in] In-phase input array pointer
+ size_t i_size, ///< [in] In-phase input array size
+ const double *q, ///< [in] Quadrature input array pointer
+ size_t q_size, ///< [in] Quadrature input array size
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft, ///< [in] FFT size
+ GnWindow window ///< [in] Window
+ );
-/**
- * @brief gn_fft16
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fft16(
- double* out, ///< [out] Interleaved Re/Im output array pointer
- size_t out_size, ///< [in] Output array size
- const int16_t* i, ///< [in] In-phase input array pointer
- size_t i_size, ///< [in] In-phase input array size
- const int16_t* q, ///< [in] Quadrature input array pointer
- size_t q_size, ///< [in] Quadrature input array size
- int n, ///< [in] Resolution
- size_t navg, ///< [in] FFT averaging number
- size_t nfft, ///< [in] FFT size
- GnWindow window, ///< [in] Window
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_fft16
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fft16 (double *out, ///< [out] Interleaved Re/Im output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int16_t *i, ///< [in] In-phase input array pointer
+ size_t i_size, ///< [in] In-phase input array size
+ const int16_t *q, ///< [in] Quadrature input array pointer
+ size_t q_size, ///< [in] Quadrature input array size
+ int n, ///< [in] Resolution
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft, ///< [in] FFT size
+ GnWindow window, ///< [in] Window
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_fft32
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fft32(
- double* out, ///< [out] Interleaved Re/Im output array pointer
- size_t out_size, ///< [in] Output array size
- const int32_t* i, ///< [in] In-phase input array pointer
- size_t i_size, ///< [in] In-phase input array size
- const int32_t* q, ///< [in] Quadrature input array pointer
- size_t q_size, ///< [in] Quadrature input array size
- int n, ///< [in] Resolution
- size_t navg, ///< [in] FFT averaging number
- size_t nfft, ///< [in] FFT size
- GnWindow window, ///< [in] Window
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_fft32
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fft32 (double *out, ///< [out] Interleaved Re/Im output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int32_t *i, ///< [in] In-phase input array pointer
+ size_t i_size, ///< [in] In-phase input array size
+ const int32_t *q, ///< [in] Quadrature input array pointer
+ size_t q_size, ///< [in] Quadrature input array size
+ int n, ///< [in] Resolution
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft, ///< [in] FFT size
+ GnWindow window, ///< [in] Window
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_fft64
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fft64(
- double* out, ///< [out] Interleaved Re/Im output array pointer
- size_t out_size, ///< [in] Output array size
- const int64_t* i, ///< [in] In-phase input array pointer
- size_t i_size, ///< [in] In-phase input array size
- const int64_t* q, ///< [in] Quadrature input array pointer
- size_t q_size, ///< [in] Quadrature input array size
- int n, ///< [in] Resolution
- size_t navg, ///< [in] FFT averaging number
- size_t nfft, ///< [in] FFT size
- GnWindow window, ///< [in] Window
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_fft64
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fft64 (double *out, ///< [out] Interleaved Re/Im output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int64_t *i, ///< [in] In-phase input array pointer
+ size_t i_size, ///< [in] In-phase input array size
+ const int64_t *q, ///< [in] Quadrature input array pointer
+ size_t q_size, ///< [in] Quadrature input array size
+ int n, ///< [in] Resolution
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft, ///< [in] FFT size
+ GnWindow window, ///< [in] Window
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_rfft
- * @return 0 on success, non-zero otherwise
- * @details This function will be implemented in the future.
- */
-__api int gn_rfft(
- double* out, ///< [out] Interleaved Re/Im output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- size_t navg, ///< [in] FFT averaging number
- size_t nfft, ///< [in] FFT size
- GnWindow window, ///< [in] Window
- GnRfftScale scale ///< [in] Scaling mode
- );
+ /**
+ * @brief gn_rfft
+ * @return 0 on success, non-zero otherwise
+ * @details This function will be implemented in the future.
+ */
+ __api int
+ gn_rfft (double *out, ///< [out] Interleaved Re/Im output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft, ///< [in] FFT size
+ GnWindow window, ///< [in] Window
+ GnRfftScale scale ///< [in] Scaling mode
+ );
-/**
- * @brief gn_rfft16
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_rfft16(
- double* out, ///< [out] Interleaved Re/Im output array pointer
- size_t out_size, ///< [in] Output array size
- const int16_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Resolution
- size_t navg, ///< [in] FFT averaging number
- size_t nfft, ///< [in] FFT size
- GnWindow window, ///< [in] Window
- GnCodeFormat format, ///< [in] Code format
- GnRfftScale scale ///< [in] Scaling mode
- );
+ /**
+ * @brief gn_rfft16
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_rfft16 (double *out, ///< [out] Interleaved Re/Im output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int16_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Resolution
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft, ///< [in] FFT size
+ GnWindow window, ///< [in] Window
+ GnCodeFormat format, ///< [in] Code format
+ GnRfftScale scale ///< [in] Scaling mode
+ );
-/**
- * @brief gn_rfft32
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_rfft32(
- double* out, ///< [out] Interleaved Re/Im output array pointer
- size_t out_size, ///< [in] Output array size
- const int32_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Resolution
- size_t navg, ///< [in] FFT averaging number
- size_t nfft, ///< [in] FFT size
- GnWindow window, ///< [in] Window
- GnCodeFormat format, ///< [in] Code format
- GnRfftScale scale ///< [in] Scaling mode
- );
+ /**
+ * @brief gn_rfft32
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_rfft32 (double *out, ///< [out] Interleaved Re/Im output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int32_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Resolution
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft, ///< [in] FFT size
+ GnWindow window, ///< [in] Window
+ GnCodeFormat format, ///< [in] Code format
+ GnRfftScale scale ///< [in] Scaling mode
+ );
-/**
- * @brief gn_rfft64
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_rfft64(
- double* out, ///< [out] Interleaved Re/Im output array pointer
- size_t out_size, ///< [in] Output array size
- const int64_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Resolution
- size_t navg, ///< [in] FFT averaging number
- size_t nfft, ///< [in] FFT size
- GnWindow window, ///< [in] Window
- GnCodeFormat format, ///< [in] Code format
- GnRfftScale scale ///< [in] Scaling mode
- );
+ /**
+ * @brief gn_rfft64
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_rfft64 (double *out, ///< [out] Interleaved Re/Im output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int64_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Resolution
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft, ///< [in] FFT size
+ GnWindow window, ///< [in] Window
+ GnCodeFormat format, ///< [in] Code format
+ GnRfftScale scale ///< [in] Scaling mode
+ );
-/**
- * \defgroup FourierTransformHelpers Helpers
- * @{
- */
+ /**
+ * \defgroup FourierTransformHelpers Helpers
+ * @{
+ */
-/**
- * @brief gn_fft_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fft_size(
- size_t* out_size, ///< [out] Output array size
- size_t i_size, ///< [in] In-phase input array size
- size_t q_size, ///< [in] Quadrature input array size
- size_t navg, ///< [in] FFT averaging number
- size_t nfft ///< [in] FFT size
- );
+ /**
+ * @brief gn_fft_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fft_size (size_t *out_size, ///< [out] Output array size
+ size_t i_size, ///< [in] In-phase input array size
+ size_t q_size, ///< [in] Quadrature input array size
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft ///< [in] FFT size
+ );
-/**
- * @brief gn_rfft_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_rfft_size(
- size_t* out_size, ///< [out] Output array size
- size_t in_size, ///< [in] Input array size
- size_t navg, ///< [in] FFT averaging number
- size_t nfft ///< [in] FFT size
- );
+ /**
+ * @brief gn_rfft_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_rfft_size (size_t *out_size, ///< [out] Output array size
+ size_t in_size, ///< [in] Input array size
+ size_t navg, ///< [in] FFT averaging number
+ size_t nfft ///< [in] FFT size
+ );
-/** @} FourierTransformHelpers */
+ /** @} FourierTransformHelpers */
-/** @} FourierTransforms */
+ /** @} FourierTransforms */
#ifdef __cplusplus
} // extern "C"
@@ -1278,89 +1268,86 @@ __api int gn_rfft_size(
/* Fourier Utilities */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup FourierUtilities Fourier Utilities
- * @{
- */
+ /**
+ * \defgroup FourierUtilities Fourier Utilities
+ * @{
+ */
-/**
- * @brief gn_alias
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_alias(
- double* out, ///< [out] Output pointer
- double fs, ///< [in] Sample rate (S/s)
- double freq, ///< [in] Frequency (Hz)
- GnFreqAxisType axis_type ///< [in] Frequency axis type
- );
+ /**
+ * @brief gn_alias
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_alias (double *out, ///< [out] Output pointer
+ double fs, ///< [in] Sample rate (S/s)
+ double freq, ///< [in] Frequency (Hz)
+ GnFreqAxisType axis_type ///< [in] Frequency axis type
+ );
-/**
- * @brief gn_coherent
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_coherent(
- double* out, ///< [out] Output pointer
- size_t nfft, ///< [in] FFT size
- double fs, ///< [in] Sample rate (S/s)
- double freq ///< [in] Desired frequency (Hz)
- );
+ /**
+ * @brief gn_coherent
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_coherent (double *out, ///< [out] Output pointer
+ size_t nfft, ///< [in] FFT size
+ double fs, ///< [in] Sample rate (S/s)
+ double freq ///< [in] Desired frequency (Hz)
+ );
-/**
- * @brief gn_fftshift
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fftshift(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_fftshift
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fftshift (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size ///< [in] Input array size
+ );
-/**
- * @brief gn_freq_axis
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_freq_axis(
- double* out, ///< [out] Array pointer
- size_t size, ///< [in] Array size
- size_t nfft, ///< [in] FFT size
- GnFreqAxisType axis_type, ///< [in] Frequency axis type
- double fs, ///< [in] Sample rate (S/s)
- GnFreqAxisFormat axis_format ///< [in] Frequency axis format
- );
+ /**
+ * @brief gn_freq_axis
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_freq_axis (double *out, ///< [out] Array pointer
+ size_t size, ///< [in] Array size
+ size_t nfft, ///< [in] FFT size
+ GnFreqAxisType axis_type, ///< [in] Frequency axis type
+ double fs, ///< [in] Sample rate (S/s)
+ GnFreqAxisFormat axis_format ///< [in] Frequency axis format
+ );
-/**
- * @brief gn_ifftshift
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_ifftshift(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size ///< [in] Input array size
- );
+ /**
+ * @brief gn_ifftshift
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_ifftshift (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size ///< [in] Input array size
+ );
-/**
- * \defgroup FourierUtilityHelpers Helpers
- * @{
- */
+ /**
+ * \defgroup FourierUtilityHelpers Helpers
+ * @{
+ */
-/**
- * @brief gn_freq_axis_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_freq_axis_size(
- size_t* size, ///< [out] Output array size
- size_t nfft, ///< [in] FFT size
- GnFreqAxisType axis_type ///< [in] Frequency axis type
- );
+ /**
+ * @brief gn_freq_axis_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_freq_axis_size (size_t *size, ///< [out] Output array size
+ size_t nfft, ///< [in] FFT size
+ GnFreqAxisType axis_type ///< [in] Frequency axis type
+ );
-/** @} FourierUtilityHelpers */
+ /** @} FourierUtilityHelpers */
-/** @} FourierUtilities */
+ /** @} FourierUtilities */
#ifdef __cplusplus
} // extern "C"
@@ -1368,129 +1355,129 @@ __api int gn_freq_axis_size(
/* Manager */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup Manager Manager
- * @{
- */
+ /**
+ * \defgroup Manager Manager
+ * @{
+ */
-/**
- * @brief gn_mgr_clear
- * @return Always returns 0
- */
-__api int gn_mgr_clear();
+ /**
+ * @brief gn_mgr_clear
+ * @return Always returns 0
+ */
+ __api int gn_mgr_clear ();
-/**
- * @brief gn_mgr_compare
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_mgr_compare(
- bool* result, ///< [out] true if the objects are equal, false otherwise
- const char* obj_key1, ///< [in] Object key 1
- const char* obj_key2 ///< [in] Object key 2
- );
+ /**
+ * @brief gn_mgr_compare
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_mgr_compare (
+ bool *result, ///< [out] true if the objects are equal, false otherwise
+ const char *obj_key1, ///< [in] Object key 1
+ const char *obj_key2 ///< [in] Object key 2
+ );
-/**
- * @brief gn_mgr_contains
- * @return Always returns 0
- */
-__api int gn_mgr_contains(
- bool* result, ///< [out] true if Manager contains key, false otherwise
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_mgr_contains
+ * @return Always returns 0
+ */
+ __api int gn_mgr_contains (
+ bool *result, ///< [out] true if Manager contains key, false otherwise
+ const char *obj_key ///< [in] Object key
+ );
-/**
- * @brief gn_mgr_remove
- * @return Always returns 0
- */
-__api int gn_mgr_remove(
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_mgr_remove
+ * @return Always returns 0
+ */
+ __api int gn_mgr_remove (const char *obj_key ///< [in] Object key
+ );
-/**
- * @brief gn_mgr_save
- * @return 0 on success, non-zero otherwise
- * @details If filename is empty, the filename is derived from obj_key.
- */
-__api int gn_mgr_save(
- char* buf, ///< [out] Pointer to character array
- size_t size, ///< [in] Size of character array
- const char* obj_key, ///< [in] Object key
- const char* filename ///< [in] Filename
- );
+ /**
+ * @brief gn_mgr_save
+ * @return 0 on success, non-zero otherwise
+ * @details If filename is empty, the filename is derived from obj_key.
+ */
+ __api int gn_mgr_save (char *buf, ///< [out] Pointer to character array
+ size_t size, ///< [in] Size of character array
+ const char *obj_key, ///< [in] Object key
+ const char *filename ///< [in] Filename
+ );
-/**
- * @brief gn_mgr_size
- * @return Always returns 0
- */
-__api int gn_mgr_size(
- size_t* size ///< [out] Number of objects owned by the manager
- );
+ /**
+ * @brief gn_mgr_size
+ * @return Always returns 0
+ */
+ __api int
+ gn_mgr_size (size_t *size ///< [out] Number of objects owned by the manager
+ );
-/**
- * @brief gn_mgr_to_string
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_mgr_to_string(
- char* buf, ///< [out] Pointer to character array
- size_t size, ///< [in] Size of character array
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_mgr_to_string
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_mgr_to_string (char *buf, ///< [out] Pointer to character array
+ size_t size, ///< [in] Size of character array
+ const char *obj_key ///< [in] Object key
+ );
-/**
- * @brief gn_mgr_type
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_mgr_type(
- char* buf, ///< [out] Pointer to character array
- size_t size, ///< [in] Size of character array
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_mgr_type
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_mgr_type (char *buf, ///< [out] Pointer to character array
+ size_t size, ///< [in] Size of character array
+ const char *obj_key ///< [in] Object key
+ );
-/**
- * \defgroup ManagerHelpers Helpers
- * @{
- */
+ /**
+ * \defgroup ManagerHelpers Helpers
+ * @{
+ */
-/**
- * @brief gn_mgr_save_filename_size
- * @return 0 on success, non-zero otherwise
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the size. See \ref gn_set_string_termination.
- */
-__api int gn_mgr_save_filename_size(
- size_t* size, ///< [out] Number of characters in filename
- const char* obj_key, ///< [in] Object key
- const char* filename ///< [in] Filename
- );
+ /**
+ * @brief gn_mgr_save_filename_size
+ * @return 0 on success, non-zero otherwise
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the size. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_mgr_save_filename_size (
+ size_t *size, ///< [out] Number of characters in filename
+ const char *obj_key, ///< [in] Object key
+ const char *filename ///< [in] Filename
+ );
-/**
- * @brief gn_mgr_to_string_size
- * @return 0 on success, non-zero otherwise
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the size. See \ref gn_set_string_termination.
- */
-__api int gn_mgr_to_string_size(
- size_t* size, ///< [out] Number of characters in the string
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_mgr_to_string_size
+ * @return 0 on success, non-zero otherwise
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the size. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_mgr_to_string_size (
+ size_t *size, ///< [out] Number of characters in the string
+ const char *obj_key ///< [in] Object key
+ );
-/**
- * @brief gn_mgr_type_size
- * @return 0 on success, non-zero otherwise
- * @details The library string termination setting determines whether or not a null terminator
- * is included in the size. See \ref gn_set_string_termination.
- */
-__api int gn_mgr_type_size(
- size_t* size, ///< [out] Number of characters in object type string
- const char* obj_key ///< [in] Object key
- );
+ /**
+ * @brief gn_mgr_type_size
+ * @return 0 on success, non-zero otherwise
+ * @details The library string termination setting determines whether or not
+ * a null terminator is included in the size. See \ref
+ * gn_set_string_termination.
+ */
+ __api int gn_mgr_type_size (
+ size_t *size, ///< [out] Number of characters in object type string
+ const char *obj_key ///< [in] Object key
+ );
-/** @} ManagerHelpers */
+ /** @} ManagerHelpers */
-/** @} Manager */
+ /** @} Manager */
#ifdef __cplusplus
} // extern "C"
@@ -1498,258 +1485,251 @@ __api int gn_mgr_type_size(
/* Signal Processing */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup SignalProcessing Signal Processing
- * @{
- */
+ /**
+ * \defgroup SignalProcessing Signal Processing
+ * @{
+ */
-/**
- * @brief gn_downsample
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_downsample(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int ratio, ///< [in] Downsample ratio
- bool interleaved ///< [in] If true, 'in' is interleaved I/Q data
- );
+ /**
+ * @brief gn_downsample
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_downsample (
+ double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int ratio, ///< [in] Downsample ratio
+ bool interleaved ///< [in] If true, 'in' is interleaved I/Q data
+ );
-/**
- * @brief gn_downsample16
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_downsample16(
- int16_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int16_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int ratio, ///< [in] Downsample ratio
- bool interleaved ///< [in] If true, 'in' is interleaved I/Q data
- );
+ /**
+ * @brief gn_downsample16
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_downsample16 (
+ int16_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int16_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int ratio, ///< [in] Downsample ratio
+ bool interleaved ///< [in] If true, 'in' is interleaved I/Q data
+ );
-/**
- * @brief gn_downsample32
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_downsample32(
- int32_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int32_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int ratio, ///< [in] Downsample ratio
- bool interleaved ///< [in] If true, 'in' is interleaved I/Q data
- );
+ /**
+ * @brief gn_downsample32
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_downsample32 (
+ int32_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int32_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int ratio, ///< [in] Downsample ratio
+ bool interleaved ///< [in] If true, 'in' is interleaved I/Q data
+ );
-/**
- * @brief gn_downsample64
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_downsample64(
- int64_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int64_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int ratio, ///< [in] Downsample ratio
- bool interleaved ///< [in] If true, 'in' is interleaved I/Q data
- );
+ /**
+ * @brief gn_downsample64
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_downsample64 (
+ int64_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int64_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int ratio, ///< [in] Downsample ratio
+ bool interleaved ///< [in] If true, 'in' is interleaved I/Q data
+ );
-/**
- * @brief gn_fshift
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fshift(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* i, ///< [in] In-phase input array pointer
- size_t i_size, ///< [in] In-phase input array size
- const double* q, ///< [in] Quadrature input array pointer
- size_t q_size, ///< [in] Quadrature input array size
- double fs, ///< [in] Sample rate
- double fshift ///< [in] Shift frequency
- );
+ /**
+ * @brief gn_fshift
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fshift (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *i, ///< [in] In-phase input array pointer
+ size_t i_size, ///< [in] In-phase input array size
+ const double *q, ///< [in] Quadrature input array pointer
+ size_t q_size, ///< [in] Quadrature input array size
+ double fs, ///< [in] Sample rate
+ double fshift ///< [in] Shift frequency
+ );
-/**
- * @brief gn_fshift16
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fshift16(
- int16_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int16_t* i, ///< [in] In-phase input array pointer
- size_t i_size, ///< [in] In-phase input array size
- const int16_t* q, ///< [in] Quadrature input array pointer
- size_t q_size, ///< [in] Quadrature input array size
- int n, ///< [in] Code width
- double fs, ///< [in] Sample rate
- double fshift, ///< [in] Shift frequency
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_fshift16
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fshift16 (int16_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int16_t *i, ///< [in] In-phase input array pointer
+ size_t i_size, ///< [in] In-phase input array size
+ const int16_t *q, ///< [in] Quadrature input array pointer
+ size_t q_size, ///< [in] Quadrature input array size
+ int n, ///< [in] Code width
+ double fs, ///< [in] Sample rate
+ double fshift, ///< [in] Shift frequency
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_fshift32
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fshift32(
- int32_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int32_t* i, ///< [in] In-phase input array pointer
- size_t i_size, ///< [in] In-phase input array size
- const int32_t* q, ///< [in] Quadrature input array pointer
- size_t q_size, ///< [in] Quadrature input array size
- int n, ///< [in] Code width
- double fs, ///< [in] Sample rate
- double fshift, ///< [in] Shift frequency
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_fshift32
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fshift32 (int32_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int32_t *i, ///< [in] In-phase input array pointer
+ size_t i_size, ///< [in] In-phase input array size
+ const int32_t *q, ///< [in] Quadrature input array pointer
+ size_t q_size, ///< [in] Quadrature input array size
+ int n, ///< [in] Code width
+ double fs, ///< [in] Sample rate
+ double fshift, ///< [in] Shift frequency
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_fshift64
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fshift64(
- int64_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int64_t* i, ///< [in] In-phase input array pointer
- size_t i_size, ///< [in] In-phase input array size
- const int64_t* q, ///< [in] Quadrature input array pointer
- size_t q_size, ///< [in] Quadrature input array size
- int n, ///< [in] Code width
- double fs, ///< [in] Sample rate
- double fshift, ///< [in] Shift frequency
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_fshift64
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int
+ gn_fshift64 (int64_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int64_t *i, ///< [in] In-phase input array pointer
+ size_t i_size, ///< [in] In-phase input array size
+ const int64_t *q, ///< [in] Quadrature input array pointer
+ size_t q_size, ///< [in] Quadrature input array size
+ int n, ///< [in] Code width
+ double fs, ///< [in] Sample rate
+ double fshift, ///< [in] Shift frequency
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_normalize16
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_normalize16(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int16_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Resolution
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_normalize16
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_normalize16 (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int16_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Resolution
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_normalize32
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_normalize32(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int32_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Resolution
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_normalize32
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_normalize32 (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int32_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Resolution
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_normalize64
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_normalize64(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const int64_t* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- int n, ///< [in] Resolution
- GnCodeFormat format ///< [in] Code format
- );
+ /**
+ * @brief gn_normalize64
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_normalize64 (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const int64_t *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ int n, ///< [in] Resolution
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_polyval
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_polyval(
- double* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- const double* c, ///< [in] Coefficient array pointer
- size_t c_size ///< [in] Coefficient array size
- );
+ /**
+ * @brief gn_polyval
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_polyval (double *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ const double *c, ///< [in] Coefficient array pointer
+ size_t c_size ///< [in] Coefficient array size
+ );
-/**
- * @brief gn_quantize16
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_quantize16(
- int16_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- double fsr, ///< [in] Full-scale range
- int n, ///< [in] Resolution
- double noise, ///< [in] Input referred RMS noise
- GnCodeFormat format ///< [in] Code format
-);
+ /**
+ * @brief gn_quantize16
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_quantize16 (int16_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ double fsr, ///< [in] Full-scale range
+ int n, ///< [in] Resolution
+ double noise, ///< [in] Input referred RMS noise
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_quantize32
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_quantize32(
- int32_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- double fsr, ///< [in] Full-scale range
- int n, ///< [in] Resolution
- double noise, ///< [in] Input referred RMS noise
- GnCodeFormat format ///< [in] Code format
-);
+ /**
+ * @brief gn_quantize32
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_quantize32 (int32_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ double fsr, ///< [in] Full-scale range
+ int n, ///< [in] Resolution
+ double noise, ///< [in] Input referred RMS noise
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * @brief gn_quantize64
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_quantize64(
- int64_t* out, ///< [out] Output array pointer
- size_t out_size, ///< [in] Output array size
- const double* in, ///< [in] Input array pointer
- size_t in_size, ///< [in] Input array size
- double fsr, ///< [in] Full-scale range
- int n, ///< [in] Resolution
- double noise, ///< [in] Input referred RMS noise
- GnCodeFormat format ///< [in] Code format
-);
+ /**
+ * @brief gn_quantize64
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_quantize64 (int64_t *out, ///< [out] Output array pointer
+ size_t out_size, ///< [in] Output array size
+ const double *in, ///< [in] Input array pointer
+ size_t in_size, ///< [in] Input array size
+ double fsr, ///< [in] Full-scale range
+ int n, ///< [in] Resolution
+ double noise, ///< [in] Input referred RMS noise
+ GnCodeFormat format ///< [in] Code format
+ );
-/**
- * \defgroup SignalProcessingHelpers Helpers
- * @{
- */
+ /**
+ * \defgroup SignalProcessingHelpers Helpers
+ * @{
+ */
-/**
- * @brief gn_downsample_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_downsample_size(
- size_t* out_size, ///< [out] Output array size
- size_t in_size, ///< [in] Input array size
- int ratio, ///< [in] Downsample ratio
- bool interleaved ///< [in] If bool, 'in' is interleaved I/Q data
- );
+ /**
+ * @brief gn_downsample_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_downsample_size (
+ size_t *out_size, ///< [out] Output array size
+ size_t in_size, ///< [in] Input array size
+ int ratio, ///< [in] Downsample ratio
+ bool interleaved ///< [in] If bool, 'in' is interleaved I/Q data
+ );
-/**
- * @brief gn_fshift_size
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_fshift_size(
- size_t* out_size, ///< [out] Output array size
- size_t i_size, ///< [in] In-phase input array size
- size_t q_size ///< [in] Quadrature input array size
- );
+ /**
+ * @brief gn_fshift_size
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fshift_size (size_t *out_size, ///< [out] Output array size
+ size_t i_size, ///< [in] In-phase input array size
+ size_t q_size ///< [in] Quadrature input array size
+ );
-/** @} SignalProcessingHelpers */
+ /** @} SignalProcessingHelpers */
-/** @} SignalProcessing */
+ /** @} SignalProcessing */
#ifdef __cplusplus
} // extern "C"
@@ -1757,137 +1737,135 @@ __api int gn_fshift_size(
/* Waveforms */
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * \defgroup Waveforms Waveforms
- * @{
- */
+ /**
+ * \defgroup Waveforms Waveforms
+ * @{
+ */
-/**
- * @brief gn_cos
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_cos(
- double* out, ///< [out] Array pointer
- size_t size, ///< [in] Array size
- double fs, ///< [in] Sample rate (S/s)
- double ampl, ///< [in] Amplitude
- double freq, ///< [in] Frequency (Hz)
- double phase, ///< [in] Phase (rad)
- double td, ///< [in] Time delay (s)
- double tj ///< [in] RMS Aperture jitter (s)
- );
+ /**
+ * @brief gn_cos
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_cos (double *out, ///< [out] Array pointer
+ size_t size, ///< [in] Array size
+ double fs, ///< [in] Sample rate (S/s)
+ double ampl, ///< [in] Amplitude
+ double freq, ///< [in] Frequency (Hz)
+ double phase, ///< [in] Phase (rad)
+ double td, ///< [in] Time delay (s)
+ double tj ///< [in] RMS Aperture jitter (s)
+ );
-/**
- * @brief gn_gaussian
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_gaussian(
- double* out, ///< [out] Array pointer
- size_t size, ///< [in] Array size
- double mean, ///< [in] Mean
- double sd ///< [in] Standard deviation
- );
+ /**
+ * @brief gn_gaussian
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_gaussian (double *out, ///< [out] Array pointer
+ size_t size, ///< [in] Array size
+ double mean, ///< [in] Mean
+ double sd ///< [in] Standard deviation
+ );
-/**
- * @brief gn_ramp
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_ramp(
- double* out, ///< [out] Array pointer
- size_t size, ///< [in] Array size
- double start, ///< [in] Start value
- double stop, ///< [in] Stop value
- double noise ///< [in] RMS noise
- );
+ /**
+ * @brief gn_ramp
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_ramp (double *out, ///< [out] Array pointer
+ size_t size, ///< [in] Array size
+ double start, ///< [in] Start value
+ double stop, ///< [in] Stop value
+ double noise ///< [in] RMS noise
+ );
-/**
- * @brief gn_sin
- * @return 0 on success, non-zero otherwise
- */
-__api int gn_sin(
- double* out, ///< [out] Array pointer
- size_t size, ///< [in] Array size
- double fs, ///< [in] Sample rate (S/s)
- double ampl, ///< [in] Amplitude
- double freq, ///< [in] Frequency (Hz)
- double phase, ///< [in] Phase (rad)
- double td, ///< [in] Time delay (s)
- double tjrms ///< [in] RMS Aperture jitter (s)
- );
+ /**
+ * @brief gn_sin
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_sin (double *out, ///< [out] Array pointer
+ size_t size, ///< [in] Array size
+ double fs, ///< [in] Sample rate (S/s)
+ double ampl, ///< [in] Amplitude
+ double freq, ///< [in] Frequency (Hz)
+ double phase, ///< [in] Phase (rad)
+ double td, ///< [in] Time delay (s)
+ double tjrms ///< [in] RMS Aperture jitter (s)
+ );
-/**
- * @brief gn_wf_analysis
- * @return 0 on success, non-zero otherwise
- * @details The results contain the following key-value pairs (see general description of
- * \ref AnalysisRoutines "Analysis Routines").
- *
- * Key | Description
- * |
---|
min | Minumum value
- * |
max | Maximum value
- * |
mid | Middle value ((max + min) / 2)
- * |
range | Range (max - min)
- * |
avg | Average value
- * |
rms | RMS value
- * |
rmsac | RMS value with DC removed
- * |
min_index | Index of first occurence of minimum value
- * |
max_index | Index of first occurence of maximum value
- * |
- */
-__api int gn_wf_analysis(
- char** rkeys, ///< [out] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const double* in, ///< [in] Waveform array pointer
- size_t in_size ///< [in] Waveform array size
- );
+ /**
+ * @brief gn_wf_analysis
+ * @return 0 on success, non-zero otherwise
+ * @details The results contain the following key-value pairs (see general
+ * description of
+ * \ref AnalysisRoutines "Analysis Routines").
+ *
+ * Key | Description
+ * |
---|
min | Minumum value
+ * |
max | Maximum value
+ * |
mid | Middle value ((max + min) / 2)
+ * |
range | Range (max - min)
+ * |
avg | Average value
+ * |
rms | RMS value
+ * |
rmsac | RMS value with DC removed
+ * |
min_index | Index of first occurence of minimum value
+ * |
max_index | Index of first occurence of maximum value
+ * |
+ */
+ __api int
+ gn_wf_analysis (char **rkeys, ///< [out] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const double *in, ///< [in] Waveform array pointer
+ size_t in_size ///< [in] Waveform array size
+ );
-/**
- * @brief gn_wf_analysis16
- * @return 0 on success, non-zero otherwise
- * @details See description of \ref gn_wf_analysis.
- */
-__api int gn_wf_analysis16(
- char** rkeys, ///< [out] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const int16_t* in, ///< [in] Waveform array pointer
- size_t in_size ///< [in] Waveform array size
- );
+ /**
+ * @brief gn_wf_analysis16
+ * @return 0 on success, non-zero otherwise
+ * @details See description of \ref gn_wf_analysis.
+ */
+ __api int
+ gn_wf_analysis16 (char **rkeys, ///< [out] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const int16_t *in, ///< [in] Waveform array pointer
+ size_t in_size ///< [in] Waveform array size
+ );
-/**
- * @brief gn_wf_analysis32
- * @return 0 on success, non-zero otherwise
- * @details See description of \ref gn_wf_analysis.
- */
-__api int gn_wf_analysis32(
- char** rkeys, ///< [out] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const int32_t* in, ///< [in] Waveform array pointer
- size_t in_size ///< [in] Waveform array size
- );
+ /**
+ * @brief gn_wf_analysis32
+ * @return 0 on success, non-zero otherwise
+ * @details See description of \ref gn_wf_analysis.
+ */
+ __api int
+ gn_wf_analysis32 (char **rkeys, ///< [out] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const int32_t *in, ///< [in] Waveform array pointer
+ size_t in_size ///< [in] Waveform array size
+ );
-/**
- * @brief gn_wf_analysis64
- * @return 0 on success, non-zero otherwise
- * @details See description of \ref gn_wf_analysis.
- */
-__api int gn_wf_analysis64(
- char** rkeys, ///< [out] Result keys array pointer
- size_t rkeys_size, ///< [in] Result keys array size
- double* rvalues, ///< [out] Result values array pointer
- size_t rvalues_size, ///< [in] Result values array size
- const int64_t* in, ///< [in] Waveform array pointer
- size_t in_size ///< [in] Waveform array size
- );
-
-/** @} Waveforms */
+ /**
+ * @brief gn_wf_analysis64
+ * @return 0 on success, non-zero otherwise
+ * @details See description of \ref gn_wf_analysis.
+ */
+ __api int
+ gn_wf_analysis64 (char **rkeys, ///< [out] Result keys array pointer
+ size_t rkeys_size, ///< [in] Result keys array size
+ double *rvalues, ///< [out] Result values array pointer
+ size_t rvalues_size, ///< [in] Result values array size
+ const int64_t *in, ///< [in] Waveform array pointer
+ size_t in_size ///< [in] Waveform array size
+ );
+
+ /** @} Waveforms */
#ifdef __cplusplus
} // extern "C"
diff --git a/bindings/c/include/cgenalyzer_private.h b/bindings/c/include/cgenalyzer_private.h
index 1d0e41a..478083a 100644
--- a/bindings/c/include/cgenalyzer_private.h
+++ b/bindings/c/include/cgenalyzer_private.h
@@ -1,24 +1,6 @@
-/*
- * cgenalyzer_private - genalyzer private header file
- *
- * Copyright (C) 2022 Analog Devices, Inc.
- * Author: Srikanth Pagadarai
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * */
-
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef CGENALYZER_PRIVATE_H
#define CGENALYZER_PRIVATE_H
@@ -33,10 +15,10 @@
#include
#include
#include
+#include
#include
#include
#include
-#include
#include
#include
#include
@@ -60,172 +42,184 @@ constexpr int gn_failure = 1;
namespace gn = ::genalyzer_impl;
-namespace util {
-
- class log
- {
- public:
-
- log()
- : m_log {},
- m_flag {false}
- {}
-
- public:
-
- bool check()
- {
- return m_flag;
- }
-
- void clear()
- {
- m_log.clear();
- m_flag = false;
- }
-
- std::string_view get() const
- {
- return m_log;
- }
-
- void set(const char* msg)
- {
- m_log = msg;
- m_flag = true;
- }
-
- size_t size() const
- {
- return m_log.size();
- }
-
- public:
-
- void append() {}
-
- template
- void append(const char* s, Types... the_rest)
- {
- m_log.append(s);
- append(the_rest...);
- }
-
- void prepend() {}
-
- template
- void prepend(const char* s, Types... the_rest)
- {
- prepend(the_rest...);
- m_log.insert(0, s);
- }
-
- private:
-
- std::string m_log;
- bool m_flag;
-
- }; // class log
-
- static log gn_error_log;
-
- template
- int return_on_exception(const char* s, Types... the_rest)
- {
- gn_error_log.set(s);
- gn_error_log.append(the_rest...);
- return gn_failure;
- }
+namespace util
+{
+
+class log
+{
+public:
+ log () : m_log{}, m_flag{ false } {}
+
+public:
+ bool
+ check ()
+ {
+ return m_flag;
+ }
+
+ void
+ clear ()
+ {
+ m_log.clear ();
+ m_flag = false;
+ }
+
+ std::string_view
+ get () const
+ {
+ return m_log;
+ }
+
+ void
+ set (const char *msg)
+ {
+ m_log = msg;
+ m_flag = true;
+ }
+
+ size_t
+ size () const
+ {
+ return m_log.size ();
+ }
+
+public:
+ void
+ append ()
+ {
+ }
+
+ template
+ void
+ append (const char *s, Types... the_rest)
+ {
+ m_log.append (s);
+ append (the_rest...);
+ }
+
+ void
+ prepend ()
+ {
+ }
+
+ template
+ void
+ prepend (const char *s, Types... the_rest)
+ {
+ prepend (the_rest...);
+ m_log.insert (0, s);
+ }
+
+private:
+ std::string m_log;
+ bool m_flag;
+
+}; // class log
+
+static log gn_error_log;
+
+template
+int
+return_on_exception (const char *s, Types... the_rest)
+{
+ gn_error_log.set (s);
+ gn_error_log.append (the_rest...);
+ return gn_failure;
+}
- template
- int check_pointer(const T* p)
+template
+int
+check_pointer (const T *p)
+{
+ if (nullptr == p)
{
- if (nullptr == p) {
- throw std::runtime_error("check_pointer : pointer is NULL");
- }
- return gn_success;
+ throw std::runtime_error ("check_pointer : pointer is NULL");
}
+ return gn_success;
+}
- size_t terminated_size(size_t string_size);
- void fill_string_buffer(
- const char* src, // Pointer to source
- size_t src_size, // Size of source; should not count null-terminator, if it exists
- char* dst, // Pointer to destination
- size_t dst_size // Size of destination
- );
- std::string get_object_key_from_filename(const std::string& filename);
+size_t terminated_size (size_t string_size);
+void fill_string_buffer (const char *src, // Pointer to source
+ size_t src_size, // Size of source; should not count
+ // null-terminator, if it exists
+ char *dst, // Pointer to destination
+ size_t dst_size // Size of destination
+);
+std::string get_object_key_from_filename (const std::string &filename);
}
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
- using namespace genalyzer_impl;
-
- struct gn_config_private {
- bool _gn_config_calloced = false;
-
- // waveform and FFT settings
- tone_type ttype;
- gn::size_t npts;
- gn::real_t sample_rate;
- gn::real_t *tone_freq;
- gn::real_t *tone_ampl;
- gn::real_t *tone_phase;
- gn::size_t num_tones;
- gn::real_t fsr;
- int qres;
- gn::real_t noise_rms;
- GnCodeFormat code_format;
- gn::size_t nfft;
- gn::size_t fft_navg;
- GnFreqAxisType axis_type;
- gn::real_t data_rate;
- gn::real_t shift_freq;
- GnWindow win;
- gn::real_t ramp_start;
- gn::real_t ramp_stop;
-
- // analysis settings
- char *obj_key;
- char *comp_key;
- int ssb_fund;
- int ssb_rest;
- int max_harm_order;
- GnDnlSignal dnla_signal_type;
- GnInlLineFit inla_fit;
- gn::size_t _code_density_size;
-
- // keys, values and sizes for Fourier analysis results
- char **_fa_result_keys;
- gn::real_t *_fa_result_values;
- gn::size_t *_fa_result_key_sizes;
- gn::size_t _fa_results_size;
-
- // keys, values and sizes for waveform analysis results
- char **_wfa_result_keys;
- gn::real_t *_wfa_result_values;
- gn::size_t *_wfa_result_key_sizes;
- gn::size_t _wfa_results_size;
-
- // keys, values and sizes for histogram results
- char **_hist_result_keys;
- gn::real_t *_hist_result_values;
- gn::size_t *_hist_result_key_sizes;
- gn::size_t _hist_results_size;
-
- // keys, values and sizes for DNL results
- char **_dnl_result_keys;
- gn::real_t *_dnl_result_values;
- gn::size_t *_dnl_result_key_sizes;
- gn::size_t _dnl_results_size;
-
- // keys, values and sizes for INL results
- char **_inl_result_keys;
- gn::real_t *_inl_result_values;
- gn::size_t *_inl_result_key_sizes;
- gn::size_t _inl_results_size;
- };
+ using namespace genalyzer_impl;
+
+ struct gn_config_private
+ {
+ bool _gn_config_calloced = false;
+
+ // waveform and FFT settings
+ tone_type ttype;
+ gn::size_t npts;
+ gn::real_t sample_rate;
+ gn::real_t *tone_freq;
+ gn::real_t *tone_ampl;
+ gn::real_t *tone_phase;
+ gn::size_t num_tones;
+ gn::real_t fsr;
+ int qres;
+ gn::real_t noise_rms;
+ GnCodeFormat code_format;
+ gn::size_t nfft;
+ gn::size_t fft_navg;
+ GnFreqAxisType axis_type;
+ gn::real_t data_rate;
+ gn::real_t shift_freq;
+ GnWindow win;
+ gn::real_t ramp_start;
+ gn::real_t ramp_stop;
+
+ // analysis settings
+ char *obj_key;
+ char *comp_key;
+ int ssb_fund;
+ int ssb_rest;
+ int max_harm_order;
+ GnDnlSignal dnla_signal_type;
+ GnInlLineFit inla_fit;
+ gn::size_t _code_density_size;
+
+ // keys, values and sizes for Fourier analysis results
+ char **_fa_result_keys;
+ gn::real_t *_fa_result_values;
+ gn::size_t *_fa_result_key_sizes;
+ gn::size_t _fa_results_size;
+
+ // keys, values and sizes for waveform analysis results
+ char **_wfa_result_keys;
+ gn::real_t *_wfa_result_values;
+ gn::size_t *_wfa_result_key_sizes;
+ gn::size_t _wfa_results_size;
+
+ // keys, values and sizes for histogram results
+ char **_hist_result_keys;
+ gn::real_t *_hist_result_values;
+ gn::size_t *_hist_result_key_sizes;
+ gn::size_t _hist_results_size;
+
+ // keys, values and sizes for DNL results
+ char **_dnl_result_keys;
+ gn::real_t *_dnl_result_values;
+ gn::size_t *_dnl_result_key_sizes;
+ gn::size_t _dnl_results_size;
+
+ // keys, values and sizes for INL results
+ char **_inl_result_keys;
+ gn::real_t *_inl_result_values;
+ gn::size_t *_inl_result_key_sizes;
+ gn::size_t _inl_results_size;
+ };
#ifdef __cplusplus
}
diff --git a/bindings/c/include/cgenalyzer_simplified_beta.h b/bindings/c/include/cgenalyzer_simplified_beta.h
index d1d9c73..868b157 100644
--- a/bindings/c/include/cgenalyzer_simplified_beta.h
+++ b/bindings/c/include/cgenalyzer_simplified_beta.h
@@ -1,24 +1,6 @@
-/*
- * cgenalyzer - genalyzer (beta) simplified API header file
- *
- * Copyright (C) 2022 Analog Devices, Inc.
- * Author: Srikanth Pagadarai
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * */
-
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef CGENALYZER_SIMPLIFIED_BETA_H
#define CGENALYZER_SIMPLIFIED_BETA_H
@@ -33,9 +15,9 @@ extern "C"
#ifdef _WIN32
#ifdef GENALYZER_EXPORTS
-#define __api __declspec(dllexport)
+#define __api __declspec (dllexport)
#else
-#define __api __declspec(dllimport)
+#define __api __declspec (dllimport)
#endif
#elif __GNUC__ >= 4 && !defined(MATLAB_MEX_FILE) \
&& !defined(MATLAB_LOADLIBRARY)
@@ -43,15 +25,15 @@ extern "C"
#else
#define __api
#endif
-
+
// opaque pointer
typedef struct gn_config_private *gn_config;
typedef enum tone_type
{
- REAL_COSINE,
- REAL_SINE,
- COMPLEX_EXP
+ REAL_COSINE,
+ REAL_SINE,
+ COMPLEX_EXP
} tone_type;
/**
@@ -59,20 +41,16 @@ extern "C"
* @return 0 on success, non-zero otherwise
* @param c genalyzer Configuration struct
*/
- __api int gn_config_free(
- gn_config *c
- );
+ __api int gn_config_free (gn_config *c);
/**
* @brief set configuration struct member: tone_type
* @return 0 on success, non-zero otherwise
- * @param ttype ENUM value to indicate input tone type. Options: REAL_COSINE, REAL_SINE, COMPLEX_EXP
+ * @param ttype ENUM value to indicate input tone type. Options: REAL_COSINE,
+ * REAL_SINE, COMPLEX_EXP
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_ttype(
- tone_type ttype,
- gn_config *c
- );
+ __api int gn_config_set_ttype (tone_type ttype, gn_config *c);
/**
* @brief set configuration struct member: npts
@@ -80,10 +58,7 @@ extern "C"
* @param npts Number of sample points in the generated waveform
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_npts(
- size_t npts,
- gn_config *c
- );
+ __api int gn_config_set_npts (size_t npts, gn_config *c);
/**
* @brief get configuration struct member: npts
@@ -91,10 +66,7 @@ extern "C"
* @param npts Number of sample points in the generated waveform
* @param c genalyzer Configuration struct
*/
- __api int gn_config_get_npts(
- size_t *npts,
- gn_config *c
- );
+ __api int gn_config_get_npts (size_t *npts, gn_config *c);
/**
* @brief set configuration struct member: sample_rate
@@ -102,10 +74,7 @@ extern "C"
* @param sample_rate Input Sample rate of the data converter
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_sample_rate(
- double sample_rate,
- gn_config *c
- );
+ __api int gn_config_set_sample_rate (double sample_rate, gn_config *c);
/**
* @brief get configuration struct member: sample_rate
@@ -113,10 +82,7 @@ extern "C"
* @param sample_rate Input Sample rate of the data converter
* @param c genalyzer Configuration struct
*/
- __api int gn_config_get_sample_rate(
- double *sample_rate,
- gn_config *c
- );
+ __api int gn_config_get_sample_rate (double *sample_rate, gn_config *c);
/**
* @brief set configuration struct member: data_rate
@@ -124,10 +90,7 @@ extern "C"
* @param data_rate Input data rate of the data converter
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_data_rate(
- double data_rate,
- gn_config *c
- );
+ __api int gn_config_set_data_rate (double data_rate, gn_config *c);
/**
* @brief set configuration struct member: shift_freq
@@ -135,10 +98,7 @@ extern "C"
* @param shift_freq Shift frequency of the data converter
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_shift_freq(
- double shift_freq,
- gn_config *c
- );
+ __api int gn_config_set_shift_freq (double shift_freq, gn_config *c);
/**
* @brief set configuration struct member: num_tones
@@ -146,10 +106,7 @@ extern "C"
* @param num_tones Number of tones to generate
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_num_tones(
- size_t num_tones,
- gn_config *c
- );
+ __api int gn_config_set_num_tones (size_t num_tones, gn_config *c);
/**
* @brief set configuration struct member: tone_freq
@@ -157,10 +114,7 @@ extern "C"
* @param tone_freq Input array of tone frequencies to generate
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_tone_freq(
- double *tone_freq,
- gn_config *c
- );
+ __api int gn_config_set_tone_freq (double *tone_freq, gn_config *c);
/**
* @brief set configuration struct member: tone_ampl
@@ -168,10 +122,7 @@ extern "C"
* @param tone_ampl Input array of tone scales to generate
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_tone_ampl(
- double *tone_ampl,
- gn_config *c
- );
+ __api int gn_config_set_tone_ampl (double *tone_ampl, gn_config *c);
/**
* @brief set configuration struct member: tone_phase
@@ -179,10 +130,7 @@ extern "C"
* @param tone_phase Input array of tone phases to generate
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_tone_phase(
- double *tone_phase,
- gn_config *c
- );
+ __api int gn_config_set_tone_phase (double *tone_phase, gn_config *c);
/**
* @brief set configuration struct member: fsr
@@ -190,10 +138,7 @@ extern "C"
* @param fsr Full-scale range of the waveform
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_fsr(
- double fsr,
- gn_config *c
- );
+ __api int gn_config_set_fsr (double fsr, gn_config *c);
/**
* @brief set configuration struct member: qres
@@ -201,10 +146,7 @@ extern "C"
* @param qres Quantization resolution
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_qres(
- int qres,
- gn_config *c
- );
+ __api int gn_config_set_qres (int qres, gn_config *c);
/**
* @brief set configuration struct member: noise_rms
@@ -212,10 +154,7 @@ extern "C"
* @param noise_rms RMS Noise
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_noise_rms(
- double noise_rms,
- gn_config *c
- );
+ __api int gn_config_set_noise_rms (double noise_rms, gn_config *c);
/**
* @brief set configuration struct member: code_format
@@ -223,10 +162,7 @@ extern "C"
* @param code_format Code format of data
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_code_format(
- GnCodeFormat code_format,
- gn_config *c
- );
+ __api int gn_config_set_code_format (GnCodeFormat code_format, gn_config *c);
/**
* @brief set configuration struct member: nfft
@@ -234,10 +170,7 @@ extern "C"
* @param nfft FFT order
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_nfft(
- size_t nfft,
- gn_config *c
- );
+ __api int gn_config_set_nfft (size_t nfft, gn_config *c);
/**
* @brief get configuration struct member: nfft
@@ -245,43 +178,31 @@ extern "C"
* @param nfft FFT order
* @param c genalyzer Configuration struct
*/
- __api int gn_config_get_nfft(
- size_t *nfft,
- gn_config *c
- );
-
+ __api int gn_config_get_nfft (size_t *nfft, gn_config *c);
+
/**
* @brief set configuration struct member: navg
* @return 0 on success, non-zero otherwise
* @param fft_navg Num. of FFTs to average
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_fft_navg(
- size_t fft_navg,
- gn_config *c
- );
-
+ __api int gn_config_set_fft_navg (size_t fft_navg, gn_config *c);
+
/**
* @brief set configuration struct member: win
* @return 0 on success, non-zero otherwise
* @param win Window function used
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_win(
- GnWindow win,
- gn_config *c
- );
-
+ __api int gn_config_set_win (GnWindow win, gn_config *c);
+
/**
* @brief set configuration struct member: ssb_fund
* @return 0 on success, non-zero otherwise
* @param ssb_fund Single side bin fundamental
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_ssb_fund(
- int ssb_fund,
- gn_config *c
- );
+ __api int gn_config_set_ssb_fund (int ssb_fund, gn_config *c);
/**
* @brief set configuration struct member: ssb_rest
@@ -289,10 +210,7 @@ extern "C"
* @param ssb_rest Single side bins rest
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_ssb_rest(
- int ssb_rest,
- gn_config *c
- );
+ __api int gn_config_set_ssb_rest (int ssb_rest, gn_config *c);
/**
* @brief set configuration struct member: max_harm_order
@@ -300,10 +218,7 @@ extern "C"
* @param max_harm_order Max order of harmonic
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_max_harm_order(
- int max_harm_order,
- gn_config *c
- );
+ __api int gn_config_set_max_harm_order (int max_harm_order, gn_config *c);
/**
* @brief set configuration struct member: dnla_signal_type
@@ -311,10 +226,8 @@ extern "C"
* @param dnla_signal_type DNL analysis signal type
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_dnla_signal_type(
- GnDnlSignal dnla_signal_type,
- gn_config *c
- );
+ __api int gn_config_set_dnla_signal_type (GnDnlSignal dnla_signal_type,
+ gn_config *c);
/**
* @brief set configuration struct member: inla_fit
@@ -322,10 +235,7 @@ extern "C"
* @param inla_fit INL analysis line fit
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_inla_fit(
- GnInlLineFit inla_fit,
- gn_config *c
- );
+ __api int gn_config_set_inla_fit (GnInlLineFit inla_fit, gn_config *c);
/**
* @brief set configuration struct member: ramp_start
@@ -333,55 +243,42 @@ extern "C"
* @param ramp_start start value of ramp
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_ramp_start(
- double ramp_start,
- gn_config *c
- );
-
+ __api int gn_config_set_ramp_start (double ramp_start, gn_config *c);
+
/**
* @brief set configuration struct member: ramp_stop
* @return 0 on success, non-zero otherwise
* @param ramp_stop stop value of ramp
* @param c genalyzer Configuration struct
*/
- __api int gn_config_set_ramp_stop(
- double ramp_stop,
- gn_config *c
- );
-
+ __api int gn_config_set_ramp_stop (double ramp_stop, gn_config *c);
+
/**
* @brief get configuration struct member: _code_density_size
* @return 0 on success, non-zero otherwise
* @param code_density_size code density size
* @param c genalyzer Configuration struct
*/
- __api int gn_config_get_code_density_size(
- size_t *code_density_size,
- gn_config *c
- );
+ __api int gn_config_get_code_density_size (size_t *code_density_size,
+ gn_config *c);
/**
* @brief Configure tone parameters to be used in measurement
* @return 0 on success, non-zero otherwise
- * @param ttype ENUM value to indicate input tone type. Options: REAL_COSINE, REAL_SINE, COMPLEX_EXP
+ * @param ttype ENUM value to indicate input tone type. Options: REAL_COSINE,
+ * REAL_SINE, COMPLEX_EXP
* @param npts Number of sample points in the generated waveform
* @param sample_rate Input Sample rate of the data converter
* @param num_tones Number of tones to generate
* @param tone_freq Input array of tone frequencies to generate
* @param tone_ampl Input array of tone scales to generate
- * @param tone_phase Input array of tone phases to generate
+ * @param tone_phase Input array of tone phases to generate
* @param c Configuration struct containing tone parameters
*/
- __api int gn_config_gen_tone (
- tone_type ttype,
- size_t npts,
- double sample_rate,
- size_t num_tones,
- double *tone_freq,
- double *tone_ampl,
- double *tone_phase,
- gn_config *c
- );
+ __api int gn_config_gen_tone (tone_type ttype, size_t npts,
+ double sample_rate, size_t num_tones,
+ double *tone_freq, double *tone_ampl,
+ double *tone_phase, gn_config *c);
/**
* @brief Configure tone parameters to be used in measurement
@@ -391,29 +288,20 @@ extern "C"
* @param ramp_stop Input stop value of ramp
* @param c Configuration struct containing ramp parameters
*/
- __api int gn_config_gen_ramp(
- size_t npts,
- double ramp_start,
- double ramp_stop,
- gn_config *c
- );
+ __api int gn_config_gen_ramp (size_t npts, double ramp_start,
+ double ramp_stop, gn_config *c);
/**
* @brief Configure quantization parameters to be used in measurement
* @return 0 on success, non-zero otherwise
* @param npts Number of sample points in the generated waveform
- * @param fsr Full-scale range of the waveform
+ * @param fsr Full-scale range of the waveform
* @param qres Quantization resolution
* @param qnoise Quantization noise
* @param c Configuration structure
*/
- __api int gn_config_quantize(
- size_t npts,
- double fsr,
- int qres,
- double qnoise,
- gn_config *c
- );
+ __api int gn_config_quantize (size_t npts, double fsr, int qres,
+ double qnoise, gn_config *c);
/**
* @brief Configure parameters to compute histogram
@@ -422,202 +310,188 @@ extern "C"
* @param qres Quantization resolution
* @param c Configuration structure
*/
- __api int gn_config_histz_nla(
- size_t npts,
- int qres,
- gn_config *c
- );
+ __api int gn_config_histz_nla (size_t npts, int qres, gn_config *c);
/**
- * @brief Configure FFT parameters
+ * @brief Configure FFT parameters
* @return 0 on success, non-zero otherwise
*/
- __api int gn_config_fftz(
- size_t npts, ///< [npts] Number of sample points in the input waveform
- int qres, ///< [qres] Quantization resolution
- size_t navg, ///< [navg] Number of FFT averages
- size_t nfft, ///< [nfft] FFT order
- GnWindow win, ///< [win] Window function to apply, Options: GnWindowBlackmanHarris, GnWindowHann, GnWindowNoWindow
- gn_config *c ///< [c] Configuration structure containing test parameters
- );
+ __api int gn_config_fftz (
+ size_t npts, ///< [npts] Number of sample points in the input waveform
+ int qres, ///< [qres] Quantization resolution
+ size_t navg, ///< [navg] Number of FFT averages
+ size_t nfft, ///< [nfft] FFT order
+ GnWindow win, ///< [win] Window function to apply, Options:
+ ///< GnWindowBlackmanHarris, GnWindowHann, GnWindowNoWindow
+ gn_config *c ///< [c] Configuration structure containing test parameters
+ );
/**
* @brief Generate sinusoidal tone based on supplied configuration.
- * @return 0 on success, non-zero otherwise
+ * @return 0 on success, non-zero otherwise
*/
- __api int gn_config_fa(
- double fixed_tone_freq, ///< [fixed_tone_freq] Fixed tone frequency
- gn_config *c ///< [c] Configuration structure containing test parameters
- );
+ __api int gn_config_fa (
+ double fixed_tone_freq, ///< [fixed_tone_freq] Fixed tone frequency
+ gn_config *c ///< [c] Configuration structure containing test parameters
+ );
/**
- * @brief Generate sinusoidal tone based on supplied configuration without specifying tone manually.
+ * @brief Generate sinusoidal tone based on supplied configuration without
+ * specifying tone manually.
* @return 0 on success, non-zero otherwise
*/
- __api int gn_config_fa_auto(
- uint8_t ssb_width, ///< [ssb_width] Number of bins to use for fundamental search and keepout of other tones
- gn_config *c ///< [c] Configuration structure containing test parameters
- );
-
+ __api int gn_config_fa_auto (
+ uint8_t ssb_width, ///< [ssb_width] Number of bins to use for fundamental
+ ///< search and keepout of other tones
+ gn_config *c ///< [c] Configuration structure containing test parameters
+ );
+
/**
* @brief Generate ramp based on supplied configuration.
* @param out Output array of ramp generated
* @param c Configuration structure of test and waveform to generate
*/
- __api int gn_gen_ramp(
- double **out,
- gn_config *c
- );
-
+ __api int gn_gen_ramp (double **out, gn_config *c);
+
/**
* @brief Generate sinusoidal tone based on supplied configuration.
- * @return 0 on success, non-zero otherwise
+ * @return 0 on success, non-zero otherwise
* @param out Output array of generated tone
* @param c Configuration structure containing test parameters
*/
- __api int gn_gen_real_tone(
- double **out,
- gn_config *c
- );
+ __api int gn_gen_real_tone (double **out, gn_config *c);
/**
* @brief Generate sinusoidal tone based on supplied configuration.
- * @return 0 on success, non-zero otherwise
+ * @return 0 on success, non-zero otherwise
* @param outi In-phase output array of generated tone
* @param outq Quadrature output array of generated tone
* @param c Configuration structure containing test parameters
*/
- __api int gn_gen_complex_tone(
- double **outi,
- double **outq,
- gn_config *c
- );
+ __api int gn_gen_complex_tone (double **outi, double **outq, gn_config *c);
/**
* @brief Quantize waveform based on supplied configuration.
* @return 0 on success, non-zero otherwise
*/
- __api int gn_quantize(
- int32_t **out, ///< [out] Quantized output waveform
- const double *in, ///< [in] Input waveform to be quantized
- gn_config *c ///< [c] Configuration structure containing test parameters
- );
+ __api int gn_quantize (
+ int32_t **out, ///< [out] Quantized output waveform
+ const double *in, ///< [in] Input waveform to be quantized
+ gn_config *c ///< [c] Configuration structure containing test parameters
+ );
/**
- * @brief Compute FFT of quantized input waveform
- * @return 0 on success, non-zero otherwise
- */
- __api int gn_fftz(
- double **out, ///< [out] Interleaved Re/Im FFT output
- const int32_t *in_i, ///< [in_i] In-phase input
- const int32_t *in_q, ///< [in_q] Quadrature input
- gn_config *c ///< [c] Configuration structure containing test parameters
- );
+ * @brief Compute FFT of quantized input waveform
+ * @return 0 on success, non-zero otherwise
+ */
+ __api int gn_fftz (
+ double **out, ///< [out] Interleaved Re/Im FFT output
+ const int32_t *in_i, ///< [in_i] In-phase input
+ const int32_t *in_q, ///< [in_q] Quadrature input
+ gn_config *c ///< [c] Configuration structure containing test parameters
+ );
/**
* @brief Compute histogram of quantized waveform
* @return 0 on success, non-zero otherwise
*/
- __api int gn_histz(
- uint64_t **hist, ///< [hist] Output - Histogram of input quantized waveform
- size_t *hist_len, ///< [hist_len] Output - Histogram size
- const int32_t *qwf, ///< [qwf] Input - Quantized input waveform
- gn_config *c ///< [c] Input - Configuration structure containing test parameters
- );
+ __api int gn_histz (
+ uint64_t *
+ *hist, ///< [hist] Output - Histogram of input quantized waveform
+ size_t *hist_len, ///< [hist_len] Output - Histogram size
+ const int32_t *qwf, ///< [qwf] Input - Quantized input waveform
+ gn_config *
+ c ///< [c] Input - Configuration structure containing test parameters
+ );
/**
* @brief Compute histogram of quantized waveform
* @return 0 on success, non-zero otherwise
*/
- __api int gn_dnlz(
- double **dnl,
- size_t *dnl_len,
- const uint64_t *hist,
- gn_config *c
- );
+ __api int gn_dnlz (double **dnl, size_t *dnl_len, const uint64_t *hist,
+ gn_config *c);
/**
* @brief Compute histogram of quantized waveform
* @return 0 on success, non-zero otherwise
*/
-
- __api int gn_inlz(
- double **inl,
- size_t *inl_len,
- const double *dnl,
- gn_config *c
- );
-
+
+ __api int gn_inlz (double **inl, size_t *inl_len, const double *dnl,
+ gn_config *c);
+
/**
* @brief Do waveform analysis and all get results
* @return 0 on success, non-zero otherwise
*/
- __api int gn_get_wfa_results(
- char ***rkeys,
- double **rvalues,
- size_t *results_size, ///< [results_size] size of results
- const int32_t *qwf, ///< [qwf] Input - Quantized input array pointer
- gn_config *c ///< [c] Input - Configuration structure containing test parameters
- );
+ __api int gn_get_wfa_results (
+ char ***rkeys, double **rvalues,
+ size_t *results_size, ///< [results_size] size of results
+ const int32_t *qwf, ///< [qwf] Input - Quantized input array pointer
+ gn_config *
+ c ///< [c] Input - Configuration structure containing test parameters
+ );
- /**
+ /**
* @brief Do histogram analysis and get results
* @return 0 on success, non-zero otherwise
*/
- __api int gn_get_ha_results(
- char ***rkeys, ///< [rkeys] Output - Result keys
- double **rvalues, ///< [rvalues] Output - Result values
- size_t *results_size, ///< [results_size] Output - Size of results
- const uint64_t *hist, ///< [hist] Input - Histogram input to be analyzed
- gn_config *c ///< [c] Input - Configuration structure containing test parameters
- );
+ __api int gn_get_ha_results (
+ char ***rkeys, ///< [rkeys] Output - Result keys
+ double **rvalues, ///< [rvalues] Output - Result values
+ size_t *results_size, ///< [results_size] Output - Size of results
+ const uint64_t *hist, ///< [hist] Input - Histogram input to be analyzed
+ gn_config *
+ c ///< [c] Input - Configuration structure containing test parameters
+ );
/**
* @brief Do DNL analysis and get results
* @return 0 on success, non-zero otherwise
*/
- __api int gn_get_dnla_results(
- char ***rkeys, ///< [rkeys] Output - Result keys
- double **rvalues, ///< [rvalues] Output - Result values
- size_t *results_size, ///< [results_size] Output - Size of results
- const double *dnl, ///< [dnl] Input - DNL input to be analyzed
- gn_config *c ///< [c] Input - Configuration structure containing test parameters
- );
+ __api int gn_get_dnla_results (
+ char ***rkeys, ///< [rkeys] Output - Result keys
+ double **rvalues, ///< [rvalues] Output - Result values
+ size_t *results_size, ///< [results_size] Output - Size of results
+ const double *dnl, ///< [dnl] Input - DNL input to be analyzed
+ gn_config *
+ c ///< [c] Input - Configuration structure containing test parameters
+ );
/**
* @brief Do INL analysis and get results
* @return 0 on success, non-zero otherwise
*/
- __api int gn_get_inla_results(
- char ***rkeys, ///< [rkeys] Output - Result keys
- double **rvalues, ///< [rvalues] Output - Result values
- size_t *results_size, ///< [results_size] Output - Size of results
- const double *inl, ///< [dnl] Input - INL input to be analyzed
- gn_config *c ///< [c] Input - Configuration structure containing test parameters
- );
+ __api int gn_get_inla_results (
+ char ***rkeys, ///< [rkeys] Output - Result keys
+ double **rvalues, ///< [rvalues] Output - Result values
+ size_t *results_size, ///< [results_size] Output - Size of results
+ const double *inl, ///< [dnl] Input - INL input to be analyzed
+ gn_config *
+ c ///< [c] Input - Configuration structure containing test parameters
+ );
/**
* @brief Do Fourier analysis and get a single result
* @return 0 on success, non-zero otherwise
*/
- __api int gn_get_fa_single_result(
- double *rvalue,
- const char* metric_name,
- double *fft_ilv, ///< [fft_ilv] Input - Interleaved Re/Im array pointer
- gn_config *c ///< [c] Input - Configuration structure containing test parameters
- );
+ __api int gn_get_fa_single_result (
+ double *rvalue, const char *metric_name,
+ double *fft_ilv, ///< [fft_ilv] Input - Interleaved Re/Im array pointer
+ gn_config *
+ c ///< [c] Input - Configuration structure containing test parameters
+ );
/**
* @brief Do Fourier analysis and all get results
* @return 0 on success, non-zero otherwise
*/
- __api int gn_get_fa_results(
- char ***rkeys,
- double **rvalues,
- size_t *results_size, ///< [results_size] size of results
- double *fft_ilv, ///< [fft_ilv] Input - Interleaved Re/Im array pointer
- gn_config *c ///< [c] Input - Configuration structure containing test parameters
- );
-
+ __api int gn_get_fa_results (
+ char ***rkeys, double **rvalues,
+ size_t *results_size, ///< [results_size] size of results
+ double *fft_ilv, ///< [fft_ilv] Input - Interleaved Re/Im array pointer
+ gn_config *
+ c ///< [c] Input - Configuration structure containing test parameters
+ );
+
#ifdef __cplusplus
}
#endif
diff --git a/bindings/c/src/CMakeLists.txt b/bindings/c/src/CMakeLists.txt
index 45c70e7..d579528 100644
--- a/bindings/c/src/CMakeLists.txt
+++ b/bindings/c/src/CMakeLists.txt
@@ -53,11 +53,11 @@ configure_file(${PROJECT_SOURCE_DIR}/libgenalyzer.pc.cmakein ${GENALYZER_PC} @ON
install(FILES ${GENALYZER_PC} DESTINATION ${INSTALL_LIB_DIR}/pkgconfig)
install(TARGETS genalyzer
- ARCHIVE DESTINATION lib
- LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
- RUNTIME DESTINATION bin
- FRAMEWORK DESTINATION lib
- PUBLIC_HEADER DESTINATION include)
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
+ RUNTIME DESTINATION bin
+ FRAMEWORK DESTINATION lib
+ PUBLIC_HEADER DESTINATION include)
include(GNUInstallDirs)
diff --git a/bindings/c/src/cgenalyzer.cpp b/bindings/c/src/cgenalyzer.cpp
index b0c240a..8661250 100644
--- a/bindings/c/src/cgenalyzer.cpp
+++ b/bindings/c/src/cgenalyzer.cpp
@@ -1,54 +1,72 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#include "cgenalyzer.h"
#include "cgenalyzer_private.h"
using namespace util;
-namespace util {
+namespace util
+{
+
+static bool gn_null_terminate = true;
- static bool gn_null_terminate = true;
+size_t
+terminated_size (size_t string_size)
+{
+ return string_size + (util::gn_null_terminate ? 1 : 0);
+}
- size_t terminated_size(size_t string_size)
+void
+fill_string_buffer (const char *src, // Pointer to source
+ size_t src_size, // Size of source; should not count
+ // null-terminator, if it exists
+ char *dst, // Pointer to destination
+ size_t dst_size // Size of destination
+)
+{
+ if (nullptr == src)
{
- return string_size + (util::gn_null_terminate ? 1 : 0);
+ throw std::runtime_error ("fill_string_buffer : source is NULL");
}
-
- void fill_string_buffer(
- const char* src, // Pointer to source
- size_t src_size, // Size of source; should not count null-terminator, if it exists
- char* dst, // Pointer to destination
- size_t dst_size // Size of destination
- )
+ if (nullptr == dst)
{
- if (nullptr == src) {
- throw std::runtime_error("fill_string_buffer : source is NULL");
- }
- if (nullptr == dst) {
- throw std::runtime_error("fill_string_buffer : destination is NULL");
- }
- if (dst_size < terminated_size(src_size)) {
- throw std::runtime_error("fill_string_buffer : destination too small");
- }
- for (size_t i = 0; i < src_size; ++i) {
- dst[i] = src[i];
- }
- if (gn_null_terminate) {
- dst[src_size] = '\0';
- }
+ throw std::runtime_error ("fill_string_buffer : destination is NULL");
+ }
+ if (dst_size < terminated_size (src_size))
+ {
+ throw std::runtime_error ("fill_string_buffer : destination too small");
}
+ for (size_t i = 0; i < src_size; ++i)
+ {
+ dst[i] = src[i];
+ }
+ if (gn_null_terminate)
+ {
+ dst[src_size] = '\0';
+ }
+}
- std::string get_object_key_from_filename(const std::string& filename)
+std::string
+get_object_key_from_filename (const std::string &filename)
+{
+ static const std::regex re{ "(" + gn::manager::key_pattern + ")[.]json$",
+ std::regex::icase };
+ std::smatch matches;
+ if (std::regex_search (filename, matches, re))
{
- static const std::regex re {"(" + gn::manager::key_pattern + ")[.]json$", std::regex::icase};
- std::smatch matches;
- if (std::regex_search(filename, matches, re)) {
- if (1 == matches.size()) {
- throw std::runtime_error("unable to derive object key from filename '" + filename + "'");
- }
- return matches[1].str();
- } else {
- throw std::runtime_error("invalid filename '" + filename + "'");
+ if (1 == matches.size ())
+ {
+ throw std::runtime_error (
+ "unable to derive object key from filename '" + filename + "'");
}
+ return matches[1].str ();
+ }
+ else
+ {
+ throw std::runtime_error ("invalid filename '" + filename + "'");
}
+}
} // namespace util
@@ -56,148 +74,189 @@ namespace util {
/* API Utilities */
/**************************************************************************/
-int gn_analysis_results_key_sizes(size_t* key_sizes, size_t key_sizes_size, GnAnalysisType type)
+int
+gn_analysis_results_key_sizes (size_t *key_sizes, size_t key_sizes_size,
+ GnAnalysisType type)
{
- try {
- util::check_pointer(key_sizes);
- std::vector keys;
- switch (gn::get_enum(type))
+ try
+ {
+ util::check_pointer (key_sizes);
+ std::vector keys;
+ switch (gn::get_enum (type))
{
- case gn::AnalysisType::DNL :
- keys = gn::dnl_analysis_ordered_keys();
- break;
- case gn::AnalysisType::Histogram :
- keys = gn::hist_analysis_ordered_keys();
- break;
- case gn::AnalysisType::INL :
- keys = gn::inl_analysis_ordered_keys();
- break;
- case gn::AnalysisType::Waveform :
- keys = gn::wf_analysis_ordered_keys();
- break;
- default :
- throw std::runtime_error("Invalid analysis type");
+ case gn::AnalysisType::DNL:
+ keys = gn::dnl_analysis_ordered_keys ();
+ break;
+ case gn::AnalysisType::Histogram:
+ keys = gn::hist_analysis_ordered_keys ();
+ break;
+ case gn::AnalysisType::INL:
+ keys = gn::inl_analysis_ordered_keys ();
+ break;
+ case gn::AnalysisType::Waveform:
+ keys = gn::wf_analysis_ordered_keys ();
+ break;
+ default:
+ throw std::runtime_error ("Invalid analysis type");
}
- if (keys.size() != key_sizes_size) {
- throw std::runtime_error("Number of keys does not match output array size");
+ if (keys.size () != key_sizes_size)
+ {
+ throw std::runtime_error (
+ "Number of keys does not match output array size");
}
- for (size_t i = 0; i < key_sizes_size; ++i) {
- key_sizes[i] = util::terminated_size(keys[i].size());
+ for (size_t i = 0; i < key_sizes_size; ++i)
+ {
+ key_sizes[i] = util::terminated_size (keys[i].size ());
}
- return gn_success;
- } catch (const std::exception& e) {
- std::fill(key_sizes, key_sizes + key_sizes_size, 0);
- return util::return_on_exception("gn_analysis_results_key_sizes : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ std::fill (key_sizes, key_sizes + key_sizes_size, 0);
+ return util::return_on_exception ("gn_analysis_results_key_sizes : ",
+ e.what ());
}
}
-int gn_analysis_results_size(size_t* size, GnAnalysisType type)
+int
+gn_analysis_results_size (size_t *size, GnAnalysisType type)
{
- try {
- util::check_pointer(size);
- switch (gn::get_enum(type))
+ try
+ {
+ util::check_pointer (size);
+ switch (gn::get_enum (type))
{
- case gn::AnalysisType::DNL :
- *size = gn::dnl_analysis_ordered_keys().size();
- break;
- case gn::AnalysisType::Histogram :
- *size = gn::hist_analysis_ordered_keys().size();
- break;
- case gn::AnalysisType::INL :
- *size = gn::inl_analysis_ordered_keys().size();
- break;
- case gn::AnalysisType::Waveform :
- *size = gn::wf_analysis_ordered_keys().size();
- break;
- default :
- throw std::runtime_error("Invalid analysis type");
+ case gn::AnalysisType::DNL:
+ *size = gn::dnl_analysis_ordered_keys ().size ();
+ break;
+ case gn::AnalysisType::Histogram:
+ *size = gn::hist_analysis_ordered_keys ().size ();
+ break;
+ case gn::AnalysisType::INL:
+ *size = gn::inl_analysis_ordered_keys ().size ();
+ break;
+ case gn::AnalysisType::Waveform:
+ *size = gn::wf_analysis_ordered_keys ().size ();
+ break;
+ default:
+ throw std::runtime_error ("Invalid analysis type");
}
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_analysis_results_size : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_analysis_results_size : ",
+ e.what ());
}
}
-int gn_enum_value(int* value, const char* enumeration, const char* enumerator)
+int
+gn_enum_value (int *value, const char *enumeration, const char *enumerator)
{
- try {
- util::check_pointer(value);
- *value = gn::enum_value(enumeration, enumerator);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_enum_value : ", e.what());
+ try
+ {
+ util::check_pointer (value);
+ *value = gn::enum_value (enumeration, enumerator);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_enum_value : ", e.what ());
}
}
-int gn_error_check(bool* error)
+int
+gn_error_check (bool *error)
{
- try {
- util::check_pointer(error);
- *error = util::gn_error_log.check();
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_error_check : ", e.what());
+ try
+ {
+ util::check_pointer (error);
+ *error = util::gn_error_log.check ();
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_error_check : ", e.what ());
}
}
-int gn_error_clear()
+int
+gn_error_clear ()
{
- util::gn_error_log.clear();
- return gn_success;
+ util::gn_error_log.clear ();
+ return gn_success;
}
-int gn_error_string(char* buf, size_t size)
+int
+gn_error_string (char *buf, size_t size)
{
- try {
- std::string_view s = util::gn_error_log.get();
- util::fill_string_buffer(s.data(), s.size(), buf, size);
- } catch (const std::exception&) {
- return gn_failure;
+ try
+ {
+ std::string_view s = util::gn_error_log.get ();
+ util::fill_string_buffer (s.data (), s.size (), buf, size);
+ }
+ catch (const std::exception &)
+ {
+ return gn_failure;
}
- return gn_success;
+ return gn_success;
}
-int gn_set_string_termination(bool null_terminated)
+int
+gn_set_string_termination (bool null_terminated)
{
- util::gn_null_terminate = null_terminated;
- return gn_success;
+ util::gn_null_terminate = null_terminated;
+ return gn_success;
}
-int gn_version_string(char* buf, size_t size)
+int
+gn_version_string (char *buf, size_t size)
{
- try {
- std::string_view s = gn::version_string();
- util::fill_string_buffer(s.data(), s.size(), buf, size);
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_version_string : ", e.what());
+ try
+ {
+ std::string_view s = gn::version_string ();
+ util::fill_string_buffer (s.data (), s.size (), buf, size);
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_version_string : ", e.what ());
}
- return gn_success;
+ return gn_success;
}
/**************************************************************************/
/* API Utility Helpers */
/**************************************************************************/
-int gn_error_string_size(size_t* size)
+int
+gn_error_string_size (size_t *size)
{
- try {
- util::check_pointer(size);
- *size = util::terminated_size(util::gn_error_log.size());
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_error_string_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ *size = util::terminated_size (util::gn_error_log.size ());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_error_string_size : ", e.what ());
}
}
-int gn_version_string_size(size_t* size)
+int
+gn_version_string_size (size_t *size)
{
- try {
- util::check_pointer(size);
- *size = util::terminated_size(gn::version_string().size());
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_version_string_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ *size = util::terminated_size (gn::version_string ().size ());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_version_string_size : ",
+ e.what ());
}
}
@@ -205,63 +264,87 @@ int gn_version_string_size(size_t* size)
/* Array Operations */
/**************************************************************************/
-int gn_abs(double* out, size_t out_size, const double* in, size_t in_size)
+int
+gn_abs (double *out, size_t out_size, const double *in, size_t in_size)
{
- try {
- gn::abs(in, in_size, out, out_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_abs : ", e.what());
+ try
+ {
+ gn::abs (in, in_size, out, out_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_abs : ", e.what ());
}
}
-int gn_angle(double* out, size_t out_size, const double* in, size_t in_size)
+int
+gn_angle (double *out, size_t out_size, const double *in, size_t in_size)
{
- try {
- gn::angle(in, in_size, out, out_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_angle : ", e.what());
+ try
+ {
+ gn::angle (in, in_size, out, out_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_angle : ", e.what ());
}
}
-int gn_db(double* out, size_t out_size, const double* in, size_t in_size)
+int
+gn_db (double *out, size_t out_size, const double *in, size_t in_size)
{
- try {
- gn::db(in, in_size, out, out_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_db : ", e.what());
+ try
+ {
+ gn::db (in, in_size, out, out_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_db : ", e.what ());
}
}
-int gn_db10(double* out, size_t out_size, const double* in, size_t in_size)
+int
+gn_db10 (double *out, size_t out_size, const double *in, size_t in_size)
{
- try {
- gn::db10(in, in_size, out, out_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_db10 : ", e.what());
+ try
+ {
+ gn::db10 (in, in_size, out, out_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_db10 : ", e.what ());
}
}
-int gn_db20(double* out, size_t out_size, const double* in, size_t in_size)
+int
+gn_db20 (double *out, size_t out_size, const double *in, size_t in_size)
{
- try {
- gn::db20(in, in_size, out, out_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_db20 : ", e.what());
+ try
+ {
+ gn::db20 (in, in_size, out, out_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_db20 : ", e.what ());
}
}
-int gn_norm(double* out, size_t out_size, const double* in, size_t in_size)
+int
+gn_norm (double *out, size_t out_size, const double *in, size_t in_size)
{
- try {
- gn::norm(in, in_size, out, out_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_norm : ", e.what());
+ try
+ {
+ gn::norm (in, in_size, out, out_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_norm : ", e.what ());
}
}
@@ -269,192 +352,250 @@ int gn_norm(double* out, size_t out_size, const double* in, size_t in_size)
/* Code Density */
/**************************************************************************/
-namespace {
+namespace
+{
- template
- int gn_hist(const char* suffix, uint64_t* hist, size_t hist_size,
- const T* in, size_t in_size, int n, GnCodeFormat format, bool preserve)
+template
+int
+gn_hist (const char *suffix, uint64_t *hist, size_t hist_size, const T *in,
+ size_t in_size, int n, GnCodeFormat format, bool preserve)
+{
+ try
{
- try {
- gn::CodeFormat f = gn::get_enum(format);
- gn::hist(hist, hist_size, in, in_size, n, f, preserve);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_hist", suffix, " : ", e.what());
- }
+ gn::CodeFormat f = gn::get_enum (format);
+ gn::hist (hist, hist_size, in, in_size, n, f, preserve);
+ return gn_success;
}
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_hist", suffix, " : ", e.what ());
+ }
+}
- template
- int gn_histx(const char* suffix, uint64_t* hist, size_t hist_size,
- const T* in, size_t in_size, int64_t min, int64_t max, bool preserve)
+template
+int
+gn_histx (const char *suffix, uint64_t *hist, size_t hist_size, const T *in,
+ size_t in_size, int64_t min, int64_t max, bool preserve)
+{
+ try
{
- try {
- gn::histx(hist, hist_size, in, in_size, min, max, preserve);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_histx", suffix, " : ", e.what());
- }
+ gn::histx (hist, hist_size, in, in_size, min, max, preserve);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_histx", suffix, " : ", e.what ());
}
+}
} // namespace anonymous
-int gn_code_axis(double* out, size_t size, int n, GnCodeFormat format)
+int
+gn_code_axis (double *out, size_t size, int n, GnCodeFormat format)
{
- try {
- gn::CodeFormat f = gn::get_enum(format);
- gn::code_axis(out, size, n, f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_code_axis : ", e.what());
+ try
+ {
+ gn::CodeFormat f = gn::get_enum (format);
+ gn::code_axis (out, size, n, f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_code_axis : ", e.what ());
}
}
-int gn_code_axisx(double* out, size_t size, int64_t min, int64_t max)
+int
+gn_code_axisx (double *out, size_t size, int64_t min, int64_t max)
{
- try {
- gn::code_axisx(out, size, min, max);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_code_axisx : ", e.what());
+ try
+ {
+ gn::code_axisx (out, size, min, max);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_code_axisx : ", e.what ());
}
}
-int gn_dnl(double* dnl, size_t dnl_size, const uint64_t* hist, size_t hist_size, GnDnlSignal type)
+int
+gn_dnl (double *dnl, size_t dnl_size, const uint64_t *hist, size_t hist_size,
+ GnDnlSignal type)
{
- try {
- gn::DnlSignal t = gn::get_enum(type);
- gn::dnl(dnl, dnl_size, hist, hist_size, t);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_dnl : ", e.what());
+ try
+ {
+ gn::DnlSignal t = gn::get_enum (type);
+ gn::dnl (dnl, dnl_size, hist, hist_size, t);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_dnl : ", e.what ());
}
}
-int gn_dnl_analysis(char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const double* dnl, size_t dnl_size)
+int
+gn_dnl_analysis (char **rkeys, size_t rkeys_size, double *rvalues,
+ size_t rvalues_size, const double *dnl, size_t dnl_size)
{
- try {
- util::check_pointer(rkeys);
- util::check_pointer(rvalues);
- const std::vector& keys = gn::dnl_analysis_ordered_keys();
- if (keys.size() != rkeys_size) {
- throw std::runtime_error("Size of result key array is wrong");
+ try
+ {
+ util::check_pointer (rkeys);
+ util::check_pointer (rvalues);
+ const std::vector &keys = gn::dnl_analysis_ordered_keys ();
+ if (keys.size () != rkeys_size)
+ {
+ throw std::runtime_error ("Size of result key array is wrong");
}
- if (rvalues_size != rkeys_size) {
- throw std::runtime_error("Size of result keys does not match size of result values");
+ if (rvalues_size != rkeys_size)
+ {
+ throw std::runtime_error (
+ "Size of result keys does not match size of result values");
}
- std::map results = gn::dnl_analysis(dnl, dnl_size);
- for (size_t i = 0; i < keys.size(); ++i) {
- const std::string& src = keys[i];
- char* dst = rkeys[i];
- size_t dst_size = util::terminated_size(src.size());
- util::fill_string_buffer(src.data(), src.size(), dst, dst_size);
- rvalues[i] = results.at(src);
+ std::map results = gn::dnl_analysis (dnl, dnl_size);
+ for (size_t i = 0; i < keys.size (); ++i)
+ {
+ const std::string &src = keys[i];
+ char *dst = rkeys[i];
+ size_t dst_size = util::terminated_size (src.size ());
+ util::fill_string_buffer (src.data (), src.size (), dst, dst_size);
+ rvalues[i] = results.at (src);
}
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_dnl_analysis : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_dnl_analysis : ", e.what ());
}
}
-int gn_hist16(uint64_t* hist, size_t hist_size, const int16_t* in, size_t in_size,
- int n, GnCodeFormat format, bool preserve)
+int
+gn_hist16 (uint64_t *hist, size_t hist_size, const int16_t *in, size_t in_size,
+ int n, GnCodeFormat format, bool preserve)
{
- return gn_hist("16", hist, hist_size, in, in_size, n, format, preserve);
+ return gn_hist ("16", hist, hist_size, in, in_size, n, format, preserve);
}
-int gn_hist32(uint64_t* hist, size_t hist_size, const int32_t* in, size_t in_size,
- int n, GnCodeFormat format, bool preserve)
+int
+gn_hist32 (uint64_t *hist, size_t hist_size, const int32_t *in, size_t in_size,
+ int n, GnCodeFormat format, bool preserve)
{
- return gn_hist("32", hist, hist_size, in, in_size, n, format, preserve);
+ return gn_hist ("32", hist, hist_size, in, in_size, n, format, preserve);
}
-int gn_hist64(uint64_t* hist, size_t hist_size, const int64_t* in, size_t in_size,
- int n, GnCodeFormat format, bool preserve)
+int
+gn_hist64 (uint64_t *hist, size_t hist_size, const int64_t *in, size_t in_size,
+ int n, GnCodeFormat format, bool preserve)
{
- return gn_hist("64", hist, hist_size, in, in_size, n, format, preserve);
+ return gn_hist ("64", hist, hist_size, in, in_size, n, format, preserve);
}
-int gn_histx16(uint64_t* hist, size_t hist_size, const int16_t* in, size_t in_size,
- int64_t min, int64_t max, bool preserve)
+int
+gn_histx16 (uint64_t *hist, size_t hist_size, const int16_t *in,
+ size_t in_size, int64_t min, int64_t max, bool preserve)
{
- return gn_histx("16", hist, hist_size, in, in_size, min, max, preserve);
+ return gn_histx ("16", hist, hist_size, in, in_size, min, max, preserve);
}
-int gn_histx32(uint64_t* hist, size_t hist_size, const int32_t* in, size_t in_size,
- int64_t min, int64_t max, bool preserve)
+int
+gn_histx32 (uint64_t *hist, size_t hist_size, const int32_t *in,
+ size_t in_size, int64_t min, int64_t max, bool preserve)
{
- return gn_histx("32", hist, hist_size, in, in_size, min, max, preserve);
+ return gn_histx ("32", hist, hist_size, in, in_size, min, max, preserve);
}
-int gn_histx64(uint64_t* hist, size_t hist_size, const int64_t* in, size_t in_size,
- int64_t min, int64_t max, bool preserve)
+int
+gn_histx64 (uint64_t *hist, size_t hist_size, const int64_t *in,
+ size_t in_size, int64_t min, int64_t max, bool preserve)
{
- return gn_histx("64", hist, hist_size, in, in_size, min, max, preserve);
+ return gn_histx ("64", hist, hist_size, in, in_size, min, max, preserve);
}
-int gn_hist_analysis(char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const uint64_t* hist, size_t hist_size)
+int
+gn_hist_analysis (char **rkeys, size_t rkeys_size, double *rvalues,
+ size_t rvalues_size, const uint64_t *hist, size_t hist_size)
{
- try {
- util::check_pointer(rkeys);
- util::check_pointer(rvalues);
- const std::vector& keys = gn::hist_analysis_ordered_keys();
- if (keys.size() != rkeys_size) {
- throw std::runtime_error("Size of result key array is wrong");
+ try
+ {
+ util::check_pointer (rkeys);
+ util::check_pointer (rvalues);
+ const std::vector &keys = gn::hist_analysis_ordered_keys ();
+ if (keys.size () != rkeys_size)
+ {
+ throw std::runtime_error ("Size of result key array is wrong");
}
- if (rvalues_size != rkeys_size) {
- throw std::runtime_error("Size of result keys does not match size of result values");
+ if (rvalues_size != rkeys_size)
+ {
+ throw std::runtime_error (
+ "Size of result keys does not match size of result values");
}
- std::map results = gn::hist_analysis(hist, hist_size);
- for (size_t i = 0; i < keys.size(); ++i) {
- const std::string& src = keys[i];
- char* dst = rkeys[i];
- size_t dst_size = util::terminated_size(src.size());
- util::fill_string_buffer(src.data(), src.size(), dst, dst_size);
- rvalues[i] = results.at(src);
+ std::map results
+ = gn::hist_analysis (hist, hist_size);
+ for (size_t i = 0; i < keys.size (); ++i)
+ {
+ const std::string &src = keys[i];
+ char *dst = rkeys[i];
+ size_t dst_size = util::terminated_size (src.size ());
+ util::fill_string_buffer (src.data (), src.size (), dst, dst_size);
+ rvalues[i] = results.at (src);
}
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_hist_analysis : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_hist_analysis : ", e.what ());
}
}
-int gn_inl(double* inl, size_t inl_size, const double* dnl, size_t dnl_size, GnInlLineFit fit)
+int
+gn_inl (double *inl, size_t inl_size, const double *dnl, size_t dnl_size,
+ GnInlLineFit fit)
{
- try {
- gn::InlLineFit f = gn::get_enum(fit);
- gn::inl(inl, inl_size, dnl, dnl_size, f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_inl : ", e.what());
+ try
+ {
+ gn::InlLineFit f = gn::get_enum (fit);
+ gn::inl (inl, inl_size, dnl, dnl_size, f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_inl : ", e.what ());
}
}
-int gn_inl_analysis(char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const double* inl, size_t inl_size)
+int
+gn_inl_analysis (char **rkeys, size_t rkeys_size, double *rvalues,
+ size_t rvalues_size, const double *inl, size_t inl_size)
{
- try {
- util::check_pointer(rkeys);
- util::check_pointer(rvalues);
- const std::vector& keys = gn::inl_analysis_ordered_keys();
- if (keys.size() != rkeys_size) {
- throw std::runtime_error("Size of result key array is wrong");
+ try
+ {
+ util::check_pointer (rkeys);
+ util::check_pointer (rvalues);
+ const std::vector &keys = gn::inl_analysis_ordered_keys ();
+ if (keys.size () != rkeys_size)
+ {
+ throw std::runtime_error ("Size of result key array is wrong");
}
- if (rvalues_size != rkeys_size) {
- throw std::runtime_error("Size of result keys does not match size of result values");
+ if (rvalues_size != rkeys_size)
+ {
+ throw std::runtime_error (
+ "Size of result keys does not match size of result values");
}
- std::map results = gn::inl_analysis(inl, inl_size);
- for (size_t i = 0; i < keys.size(); ++i) {
- const std::string& src = keys[i];
- char* dst = rkeys[i];
- size_t dst_size = util::terminated_size(src.size());
- util::fill_string_buffer(src.data(), src.size(), dst, dst_size);
- rvalues[i] = results.at(src);
+ std::map results = gn::inl_analysis (inl, inl_size);
+ for (size_t i = 0; i < keys.size (); ++i)
+ {
+ const std::string &src = keys[i];
+ char *dst = rkeys[i];
+ size_t dst_size = util::terminated_size (src.size ());
+ util::fill_string_buffer (src.data (), src.size (), dst, dst_size);
+ rvalues[i] = results.at (src);
}
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_inl_analysis : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_inl_analysis : ", e.what ());
}
}
@@ -462,28 +603,36 @@ int gn_inl_analysis(char** rkeys, size_t rkeys_size, double* rvalues, size_t rva
/* Code Density Helpers */
/**************************************************************************/
-int gn_code_density_size(size_t* size, int n, GnCodeFormat format)
+int
+gn_code_density_size (size_t *size, int n, GnCodeFormat format)
{
- try {
- util::check_pointer(size);
- gn::CodeFormat f = gn::get_enum(format);
- *size = gn::code_density_size(n, f);
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_code_density_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ gn::CodeFormat f = gn::get_enum (format);
+ *size = gn::code_density_size (n, f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_code_density_size : ", e.what ());
}
}
-int gn_code_densityx_size(size_t* size, int64_t min, int64_t max)
+int
+gn_code_densityx_size (size_t *size, int64_t min, int64_t max)
{
- try {
- util::check_pointer(size);
- *size = gn::code_densityx_size(min, max);
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_code_densityx_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ *size = gn::code_densityx_size (min, max);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_code_densityx_size : ", e.what ());
}
}
@@ -491,192 +640,267 @@ int gn_code_densityx_size(size_t* size, int64_t min, int64_t max)
/* Fourier Analysis */
/**************************************************************************/
-namespace {
+namespace
+{
- using fa_ptr = std::shared_ptr;
+using fa_ptr = std::shared_ptr;
- fa_ptr get_fa_object(const std::string& obj_key)
+fa_ptr
+get_fa_object (const std::string &obj_key)
+{
+ gn::object::pointer pobj = gn::manager::get_object (obj_key);
+ const gn::ObjectType obj_type = gn::ObjectType::FourierAnalysis;
+ if (obj_type != pobj->object_type ())
{
- gn::object::pointer pobj = gn::manager::get_object(obj_key);
- const gn::ObjectType obj_type = gn::ObjectType::FourierAnalysis;
- if (obj_type != pobj->object_type()) {
- throw std::runtime_error("object '" + obj_key + "' is not of type "
- + gn::object_type_map.at(static_cast(obj_type)));
- }
- return std::static_pointer_cast(pobj);
+ throw std::runtime_error (
+ "object '" + obj_key + "' is not of type "
+ + gn::object_type_map.at (static_cast (obj_type)));
}
+ return std::static_pointer_cast (pobj);
+}
- fa_ptr get_fa_object_or_load_from_file(std::string cfg_id)
+fa_ptr
+get_fa_object_or_load_from_file (std::string cfg_id)
+{
+ if (gn::manager::contains (cfg_id))
{
- if (gn::manager::contains(cfg_id)) {
- return get_fa_object(cfg_id);
- } else {
- return gn::fourier_analysis::load(cfg_id);
- }
+ return get_fa_object (cfg_id);
+ }
+ else
+ {
+ return gn::fourier_analysis::load (cfg_id);
}
+}
- size_t get_fa_result_key_index(const char** rkeys, size_t rkeys_size, const char* rkey)
+size_t
+get_fa_result_key_index (const char **rkeys, size_t rkeys_size,
+ const char *rkey)
+{
+ size_t i = 0;
+ for (; i < rkeys_size; ++i)
{
- size_t i = 0;
- for (; i < rkeys_size; ++i) {
- if (0 == strcmp(rkeys[i], rkey)) {
- break;
- }
- }
- if (rkeys_size == i) {
- throw std::runtime_error("Result key '" + std::string(rkey) + "' not found");
+ if (0 == strcmp (rkeys[i], rkey))
+ {
+ break;
}
- return i;
}
+ if (rkeys_size == i)
+ {
+ throw std::runtime_error ("Result key '" + std::string (rkey)
+ + "' not found");
+ }
+ return i;
+}
- std::string get_fa_result_string(const char** rkeys, size_t rkeys_size,
- const double* rvalues, size_t rvalues_size, const char* rkey)
+std::string
+get_fa_result_string (const char **rkeys, size_t rkeys_size,
+ const double *rvalues, size_t rvalues_size,
+ const char *rkey)
+{
+ if (rkeys_size != rvalues_size)
{
- if (rkeys_size != rvalues_size) {
- throw std::runtime_error("Size of result keys does not match size of result values");
- }
- if (gn::fa_result_map.contains(rkey, true)) {
- gn::FAResult renum = static_cast(gn::fa_result_map.at(rkey));
- if (gn::FAResult::CarrierIndex == renum ||
- gn::FAResult::MaxSpurIndex == renum) {
- // Caller requests the Carrier or MaxSpur tone key.
- size_t key_index = get_fa_result_key_index(rkeys, rkeys_size, rkey);
- size_t order_index = static_cast(rvalues[key_index]);
- int order_index_int = static_cast(gn::FAToneResult::OrderIndex);
- std::string search_str = ":" + gn::fa_tone_result_map.at(order_index_int);
- const char* search_cstr = search_str.c_str();
- size_t i = 0;
- for (; i < rvalues_size; ++i) {
- if (strstr(rkeys[i], search_cstr)) {
- if (rvalues[i] == order_index) {
- break;
- }
+ throw std::runtime_error (
+ "Size of result keys does not match size of result values");
+ }
+ if (gn::fa_result_map.contains (rkey, true))
+ {
+ gn::FAResult renum
+ = static_cast (gn::fa_result_map.at (rkey));
+ if (gn::FAResult::CarrierIndex == renum
+ || gn::FAResult::MaxSpurIndex == renum)
+ {
+ // Caller requests the Carrier or MaxSpur tone key.
+ size_t key_index = get_fa_result_key_index (rkeys, rkeys_size, rkey);
+ size_t order_index = static_cast (rvalues[key_index]);
+ int order_index_int
+ = static_cast (gn::FAToneResult::OrderIndex);
+ std::string search_str
+ = ":" + gn::fa_tone_result_map.at (order_index_int);
+ const char *search_cstr = search_str.c_str ();
+ size_t i = 0;
+ for (; i < rvalues_size; ++i)
+ {
+ if (strstr (rkeys[i], search_cstr))
+ {
+ if (rvalues[i] == order_index)
+ {
+ break;
}
}
- if (rvalues_size == i) {
- return "Not Found";
- } else {
- return gn::fourier_analysis::split_key(rkeys[i]).first;
- }
}
- } else {
- // In the future, there could be a string associated with a tone result.
+ if (rvalues_size == i)
+ {
+ return "Not Found";
+ }
+ else
+ {
+ return gn::fourier_analysis::split_key (rkeys[i]).first;
+ }
}
- throw std::runtime_error("no string associated with result key '" + std::string(rkey) + "'");
}
+ else
+ {
+ // In the future, there could be a string associated with a tone result.
+ }
+ throw std::runtime_error ("no string associated with result key '"
+ + std::string (rkey) + "'");
+}
- int get_fa_single_result(
- const gn::fourier_analysis_results& results, const char* rkey, double* rvalue)
+int
+get_fa_single_result (const gn::fourier_analysis_results &results,
+ const char *rkey, double *rvalue)
+{
+ *rvalue = 0.0;
+ std::pair keys
+ = gn::fourier_analysis::split_key (rkey);
+ if (!keys.first.empty ())
{
- *rvalue = 0.0;
- std::pair keys = gn::fourier_analysis::split_key(rkey);
- if (!keys.first.empty()) {
- if (keys.second.empty()) {
- if (gn::fa_result_map.contains(keys.first)) {
- int i = gn::fa_result_map.at(keys.first);
- *rvalue = results.get(static_cast(i));
- return gn_success;
- }
- } else {
- if (results.contains_tone(keys.first)) {
- const gn::fa_tone_results& tres = results.get_tone(keys.first);
- if (gn::fa_tone_result_map.at(keys.second)) {
- int i = gn::fa_tone_result_map.at(keys.second);
- *rvalue = tres.get(static_cast(i));
- return gn_success;
- }
+ if (keys.second.empty ())
+ {
+ if (gn::fa_result_map.contains (keys.first))
+ {
+ int i = gn::fa_result_map.at (keys.first);
+ *rvalue = results.get (static_cast (i));
+ return gn_success;
+ }
+ }
+ else
+ {
+ if (results.contains_tone (keys.first))
+ {
+ const gn::fa_tone_results &tres = results.get_tone (keys.first);
+ if (gn::fa_tone_result_map.at (keys.second))
+ {
+ int i = gn::fa_tone_result_map.at (keys.second);
+ *rvalue = tres.get (static_cast (i));
+ return gn_success;
}
}
}
- return gn_failure;
}
+ return gn_failure;
+}
} // namespace anonymous
-int gn_fft_analysis(char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const char* cfg_id, const double* in, size_t in_size, size_t nfft, GnFreqAxisType axis_type)
+int
+gn_fft_analysis (char **rkeys, size_t rkeys_size, double *rvalues,
+ size_t rvalues_size, const char *cfg_id, const double *in,
+ size_t in_size, size_t nfft, GnFreqAxisType axis_type)
{
- try {
- if (rkeys_size != rvalues_size) {
- throw std::runtime_error("Size of result keys does not match size of result values");
+ try
+ {
+ if (rkeys_size != rvalues_size)
+ {
+ throw std::runtime_error (
+ "Size of result keys does not match size of result values");
}
- fa_ptr obj = get_fa_object_or_load_from_file(cfg_id);
- gn::FreqAxisType at = gn::get_enum(axis_type);
- gn::fourier_analysis_results results = obj->analyze(in, in_size, nfft, at);
- // The rest of this function flattens results into a key-array and value-array pair
- size_t i = 0; // index for rkeys, rvalues
- const std::map& rmap = results.results;
- for (int j = 0; j < static_cast(gn::FAResult::__SIZE__); ++j) {
- const std::string& src = gn::fa_result_map.at(j);
- char* dst = rkeys[i];
- size_t dst_size = util::terminated_size(src.size());
- util::fill_string_buffer(src.data(), src.size(), dst, dst_size);
- rvalues[i] = rmap.at(static_cast(j));
- i += 1;
+ fa_ptr obj = get_fa_object_or_load_from_file (cfg_id);
+ gn::FreqAxisType at = gn::get_enum (axis_type);
+ gn::fourier_analysis_results results
+ = obj->analyze (in, in_size, nfft, at);
+ // The rest of this function flattens results into a key-array and
+ // value-array pair
+ size_t i = 0; // index for rkeys, rvalues
+ const std::map &rmap = results.results;
+ for (int j = 0; j < static_cast (gn::FAResult::__SIZE__); ++j)
+ {
+ const std::string &src = gn::fa_result_map.at (j);
+ char *dst = rkeys[i];
+ size_t dst_size = util::terminated_size (src.size ());
+ util::fill_string_buffer (src.data (), src.size (), dst, dst_size);
+ rvalues[i] = rmap.at (static_cast (j));
+ i += 1;
}
- for (const std::string& tkey : results.tone_keys) {
- const gn::fa_tone_results& tone_results = results.get_tone(tkey);
- const std::map& trmap = tone_results.results;
- for (int j = 0; j < static_cast(gn::FAToneResult::__SIZE__); ++j) {
- std::string src = gn::fourier_analysis::flat_tone_key(tkey, j);
- char* dst = rkeys[i];
- size_t dst_size = util::terminated_size(src.size());
- util::fill_string_buffer(src.data(), src.size(), dst, dst_size);
- rvalues[i] = trmap.at(static_cast(j));
- i += 1;
+ for (const std::string &tkey : results.tone_keys)
+ {
+ const gn::fa_tone_results &tone_results = results.get_tone (tkey);
+ const std::map &trmap
+ = tone_results.results;
+ for (int j = 0; j < static_cast (gn::FAToneResult::__SIZE__);
+ ++j)
+ {
+ std::string src = gn::fourier_analysis::flat_tone_key (tkey, j);
+ char *dst = rkeys[i];
+ size_t dst_size = util::terminated_size (src.size ());
+ util::fill_string_buffer (src.data (), src.size (), dst,
+ dst_size);
+ rvalues[i] = trmap.at (static_cast (j));
+ i += 1;
}
}
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_execute : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_execute : ", e.what ());
}
}
-int gn_fft_analysis_select(double* rvalues, size_t rvalues_size,
- const char* cfg_id, const char** rkeys, size_t rkeys_size,
- const double* in, size_t in_size, size_t nfft, GnFreqAxisType axis_type)
+int
+gn_fft_analysis_select (double *rvalues, size_t rvalues_size,
+ const char *cfg_id, const char **rkeys,
+ size_t rkeys_size, const double *in, size_t in_size,
+ size_t nfft, GnFreqAxisType axis_type)
{
- try {
- if (rkeys_size != rvalues_size) {
- throw std::runtime_error("Size of result keys does not match size of result values");
+ try
+ {
+ if (rkeys_size != rvalues_size)
+ {
+ throw std::runtime_error (
+ "Size of result keys does not match size of result values");
}
- fa_ptr obj = get_fa_object_or_load_from_file(cfg_id);
- gn::FreqAxisType at = gn::get_enum(axis_type);
- gn::fourier_analysis_results results = obj->analyze(in, in_size, nfft, at);
- std::string missing_keys {};
- for (size_t i = 0; i < rkeys_size; ++i) {
- int error = get_fa_single_result(results, rkeys[i], &rvalues[i]);
- if (error) {
- if (!missing_keys.empty()) {
- missing_keys += ", ";
+ fa_ptr obj = get_fa_object_or_load_from_file (cfg_id);
+ gn::FreqAxisType at = gn::get_enum (axis_type);
+ gn::fourier_analysis_results results
+ = obj->analyze (in, in_size, nfft, at);
+ std::string missing_keys{};
+ for (size_t i = 0; i < rkeys_size; ++i)
+ {
+ int error = get_fa_single_result (results, rkeys[i], &rvalues[i]);
+ if (error)
+ {
+ if (!missing_keys.empty ())
+ {
+ missing_keys += ", ";
}
- missing_keys.append("'" + std::string(rkeys[i]) + "'");
+ missing_keys.append ("'" + std::string (rkeys[i]) + "'");
}
}
- if (!missing_keys.empty()) {
- throw std::runtime_error("Keys not found: " + missing_keys);
+ if (!missing_keys.empty ())
+ {
+ throw std::runtime_error ("Keys not found: " + missing_keys);
}
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_execute2 : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_execute2 : ", e.what ());
}
}
-int gn_fft_analysis_single(double* rvalue,
- const char* cfg_id, const char* rkey,
- const double* in, size_t in_size, size_t nfft, GnFreqAxisType axis_type)
+int
+gn_fft_analysis_single (double *rvalue, const char *cfg_id, const char *rkey,
+ const double *in, size_t in_size, size_t nfft,
+ GnFreqAxisType axis_type)
{
- try {
- fa_ptr obj = get_fa_object_or_load_from_file(cfg_id);
- gn::FreqAxisType at = gn::get_enum(axis_type);
- gn::fourier_analysis_results results = obj->analyze(in, in_size, nfft, at);
- int error = get_fa_single_result(results, rkey, rvalue);
- if (error) {
- throw std::runtime_error("Key '" + std::string(rkey) + "' not found");
+ try
+ {
+ fa_ptr obj = get_fa_object_or_load_from_file (cfg_id);
+ gn::FreqAxisType at = gn::get_enum (axis_type);
+ gn::fourier_analysis_results results
+ = obj->analyze (in, in_size, nfft, at);
+ int error = get_fa_single_result (results, rkey, rvalue);
+ if (error)
+ {
+ throw std::runtime_error ("Key '" + std::string (rkey)
+ + "' not found");
}
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_execute1 : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_execute1 : ", e.what ());
}
}
@@ -684,324 +908,433 @@ int gn_fft_analysis_single(double* rvalue,
/* Fourier Analysis Configuration */
/**************************************************************************/
-int gn_fa_analysis_band(const char* obj_key, double center, double width)
+int
+gn_fa_analysis_band (const char *obj_key, double center, double width)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- std::string center_s = gn::to_string(center, gn::FPFormat::Eng);
- std::string width_s = gn::to_string(width, gn::FPFormat::Eng);
- obj->set_analysis_band(center_s, width_s);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_analysis_band : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ std::string center_s = gn::to_string (center, gn::FPFormat::Eng);
+ std::string width_s = gn::to_string (width, gn::FPFormat::Eng);
+ obj->set_analysis_band (center_s, width_s);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_analysis_band : ", e.what ());
}
}
-int gn_fa_analysis_band_e(const char* obj_key, const char* center, const char* width)
+int
+gn_fa_analysis_band_e (const char *obj_key, const char *center,
+ const char *width)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_analysis_band(center, width);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_analysis_band_e : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_analysis_band (center, width);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_analysis_band_e : ", e.what ());
}
}
-int gn_fa_clk(const char* obj_key, const int* clk, size_t clk_size, bool as_noise)
+int
+gn_fa_clk (const char *obj_key, const int *clk, size_t clk_size, bool as_noise)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- std::set clk2 (clk, clk + clk_size);
- obj->set_clk(clk2);
- obj->clk_as_noise = as_noise;
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_clk : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ std::set clk2 (clk, clk + clk_size);
+ obj->set_clk (clk2);
+ obj->clk_as_noise = as_noise;
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_clk : ", e.what ());
}
}
-int gn_fa_conv_offset(const char* obj_key, bool enable)
+int
+gn_fa_conv_offset (const char *obj_key, bool enable)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->en_conv_offset = enable;
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_conv_offset : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->en_conv_offset = enable;
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_conv_offset : ", e.what ());
}
}
-int gn_fa_create(const char* obj_key)
+int
+gn_fa_create (const char *obj_key)
{
- try {
- gn::manager::add_object(obj_key, gn::fourier_analysis::create(), false);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_create : ", e.what());
+ try
+ {
+ gn::manager::add_object (obj_key, gn::fourier_analysis::create (),
+ false);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_create : ", e.what ());
}
}
-int gn_fa_dc(const char* obj_key, bool as_dist)
+int
+gn_fa_dc (const char *obj_key, bool as_dist)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->dc_as_dist = as_dist;
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_dc : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->dc_as_dist = as_dist;
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_dc : ", e.what ());
}
}
-int gn_fa_fdata(const char* obj_key, double f)
+int
+gn_fa_fdata (const char *obj_key, double f)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- std::string f_s = gn::to_string(f, gn::FPFormat::Eng);
- obj->set_fdata(f_s);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fdata : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ std::string f_s = gn::to_string (f, gn::FPFormat::Eng);
+ obj->set_fdata (f_s);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fdata : ", e.what ());
}
}
-int gn_fa_fdata_e(const char* obj_key, const char* f)
+int
+gn_fa_fdata_e (const char *obj_key, const char *f)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_fdata(f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fdata_e : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_fdata (f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fdata_e : ", e.what ());
}
}
-int gn_fa_fixed_tone(
- const char* obj_key, const char* comp_key, GnFACompTag tag, double freq, int ssb)
+int
+gn_fa_fixed_tone (const char *obj_key, const char *comp_key, GnFACompTag tag,
+ double freq, int ssb)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- gn::FACompTag t = gn::get_enum(tag);
- std::string freq_s = gn::to_string(freq, gn::FPFormat::Eng);
- obj->add_fixed_tone(comp_key, t, freq_s, ssb);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fixed_tone : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ gn::FACompTag t = gn::get_enum (tag);
+ std::string freq_s = gn::to_string (freq, gn::FPFormat::Eng);
+ obj->add_fixed_tone (comp_key, t, freq_s, ssb);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fixed_tone : ", e.what ());
}
}
-int gn_fa_fixed_tone_e(
- const char* obj_key, const char* comp_key, GnFACompTag tag, const char* freq, int ssb)
+int
+gn_fa_fixed_tone_e (const char *obj_key, const char *comp_key, GnFACompTag tag,
+ const char *freq, int ssb)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- gn::FACompTag t = gn::get_enum(tag);
- obj->add_fixed_tone(comp_key, t, freq, ssb);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fixed_tone_e : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ gn::FACompTag t = gn::get_enum (tag);
+ obj->add_fixed_tone (comp_key, t, freq, ssb);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fixed_tone_e : ", e.what ());
}
}
-int gn_fa_fsample(const char* obj_key, double f)
+int
+gn_fa_fsample (const char *obj_key, double f)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- std::string f_s = gn::to_string(f, gn::FPFormat::Eng);
- obj->set_fsample(f_s);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fsample : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ std::string f_s = gn::to_string (f, gn::FPFormat::Eng);
+ obj->set_fsample (f_s);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fsample : ", e.what ());
}
}
-int gn_fa_fsample_e(const char* obj_key, const char* f)
+int
+gn_fa_fsample_e (const char *obj_key, const char *f)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_fsample(f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fsample_e : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_fsample (f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fsample_e : ", e.what ());
}
}
-int gn_fa_fshift(const char* obj_key, double f)
+int
+gn_fa_fshift (const char *obj_key, double f)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- std::string f_s = gn::to_string(f, gn::FPFormat::Eng);
- obj->set_fshift(f_s);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fshift : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ std::string f_s = gn::to_string (f, gn::FPFormat::Eng);
+ obj->set_fshift (f_s);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fshift : ", e.what ());
}
}
-int gn_fa_fshift_e(const char* obj_key, const char* f)
+int
+gn_fa_fshift_e (const char *obj_key, const char *f)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_fshift(f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fshift_e : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_fshift (f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fshift_e : ", e.what ());
}
}
-int gn_fa_fund_images(const char* obj_key, bool enable)
+int
+gn_fa_fund_images (const char *obj_key, bool enable)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->en_fund_images = enable;
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_fund_images : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->en_fund_images = enable;
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_fund_images : ", e.what ());
}
}
-int gn_fa_hd(const char* obj_key, int n)
+int
+gn_fa_hd (const char *obj_key, int n)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_hd(n);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_hd : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_hd (n);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_hd : ", e.what ());
}
}
-int gn_fa_ilv(const char* obj_key, const int* ilv, size_t ilv_size, bool as_noise)
+int
+gn_fa_ilv (const char *obj_key, const int *ilv, size_t ilv_size, bool as_noise)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- std::set ilv2 (ilv, ilv + ilv_size);
- obj->set_ilv(ilv2);
- obj->ilv_as_noise = as_noise;
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_ilv : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ std::set ilv2 (ilv, ilv + ilv_size);
+ obj->set_ilv (ilv2);
+ obj->ilv_as_noise = as_noise;
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_ilv : ", e.what ());
}
}
-int gn_fa_imd(const char* obj_key, int n)
+int
+gn_fa_imd (const char *obj_key, int n)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_imd(n);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_imd : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_imd (n);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_imd : ", e.what ());
}
}
-int gn_fa_load(char* buf, size_t size, const char* filename, const char* obj_key)
+int
+gn_fa_load (char *buf, size_t size, const char *filename, const char *obj_key)
{
- try {
- std::string key (obj_key);
- if (key.empty()) {
- key = util::get_object_key_from_filename(filename);
+ try
+ {
+ std::string key (obj_key);
+ if (key.empty ())
+ {
+ key = util::get_object_key_from_filename (filename);
}
- gn::manager::add_object(key, gn::fourier_analysis::load(filename), true);
- util::fill_string_buffer(key.data(), key.size(), buf, size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_load : ", e.what());
+ gn::manager::add_object (key, gn::fourier_analysis::load (filename),
+ true);
+ util::fill_string_buffer (key.data (), key.size (), buf, size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_load : ", e.what ());
}
}
-int gn_fa_max_tone(
- const char* obj_key,
- const char* comp_key,
- GnFACompTag tag,
- int ssb)
+int
+gn_fa_max_tone (const char *obj_key, const char *comp_key, GnFACompTag tag,
+ int ssb)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- gn::FACompTag t = gn::get_enum(tag);
- obj->add_max_tone(comp_key, t, "0.0", "fdata", ssb);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_max_tone : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ gn::FACompTag t = gn::get_enum (tag);
+ obj->add_max_tone (comp_key, t, "0.0", "fdata", ssb);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_max_tone : ", e.what ());
}
}
-int gn_fa_preview(char* buf, size_t size, const char* cfg_id, bool cplx)
+int
+gn_fa_preview (char *buf, size_t size, const char *cfg_id, bool cplx)
{
- try {
- fa_ptr obj = get_fa_object_or_load_from_file(cfg_id);
- std::string s = obj->preview(cplx);
- util::fill_string_buffer(s.data(), s.size(), buf, size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_preview : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object_or_load_from_file (cfg_id);
+ std::string s = obj->preview (cplx);
+ util::fill_string_buffer (s.data (), s.size (), buf, size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_preview : ", e.what ());
}
}
-int gn_fa_quad_errors(const char* obj_key, bool enable)
+int
+gn_fa_quad_errors (const char *obj_key, bool enable)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->en_quad_errors = enable;
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_quad_errors : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->en_quad_errors = enable;
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_quad_errors : ", e.what ());
}
}
-int gn_fa_remove_comp(const char* obj_key, const char* comp_key)
+int
+gn_fa_remove_comp (const char *obj_key, const char *comp_key)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->remove_comp(comp_key);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_remove_comp : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->remove_comp (comp_key);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_remove_comp : ", e.what ());
}
}
-int gn_fa_reset(const char* obj_key)
+int
+gn_fa_reset (const char *obj_key)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->reset();
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_reset : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->reset ();
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_reset : ", e.what ());
}
}
-int gn_fa_ssb(const char* obj_key, GnFASsb group, int ssb)
+int
+gn_fa_ssb (const char *obj_key, GnFASsb group, int ssb)
{
- try {
- gn::FASsb g = gn::get_enum(group);
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_ssb(g, ssb);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_ssb_dc : ", e.what());
+ try
+ {
+ gn::FASsb g = gn::get_enum (group);
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_ssb (g, ssb);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_ssb_dc : ", e.what ());
}
}
-int gn_fa_var(const char* obj_key, const char* name, double value)
+int
+gn_fa_var (const char *obj_key, const char *name, double value)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_var(name, value);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_var : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_var (name, value);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_var : ", e.what ());
}
}
-int gn_fa_wo(const char* obj_key, int n)
+int
+gn_fa_wo (const char *obj_key, int n)
{
- try {
- fa_ptr obj = get_fa_object(obj_key);
- obj->set_wo(n);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_wo : ", e.what());
+ try
+ {
+ fa_ptr obj = get_fa_object (obj_key);
+ obj->set_wo (n);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_wo : ", e.what ());
}
}
@@ -1009,33 +1342,46 @@ int gn_fa_wo(const char* obj_key, int n)
/* Fourier Analysis Results */
/**************************************************************************/
-int gn_fa_result(double* result, const char** rkeys, size_t rkeys_size,
- const double* rvalues, size_t rvalues_size, const char* rkey)
+int
+gn_fa_result (double *result, const char **rkeys, size_t rkeys_size,
+ const double *rvalues, size_t rvalues_size, const char *rkey)
{
- try {
- util::check_pointer(result);
- if (rkeys_size != rvalues_size) {
- throw std::runtime_error("Size of result keys does not match size of result values");
+ try
+ {
+ util::check_pointer (result);
+ if (rkeys_size != rvalues_size)
+ {
+ throw std::runtime_error (
+ "Size of result keys does not match size of result values");
}
- size_t key_index = get_fa_result_key_index(rkeys, rkeys_size, rkey);
- *result = rvalues[key_index];
- return gn_success;
- } catch (const std::exception& e) {
- *result = 0.0;
- return util::return_on_exception("gn_fa_result : ", e.what());
+ size_t key_index = get_fa_result_key_index (rkeys, rkeys_size, rkey);
+ *result = rvalues[key_index];
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *result = 0.0;
+ return util::return_on_exception ("gn_fa_result : ", e.what ());
}
}
-int gn_fa_result_string(char* result, size_t result_size, const char** rkeys, size_t rkeys_size,
- const double* rvalues, size_t rvalues_size, const char* rkey)
+int
+gn_fa_result_string (char *result, size_t result_size, const char **rkeys,
+ size_t rkeys_size, const double *rvalues,
+ size_t rvalues_size, const char *rkey)
{
- try {
- util::check_pointer(result);
- std::string rstr = get_fa_result_string(rkeys, rkeys_size, rvalues, rvalues_size, rkey);
- util::fill_string_buffer(rstr.data(), rstr.size(), result, result_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_result_string : ", e.what());
+ try
+ {
+ util::check_pointer (result);
+ std::string rstr = get_fa_result_string (rkeys, rkeys_size, rvalues,
+ rvalues_size, rkey);
+ util::fill_string_buffer (rstr.data (), rstr.size (), result,
+ result_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fa_result_string : ", e.what ());
}
}
@@ -1043,79 +1389,110 @@ int gn_fa_result_string(char* result, size_t result_size, const char** rkeys, si
/* Fourier Analysis Helpers */
/**************************************************************************/
-int gn_fa_load_key_size(size_t* size, const char* filename, const char* obj_key)
+int
+gn_fa_load_key_size (size_t *size, const char *filename, const char *obj_key)
{
- try {
- util::check_pointer(size);
- std::string key (obj_key);
- if (key.empty()) {
- key = util::get_object_key_from_filename(filename);
+ try
+ {
+ util::check_pointer (size);
+ std::string key (obj_key);
+ if (key.empty ())
+ {
+ key = util::get_object_key_from_filename (filename);
}
- *size = util::terminated_size(key.size());
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_fa_load_key_size : ", e.what());
+ *size = util::terminated_size (key.size ());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_fa_load_key_size : ", e.what ());
}
}
-int gn_fa_preview_size(size_t* size, const char* cfg_id, bool cplx)
+int
+gn_fa_preview_size (size_t *size, const char *cfg_id, bool cplx)
{
- try {
- util::check_pointer(size);
- fa_ptr obj = get_fa_object_or_load_from_file(cfg_id);
- std::string s = obj->preview(cplx);
- *size = util::terminated_size(s.size());
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_fa_preview_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ fa_ptr obj = get_fa_object_or_load_from_file (cfg_id);
+ std::string s = obj->preview (cplx);
+ *size = util::terminated_size (s.size ());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_fa_preview_size : ", e.what ());
}
}
-int gn_fa_result_string_size(size_t* size, const char** rkeys, size_t rkeys_size,
- const double* rvalues, size_t rvalues_size, const char* rkey)
+int
+gn_fa_result_string_size (size_t *size, const char **rkeys, size_t rkeys_size,
+ const double *rvalues, size_t rvalues_size,
+ const char *rkey)
{
- try {
- util::check_pointer(size);
- std::string rstr = get_fa_result_string(rkeys, rkeys_size, rvalues, rvalues_size, rkey);
- *size = util::terminated_size(rstr.size());
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_fa_result_string_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ std::string rstr = get_fa_result_string (rkeys, rkeys_size, rvalues,
+ rvalues_size, rkey);
+ *size = util::terminated_size (rstr.size ());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_fa_result_string_size : ",
+ e.what ());
}
}
-int gn_fft_analysis_results_key_sizes(size_t* key_sizes, size_t key_sizes_size,
- const char* cfg_id, size_t in_size, size_t nfft)
+int
+gn_fft_analysis_results_key_sizes (size_t *key_sizes, size_t key_sizes_size,
+ const char *cfg_id, size_t in_size,
+ size_t nfft)
{
- try {
- fa_ptr obj = get_fa_object_or_load_from_file(cfg_id);
- std::vector key_sizes_src = obj->result_key_lengths(in_size, nfft);
- if (key_sizes_src.size() != key_sizes_size) {
- throw std::runtime_error("Number of keys does not match output array size");
+ try
+ {
+ fa_ptr obj = get_fa_object_or_load_from_file (cfg_id);
+ std::vector key_sizes_src
+ = obj->result_key_lengths (in_size, nfft);
+ if (key_sizes_src.size () != key_sizes_size)
+ {
+ throw std::runtime_error (
+ "Number of keys does not match output array size");
}
- for (size_t i = 0; i < key_sizes_size; ++i) {
- key_sizes[i] = util::terminated_size(key_sizes_src[i]);
+ for (size_t i = 0; i < key_sizes_size; ++i)
+ {
+ key_sizes[i] = util::terminated_size (key_sizes_src[i]);
}
- return gn_success;
- } catch (const std::exception& e) {
- std::fill(key_sizes, key_sizes + key_sizes_size, 0);
- return util::return_on_exception("gn_fa_results_key_sizes : ", e.what());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ std::fill (key_sizes, key_sizes + key_sizes_size, 0);
+ return util::return_on_exception ("gn_fa_results_key_sizes : ",
+ e.what ());
}
}
-int gn_fft_analysis_results_size(size_t* size, const char* cfg_id, size_t in_size, size_t nfft)
+int
+gn_fft_analysis_results_size (size_t *size, const char *cfg_id, size_t in_size,
+ size_t nfft)
{
- try {
- util::check_pointer(size);
- fa_ptr obj = get_fa_object_or_load_from_file(cfg_id);
- *size = obj->results_size(in_size, nfft);
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_fa_results_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ fa_ptr obj = get_fa_object_or_load_from_file (cfg_id);
+ *size = obj->results_size (in_size, nfft);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_fa_results_size : ", e.what ());
}
}
@@ -1123,131 +1500,172 @@ int gn_fft_analysis_results_size(size_t* size, const char* cfg_id, size_t in_siz
/* Fourier Transforms */
/**************************************************************************/
-namespace {
+namespace
+{
- template
- int gn_fftxx(const char* suffix, double* out, size_t out_size,
- const T* i, size_t i_size, const T* q, size_t q_size,
- int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format)
+template
+int
+gn_fftxx (const char *suffix, double *out, size_t out_size, const T *i,
+ size_t i_size, const T *q, size_t q_size, int n, size_t navg,
+ size_t nfft, GnWindow window, GnCodeFormat format)
+{
+ try
{
- try {
- gn::Window w = gn::get_enum(window);
- gn::CodeFormat f = gn::get_enum(format);
- gn::fft(i, i_size, q, q_size, out, out_size, n, navg, nfft, w, f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fft", suffix, " : ", e.what());
- }
+ gn::Window w = gn::get_enum (window);
+ gn::CodeFormat f = gn::get_enum (format);
+ gn::fft (i, i_size, q, q_size, out, out_size, n, navg, nfft, w, f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fft", suffix, " : ", e.what ());
}
+}
- template
- int gn_rfftxx(const char* suffix, double* out, size_t out_size,
- const T* in, size_t in_size,
- int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format, GnRfftScale scale)
+template
+int
+gn_rfftxx (const char *suffix, double *out, size_t out_size, const T *in,
+ size_t in_size, int n, size_t navg, size_t nfft, GnWindow window,
+ GnCodeFormat format, GnRfftScale scale)
+{
+ try
{
- try {
- gn::Window w = gn::get_enum(window);
- gn::CodeFormat f = gn::get_enum(format);
- gn::RfftScale s = gn::get_enum(scale);
- gn::rfft(in, in_size, out, out_size, n, navg, nfft, w, f, s);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_rfft", suffix, " : ", e.what());
- }
+ gn::Window w = gn::get_enum (window);
+ gn::CodeFormat f = gn::get_enum (format);
+ gn::RfftScale s = gn::get_enum (scale);
+ gn::rfft (in, in_size, out, out_size, n, navg, nfft, w, f, s);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_rfft", suffix, " : ", e.what ());
}
+}
} // namespace anonymous
-int gn_fft(double* out, size_t out_size,
- const double* i, size_t i_size, const double* q, size_t q_size,
- size_t navg, size_t nfft, GnWindow window)
+int
+gn_fft (double *out, size_t out_size, const double *i, size_t i_size,
+ const double *q, size_t q_size, size_t navg, size_t nfft,
+ GnWindow window)
{
- try {
- gn::Window w = gn::get_enum(window);
- gn::fft(i, i_size, q, q_size, out, out_size, navg, nfft, w);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fft : ", e.what());
+ try
+ {
+ gn::Window w = gn::get_enum (window);
+ gn::fft (i, i_size, q, q_size, out, out_size, navg, nfft, w);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fft : ", e.what ());
}
}
-int gn_fft16(double* out, size_t out_size,
- const int16_t* i, size_t i_size, const int16_t* q, size_t q_size,
- int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format)
+int
+gn_fft16 (double *out, size_t out_size, const int16_t *i, size_t i_size,
+ const int16_t *q, size_t q_size, int n, size_t navg, size_t nfft,
+ GnWindow window, GnCodeFormat format)
{
- return gn_fftxx("16", out, out_size, i, i_size, q, q_size, n, navg, nfft, window, format);
+ return gn_fftxx ("16", out, out_size, i, i_size, q, q_size, n, navg, nfft,
+ window, format);
}
-int gn_fft32(double* out, size_t out_size,
- const int32_t* i, size_t i_size, const int32_t* q, size_t q_size,
- int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format)
+int
+gn_fft32 (double *out, size_t out_size, const int32_t *i, size_t i_size,
+ const int32_t *q, size_t q_size, int n, size_t navg, size_t nfft,
+ GnWindow window, GnCodeFormat format)
{
- return gn_fftxx("32", out, out_size, i, i_size, q, q_size, n, navg, nfft, window, format);
+ return gn_fftxx ("32", out, out_size, i, i_size, q, q_size, n, navg, nfft,
+ window, format);
}
-int gn_fft64(double* out, size_t out_size,
- const int64_t* i, size_t i_size, const int64_t* q, size_t q_size,
- int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format)
+int
+gn_fft64 (double *out, size_t out_size, const int64_t *i, size_t i_size,
+ const int64_t *q, size_t q_size, int n, size_t navg, size_t nfft,
+ GnWindow window, GnCodeFormat format)
{
- return gn_fftxx("64", out, out_size, i, i_size, q, q_size, n, navg, nfft, window, format);
+ return gn_fftxx ("64", out, out_size, i, i_size, q, q_size, n, navg, nfft,
+ window, format);
}
-int gn_rfft(double* out, size_t out_size, const double* in, size_t in_size,
- size_t navg, size_t nfft, GnWindow window, GnRfftScale scale)
+int
+gn_rfft (double *out, size_t out_size, const double *in, size_t in_size,
+ size_t navg, size_t nfft, GnWindow window, GnRfftScale scale)
{
- try {
- gn::Window w = gn::get_enum(window);
- gn::RfftScale s = gn::get_enum(scale);
- gn::rfft(in, in_size, out, out_size, navg, nfft, w, s);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_rfft : ", e.what());
+ try
+ {
+ gn::Window w = gn::get_enum (window);
+ gn::RfftScale s = gn::get_enum (scale);
+ gn::rfft (in, in_size, out, out_size, navg, nfft, w, s);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_rfft : ", e.what ());
}
}
-int gn_rfft16(double* out, size_t out_size, const int16_t* in, size_t in_size,
- int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format, GnRfftScale scale)
+int
+gn_rfft16 (double *out, size_t out_size, const int16_t *in, size_t in_size,
+ int n, size_t navg, size_t nfft, GnWindow window,
+ GnCodeFormat format, GnRfftScale scale)
{
- return gn_rfftxx("16", out, out_size, in, in_size, n, navg, nfft, window, format, scale);
+ return gn_rfftxx ("16", out, out_size, in, in_size, n, navg, nfft, window,
+ format, scale);
}
-int gn_rfft32(double* out, size_t out_size, const int32_t* in, size_t in_size,
- int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format, GnRfftScale scale)
+int
+gn_rfft32 (double *out, size_t out_size, const int32_t *in, size_t in_size,
+ int n, size_t navg, size_t nfft, GnWindow window,
+ GnCodeFormat format, GnRfftScale scale)
{
- return gn_rfftxx("32", out, out_size, in, in_size, n, navg, nfft, window, format, scale);
+ return gn_rfftxx ("32", out, out_size, in, in_size, n, navg, nfft, window,
+ format, scale);
}
-int gn_rfft64(double* out, size_t out_size, const int64_t* in, size_t in_size,
- int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format, GnRfftScale scale)
+int
+gn_rfft64 (double *out, size_t out_size, const int64_t *in, size_t in_size,
+ int n, size_t navg, size_t nfft, GnWindow window,
+ GnCodeFormat format, GnRfftScale scale)
{
- return gn_rfftxx("64", out, out_size, in, in_size, n, navg, nfft, window, format, scale);
+ return gn_rfftxx ("64", out, out_size, in, in_size, n, navg, nfft, window,
+ format, scale);
}
/**************************************************************************/
/* Fourier Transform Helpers */
/**************************************************************************/
-int gn_fft_size(size_t* out_size, size_t i_size, size_t q_size, size_t navg, size_t nfft)
+int
+gn_fft_size (size_t *out_size, size_t i_size, size_t q_size, size_t navg,
+ size_t nfft)
{
- try {
- util::check_pointer(out_size);
- *out_size = gn::fft_size(i_size, q_size, navg, nfft);
- return gn_success;
- } catch (const std::exception& e) {
- *out_size = 0;
- return util::return_on_exception("gn_fft_size : ", e.what());
+ try
+ {
+ util::check_pointer (out_size);
+ *out_size = gn::fft_size (i_size, q_size, navg, nfft);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *out_size = 0;
+ return util::return_on_exception ("gn_fft_size : ", e.what ());
}
}
-int gn_rfft_size(size_t* out_size, size_t in_size, size_t navg, size_t nfft)
+int
+gn_rfft_size (size_t *out_size, size_t in_size, size_t navg, size_t nfft)
{
- try {
- util::check_pointer(out_size);
- *out_size = gn::rfft_size(in_size, navg, nfft);
- return gn_success;
- } catch (const std::exception& e) {
- *out_size = 0;
- return util::return_on_exception("gn_rfft_size : ", e.what());
+ try
+ {
+ util::check_pointer (out_size);
+ *out_size = gn::rfft_size (in_size, navg, nfft);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *out_size = 0;
+ return util::return_on_exception ("gn_rfft_size : ", e.what ());
}
}
@@ -1255,59 +1673,79 @@ int gn_rfft_size(size_t* out_size, size_t in_size, size_t navg, size_t nfft)
/* Fourier Utilities */
/**************************************************************************/
-int gn_alias(double* out, double fs, double freq, GnFreqAxisType axis_type)
+int
+gn_alias (double *out, double fs, double freq, GnFreqAxisType axis_type)
{
- try {
- util::check_pointer(out);
- gn::FreqAxisType at = gn::get_enum(axis_type);
- *out = gn::alias(fs, freq, at);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_alias : ", e.what());
+ try
+ {
+ util::check_pointer (out);
+ gn::FreqAxisType at = gn::get_enum (axis_type);
+ *out = gn::alias (fs, freq, at);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_alias : ", e.what ());
}
}
-int gn_coherent(double* out, size_t nfft, double fs, double freq)
+int
+gn_coherent (double *out, size_t nfft, double fs, double freq)
{
- try {
- util::check_pointer(out);
- *out = gn::coherent(nfft, fs, freq);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_coherent : ", e.what());
+ try
+ {
+ util::check_pointer (out);
+ *out = gn::coherent (nfft, fs, freq);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_coherent : ", e.what ());
}
}
-int gn_fftshift(double* out, size_t out_size, const double* in, size_t in_size)
+int
+gn_fftshift (double *out, size_t out_size, const double *in, size_t in_size)
{
- try {
- gn::fftshift(in, in_size, out, out_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fftshift : ", e.what());
+ try
+ {
+ gn::fftshift (in, in_size, out, out_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fftshift : ", e.what ());
}
}
-int gn_freq_axis(double* out, size_t size,
- size_t nfft, GnFreqAxisType axis_type, double fs, GnFreqAxisFormat axis_format)
+int
+gn_freq_axis (double *out, size_t size, size_t nfft, GnFreqAxisType axis_type,
+ double fs, GnFreqAxisFormat axis_format)
{
- try {
- gn::FreqAxisType at = gn::get_enum(axis_type);
- gn::FreqAxisFormat af = gn::get_enum(axis_format);
- gn::freq_axis(out, size, nfft, at, fs, af);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fftshift : ", e.what());
+ try
+ {
+ gn::FreqAxisType at = gn::get_enum (axis_type);
+ gn::FreqAxisFormat af = gn::get_enum (axis_format);
+ gn::freq_axis (out, size, nfft, at, fs, af);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fftshift : ", e.what ());
}
}
-int gn_ifftshift(double* out, size_t out_size, const double* in, size_t in_size)
+int
+gn_ifftshift (double *out, size_t out_size, const double *in, size_t in_size)
{
- try {
- gn::ifftshift(in, in_size, out, out_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_ifftshift : ", e.what());
+ try
+ {
+ gn::ifftshift (in, in_size, out, out_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_ifftshift : ", e.what ());
}
}
@@ -1315,16 +1753,20 @@ int gn_ifftshift(double* out, size_t out_size, const double* in, size_t in_size)
/* Fourier Utility Helpers */
/**************************************************************************/
-int gn_freq_axis_size(size_t* size, size_t nfft, GnFreqAxisType axis_type)
+int
+gn_freq_axis_size (size_t *size, size_t nfft, GnFreqAxisType axis_type)
{
- try {
- util::check_pointer(size);
- gn::FreqAxisType at = gn::get_enum(axis_type);
- *size = gn::freq_axis_size(nfft, at);
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_freq_axis_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ gn::FreqAxisType at = gn::get_enum (axis_type);
+ *size = gn::freq_axis_size (nfft, at);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_freq_axis_size : ", e.what ());
}
}
@@ -1332,71 +1774,91 @@ int gn_freq_axis_size(size_t* size, size_t nfft, GnFreqAxisType axis_type)
/* Manager */
/**************************************************************************/
-int gn_mgr_clear()
+int
+gn_mgr_clear ()
{
- gn::manager::clear();
- return gn_success;
+ gn::manager::clear ();
+ return gn_success;
}
-int gn_mgr_compare(bool* result, const char* obj_key1, const char* obj_key2)
+int
+gn_mgr_compare (bool *result, const char *obj_key1, const char *obj_key2)
{
- try {
- *result = gn::manager::equal(obj_key1, obj_key2);
- return gn_success;
- } catch (const std::exception& e) {
- *result = false;
- return util::return_on_exception("gn_mgr_equal : ", e.what());
+ try
+ {
+ *result = gn::manager::equal (obj_key1, obj_key2);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *result = false;
+ return util::return_on_exception ("gn_mgr_equal : ", e.what ());
}
}
-int gn_mgr_contains(bool* result, const char* obj_key)
+int
+gn_mgr_contains (bool *result, const char *obj_key)
{
- *result = gn::manager::contains(obj_key);
- return gn_success;
+ *result = gn::manager::contains (obj_key);
+ return gn_success;
}
-int gn_mgr_remove(const char* obj_key)
+int
+gn_mgr_remove (const char *obj_key)
{
- gn::manager::remove(obj_key);
- return gn_success;
+ gn::manager::remove (obj_key);
+ return gn_success;
}
-int gn_mgr_save(char* buf, size_t size, const char* obj_key, const char* filename)
+int
+gn_mgr_save (char *buf, size_t size, const char *obj_key, const char *filename)
{
- try {
- std::string fn = gn::manager::save(obj_key, filename);
- util::fill_string_buffer(fn.data(), fn.size(), buf, size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_mgr_save : ", e.what());
+ try
+ {
+ std::string fn = gn::manager::save (obj_key, filename);
+ util::fill_string_buffer (fn.data (), fn.size (), buf, size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_mgr_save : ", e.what ());
}
}
-int gn_mgr_size(size_t* size)
+int
+gn_mgr_size (size_t *size)
{
- *size = gn::manager::size();
- return gn_success;
+ *size = gn::manager::size ();
+ return gn_success;
}
-int gn_mgr_to_string(char* buf, size_t size, const char* obj_key)
+int
+gn_mgr_to_string (char *buf, size_t size, const char *obj_key)
{
- try {
- std::string s = gn::manager::to_string(obj_key);
- util::fill_string_buffer(s.data(), s.size(), buf, size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_mgr_to_string : ", e.what());
+ try
+ {
+ std::string s = gn::manager::to_string (obj_key);
+ util::fill_string_buffer (s.data (), s.size (), buf, size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_mgr_to_string : ", e.what ());
}
}
-int gn_mgr_type(char* buf, size_t size, const char* obj_key)
+int
+gn_mgr_type (char *buf, size_t size, const char *obj_key)
{
- try {
- std::string s = gn::manager::type_str(obj_key);
- util::fill_string_buffer(s.data(), s.size(), buf, size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_mgr_type : ", e.what());
+ try
+ {
+ std::string s = gn::manager::type_str (obj_key);
+ util::fill_string_buffer (s.data (), s.size (), buf, size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_mgr_type : ", e.what ());
}
}
@@ -1404,40 +1866,56 @@ int gn_mgr_type(char* buf, size_t size, const char* obj_key)
/* Manager Helpers */
/**************************************************************************/
-int gn_mgr_save_filename_size(size_t* size, const char* obj_key, const char* filename)
+int
+gn_mgr_save_filename_size (size_t *size, const char *obj_key,
+ const char *filename)
{
- try {
- util::check_pointer(size);
- size_t fn_size = gn::manager::get_filename_from_object_key(obj_key, filename).size();
- *size = util::terminated_size(fn_size);
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_mgr_save_filename_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ size_t fn_size
+ = gn::manager::get_filename_from_object_key (obj_key, filename)
+ .size ();
+ *size = util::terminated_size (fn_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_mgr_save_filename_size : ",
+ e.what ());
}
}
-int gn_mgr_to_string_size(size_t* size, const char* obj_key)
+int
+gn_mgr_to_string_size (size_t *size, const char *obj_key)
{
- try {
- util::check_pointer(size);
- *size = util::terminated_size(gn::manager::to_string(obj_key).size());
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_mgr_to_string_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ *size = util::terminated_size (gn::manager::to_string (obj_key).size ());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_mgr_to_string_size : ", e.what ());
}
}
-int gn_mgr_type_size(size_t* size, const char* obj_key)
+int
+gn_mgr_type_size (size_t *size, const char *obj_key)
{
- try {
- util::check_pointer(size);
- *size = util::terminated_size(gn::manager::type_str(obj_key).size());
- return gn_success;
- } catch (const std::exception& e) {
- *size = 0;
- return util::return_on_exception("gn_mgr_type_size : ", e.what());
+ try
+ {
+ util::check_pointer (size);
+ *size = util::terminated_size (gn::manager::type_str (obj_key).size ());
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *size = 0;
+ return util::return_on_exception ("gn_mgr_type_size : ", e.what ());
}
}
@@ -1445,190 +1923,244 @@ int gn_mgr_type_size(size_t* size, const char* obj_key)
/* Signal Processing */
/**************************************************************************/
-namespace {
+namespace
+{
- template
- int gn_downsamplex(const char* suffix, T* out, size_t out_size,
- const T* in, size_t in_size, int ratio, bool interleaved)
+template
+int
+gn_downsamplex (const char *suffix, T *out, size_t out_size, const T *in,
+ size_t in_size, int ratio, bool interleaved)
+{
+ try
{
- try {
- gn::downsample(in, in_size, out, out_size, ratio, interleaved);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_downsample", suffix, " : ", e.what());
- }
+ gn::downsample (in, in_size, out, out_size, ratio, interleaved);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_downsample", suffix, " : ",
+ e.what ());
}
+}
- template
- int gn_fshiftx(const char* suffix, T* out, size_t out_size,
- const T* i, size_t i_size, const T* q, size_t q_size,
- int n, double fs, double fshift, GnCodeFormat format)
+template
+int
+gn_fshiftx (const char *suffix, T *out, size_t out_size, const T *i,
+ size_t i_size, const T *q, size_t q_size, int n, double fs,
+ double fshift, GnCodeFormat format)
+{
+ try
{
- try {
- gn::CodeFormat f = gn::get_enum(format);
- gn::fshift(i, i_size, q, q_size, out, out_size, n, fs, fshift, f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fshift", suffix, " : ", e.what());
- }
+ gn::CodeFormat f = gn::get_enum (format);
+ gn::fshift (i, i_size, q, q_size, out, out_size, n, fs, fshift, f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fshift", suffix, " : ", e.what ());
}
+}
- template
- int gn_normalize(const char* suffix, double* out, size_t out_size,
- const T* in, size_t in_size, int n, GnCodeFormat format)
+template
+int
+gn_normalize (const char *suffix, double *out, size_t out_size, const T *in,
+ size_t in_size, int n, GnCodeFormat format)
+{
+ try
{
- try {
- gn::CodeFormat f = gn::get_enum(format);
- gn::normalize(in, in_size, out, out_size, n, f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_normalize", suffix, " : ", e.what());
- }
+ gn::CodeFormat f = gn::get_enum (format);
+ gn::normalize (in, in_size, out, out_size, n, f);
+ return gn_success;
}
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_normalize", suffix, " : ",
+ e.what ());
+ }
+}
- template
- int gn_quantize(const char* suffix, T* out, size_t out_size,
- const double* in, size_t in_size, double fsr, int n, double noise, GnCodeFormat format)
+template
+int
+gn_quantize (const char *suffix, T *out, size_t out_size, const double *in,
+ size_t in_size, double fsr, int n, double noise,
+ GnCodeFormat format)
+{
+ try
{
- try {
- gn::CodeFormat f = gn::get_enum(format);
- gn::quantize(in, in_size, out, out_size, fsr, n, noise, f);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_quantize", suffix, " : ", e.what());
- }
+ gn::CodeFormat f = gn::get_enum (format);
+ gn::quantize (in, in_size, out, out_size, fsr, n, noise, f);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_quantize", suffix, " : ",
+ e.what ());
}
+}
} // namespace anonymous
-int gn_downsample(double* out, size_t out_size,
- const double* in, size_t in_size, int ratio, bool interleaved)
+int
+gn_downsample (double *out, size_t out_size, const double *in, size_t in_size,
+ int ratio, bool interleaved)
{
- return gn_downsamplex("", out, out_size, in, in_size, ratio, interleaved);
+ return gn_downsamplex ("", out, out_size, in, in_size, ratio, interleaved);
}
-int gn_downsample16(int16_t* out, size_t out_size,
- const int16_t* in, size_t in_size, int ratio, bool interleaved)
+int
+gn_downsample16 (int16_t *out, size_t out_size, const int16_t *in,
+ size_t in_size, int ratio, bool interleaved)
{
- return gn_downsamplex("16", out, out_size, in, in_size, ratio, interleaved);
+ return gn_downsamplex ("16", out, out_size, in, in_size, ratio, interleaved);
}
-int gn_downsample32(int32_t* out, size_t out_size,
- const int32_t* in, size_t in_size, int ratio, bool interleaved)
+int
+gn_downsample32 (int32_t *out, size_t out_size, const int32_t *in,
+ size_t in_size, int ratio, bool interleaved)
{
- return gn_downsamplex("32", out, out_size, in, in_size, ratio, interleaved);
+ return gn_downsamplex ("32", out, out_size, in, in_size, ratio, interleaved);
}
-int gn_downsample64(int64_t* out, size_t out_size,
- const int64_t* in, size_t in_size, int ratio, bool interleaved)
+int
+gn_downsample64 (int64_t *out, size_t out_size, const int64_t *in,
+ size_t in_size, int ratio, bool interleaved)
{
- return gn_downsamplex("64", out, out_size, in, in_size, ratio, interleaved);
+ return gn_downsamplex ("64", out, out_size, in, in_size, ratio, interleaved);
}
-int gn_fshift(double* out, size_t out_size,
- const double* i, size_t i_size, const double* q, size_t q_size, double fs, double fshift)
+int
+gn_fshift (double *out, size_t out_size, const double *i, size_t i_size,
+ const double *q, size_t q_size, double fs, double fshift)
{
- try {
- gn::fshift(i, i_size, q, q_size, out, out_size, fs, fshift);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fshift : ", e.what());
+ try
+ {
+ gn::fshift (i, i_size, q, q_size, out, out_size, fs, fshift);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_fshift : ", e.what ());
}
}
-int gn_fshift16(int16_t* out, size_t out_size,
- const int16_t* i, size_t i_size, const int16_t* q, size_t q_size,
- int n, double fs, double fshift, GnCodeFormat format)
+int
+gn_fshift16 (int16_t *out, size_t out_size, const int16_t *i, size_t i_size,
+ const int16_t *q, size_t q_size, int n, double fs, double fshift,
+ GnCodeFormat format)
{
- return gn_fshiftx("16", out, out_size, i, i_size, q, q_size, n, fs, fshift, format);
+ return gn_fshiftx ("16", out, out_size, i, i_size, q, q_size, n, fs, fshift,
+ format);
}
-int gn_fshift32(int32_t* out, size_t out_size,
- const int32_t* i, size_t i_size, const int32_t* q, size_t q_size,
- int n, double fs, double fshift, GnCodeFormat format)
+int
+gn_fshift32 (int32_t *out, size_t out_size, const int32_t *i, size_t i_size,
+ const int32_t *q, size_t q_size, int n, double fs, double fshift,
+ GnCodeFormat format)
{
- return gn_fshiftx("32", out, out_size, i, i_size, q, q_size, n, fs, fshift, format);
+ return gn_fshiftx ("32", out, out_size, i, i_size, q, q_size, n, fs, fshift,
+ format);
}
-int gn_fshift64(int64_t* out, size_t out_size,
- const int64_t* i, size_t i_size, const int64_t* q, size_t q_size,
- int n, double fs, double fshift, GnCodeFormat format)
+int
+gn_fshift64 (int64_t *out, size_t out_size, const int64_t *i, size_t i_size,
+ const int64_t *q, size_t q_size, int n, double fs, double fshift,
+ GnCodeFormat format)
{
- return gn_fshiftx("64", out, out_size, i, i_size, q, q_size, n, fs, fshift, format);
+ return gn_fshiftx ("64", out, out_size, i, i_size, q, q_size, n, fs, fshift,
+ format);
}
-int gn_normalize16(double* out, size_t out_size,
- const int16_t* in, size_t in_size, int n, GnCodeFormat format)
+int
+gn_normalize16 (double *out, size_t out_size, const int16_t *in,
+ size_t in_size, int n, GnCodeFormat format)
{
- return gn_normalize("16", out, out_size, in, in_size, n, format);
+ return gn_normalize ("16", out, out_size, in, in_size, n, format);
}
-int gn_normalize32(double* out, size_t out_size,
- const int32_t* in, size_t in_size, int n, GnCodeFormat format)
+int
+gn_normalize32 (double *out, size_t out_size, const int32_t *in,
+ size_t in_size, int n, GnCodeFormat format)
{
- return gn_normalize("32", out, out_size, in, in_size, n, format);
+ return gn_normalize ("32", out, out_size, in, in_size, n, format);
}
-int gn_normalize64(double* out, size_t out_size,
- const int64_t* in, size_t in_size, int n, GnCodeFormat format)
+int
+gn_normalize64 (double *out, size_t out_size, const int64_t *in,
+ size_t in_size, int n, GnCodeFormat format)
{
- return gn_normalize("64", out, out_size, in, in_size, n, format);
+ return gn_normalize ("64", out, out_size, in, in_size, n, format);
}
-int gn_polyval(double* out, size_t out_size,
- const double* in, size_t in_size, const double* c, size_t c_size)
+int
+gn_polyval (double *out, size_t out_size, const double *in, size_t in_size,
+ const double *c, size_t c_size)
{
- try {
- gn::polyval(in, in_size, out, out_size, c, c_size);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_polyval : ", e.what());
+ try
+ {
+ gn::polyval (in, in_size, out, out_size, c, c_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_polyval : ", e.what ());
}
}
-int gn_quantize16(int16_t* out, size_t out_size,
- const double* in, size_t in_size, double fsr, int n, double noise, GnCodeFormat format)
+int
+gn_quantize16 (int16_t *out, size_t out_size, const double *in, size_t in_size,
+ double fsr, int n, double noise, GnCodeFormat format)
{
- return gn_quantize("16", out, out_size, in, in_size, fsr, n, noise, format);
+ return gn_quantize ("16", out, out_size, in, in_size, fsr, n, noise, format);
}
-int gn_quantize32(int32_t* out, size_t out_size,
- const double* in, size_t in_size, double fsr, int n, double noise, GnCodeFormat format)
+int
+gn_quantize32 (int32_t *out, size_t out_size, const double *in, size_t in_size,
+ double fsr, int n, double noise, GnCodeFormat format)
{
- return gn_quantize("32", out, out_size, in, in_size, fsr, n, noise, format);
+ return gn_quantize ("32", out, out_size, in, in_size, fsr, n, noise, format);
}
-int gn_quantize64(int64_t* out, size_t out_size,
- const double* in, size_t in_size, double fsr, int n, double noise, GnCodeFormat format)
+int
+gn_quantize64 (int64_t *out, size_t out_size, const double *in, size_t in_size,
+ double fsr, int n, double noise, GnCodeFormat format)
{
- return gn_quantize("64", out, out_size, in, in_size, fsr, n, noise, format);
+ return gn_quantize ("64", out, out_size, in, in_size, fsr, n, noise, format);
}
/**************************************************************************/
/* Signal Processing Helpers */
/**************************************************************************/
-int gn_downsample_size(size_t* out_size, size_t in_size, int ratio, bool interleaved)
+int
+gn_downsample_size (size_t *out_size, size_t in_size, int ratio,
+ bool interleaved)
{
- try {
- util::check_pointer(out_size);
- *out_size = gn::downsample_size(in_size, ratio, interleaved);
- return gn_success;
- } catch (const std::exception& e) {
- *out_size = 0;
- return util::return_on_exception("gn_downsample_size : ", e.what());
+ try
+ {
+ util::check_pointer (out_size);
+ *out_size = gn::downsample_size (in_size, ratio, interleaved);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *out_size = 0;
+ return util::return_on_exception ("gn_downsample_size : ", e.what ());
}
}
-int gn_fshift_size(size_t* out_size, size_t i_size, size_t q_size)
+int
+gn_fshift_size (size_t *out_size, size_t i_size, size_t q_size)
{
- try {
- util::check_pointer(out_size);
- *out_size = gn::fshift_size(i_size, q_size);
- return gn_success;
- } catch (const std::exception& e) {
- *out_size = 0;
- return util::return_on_exception("gn_fshift_size : ", e.what());
+ try
+ {
+ util::check_pointer (out_size);
+ *out_size = gn::fshift_size (i_size, q_size);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ *out_size = 0;
+ return util::return_on_exception ("gn_fshift_size : ", e.what ());
}
}
@@ -1636,101 +2168,135 @@ int gn_fshift_size(size_t* out_size, size_t i_size, size_t q_size)
/* Waveforms */
/**************************************************************************/
-namespace {
+namespace
+{
- template
- int gn_wf_analysisx(const char* suffix,
- char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const T* in, size_t in_size)
+template
+int
+gn_wf_analysisx (const char *suffix, char **rkeys, size_t rkeys_size,
+ double *rvalues, size_t rvalues_size, const T *in,
+ size_t in_size)
+{
+ try
{
- try {
- util::check_pointer(rkeys);
- util::check_pointer(rvalues);
- const std::vector& keys = gn::wf_analysis_ordered_keys();
- if (keys.size() != rkeys_size) {
- throw std::runtime_error("Size of result key array is wrong");
- }
- if (rvalues_size != rkeys_size) {
- throw std::runtime_error("Size of result keys does not match size of result values");
- }
- std::map results = gn::wf_analysis(in, in_size);
- for (size_t i = 0; i < keys.size(); ++i) {
- const std::string& src = keys[i];
- char* dst = rkeys[i];
- size_t dst_size = util::terminated_size(src.size());
- util::fill_string_buffer(src.data(), src.size(), dst, dst_size);
- rvalues[i] = results.at(src);
- }
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_wf_analysis", suffix, " : ", e.what());
+ util::check_pointer (rkeys);
+ util::check_pointer (rvalues);
+ const std::vector &keys = gn::wf_analysis_ordered_keys ();
+ if (keys.size () != rkeys_size)
+ {
+ throw std::runtime_error ("Size of result key array is wrong");
+ }
+ if (rvalues_size != rkeys_size)
+ {
+ throw std::runtime_error (
+ "Size of result keys does not match size of result values");
+ }
+ std::map results = gn::wf_analysis (in, in_size);
+ for (size_t i = 0; i < keys.size (); ++i)
+ {
+ const std::string &src = keys[i];
+ char *dst = rkeys[i];
+ size_t dst_size = util::terminated_size (src.size ());
+ util::fill_string_buffer (src.data (), src.size (), dst, dst_size);
+ rvalues[i] = results.at (src);
}
+ return gn_success;
}
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_wf_analysis", suffix, " : ",
+ e.what ());
+ }
+}
} // namespace anonymous
-int gn_cos(double* out, size_t size,
- double fs, double ampl, double freq, double phase, double td, double tj)
+int
+gn_cos (double *out, size_t size, double fs, double ampl, double freq,
+ double phase, double td, double tj)
{
- try {
- gn::cos(out, size, fs, ampl, freq, phase, td, tj);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_cos : ", e.what());
+ try
+ {
+ gn::cos (out, size, fs, ampl, freq, phase, td, tj);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_cos : ", e.what ());
}
}
-int gn_gaussian(double* out, size_t size, double mean, double sd)
+int
+gn_gaussian (double *out, size_t size, double mean, double sd)
{
- try {
- gn::gaussian(out, size, mean, sd);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_gaussian : ", e.what());
+ try
+ {
+ gn::gaussian (out, size, mean, sd);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_gaussian : ", e.what ());
}
}
-int gn_ramp(double* out, size_t size, double start, double stop, double noise)
+int
+gn_ramp (double *out, size_t size, double start, double stop, double noise)
{
- try {
- gn::ramp(out, size, start, stop, noise);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_ramp : ", e.what());
+ try
+ {
+ gn::ramp (out, size, start, stop, noise);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_ramp : ", e.what ());
}
}
-int gn_sin(double* out, size_t size,
- double fs, double ampl, double freq, double phase, double td, double tj)
+int
+gn_sin (double *out, size_t size, double fs, double ampl, double freq,
+ double phase, double td, double tj)
{
- try {
- gn::sin(out, size, fs, ampl, freq, phase, td, tj);
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_sin : ", e.what());
+ try
+ {
+ gn::sin (out, size, fs, ampl, freq, phase, td, tj);
+ return gn_success;
+ }
+ catch (const std::exception &e)
+ {
+ return util::return_on_exception ("gn_sin : ", e.what ());
}
}
-int gn_wf_analysis(char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const double* in, size_t in_size)
+int
+gn_wf_analysis (char **rkeys, size_t rkeys_size, double *rvalues,
+ size_t rvalues_size, const double *in, size_t in_size)
{
- return gn_wf_analysisx("", rkeys, rkeys_size, rvalues, rvalues_size, in, in_size);
+ return gn_wf_analysisx ("", rkeys, rkeys_size, rvalues, rvalues_size, in,
+ in_size);
}
-int gn_wf_analysis16(char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const int16_t* in, size_t in_size)
+int
+gn_wf_analysis16 (char **rkeys, size_t rkeys_size, double *rvalues,
+ size_t rvalues_size, const int16_t *in, size_t in_size)
{
- return gn_wf_analysisx("16", rkeys, rkeys_size, rvalues, rvalues_size, in, in_size);
+ return gn_wf_analysisx ("16", rkeys, rkeys_size, rvalues, rvalues_size, in,
+ in_size);
}
-int gn_wf_analysis32(char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const int32_t* in, size_t in_size)
+int
+gn_wf_analysis32 (char **rkeys, size_t rkeys_size, double *rvalues,
+ size_t rvalues_size, const int32_t *in, size_t in_size)
{
- return gn_wf_analysisx("32", rkeys, rkeys_size, rvalues, rvalues_size, in, in_size);
+ return gn_wf_analysisx ("32", rkeys, rkeys_size, rvalues, rvalues_size, in,
+ in_size);
}
-int gn_wf_analysis64(char** rkeys, size_t rkeys_size, double* rvalues, size_t rvalues_size,
- const int64_t* in, size_t in_size)
+int
+gn_wf_analysis64 (char **rkeys, size_t rkeys_size, double *rvalues,
+ size_t rvalues_size, const int64_t *in, size_t in_size)
{
- return gn_wf_analysisx("64", rkeys, rkeys_size, rvalues, rvalues_size, in, in_size);
+ return gn_wf_analysisx ("64", rkeys, rkeys_size, rvalues, rvalues_size, in,
+ in_size);
}
\ No newline at end of file
diff --git a/bindings/c/src/cgenalyzer_simplified_beta.cpp b/bindings/c/src/cgenalyzer_simplified_beta.cpp
index 264e8ae..527bbb0 100644
--- a/bindings/c/src/cgenalyzer_simplified_beta.cpp
+++ b/bindings/c/src/cgenalyzer_simplified_beta.cpp
@@ -1,1169 +1,1335 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#include "cgenalyzer_simplified_beta.h"
#include "cgenalyzer_private.h"
-extern "C" {
- int gn_config_free(gn_config *c)
- {
- if ((*c)->obj_key){
- gn_mgr_remove((*c)->obj_key);
- free((*c)->obj_key);
- }
- if ((*c)->comp_key){
- gn_fa_remove_comp((*c)->obj_key, (*c)->comp_key);
- free((*c)->comp_key);
- }
- if (((*c)->_fa_results_size) > 0)
- {
- for (size_t i = 0; i < (*c)->_fa_results_size; i++)
- free((*c)->_fa_result_keys[i]);
- free((*c)->_fa_result_keys);
- free((*c)->_fa_result_key_sizes);
- free((*c)->_fa_result_values);
- }
- if (((*c)->_wfa_results_size) > 0)
- {
- for (size_t i = 0; i < (*c)->_wfa_results_size; i++)
- free((*c)->_wfa_result_keys[i]);
- free((*c)->_wfa_result_keys);
- free((*c)->_wfa_result_key_sizes);
- free((*c)->_wfa_result_values);
- }
- if (((*c)->_hist_results_size) > 0)
- {
- for (size_t i = 0; i < (*c)->_hist_results_size; i++)
- free((*c)->_hist_result_keys[i]);
- free((*c)->_hist_result_keys);
- free((*c)->_hist_result_key_sizes);
- free((*c)->_hist_result_values);
- }
- if (((*c)->_dnl_results_size) > 0)
- {
- for (size_t i = 0; i < (*c)->_dnl_results_size; i++)
- free((*c)->_dnl_result_keys[i]);
- free((*c)->_dnl_result_keys);
- free((*c)->_dnl_result_key_sizes);
- free((*c)->_dnl_result_values);
- }
- if (((*c)->_inl_results_size) > 0)
- {
- for (size_t i = 0; i < (*c)->_inl_results_size; i++)
- free((*c)->_inl_result_keys[i]);
- free((*c)->_inl_result_keys);
- free((*c)->_inl_result_key_sizes);
- free((*c)->_inl_result_values);
- }
- free(*c);
-
- return gn_success;
- }
-
- int gn_config_set_ttype(tone_type ttype, gn_config *c)
- {
- if (!((ttype == REAL_COSINE) || (ttype == REAL_SINE) || (ttype == COMPLEX_EXP)))
- {
- printf("ERROR: Invalid selection of ttype for tone generation\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->ttype = ttype;
-
- return gn_success;
- }
-
- int gn_config_set_npts(size_t npts, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->npts = npts;
- return gn_success;
- }
-
- int gn_config_get_npts(size_t *npts, gn_config *c)
- {
- if (!(*c))
- {
- printf("config struct is NULL\n");
- return gn_failure;
- }
- *npts = (*c)->npts;
- return gn_success;
- }
-
- int gn_config_set_sample_rate(gn::real_t sample_rate, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->sample_rate = sample_rate;
- return gn_success;
- }
-
- int gn_config_get_sample_rate(double *sample_rate, gn_config *c)
- {
- if (!(*c))
- {
- printf("config struct is NULL\n");
- return gn_failure;
- }
- *sample_rate = (*c)->sample_rate;
- return gn_success;
- }
-
- int gn_config_set_data_rate(gn::real_t data_rate, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->data_rate = data_rate;
- return gn_success;
- }
-
- int gn_config_set_shift_freq(gn::real_t shift_freq, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->shift_freq = shift_freq;
- return gn_success;
- }
-
- int gn_config_set_num_tones(size_t num_tones, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->num_tones = num_tones;
- return gn_success;
- }
-
- int gn_config_set_tone_freq(gn::real_t *tone_freq, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->tone_freq = tone_freq;
- return gn_success;
- }
-
- int gn_config_set_tone_ampl(gn::real_t *tone_ampl, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->tone_ampl = tone_ampl;
- return gn_success;
- }
-
- int gn_config_set_tone_phase(gn::real_t *tone_phase, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->tone_phase = tone_phase;
- return gn_success;
- }
-
- int gn_config_set_fsr(gn::real_t fsr, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->fsr = fsr;
- return gn_success;
- }
-
- int gn_config_set_qres(int qres, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->qres = qres;
- return gn_success;
- }
-
- int gn_config_set_noise_rms(gn::real_t noise_rms, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->noise_rms = noise_rms;
- return gn_success;
- }
-
- int gn_config_set_code_format(GnCodeFormat code_format, gn_config *c)
- {
- if (!((code_format == GnCodeFormatOffsetBinary) || (code_format == GnCodeFormatTwosComplement)))
- {
- printf("ERROR: Invalid selection of code format\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->code_format = code_format;
- return gn_success;
- }
-
- int gn_config_set_nfft(size_t nfft, gn_config *c)
- {
- if (((*c)->nfft) > ((*c)->npts))
- {
- printf("ERROR: FFT order cannot be greater than the number of sample points\n");
- return gn_failure;
- }
-
- double rem = 1.0*(((*c)->npts)%((*c)->nfft));
- if (rem > 0)
- {
- printf("ERROR: FFT order has to be a multiple of the number of sample points\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->nfft = nfft;
- (*c)->fft_navg = (*c)->npts/(*c)->nfft;
- return gn_success;
- }
-
- int gn_config_get_nfft(size_t *nfft, gn_config *c)
- {
- if (!(*c))
- {
- printf("here - config struct is NULL\n");
- return gn_failure;
- }
- *nfft = (*c)->nfft;
- return gn_success;
- }
-
- int gn_config_set_fft_navg(size_t fft_navg, gn_config *c)
- {
- if (((*c)->fft_navg) > ((*c)->npts))
- {
- printf("ERROR: Number of FFT averages cannot be greater than the number of sample points\n");
- return gn_failure;
- }
-
- double rem = 1.0*(((*c)->npts)%((*c)->fft_navg));
- if (rem > 0)
- {
- printf("ERROR: Number of FFT averages has to be a multiple of the number of sample points\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->fft_navg = fft_navg;
- (*c)->nfft = (*c)->npts/(*c)->fft_navg;
- return gn_success;
- }
-
- int gn_config_set_win(GnWindow win, gn_config *c)
- {
- if (!((win == GnWindowBlackmanHarris) || (win == GnWindowHann) || (win == GnWindowNoWindow)))
- {
- printf("ERROR: Invalid selection of window function\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->win = win;
- return gn_success;
- }
-
- int gn_config_set_ssb_fund(int ssb_fund, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->ssb_fund = ssb_fund;
- return gn_success;
- }
-
- int gn_config_set_ssb_rest(int ssb_rest, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->ssb_rest = ssb_rest;
- return gn_success;
- }
-
- int gn_config_set_max_harm_order(int max_harm_order, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->max_harm_order = max_harm_order;
- return gn_success;
- }
-
- int gn_config_set_dnla_signal_type(GnDnlSignal dnla_signal_type, gn_config *c)
- {
- if (!((dnla_signal_type == GnDnlSignalRamp) || (dnla_signal_type == GnDnlSignalTone)))
- {
- printf("ERROR: Invalid selection of DNL analysis signal type\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->dnla_signal_type = dnla_signal_type;
- return gn_success;
- }
-
- int gn_config_set_inla_fit(GnInlLineFit inla_fit, gn_config *c)
- {
- if (!((inla_fit == GnInlLineFitBestFit) || (inla_fit == GnInlLineFitEndFit) || (inla_fit == GnInlLineFitNoFit)))
- {
- printf("ERROR: Invalid selection of INL line fit\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->inla_fit = inla_fit;
- return gn_success;
- }
-
- int gn_config_set_ramp_start(double ramp_start, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->ramp_start = ramp_start;
- return gn_success;
- }
-
- int gn_config_set_ramp_stop(double ramp_stop, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->ramp_stop = ramp_stop;
- return gn_success;
- }
-
- int gn_config_get_code_density_size(size_t *code_density_size, gn_config *c)
- {
- if (!(*c))
- {
- printf("config struct is NULL\n");
- return gn_failure;
- }
- *code_density_size = (*c)->_code_density_size;
- return gn_success;
- }
-
- int gn_config_gen_tone(tone_type ttype, size_t npts, gn::real_t sample_rate, size_t num_tones, gn::real_t *tone_freq, gn::real_t *tone_ampl, gn::real_t *tone_phase, gn_config *c)
- {
- if (!((ttype == REAL_COSINE) || (ttype == REAL_SINE) || (ttype == COMPLEX_EXP)))
- {
- printf("ERROR: Invalid selection of waveform type for tone generation\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->ttype = ttype;
- (*c)->npts = npts;
- (*c)->sample_rate = sample_rate;
- (*c)->num_tones = num_tones;
- (*c)->tone_freq = tone_freq;
- (*c)->tone_ampl = tone_ampl;
- (*c)->tone_phase = tone_phase;
-
- return gn_success;
- }
-
- int gn_config_gen_ramp(size_t npts, double ramp_start, double ramp_stop, gn_config *c)
- {
- if (ramp_stop < ramp_start)
- {
- printf("ERROR: ramp stop value cannot be smaller than ramp start value for ramp generation\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->npts = npts;
- (*c)->ramp_start = ramp_start;
- (*c)->ramp_stop = ramp_stop;
- (*c)->noise_rms = 0.0;
-
- return gn_success;
- }
-
- int gn_config_quantize(size_t npts, gn::real_t fsr, int qres, gn::real_t noise_rms, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->npts = npts;
- (*c)->fsr = fsr;
- (*c)->qres = qres;
- (*c)->noise_rms = noise_rms;
- (*c)->code_format = GnCodeFormatTwosComplement;
-
- return gn_success;
- }
-
- int gn_config_histz_nla(size_t npts, int qres, gn_config *c)
- {
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
- (*c)->npts = npts;
- (*c)->qres = qres;
- (*c)->code_format = GnCodeFormatTwosComplement;
- (*c)->inla_fit = GnInlLineFitBestFit;
-
- return gn_success;
- }
-
- int gn_config_fftz(size_t npts, int qres, size_t fft_navg, size_t nfft, GnWindow win, gn_config *c)
- {
- if (npts != (fft_navg*nfft))
- {
- printf("ERROR: Number of samples points in the waveform has to equal FFT order times number of FFT averages\n");
- return gn_failure;
- }
-
- if (!((win == GnWindowBlackmanHarris) || (win == GnWindowHann) || (win == GnWindowNoWindow)))
- {
- printf("ERROR: Invalid selection of window function\n");
- return gn_failure;
- }
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
-
- (*c)->npts = npts;
- (*c)->qres = qres;
- (*c)->fft_navg = fft_navg;
- (*c)->nfft = nfft;
- (*c)->win = win;
- (*c)->code_format = GnCodeFormatTwosComplement;
-
- return gn_success;
- }
-
- int gn_config_fa_auto(uint8_t ssb_width, gn_config *c)
- {
- int err_code;
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
-
- if ((*c)->sample_rate <= 0) {
- printf("ERROR: Sample rate must be set before configuring Fourier analysis\n");
- return gn_failure;
- }
-
- (*c)->obj_key = (char *)calloc(3, sizeof(char));
- strcpy((*c)->obj_key, "fa");
- (*c)->comp_key = (char *)calloc(2, sizeof(char));
- strcpy((*c)->comp_key, "A");
-
- (*c)->ssb_fund = ssb_width;
- (*c)->ssb_rest = 0;
- (*c)->max_harm_order = 3;
- (*c)->axis_type = GnFreqAxisTypeDcCenter;
-
- // configure object key for Fourier analysis
- err_code = gn_fa_create((*c)->obj_key);
-
- // configure component key for Fourier analysis
- err_code += gn_fa_max_tone((*c)->obj_key, (*c)->comp_key, GnFACompTagSignal, (*c)->ssb_fund);
-
- // configure harmonic order for Fourier analysis
- err_code += gn_fa_hd((*c)->obj_key, (*c)->max_harm_order);
-
- // configure single-side bins for Fourier analysis
- err_code += gn_fa_ssb((*c)->obj_key, GnFASsbDefault, (*c)->ssb_rest);
- err_code += gn_fa_ssb((*c)->obj_key, GnFASsbDC, -1);
- err_code += gn_fa_ssb((*c)->obj_key, GnFASsbSignal, -1);
- err_code += gn_fa_ssb((*c)->obj_key, GnFASsbWO, -1);
-
- // configure sample-rate, data-rate, shift frequency, and converter offset
- err_code += gn_fa_fsample((*c)->obj_key, (*c)->sample_rate);
- err_code += gn_fa_fdata((*c)->obj_key, (*c)->sample_rate);
- err_code += gn_fa_fshift((*c)->obj_key, 0.0);
- err_code += gn_fa_conv_offset((*c)->obj_key, false);
-
- return (err_code);
- }
-
-
- int gn_config_fa(gn::real_t fixed_tone_freq, gn_config *c)
- {
- int err_code;
-
- if (!(*c))
- {
- gn_config c_p;
- c_p = (gn_config)calloc(1, sizeof(*c_p));
- if (!(c_p))
- {
- printf("insufficient memory\n");
- return ENOMEM;
- }
- else
- *c = c_p;
- }
-
- if ((*c)->sample_rate <= 0) {
- printf("ERROR: Sample rate must be set before configuring Fourier analysis\n");
- return gn_failure;
- }
-
- (*c)->obj_key = (char *)calloc(3, sizeof(char));
- strcpy((*c)->obj_key, "fa");
- (*c)->comp_key = (char *)calloc(2, sizeof(char));
- strcpy((*c)->comp_key, "A");
-
- (*c)->ssb_fund = 120;
- (*c)->ssb_rest = 0;
- (*c)->max_harm_order = 3;
- (*c)->axis_type = GnFreqAxisTypeDcCenter;
-
- // configure object key for Fourier analysis
- err_code = gn_fa_create((*c)->obj_key);
-
- // configure component key for Fourier analysis
- err_code += gn_fa_fixed_tone((*c)->obj_key, (*c)->comp_key, GnFACompTagSignal, fixed_tone_freq, (*c)->ssb_fund);
-
- // configure harmonic order for Fourier analysis
- err_code += gn_fa_hd((*c)->obj_key, (*c)->max_harm_order);
-
- // configure single-side bins for Fourier analysis
- err_code += gn_fa_ssb((*c)->obj_key, GnFASsbDefault, (*c)->ssb_rest);
- err_code += gn_fa_ssb((*c)->obj_key, GnFASsbDC, -1);
- err_code += gn_fa_ssb((*c)->obj_key, GnFASsbSignal, -1);
- err_code += gn_fa_ssb((*c)->obj_key, GnFASsbWO, -1);
-
- // configure sample-rate, data-rate, shift frequency, and converter offset
- err_code += gn_fa_fsample((*c)->obj_key, (*c)->sample_rate);
- err_code += gn_fa_fdata((*c)->obj_key, (*c)->sample_rate);
- err_code += gn_fa_fshift((*c)->obj_key, 0.0);
- err_code += gn_fa_conv_offset((*c)->obj_key, false);
-
- return (err_code);
- }
-
- // waveform generation
- int gn_gen_ramp(gn::real_t **out, gn_config *c)
- {
- int err_code;
- gn::real_t *awf = (gn::real_t *)calloc((*c)->npts, sizeof(gn::real_t));
- err_code = gn_ramp(awf, (*c)->npts, (*c)->ramp_start, (*c)->ramp_stop, (*c)->noise_rms);
- *out = awf;
-
- return err_code;
- }
-
- int gn_gen_real_tone(gn::real_t **out, gn_config *c)
- {
- int err_code = 0;
- gn::real_t *awf = (gn::real_t *)calloc((*c)->npts, sizeof(gn::real_t));
-
- for (size_t i = 0; i < (*c)->num_tones; i++)
- {
- gn::real_t *tmp = (gn::real_t *)calloc((*c)->npts, sizeof(gn::real_t));
- if ((*c)->ttype == REAL_COSINE)
- err_code = gn_cos(tmp, (*c)->npts, (*c)->sample_rate, (*c)->tone_ampl[i], (*c)->tone_freq[i], (*c)->tone_phase[i], 0, 0);
- else if ((*c)->ttype == REAL_SINE)
- err_code = gn_sin(tmp, (*c)->npts, (*c)->sample_rate, (*c)->tone_ampl[i], (*c)->tone_freq[i], (*c)->tone_phase[i], 0, 0);
- if (!err_code)
- {
- for (size_t j = 0; j < (*c)->npts; j++)
- awf[j] = awf[j] + tmp[j];
- }
- }
- *out = awf;
-
- return err_code;
- }
-
- int gn_gen_complex_tone(gn::real_t **outi, gn::real_t **outq, gn_config *c)
- {
- int err_code = 0;
- gn::real_t *awfi = (gn::real_t *)calloc((*c)->npts, sizeof(gn::real_t));
- gn::real_t *awfq = (gn::real_t *)calloc((*c)->npts, sizeof(gn::real_t));
-
- for (size_t i = 0; i < (*c)->num_tones; i++) {
- gn::real_t *tmp = (gn::real_t *)calloc((*c)->npts, sizeof(gn::real_t));
- err_code = gn_cos(tmp, (*c)->npts, (*c)->sample_rate, (*c)->tone_ampl[i], (*c)->tone_freq[i], (*c)->tone_phase[i], 0, 0);
- if (!err_code)
- {
- for (size_t j = 0; j < (*c)->npts; j++)
- awfi[j] = awfi[j] + tmp[j];
- }
- tmp = (gn::real_t *)calloc((*c)->npts, sizeof(gn::real_t));
- err_code = gn_sin(tmp, (*c)->npts, (*c)->sample_rate, (*c)->tone_ampl[i], (*c)->tone_freq[i], (*c)->tone_phase[i], 0, 0);
- if (!err_code)
- {
- for (size_t j = 0; j < (*c)->npts; j++)
- awfq[j] = awfq[j] + tmp[j];
- }
- }
- *outi = awfi;
- *outq = awfq;
-
- return err_code;
- }
-
- // processing
- int gn_quantize(int32_t **out, const gn::real_t *in, gn_config *c)
- {
- int err_code;
- int32_t *qwf = (int32_t *)calloc((*c)->npts, sizeof(int32_t));
-
- err_code = gn_quantize32(qwf, (*c)->npts, in, (*c)->npts, (*c)->fsr, (*c)->qres, (*c)->noise_rms, (*c)->code_format);
- *out = qwf;
-
- return err_code;
- }
-
- int gn_fftz(gn::real_t **out, const int32_t *in_i, const int32_t *in_q, gn_config *c)
- {
- int err_code;
- gn::real_t *fft_of_in = (gn::real_t *)calloc(2*(*c)->nfft, sizeof(gn::real_t));
-
- err_code = gn_fft32(fft_of_in, 2*(*c)->nfft, in_i, (*c)->npts, in_q, (*c)->npts, (*c)->qres, (*c)->fft_navg, (*c)->nfft, (*c)->win, (*c)->code_format);
- *out = fft_of_in;
-
- return err_code;
- }
-
- int gn_histz(uint64_t **hist, size_t *hist_len, const int32_t *qwf, gn_config *c)
- {
- int err_code;
- uint64_t *out = NULL;
-
- err_code = gn_code_density_size(&((*c)->_code_density_size), (*c)->qres, (*c)->code_format);
- out = (uint64_t *)calloc((*c)->_code_density_size, sizeof(uint64_t));
- err_code += gn_hist32(out, (*c)->_code_density_size, qwf, (*c)->npts, (*c)->qres, (*c)->code_format, false);
- *hist = out;
- *hist_len = (*c)->_code_density_size;
-
- return err_code;
- }
-
- int gn_dnlz(double **dnl, size_t *dnl_len, const uint64_t *hist, gn_config *c)
- {
- int err_code;
- double *out = NULL;
-
- err_code = gn_code_density_size(&((*c)->_code_density_size), (*c)->qres, (*c)->code_format);
- out = (double *)calloc((*c)->_code_density_size, sizeof(double));
- err_code = gn_dnl(out, (*c)->_code_density_size, hist, (*c)->_code_density_size, (*c)->dnla_signal_type);
- *dnl = out;
- *dnl_len = (*c)->_code_density_size;
-
- return err_code;
- }
-
- int gn_inlz(double **inl, size_t *inl_len, const double *dnl, gn_config *c)
- {
- int err_code;
- double *out = NULL;
-
- err_code = gn_code_density_size(&((*c)->_code_density_size), (*c)->qres, (*c)->code_format);
- out = (double *)calloc((*c)->_code_density_size, sizeof(double));
- err_code = gn_inl(out, (*c)->_code_density_size, dnl, (*c)->_code_density_size, (*c)->inla_fit);
- *inl = out;
- *inl_len = (*c)->_code_density_size;
-
- return err_code;
- }
-
- // Waveform/Histogram/DNL/INL/Fourier Analysis
- int gn_get_wfa_results(char ***rkeys, gn::real_t **rvalues, size_t *results_size, const int32_t *qwf, gn_config *c)
- {
- int err_code = 0;
-
- // get results size
- err_code = gn_analysis_results_size(&((*c)->_wfa_results_size), GnAnalysisTypeWaveform);
-
- // allocate memory for result keys and values
- (*c)->_wfa_result_keys = (char **)calloc(((*c)->_wfa_results_size), sizeof(char*));
- (*c)->_wfa_result_values = (gn::real_t *)calloc(((*c)->_wfa_results_size), sizeof(gn::real_t));
-
- // get result key sizes
- (*c)->_wfa_result_key_sizes = (size_t *)calloc(((*c)->_wfa_results_size), sizeof(size_t));
- err_code += gn_analysis_results_key_sizes((*c)->_wfa_result_key_sizes, (*c)->_wfa_results_size, GnAnalysisTypeWaveform);
-
- // allocate memory for each result key
- for (size_t i = 0; i < (*c)->_wfa_results_size; ++i)
- (*c)->_wfa_result_keys[i] = (char *)calloc((*c)->_wfa_result_key_sizes[i], sizeof(char));
-
- // execute analysis
- err_code += gn_wf_analysis32((*c)->_wfa_result_keys, (*c)->_wfa_results_size, (*c)->_wfa_result_values, (*c)->_wfa_results_size, qwf, (*c)->npts);
-
- // copy keys
- *rkeys = (char **)calloc(((*c)->_wfa_results_size), sizeof(char*));
- for (size_t i = 0; i < (*c)->_wfa_results_size; ++i)
- (*rkeys)[i] = (char *)calloc((*c)->_wfa_result_key_sizes[i], sizeof(char));
-
- // copy values
- *rvalues = (gn::real_t *)calloc(((*c)->_wfa_results_size), sizeof(gn::real_t));
- for (size_t i = 0; i < (*c)->_wfa_results_size; ++i)
- {
- strcpy((*rkeys)[i], (*c)->_wfa_result_keys[i]);
- (*rvalues)[i] = (*c)->_wfa_result_values[i];
- }
- *results_size = (*c)->_wfa_results_size;
-
- return(err_code);
- }
-
- int gn_get_ha_results(char ***rkeys, gn::real_t **rvalues, size_t *results_size, const uint64_t *hist, gn_config *c)
- {
- int err_code = 0;
-
- // get results size
- err_code = gn_analysis_results_size(&((*c)->_hist_results_size), GnAnalysisTypeHistogram);
-
- // allocate memory for result keys and values
- (*c)->_hist_result_keys = (char **)calloc(((*c)->_hist_results_size), sizeof(char*));
- (*c)->_hist_result_values = (gn::real_t *)calloc(((*c)->_hist_results_size), sizeof(gn::real_t));
-
- // get result key sizes
- (*c)->_hist_result_key_sizes = (size_t *)calloc(((*c)->_hist_results_size), sizeof(size_t));
- err_code += gn_analysis_results_key_sizes((*c)->_hist_result_key_sizes, (*c)->_hist_results_size, GnAnalysisTypeHistogram);
-
- // allocate memory for each result key
- for (size_t i = 0; i < (*c)->_hist_results_size; ++i)
- (*c)->_hist_result_keys[i] = (char *)calloc((*c)->_hist_result_key_sizes[i], sizeof(char));
-
- // execute analysis
- err_code += gn_hist_analysis((*c)->_hist_result_keys, (*c)->_hist_results_size, (*c)->_hist_result_values, (*c)->_hist_results_size, hist, (*c)->_code_density_size);
-
- // copy keys
- *rkeys = (char **)calloc(((*c)->_hist_results_size), sizeof(char*));
- for (size_t i = 0; i < (*c)->_hist_results_size; ++i)
- (*rkeys)[i] = (char *)calloc((*c)->_hist_result_key_sizes[i], sizeof(char));
-
- // copy values
- *rvalues = (gn::real_t *)calloc(((*c)->_hist_results_size), sizeof(gn::real_t));
- for (size_t i = 0; i < (*c)->_hist_results_size; ++i)
- {
- strcpy((*rkeys)[i], (*c)->_hist_result_keys[i]);
- (*rvalues)[i] = (*c)->_hist_result_values[i];
- }
- *results_size = (*c)->_hist_results_size;
-
- return(err_code);
- }
-
- int gn_get_dnla_results(char ***rkeys, gn::real_t **rvalues, size_t *results_size, const gn::real_t *dnl, gn_config *c)
- {
- int err_code;
-
- // get results size
- err_code = gn_analysis_results_size(&((*c)->_dnl_results_size), GnAnalysisTypeDNL);
-
- // allocate memory for result keys and values
- (*c)->_dnl_result_keys = (char **)calloc(((*c)->_dnl_results_size), sizeof(char*));
- (*c)->_dnl_result_values = (gn::real_t *)calloc(((*c)->_dnl_results_size), sizeof(gn::real_t));
-
- // get result key sizes
- (*c)->_dnl_result_key_sizes = (size_t *)calloc(((*c)->_dnl_results_size), sizeof(size_t));
- err_code += gn_analysis_results_key_sizes((*c)->_dnl_result_key_sizes, (*c)->_dnl_results_size, GnAnalysisTypeDNL);
-
- // allocate memory for each result key
- for (size_t i = 0; i < (*c)->_dnl_results_size; ++i)
- (*c)->_dnl_result_keys[i] = (char *)calloc((*c)->_dnl_result_key_sizes[i], sizeof(char));
-
- // execute analysis
- err_code += gn_dnl_analysis((*c)->_dnl_result_keys, (*c)->_dnl_results_size, (*c)->_dnl_result_values, (*c)->_dnl_results_size, dnl, (*c)->_code_density_size);
-
- // copy keys
- *rkeys = (char **)calloc(((*c)->_dnl_results_size), sizeof(char*));
- for (size_t i = 0; i < (*c)->_dnl_results_size; ++i)
- (*rkeys)[i] = (char *)calloc((*c)->_dnl_result_key_sizes[i], sizeof(char));
-
- // copy values
- *rvalues = (gn::real_t *)calloc(((*c)->_dnl_results_size), sizeof(gn::real_t));
- for (size_t i = 0; i < (*c)->_dnl_results_size; ++i)
- {
- strcpy((*rkeys)[i], (*c)->_dnl_result_keys[i]);
- (*rvalues)[i] = (*c)->_dnl_result_values[i];
- }
- *results_size = (*c)->_dnl_results_size;
-
- return(err_code);
- }
-
- int gn_get_inla_results(char ***rkeys, gn::real_t **rvalues, size_t *results_size, const gn::real_t *inl, gn_config *c)
- {
- int err_code;
-
- // get results size
- err_code = gn_analysis_results_size(&((*c)->_inl_results_size), GnAnalysisTypeINL);
-
- // allocate memory for result keys and values
- (*c)->_inl_result_keys = (char **)calloc(((*c)->_inl_results_size), sizeof(char*));
- (*c)->_inl_result_values = (gn::real_t *)calloc(((*c)->_inl_results_size), sizeof(gn::real_t));
-
- // get result key sizes
- (*c)->_inl_result_key_sizes = (size_t *)calloc(((*c)->_inl_results_size), sizeof(size_t));
- err_code += gn_analysis_results_key_sizes((*c)->_inl_result_key_sizes, (*c)->_inl_results_size, GnAnalysisTypeINL);
-
- // allocate memory for each result key
- for (size_t i = 0; i < (*c)->_inl_results_size; ++i)
- (*c)->_inl_result_keys[i] = (char *)calloc((*c)->_inl_result_key_sizes[i], sizeof(char));
-
- // execute analysis
- err_code += gn_inl_analysis((*c)->_inl_result_keys, (*c)->_inl_results_size, (*c)->_inl_result_values, (*c)->_inl_results_size, inl, (*c)->_code_density_size);
-
- // copy keys
- *rkeys = (char **)calloc(((*c)->_inl_results_size), sizeof(char*));
- for (size_t i = 0; i < (*c)->_inl_results_size; ++i)
- (*rkeys)[i] = (char *)calloc((*c)->_inl_result_key_sizes[i], sizeof(char));
-
- // copy values
- *rvalues = (gn::real_t *)calloc(((*c)->_inl_results_size), sizeof(gn::real_t));
- for (size_t i = 0; i < (*c)->_inl_results_size; ++i)
- {
- strcpy((*rkeys)[i], (*c)->_inl_result_keys[i]);
- (*rvalues)[i] = (*c)->_inl_result_values[i];
- }
- *results_size = (*c)->_inl_results_size;
-
- return(err_code);
- }
-
- int gn_get_fa_single_result(gn::real_t *rvalue, const char *metric_name, gn::real_t *fft_ilv, gn_config *c)
- {
- int err_code;
- size_t i;
- bool metric_found = false;
- size_t results_size;
- char **rkeys;
- double *rvalues;
-
- // compute all results
- err_code = gn_get_fa_results(&rkeys, &rvalues, &results_size, fft_ilv, &(*c));
- for (i = 0; i < results_size; i++)
- {
- if (!strcmp(metric_name, rkeys[i]))
- {
- metric_found = true;
- break;
- }
- }
- if (!metric_found)
- {
- printf("ERROR: Invalid selection of metric\n");
- return gn_failure;
- }
- *rvalue = rvalues[i];
-
- return err_code;
- }
-
- int gn_get_fa_results(char ***rkeys, gn::real_t **rvalues, size_t *results_size, gn::real_t *fft_ilv, gn_config *c)
- {
- int err_code = 0;
- size_t *result_key_sizes;
-
- // get results size
- err_code = gn_fft_analysis_results_size(results_size, (*c)->obj_key, 2*(*c)->nfft, (*c)->nfft);
-
- // allocate memory for result keys and values
- *rkeys = (char **)calloc(*results_size, sizeof(char*));
- *rvalues = (gn::real_t *)calloc(*results_size, sizeof(gn::real_t));
-
- // get result key sizes
- result_key_sizes = (size_t *)calloc(*results_size, sizeof(size_t));
- err_code += gn_fft_analysis_results_key_sizes(result_key_sizes, *results_size, (*c)->obj_key, 2*(*c)->nfft, (*c)->nfft);
-
- // allocate memory for each result key
- for (size_t i = 0; i < *results_size; ++i)
- (*rkeys)[i] = (char *)calloc(result_key_sizes[i], sizeof(char));
-
- // execute analysis
- err_code += gn_fft_analysis(*rkeys, *results_size, *rvalues, *results_size, (*c)->obj_key, fft_ilv, 2*(*c)->nfft, (*c)->nfft, (*c)->axis_type);
-
- return (err_code);
- }
+extern "C"
+{
+ int
+ gn_config_free (gn_config *c)
+ {
+ if ((*c)->obj_key)
+ {
+ gn_mgr_remove ((*c)->obj_key);
+ free ((*c)->obj_key);
+ }
+ if ((*c)->comp_key)
+ {
+ gn_fa_remove_comp ((*c)->obj_key, (*c)->comp_key);
+ free ((*c)->comp_key);
+ }
+ if (((*c)->_fa_results_size) > 0)
+ {
+ for (size_t i = 0; i < (*c)->_fa_results_size; i++)
+ free ((*c)->_fa_result_keys[i]);
+ free ((*c)->_fa_result_keys);
+ free ((*c)->_fa_result_key_sizes);
+ free ((*c)->_fa_result_values);
+ }
+ if (((*c)->_wfa_results_size) > 0)
+ {
+ for (size_t i = 0; i < (*c)->_wfa_results_size; i++)
+ free ((*c)->_wfa_result_keys[i]);
+ free ((*c)->_wfa_result_keys);
+ free ((*c)->_wfa_result_key_sizes);
+ free ((*c)->_wfa_result_values);
+ }
+ if (((*c)->_hist_results_size) > 0)
+ {
+ for (size_t i = 0; i < (*c)->_hist_results_size; i++)
+ free ((*c)->_hist_result_keys[i]);
+ free ((*c)->_hist_result_keys);
+ free ((*c)->_hist_result_key_sizes);
+ free ((*c)->_hist_result_values);
+ }
+ if (((*c)->_dnl_results_size) > 0)
+ {
+ for (size_t i = 0; i < (*c)->_dnl_results_size; i++)
+ free ((*c)->_dnl_result_keys[i]);
+ free ((*c)->_dnl_result_keys);
+ free ((*c)->_dnl_result_key_sizes);
+ free ((*c)->_dnl_result_values);
+ }
+ if (((*c)->_inl_results_size) > 0)
+ {
+ for (size_t i = 0; i < (*c)->_inl_results_size; i++)
+ free ((*c)->_inl_result_keys[i]);
+ free ((*c)->_inl_result_keys);
+ free ((*c)->_inl_result_key_sizes);
+ free ((*c)->_inl_result_values);
+ }
+ free (*c);
+
+ return gn_success;
+ }
+
+ int
+ gn_config_set_ttype (tone_type ttype, gn_config *c)
+ {
+ if (!((ttype == REAL_COSINE) || (ttype == REAL_SINE)
+ || (ttype == COMPLEX_EXP)))
+ {
+ printf ("ERROR: Invalid selection of ttype for tone generation\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->ttype = ttype;
+
+ return gn_success;
+ }
+
+ int
+ gn_config_set_npts (size_t npts, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->npts = npts;
+ return gn_success;
+ }
+
+ int
+ gn_config_get_npts (size_t *npts, gn_config *c)
+ {
+ if (!(*c))
+ {
+ printf ("config struct is NULL\n");
+ return gn_failure;
+ }
+ *npts = (*c)->npts;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_sample_rate (gn::real_t sample_rate, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->sample_rate = sample_rate;
+ return gn_success;
+ }
+
+ int
+ gn_config_get_sample_rate (double *sample_rate, gn_config *c)
+ {
+ if (!(*c))
+ {
+ printf ("config struct is NULL\n");
+ return gn_failure;
+ }
+ *sample_rate = (*c)->sample_rate;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_data_rate (gn::real_t data_rate, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->data_rate = data_rate;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_shift_freq (gn::real_t shift_freq, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->shift_freq = shift_freq;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_num_tones (size_t num_tones, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->num_tones = num_tones;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_tone_freq (gn::real_t *tone_freq, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->tone_freq = tone_freq;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_tone_ampl (gn::real_t *tone_ampl, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->tone_ampl = tone_ampl;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_tone_phase (gn::real_t *tone_phase, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->tone_phase = tone_phase;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_fsr (gn::real_t fsr, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->fsr = fsr;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_qres (int qres, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->qres = qres;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_noise_rms (gn::real_t noise_rms, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->noise_rms = noise_rms;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_code_format (GnCodeFormat code_format, gn_config *c)
+ {
+ if (!((code_format == GnCodeFormatOffsetBinary)
+ || (code_format == GnCodeFormatTwosComplement)))
+ {
+ printf ("ERROR: Invalid selection of code format\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->code_format = code_format;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_nfft (size_t nfft, gn_config *c)
+ {
+ if (((*c)->nfft) > ((*c)->npts))
+ {
+ printf ("ERROR: FFT order cannot be greater than the number of sample "
+ "points\n");
+ return gn_failure;
+ }
+
+ double rem = 1.0 * (((*c)->npts) % ((*c)->nfft));
+ if (rem > 0)
+ {
+ printf ("ERROR: FFT order has to be a multiple of the number of "
+ "sample points\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->nfft = nfft;
+ (*c)->fft_navg = (*c)->npts / (*c)->nfft;
+ return gn_success;
+ }
+
+ int
+ gn_config_get_nfft (size_t *nfft, gn_config *c)
+ {
+ if (!(*c))
+ {
+ printf ("here - config struct is NULL\n");
+ return gn_failure;
+ }
+ *nfft = (*c)->nfft;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_fft_navg (size_t fft_navg, gn_config *c)
+ {
+ if (((*c)->fft_navg) > ((*c)->npts))
+ {
+ printf ("ERROR: Number of FFT averages cannot be greater than the "
+ "number of sample points\n");
+ return gn_failure;
+ }
+
+ double rem = 1.0 * (((*c)->npts) % ((*c)->fft_navg));
+ if (rem > 0)
+ {
+ printf ("ERROR: Number of FFT averages has to be a multiple of the "
+ "number of sample points\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->fft_navg = fft_navg;
+ (*c)->nfft = (*c)->npts / (*c)->fft_navg;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_win (GnWindow win, gn_config *c)
+ {
+ if (!((win == GnWindowBlackmanHarris) || (win == GnWindowHann)
+ || (win == GnWindowNoWindow)))
+ {
+ printf ("ERROR: Invalid selection of window function\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->win = win;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_ssb_fund (int ssb_fund, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->ssb_fund = ssb_fund;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_ssb_rest (int ssb_rest, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->ssb_rest = ssb_rest;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_max_harm_order (int max_harm_order, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->max_harm_order = max_harm_order;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_dnla_signal_type (GnDnlSignal dnla_signal_type, gn_config *c)
+ {
+ if (!((dnla_signal_type == GnDnlSignalRamp)
+ || (dnla_signal_type == GnDnlSignalTone)))
+ {
+ printf ("ERROR: Invalid selection of DNL analysis signal type\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->dnla_signal_type = dnla_signal_type;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_inla_fit (GnInlLineFit inla_fit, gn_config *c)
+ {
+ if (!((inla_fit == GnInlLineFitBestFit) || (inla_fit == GnInlLineFitEndFit)
+ || (inla_fit == GnInlLineFitNoFit)))
+ {
+ printf ("ERROR: Invalid selection of INL line fit\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->inla_fit = inla_fit;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_ramp_start (double ramp_start, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->ramp_start = ramp_start;
+ return gn_success;
+ }
+
+ int
+ gn_config_set_ramp_stop (double ramp_stop, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->ramp_stop = ramp_stop;
+ return gn_success;
+ }
+
+ int
+ gn_config_get_code_density_size (size_t *code_density_size, gn_config *c)
+ {
+ if (!(*c))
+ {
+ printf ("config struct is NULL\n");
+ return gn_failure;
+ }
+ *code_density_size = (*c)->_code_density_size;
+ return gn_success;
+ }
+
+ int
+ gn_config_gen_tone (tone_type ttype, size_t npts, gn::real_t sample_rate,
+ size_t num_tones, gn::real_t *tone_freq,
+ gn::real_t *tone_ampl, gn::real_t *tone_phase,
+ gn_config *c)
+ {
+ if (!((ttype == REAL_COSINE) || (ttype == REAL_SINE)
+ || (ttype == COMPLEX_EXP)))
+ {
+ printf (
+ "ERROR: Invalid selection of waveform type for tone generation\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->ttype = ttype;
+ (*c)->npts = npts;
+ (*c)->sample_rate = sample_rate;
+ (*c)->num_tones = num_tones;
+ (*c)->tone_freq = tone_freq;
+ (*c)->tone_ampl = tone_ampl;
+ (*c)->tone_phase = tone_phase;
+
+ return gn_success;
+ }
+
+ int
+ gn_config_gen_ramp (size_t npts, double ramp_start, double ramp_stop,
+ gn_config *c)
+ {
+ if (ramp_stop < ramp_start)
+ {
+ printf ("ERROR: ramp stop value cannot be smaller than ramp start "
+ "value for ramp generation\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->npts = npts;
+ (*c)->ramp_start = ramp_start;
+ (*c)->ramp_stop = ramp_stop;
+ (*c)->noise_rms = 0.0;
+
+ return gn_success;
+ }
+
+ int
+ gn_config_quantize (size_t npts, gn::real_t fsr, int qres,
+ gn::real_t noise_rms, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->npts = npts;
+ (*c)->fsr = fsr;
+ (*c)->qres = qres;
+ (*c)->noise_rms = noise_rms;
+ (*c)->code_format = GnCodeFormatTwosComplement;
+
+ return gn_success;
+ }
+
+ int
+ gn_config_histz_nla (size_t npts, int qres, gn_config *c)
+ {
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+ (*c)->npts = npts;
+ (*c)->qres = qres;
+ (*c)->code_format = GnCodeFormatTwosComplement;
+ (*c)->inla_fit = GnInlLineFitBestFit;
+
+ return gn_success;
+ }
+
+ int
+ gn_config_fftz (size_t npts, int qres, size_t fft_navg, size_t nfft,
+ GnWindow win, gn_config *c)
+ {
+ if (npts != (fft_navg * nfft))
+ {
+ printf ("ERROR: Number of samples points in the waveform has to equal "
+ "FFT order times number of FFT averages\n");
+ return gn_failure;
+ }
+
+ if (!((win == GnWindowBlackmanHarris) || (win == GnWindowHann)
+ || (win == GnWindowNoWindow)))
+ {
+ printf ("ERROR: Invalid selection of window function\n");
+ return gn_failure;
+ }
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+
+ (*c)->npts = npts;
+ (*c)->qres = qres;
+ (*c)->fft_navg = fft_navg;
+ (*c)->nfft = nfft;
+ (*c)->win = win;
+ (*c)->code_format = GnCodeFormatTwosComplement;
+
+ return gn_success;
+ }
+
+ int
+ gn_config_fa_auto (uint8_t ssb_width, gn_config *c)
+ {
+ int err_code;
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+
+ if ((*c)->sample_rate <= 0)
+ {
+ printf ("ERROR: Sample rate must be set before configuring Fourier "
+ "analysis\n");
+ return gn_failure;
+ }
+
+ (*c)->obj_key = (char *)calloc (3, sizeof (char));
+ strcpy ((*c)->obj_key, "fa");
+ (*c)->comp_key = (char *)calloc (2, sizeof (char));
+ strcpy ((*c)->comp_key, "A");
+
+ (*c)->ssb_fund = ssb_width;
+ (*c)->ssb_rest = 0;
+ (*c)->max_harm_order = 3;
+ (*c)->axis_type = GnFreqAxisTypeDcCenter;
+
+ // configure object key for Fourier analysis
+ err_code = gn_fa_create ((*c)->obj_key);
+
+ // configure component key for Fourier analysis
+ err_code += gn_fa_max_tone ((*c)->obj_key, (*c)->comp_key,
+ GnFACompTagSignal, (*c)->ssb_fund);
+
+ // configure harmonic order for Fourier analysis
+ err_code += gn_fa_hd ((*c)->obj_key, (*c)->max_harm_order);
+
+ // configure single-side bins for Fourier analysis
+ err_code += gn_fa_ssb ((*c)->obj_key, GnFASsbDefault, (*c)->ssb_rest);
+ err_code += gn_fa_ssb ((*c)->obj_key, GnFASsbDC, -1);
+ err_code += gn_fa_ssb ((*c)->obj_key, GnFASsbSignal, -1);
+ err_code += gn_fa_ssb ((*c)->obj_key, GnFASsbWO, -1);
+
+ // configure sample-rate, data-rate, shift frequency, and converter offset
+ err_code += gn_fa_fsample ((*c)->obj_key, (*c)->sample_rate);
+ err_code += gn_fa_fdata ((*c)->obj_key, (*c)->sample_rate);
+ err_code += gn_fa_fshift ((*c)->obj_key, 0.0);
+ err_code += gn_fa_conv_offset ((*c)->obj_key, false);
+
+ return (err_code);
+ }
+
+ int
+ gn_config_fa (gn::real_t fixed_tone_freq, gn_config *c)
+ {
+ int err_code;
+
+ if (!(*c))
+ {
+ gn_config c_p;
+ c_p = (gn_config)calloc (1, sizeof (*c_p));
+ if (!(c_p))
+ {
+ printf ("insufficient memory\n");
+ return ENOMEM;
+ }
+ else
+ *c = c_p;
+ }
+
+ if ((*c)->sample_rate <= 0)
+ {
+ printf ("ERROR: Sample rate must be set before configuring Fourier "
+ "analysis\n");
+ return gn_failure;
+ }
+
+ (*c)->obj_key = (char *)calloc (3, sizeof (char));
+ strcpy ((*c)->obj_key, "fa");
+ (*c)->comp_key = (char *)calloc (2, sizeof (char));
+ strcpy ((*c)->comp_key, "A");
+
+ (*c)->ssb_fund = 120;
+ (*c)->ssb_rest = 0;
+ (*c)->max_harm_order = 3;
+ (*c)->axis_type = GnFreqAxisTypeDcCenter;
+
+ // configure object key for Fourier analysis
+ err_code = gn_fa_create ((*c)->obj_key);
+
+ // configure component key for Fourier analysis
+ err_code
+ += gn_fa_fixed_tone ((*c)->obj_key, (*c)->comp_key, GnFACompTagSignal,
+ fixed_tone_freq, (*c)->ssb_fund);
+
+ // configure harmonic order for Fourier analysis
+ err_code += gn_fa_hd ((*c)->obj_key, (*c)->max_harm_order);
+
+ // configure single-side bins for Fourier analysis
+ err_code += gn_fa_ssb ((*c)->obj_key, GnFASsbDefault, (*c)->ssb_rest);
+ err_code += gn_fa_ssb ((*c)->obj_key, GnFASsbDC, -1);
+ err_code += gn_fa_ssb ((*c)->obj_key, GnFASsbSignal, -1);
+ err_code += gn_fa_ssb ((*c)->obj_key, GnFASsbWO, -1);
+
+ // configure sample-rate, data-rate, shift frequency, and converter offset
+ err_code += gn_fa_fsample ((*c)->obj_key, (*c)->sample_rate);
+ err_code += gn_fa_fdata ((*c)->obj_key, (*c)->sample_rate);
+ err_code += gn_fa_fshift ((*c)->obj_key, 0.0);
+ err_code += gn_fa_conv_offset ((*c)->obj_key, false);
+
+ return (err_code);
+ }
+
+ // waveform generation
+ int
+ gn_gen_ramp (gn::real_t **out, gn_config *c)
+ {
+ int err_code;
+ gn::real_t *awf = (gn::real_t *)calloc ((*c)->npts, sizeof (gn::real_t));
+ err_code = gn_ramp (awf, (*c)->npts, (*c)->ramp_start, (*c)->ramp_stop,
+ (*c)->noise_rms);
+ *out = awf;
+
+ return err_code;
+ }
+
+ int
+ gn_gen_real_tone (gn::real_t **out, gn_config *c)
+ {
+ int err_code = 0;
+ gn::real_t *awf = (gn::real_t *)calloc ((*c)->npts, sizeof (gn::real_t));
+
+ for (size_t i = 0; i < (*c)->num_tones; i++)
+ {
+ gn::real_t *tmp
+ = (gn::real_t *)calloc ((*c)->npts, sizeof (gn::real_t));
+ if ((*c)->ttype == REAL_COSINE)
+ err_code
+ = gn_cos (tmp, (*c)->npts, (*c)->sample_rate, (*c)->tone_ampl[i],
+ (*c)->tone_freq[i], (*c)->tone_phase[i], 0, 0);
+ else if ((*c)->ttype == REAL_SINE)
+ err_code
+ = gn_sin (tmp, (*c)->npts, (*c)->sample_rate, (*c)->tone_ampl[i],
+ (*c)->tone_freq[i], (*c)->tone_phase[i], 0, 0);
+ if (!err_code)
+ {
+ for (size_t j = 0; j < (*c)->npts; j++)
+ awf[j] = awf[j] + tmp[j];
+ }
+ }
+ *out = awf;
+
+ return err_code;
+ }
+
+ int
+ gn_gen_complex_tone (gn::real_t **outi, gn::real_t **outq, gn_config *c)
+ {
+ int err_code = 0;
+ gn::real_t *awfi = (gn::real_t *)calloc ((*c)->npts, sizeof (gn::real_t));
+ gn::real_t *awfq = (gn::real_t *)calloc ((*c)->npts, sizeof (gn::real_t));
+
+ for (size_t i = 0; i < (*c)->num_tones; i++)
+ {
+ gn::real_t *tmp
+ = (gn::real_t *)calloc ((*c)->npts, sizeof (gn::real_t));
+ err_code
+ = gn_cos (tmp, (*c)->npts, (*c)->sample_rate, (*c)->tone_ampl[i],
+ (*c)->tone_freq[i], (*c)->tone_phase[i], 0, 0);
+ if (!err_code)
+ {
+ for (size_t j = 0; j < (*c)->npts; j++)
+ awfi[j] = awfi[j] + tmp[j];
+ }
+ tmp = (gn::real_t *)calloc ((*c)->npts, sizeof (gn::real_t));
+ err_code
+ = gn_sin (tmp, (*c)->npts, (*c)->sample_rate, (*c)->tone_ampl[i],
+ (*c)->tone_freq[i], (*c)->tone_phase[i], 0, 0);
+ if (!err_code)
+ {
+ for (size_t j = 0; j < (*c)->npts; j++)
+ awfq[j] = awfq[j] + tmp[j];
+ }
+ }
+ *outi = awfi;
+ *outq = awfq;
+
+ return err_code;
+ }
+
+ // processing
+ int
+ gn_quantize (int32_t **out, const gn::real_t *in, gn_config *c)
+ {
+ int err_code;
+ int32_t *qwf = (int32_t *)calloc ((*c)->npts, sizeof (int32_t));
+
+ err_code = gn_quantize32 (qwf, (*c)->npts, in, (*c)->npts, (*c)->fsr,
+ (*c)->qres, (*c)->noise_rms, (*c)->code_format);
+ *out = qwf;
+
+ return err_code;
+ }
+
+ int
+ gn_fftz (gn::real_t **out, const int32_t *in_i, const int32_t *in_q,
+ gn_config *c)
+ {
+ int err_code;
+ gn::real_t *fft_of_in
+ = (gn::real_t *)calloc (2 * (*c)->nfft, sizeof (gn::real_t));
+
+ err_code = gn_fft32 (fft_of_in, 2 * (*c)->nfft, in_i, (*c)->npts, in_q,
+ (*c)->npts, (*c)->qres, (*c)->fft_navg, (*c)->nfft,
+ (*c)->win, (*c)->code_format);
+ *out = fft_of_in;
+
+ return err_code;
+ }
+
+ int
+ gn_histz (uint64_t **hist, size_t *hist_len, const int32_t *qwf,
+ gn_config *c)
+ {
+ int err_code;
+ uint64_t *out = NULL;
+
+ err_code = gn_code_density_size (&((*c)->_code_density_size), (*c)->qres,
+ (*c)->code_format);
+ out = (uint64_t *)calloc ((*c)->_code_density_size, sizeof (uint64_t));
+ err_code += gn_hist32 (out, (*c)->_code_density_size, qwf, (*c)->npts,
+ (*c)->qres, (*c)->code_format, false);
+ *hist = out;
+ *hist_len = (*c)->_code_density_size;
+
+ return err_code;
+ }
+
+ int
+ gn_dnlz (double **dnl, size_t *dnl_len, const uint64_t *hist, gn_config *c)
+ {
+ int err_code;
+ double *out = NULL;
+
+ err_code = gn_code_density_size (&((*c)->_code_density_size), (*c)->qres,
+ (*c)->code_format);
+ out = (double *)calloc ((*c)->_code_density_size, sizeof (double));
+ err_code = gn_dnl (out, (*c)->_code_density_size, hist,
+ (*c)->_code_density_size, (*c)->dnla_signal_type);
+ *dnl = out;
+ *dnl_len = (*c)->_code_density_size;
+
+ return err_code;
+ }
+
+ int
+ gn_inlz (double **inl, size_t *inl_len, const double *dnl, gn_config *c)
+ {
+ int err_code;
+ double *out = NULL;
+
+ err_code = gn_code_density_size (&((*c)->_code_density_size), (*c)->qres,
+ (*c)->code_format);
+ out = (double *)calloc ((*c)->_code_density_size, sizeof (double));
+ err_code = gn_inl (out, (*c)->_code_density_size, dnl,
+ (*c)->_code_density_size, (*c)->inla_fit);
+ *inl = out;
+ *inl_len = (*c)->_code_density_size;
+
+ return err_code;
+ }
+
+ // Waveform/Histogram/DNL/INL/Fourier Analysis
+ int
+ gn_get_wfa_results (char ***rkeys, gn::real_t **rvalues,
+ size_t *results_size, const int32_t *qwf, gn_config *c)
+ {
+ int err_code = 0;
+
+ // get results size
+ err_code = gn_analysis_results_size (&((*c)->_wfa_results_size),
+ GnAnalysisTypeWaveform);
+
+ // allocate memory for result keys and values
+ (*c)->_wfa_result_keys
+ = (char **)calloc (((*c)->_wfa_results_size), sizeof (char *));
+ (*c)->_wfa_result_values = (gn::real_t *)calloc (((*c)->_wfa_results_size),
+ sizeof (gn::real_t));
+
+ // get result key sizes
+ (*c)->_wfa_result_key_sizes
+ = (size_t *)calloc (((*c)->_wfa_results_size), sizeof (size_t));
+ err_code += gn_analysis_results_key_sizes ((*c)->_wfa_result_key_sizes,
+ (*c)->_wfa_results_size,
+ GnAnalysisTypeWaveform);
+
+ // allocate memory for each result key
+ for (size_t i = 0; i < (*c)->_wfa_results_size; ++i)
+ (*c)->_wfa_result_keys[i]
+ = (char *)calloc ((*c)->_wfa_result_key_sizes[i], sizeof (char));
+
+ // execute analysis
+ err_code += gn_wf_analysis32 (
+ (*c)->_wfa_result_keys, (*c)->_wfa_results_size,
+ (*c)->_wfa_result_values, (*c)->_wfa_results_size, qwf, (*c)->npts);
+
+ // copy keys
+ *rkeys = (char **)calloc (((*c)->_wfa_results_size), sizeof (char *));
+ for (size_t i = 0; i < (*c)->_wfa_results_size; ++i)
+ (*rkeys)[i]
+ = (char *)calloc ((*c)->_wfa_result_key_sizes[i], sizeof (char));
+
+ // copy values
+ *rvalues = (gn::real_t *)calloc (((*c)->_wfa_results_size),
+ sizeof (gn::real_t));
+ for (size_t i = 0; i < (*c)->_wfa_results_size; ++i)
+ {
+ strcpy ((*rkeys)[i], (*c)->_wfa_result_keys[i]);
+ (*rvalues)[i] = (*c)->_wfa_result_values[i];
+ }
+ *results_size = (*c)->_wfa_results_size;
+
+ return (err_code);
+ }
+
+ int
+ gn_get_ha_results (char ***rkeys, gn::real_t **rvalues, size_t *results_size,
+ const uint64_t *hist, gn_config *c)
+ {
+ int err_code = 0;
+
+ // get results size
+ err_code = gn_analysis_results_size (&((*c)->_hist_results_size),
+ GnAnalysisTypeHistogram);
+
+ // allocate memory for result keys and values
+ (*c)->_hist_result_keys
+ = (char **)calloc (((*c)->_hist_results_size), sizeof (char *));
+ (*c)->_hist_result_values = (gn::real_t *)calloc (
+ ((*c)->_hist_results_size), sizeof (gn::real_t));
+
+ // get result key sizes
+ (*c)->_hist_result_key_sizes
+ = (size_t *)calloc (((*c)->_hist_results_size), sizeof (size_t));
+ err_code += gn_analysis_results_key_sizes ((*c)->_hist_result_key_sizes,
+ (*c)->_hist_results_size,
+ GnAnalysisTypeHistogram);
+
+ // allocate memory for each result key
+ for (size_t i = 0; i < (*c)->_hist_results_size; ++i)
+ (*c)->_hist_result_keys[i]
+ = (char *)calloc ((*c)->_hist_result_key_sizes[i], sizeof (char));
+
+ // execute analysis
+ err_code += gn_hist_analysis (
+ (*c)->_hist_result_keys, (*c)->_hist_results_size,
+ (*c)->_hist_result_values, (*c)->_hist_results_size, hist,
+ (*c)->_code_density_size);
+
+ // copy keys
+ *rkeys = (char **)calloc (((*c)->_hist_results_size), sizeof (char *));
+ for (size_t i = 0; i < (*c)->_hist_results_size; ++i)
+ (*rkeys)[i]
+ = (char *)calloc ((*c)->_hist_result_key_sizes[i], sizeof (char));
+
+ // copy values
+ *rvalues = (gn::real_t *)calloc (((*c)->_hist_results_size),
+ sizeof (gn::real_t));
+ for (size_t i = 0; i < (*c)->_hist_results_size; ++i)
+ {
+ strcpy ((*rkeys)[i], (*c)->_hist_result_keys[i]);
+ (*rvalues)[i] = (*c)->_hist_result_values[i];
+ }
+ *results_size = (*c)->_hist_results_size;
+
+ return (err_code);
+ }
+
+ int
+ gn_get_dnla_results (char ***rkeys, gn::real_t **rvalues,
+ size_t *results_size, const gn::real_t *dnl,
+ gn_config *c)
+ {
+ int err_code;
+
+ // get results size
+ err_code = gn_analysis_results_size (&((*c)->_dnl_results_size),
+ GnAnalysisTypeDNL);
+
+ // allocate memory for result keys and values
+ (*c)->_dnl_result_keys
+ = (char **)calloc (((*c)->_dnl_results_size), sizeof (char *));
+ (*c)->_dnl_result_values = (gn::real_t *)calloc (((*c)->_dnl_results_size),
+ sizeof (gn::real_t));
+
+ // get result key sizes
+ (*c)->_dnl_result_key_sizes
+ = (size_t *)calloc (((*c)->_dnl_results_size), sizeof (size_t));
+ err_code += gn_analysis_results_key_sizes ((*c)->_dnl_result_key_sizes,
+ (*c)->_dnl_results_size,
+ GnAnalysisTypeDNL);
+
+ // allocate memory for each result key
+ for (size_t i = 0; i < (*c)->_dnl_results_size; ++i)
+ (*c)->_dnl_result_keys[i]
+ = (char *)calloc ((*c)->_dnl_result_key_sizes[i], sizeof (char));
+
+ // execute analysis
+ err_code
+ += gn_dnl_analysis ((*c)->_dnl_result_keys, (*c)->_dnl_results_size,
+ (*c)->_dnl_result_values, (*c)->_dnl_results_size,
+ dnl, (*c)->_code_density_size);
+
+ // copy keys
+ *rkeys = (char **)calloc (((*c)->_dnl_results_size), sizeof (char *));
+ for (size_t i = 0; i < (*c)->_dnl_results_size; ++i)
+ (*rkeys)[i]
+ = (char *)calloc ((*c)->_dnl_result_key_sizes[i], sizeof (char));
+
+ // copy values
+ *rvalues = (gn::real_t *)calloc (((*c)->_dnl_results_size),
+ sizeof (gn::real_t));
+ for (size_t i = 0; i < (*c)->_dnl_results_size; ++i)
+ {
+ strcpy ((*rkeys)[i], (*c)->_dnl_result_keys[i]);
+ (*rvalues)[i] = (*c)->_dnl_result_values[i];
+ }
+ *results_size = (*c)->_dnl_results_size;
+
+ return (err_code);
+ }
+
+ int
+ gn_get_inla_results (char ***rkeys, gn::real_t **rvalues,
+ size_t *results_size, const gn::real_t *inl,
+ gn_config *c)
+ {
+ int err_code;
+
+ // get results size
+ err_code = gn_analysis_results_size (&((*c)->_inl_results_size),
+ GnAnalysisTypeINL);
+
+ // allocate memory for result keys and values
+ (*c)->_inl_result_keys
+ = (char **)calloc (((*c)->_inl_results_size), sizeof (char *));
+ (*c)->_inl_result_values = (gn::real_t *)calloc (((*c)->_inl_results_size),
+ sizeof (gn::real_t));
+
+ // get result key sizes
+ (*c)->_inl_result_key_sizes
+ = (size_t *)calloc (((*c)->_inl_results_size), sizeof (size_t));
+ err_code += gn_analysis_results_key_sizes ((*c)->_inl_result_key_sizes,
+ (*c)->_inl_results_size,
+ GnAnalysisTypeINL);
+
+ // allocate memory for each result key
+ for (size_t i = 0; i < (*c)->_inl_results_size; ++i)
+ (*c)->_inl_result_keys[i]
+ = (char *)calloc ((*c)->_inl_result_key_sizes[i], sizeof (char));
+
+ // execute analysis
+ err_code
+ += gn_inl_analysis ((*c)->_inl_result_keys, (*c)->_inl_results_size,
+ (*c)->_inl_result_values, (*c)->_inl_results_size,
+ inl, (*c)->_code_density_size);
+
+ // copy keys
+ *rkeys = (char **)calloc (((*c)->_inl_results_size), sizeof (char *));
+ for (size_t i = 0; i < (*c)->_inl_results_size; ++i)
+ (*rkeys)[i]
+ = (char *)calloc ((*c)->_inl_result_key_sizes[i], sizeof (char));
+
+ // copy values
+ *rvalues = (gn::real_t *)calloc (((*c)->_inl_results_size),
+ sizeof (gn::real_t));
+ for (size_t i = 0; i < (*c)->_inl_results_size; ++i)
+ {
+ strcpy ((*rkeys)[i], (*c)->_inl_result_keys[i]);
+ (*rvalues)[i] = (*c)->_inl_result_values[i];
+ }
+ *results_size = (*c)->_inl_results_size;
+
+ return (err_code);
+ }
+
+ int
+ gn_get_fa_single_result (gn::real_t *rvalue, const char *metric_name,
+ gn::real_t *fft_ilv, gn_config *c)
+ {
+ int err_code;
+ size_t i;
+ bool metric_found = false;
+ size_t results_size;
+ char **rkeys;
+ double *rvalues;
+
+ // compute all results
+ err_code
+ = gn_get_fa_results (&rkeys, &rvalues, &results_size, fft_ilv, &(*c));
+ for (i = 0; i < results_size; i++)
+ {
+ if (!strcmp (metric_name, rkeys[i]))
+ {
+ metric_found = true;
+ break;
+ }
+ }
+ if (!metric_found)
+ {
+ printf ("ERROR: Invalid selection of metric\n");
+ return gn_failure;
+ }
+ *rvalue = rvalues[i];
+
+ return err_code;
+ }
+
+ int
+ gn_get_fa_results (char ***rkeys, gn::real_t **rvalues, size_t *results_size,
+ gn::real_t *fft_ilv, gn_config *c)
+ {
+ int err_code = 0;
+ size_t *result_key_sizes;
+
+ // get results size
+ err_code = gn_fft_analysis_results_size (results_size, (*c)->obj_key,
+ 2 * (*c)->nfft, (*c)->nfft);
+
+ // allocate memory for result keys and values
+ *rkeys = (char **)calloc (*results_size, sizeof (char *));
+ *rvalues = (gn::real_t *)calloc (*results_size, sizeof (gn::real_t));
+
+ // get result key sizes
+ result_key_sizes = (size_t *)calloc (*results_size, sizeof (size_t));
+ err_code += gn_fft_analysis_results_key_sizes (
+ result_key_sizes, *results_size, (*c)->obj_key, 2 * (*c)->nfft,
+ (*c)->nfft);
+
+ // allocate memory for each result key
+ for (size_t i = 0; i < *results_size; ++i)
+ (*rkeys)[i] = (char *)calloc (result_key_sizes[i], sizeof (char));
+
+ // execute analysis
+ err_code += gn_fft_analysis (*rkeys, *results_size, *rvalues,
+ *results_size, (*c)->obj_key, fft_ilv,
+ 2 * (*c)->nfft, (*c)->nfft, (*c)->axis_type);
+
+ return (err_code);
+ }
}
\ No newline at end of file
diff --git a/bindings/python/genalyzer/__init__.py b/bindings/python/genalyzer/__init__.py
index 96d18a9..aa194a3 100644
--- a/bindings/python/genalyzer/__init__.py
+++ b/bindings/python/genalyzer/__init__.py
@@ -1,6 +1,9 @@
+# Copyright (C) 2024 Analog Devices, Inc.
+#
+# SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+
"""Python bindings for Genalyzer"""
-# Version of the genalyzer bindings (which may be different than the library version)
__version__ = "0.1.1"
__author__ = "Analog Devices, Inc."
diff --git a/bindings/python/genalyzer/helpers/__init__.py b/bindings/python/genalyzer/helpers/__init__.py
index 0d382a4..5d38c35 100644
--- a/bindings/python/genalyzer/helpers/__init__.py
+++ b/bindings/python/genalyzer/helpers/__init__.py
@@ -1,3 +1,7 @@
+# Copyright (C) 2024 Analog Devices, Inc.
+#
+# SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+
try:
from .waveform_gen import WaveformGen
except ImportError:
diff --git a/bindings/python/genalyzer/helpers/waveform_gen.py b/bindings/python/genalyzer/helpers/waveform_gen.py
index 883d697..c3598c1 100644
--- a/bindings/python/genalyzer/helpers/waveform_gen.py
+++ b/bindings/python/genalyzer/helpers/waveform_gen.py
@@ -1,3 +1,7 @@
+# Copyright (C) 2024 Analog Devices, Inc.
+#
+# SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+
from ..simplified_beta import (
config_gen_tone,
gen_real_tone,
diff --git a/bindings/python/genalyzer/pygenalyzer.py b/bindings/python/genalyzer/pygenalyzer.py
index a199690..212dffb 100644
--- a/bindings/python/genalyzer/pygenalyzer.py
+++ b/bindings/python/genalyzer/pygenalyzer.py
@@ -1,27 +1,11 @@
-"""
-* pygenalyzer - genalyzer API header file
-*
-* Copyright (C) 2022 Analog Devices, Inc.
-* Author: Peter Derounian
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-"""
+# Copyright (C) 2024 Analog Devices, Inc.
+#
+# SPDX short identifier: ADIBSD OR GPL-2.0-or-later
"""
Python wrapper for Genalyzer Library (genalyzer_plus_plus)
"""
+
import ctypes as _ctypes
from ctypes.util import find_library as _find_library
from enum import IntEnum as _IntEnum
diff --git a/bindings/python/genalyzer/simplified_beta/__init__.py b/bindings/python/genalyzer/simplified_beta/__init__.py
index 89a94fb..d1b6d7f 100644
--- a/bindings/python/genalyzer/simplified_beta/__init__.py
+++ b/bindings/python/genalyzer/simplified_beta/__init__.py
@@ -1,3 +1,7 @@
+# Copyright (C) 2024 Analog Devices, Inc.
+#
+# SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+
from .simplified_beta import (
config_free,
config_gen_ramp,
diff --git a/bindings/python/genalyzer/simplified_beta/simplified_beta.py b/bindings/python/genalyzer/simplified_beta/simplified_beta.py
index 1e233b3..49b6d50 100644
--- a/bindings/python/genalyzer/simplified_beta/simplified_beta.py
+++ b/bindings/python/genalyzer/simplified_beta/simplified_beta.py
@@ -1,23 +1,6 @@
-"""
-* cgenalyzer - genalyzer API header file
-*
-* Copyright (C) 2022 Analog Devices, Inc.
-* Author: Srikanth Pagadarai
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-"""
+# Copyright (C) 2024 Analog Devices, Inc.
+#
+# SPDX short identifier: ADIBSD OR GPL-2.0-or-later
from dataclasses import dataclass, field
diff --git a/cmake/FindBreathe.cmake b/cmake/FindBREATHE.cmake
similarity index 80%
rename from cmake/FindBreathe.cmake
rename to cmake/FindBREATHE.cmake
index 239a224..0aed416 100644
--- a/cmake/FindBreathe.cmake
+++ b/cmake/FindBREATHE.cmake
@@ -7,7 +7,7 @@ if(BREATHE_APIDOC)
endif()
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Breathe REQUIRED_VARS BREATHE_APIDOC
+find_package_handle_standard_args(BREATHE REQUIRED_VARS BREATHE_APIDOC
VERSION_VAR BREATHE_VERSION
)
diff --git a/cmake/FindFFTW.cmake b/cmake/FindFFTW.cmake
index fb8476d..007c641 100644
--- a/cmake/FindFFTW.cmake
+++ b/cmake/FindFFTW.cmake
@@ -33,21 +33,21 @@
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# OF THIS SOFTWARE, EVEN ifADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Usage:
# find_package(FFTW [REQUIRED] [QUIET] [COMPONENTS component1 ... componentX] )
#
# It sets the following variables:
-# FFTW_FOUND ... true if fftw is found on the system
-# FFTW_[component]_LIB_FOUND ... true if the component is found on the system (see components below)
+# FFTW_FOUND ... true iffftw is found on the system
+# FFTW_[component]_LIB_FOUND ... true ifthe component is found on the system (see components below)
# FFTW_LIBRARIES ... full paths to all found fftw libraries
# FFTW_[component]_LIB ... full path to one of the components (see below)
# FFTW_INCLUDE_DIRS ... fftw include directory paths
#
# The following variables will be checked by the function
-# FFTW_USE_STATIC_LIBS ... if true, only static libraries are found, otherwise both static and shared.
-# FFTW_ROOT ... if set, the libraries are exclusively searched
+# FFTW_USE_STATIC_LIBS ... iftrue, only static libraries are found, otherwise both static and shared.
+# FFTW_ROOT ... ifset, the libraries are exclusively searched
# under this path
#
# This package supports the following components:
@@ -70,7 +70,7 @@ if( NOT FFTW_ROOT AND DEFINED ENV{FFTWDIR} )
set( FFTW_ROOT $ENV{FFTWDIR} )
endif()
-# Check if we can use PkgConfig
+# Check ifwe can use PkgConfig
find_package(PkgConfig)
#Determine from PKG
@@ -230,113 +230,113 @@ else()
PATHS ${PKG_FFTW_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR}
)
-endif( FFTW_ROOT )
+endif()
#--------------------------------------- components
-if (FFTW_DOUBLE_LIB)
+if(FFTW_DOUBLE_LIB)
set(FFTW_DOUBLE_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_LIB})
add_library(FFTW::Double INTERFACE IMPORTED)
set_target_properties(FFTW::Double
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_LIB}"
)
else()
set(FFTW_DOUBLE_LIB_FOUND FALSE)
endif()
-if (FFTW_FLOAT_LIB)
+if(FFTW_FLOAT_LIB)
set(FFTW_FLOAT_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_LIB})
add_library(FFTW::Float INTERFACE IMPORTED)
set_target_properties(FFTW::Float
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_LIB}"
)
else()
set(FFTW_FLOAT_LIB_FOUND FALSE)
endif()
-if (FFTW_LONGDOUBLE_LIB)
+if(FFTW_LONGDOUBLE_LIB)
set(FFTW_LONGDOUBLE_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_LIB})
add_library(FFTW::LongDouble INTERFACE IMPORTED)
set_target_properties(FFTW::LongDouble
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_LIB}"
)
else()
set(FFTW_LONGDOUBLE_LIB_FOUND FALSE)
endif()
-if (FFTW_DOUBLE_THREADS_LIB)
+if(FFTW_DOUBLE_THREADS_LIB)
set(FFTW_DOUBLE_THREADS_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_THREADS_LIB})
add_library(FFTW::DoubleThreads INTERFACE IMPORTED)
set_target_properties(FFTW::DoubleThreads
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLETHREADS_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLETHREADS_LIB}"
)
else()
set(FFTW_DOUBLE_THREADS_LIB_FOUND FALSE)
endif()
-if (FFTW_FLOAT_THREADS_LIB)
+if(FFTW_FLOAT_THREADS_LIB)
set(FFTW_FLOAT_THREADS_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_THREADS_LIB})
add_library(FFTW::FloatThreads INTERFACE IMPORTED)
set_target_properties(FFTW::FloatThreads
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_THREADS_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_THREADS_LIB}"
)
else()
set(FFTW_FLOAT_THREADS_LIB_FOUND FALSE)
endif()
-if (FFTW_LONGDOUBLE_THREADS_LIB)
+if(FFTW_LONGDOUBLE_THREADS_LIB)
set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_THREADS_LIB})
add_library(FFTW::LongDoubleThreads INTERFACE IMPORTED)
set_target_properties(FFTW::LongDoubleThreads
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_THREADS_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_THREADS_LIB}"
)
else()
set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND FALSE)
endif()
-if (FFTW_DOUBLE_OPENMP_LIB)
+if(FFTW_DOUBLE_OPENMP_LIB)
set(FFTW_DOUBLE_OPENMP_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_OPENMP_LIB})
add_library(FFTW::DoubleOpenMP INTERFACE IMPORTED)
set_target_properties(FFTW::DoubleOpenMP
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_OPENMP_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_OPENMP_LIB}"
)
else()
set(FFTW_DOUBLE_OPENMP_LIB_FOUND FALSE)
endif()
-if (FFTW_FLOAT_OPENMP_LIB)
+if(FFTW_FLOAT_OPENMP_LIB)
set(FFTW_FLOAT_OPENMP_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_OPENMP_LIB})
add_library(FFTW::FloatOpenMP INTERFACE IMPORTED)
set_target_properties(FFTW::FloatOpenMP
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_OPENMP_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_OPENMP_LIB}"
)
else()
set(FFTW_FLOAT_OPENMP_LIB_FOUND FALSE)
endif()
-if (FFTW_LONGDOUBLE_OPENMP_LIB)
+if(FFTW_LONGDOUBLE_OPENMP_LIB)
set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_OPENMP_LIB})
add_library(FFTW::LongDoubleOpenMP INTERFACE IMPORTED)
set_target_properties(FFTW::LongDoubleOpenMP
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
- INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_OPENMP_LIB}"
+ INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_OPENMP_LIB}"
)
else()
set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND FALSE)
diff --git a/cmake/FindSPHINX.cmake b/cmake/FindSPHINX.cmake
new file mode 100644
index 0000000..1d37510
--- /dev/null
+++ b/cmake/FindSPHINX.cmake
@@ -0,0 +1,7 @@
+#Look for an executable called sphinx-build
+find_program(SPHINX_EXECUTABLE NAMES sphinx-build DOC "Path to sphinx-build executable")
+
+include(FindPackageHandleStandardArgs)
+
+#Handle standard arguments to find_package like REQUIRED and QUIET
+find_package_handle_standard_args(SPHINX "Failed to find sphinx-build executable" SPHINX_EXECUTABLE)
diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake
deleted file mode 100644
index 990f979..0000000
--- a/cmake/FindSphinx.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-#Look for an executable called sphinx-build
-find_program(SPHINX_EXECUTABLE
- NAMES sphinx-build
- DOC "Path to sphinx-build executable")
-
-include(FindPackageHandleStandardArgs)
-
-#Handle standard arguments to find_package like REQUIRED and QUIET
-find_package_handle_standard_args(Sphinx
- "Failed to find sphinx-build executable"
- SPHINX_EXECUTABLE)
diff --git a/cmake/Modules/Findgenalyzer_plus_plus.cmake b/cmake/Modules/FindGENALYZER_PLUS_PLUS.cmake
similarity index 80%
rename from cmake/Modules/Findgenalyzer_plus_plus.cmake
rename to cmake/Modules/FindGENALYZER_PLUS_PLUS.cmake
index 9b60c2f..9d14a58 100644
--- a/cmake/Modules/Findgenalyzer_plus_plus.cmake
+++ b/cmake/Modules/FindGENALYZER_PLUS_PLUS.cmake
@@ -1,5 +1,5 @@
if(NOT GENALYZER_PLUS_PLUS_FOUND)
- find_path(GENALYZER_PLUS_PLUS_INCLUDE_DIRS
+ find_path(GENALYZER_PLUS_PLUS_INCLUDE_DIRS
NAMES
array_ops.hpp
code_density.hpp
@@ -30,8 +30,8 @@ if(NOT GENALYZER_PLUS_PLUS_FOUND)
/usr/local/include/
)
- find_library(GENALYZER_PLUS_PLUS_LIBRARIES
- NAMES
+ find_library(GENALYZER_PLUS_PLUS_LIBRARIES
+ NAMES
genalyzer_plus_plus
PATHS
/usr/lib
@@ -41,11 +41,11 @@ if(NOT GENALYZER_PLUS_PLUS_FOUND)
if(GENALYZER_PLUS_PLUS_INCLUDE_DIRS AND GENALYZER_PLUS_PLUS_LIBRARIES)
set(GENALYZER_PLUS_PLUS_FOUND TRUE CACHE INTERNAL "libgenalyzer_plus_plus found")
message(STATUS "Found libgenalyzer_plus_plus: ${GENALYZER_PLUS_PLUS_INCLUDE_DIRS}, ${GENALYZER_PLUS_PLUS_LIBRARIES}")
-else(GENALYZER_PLUS_PLUS_INCLUDE_DIRS AND GENALYZER_PLUS_PLUS_LIBRARIES)
+else()
set(GENALYZER_PLUS_PLUS_FOUND FALSE CACHE INTERNAL "libgenalyzer_plus_plus found")
message(STATUS "libgenalyzer_plus_plus not found.")
-endif(GENALYZER_PLUS_PLUS_INCLUDE_DIRS AND GENALYZER_PLUS_PLUS_LIBRARIES)
+endif()
mark_as_advanced(GENALYZER_PLUS_PLUS_LIBRARIES AND GENALYZER_PLUS_PLUS_INCLUDE_DIRS)
-endif(NOT GENALYZER_PLUS_PLUS_FOUND)
+endif()
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 1676d3a..4a933f6 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -10,10 +10,10 @@ configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
- DEPENDS ${GENALYZER_PUBLIC_HEADERS}
- COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
- MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
- COMMENT "Generating docs")
+ DEPENDS ${GENALYZER_PUBLIC_HEADERS}
+ COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
+ MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
+ COMMENT "Generating docs")
add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})
diff --git a/doc/general_example_noise_configuration.c b/doc/general_example_noise_configuration.c
index fe01979..9d73007 100644
--- a/doc/general_example_noise_configuration.c
+++ b/doc/general_example_noise_configuration.c
@@ -1,12 +1,6 @@
- // configuration
- config_noise_meas(&c,
- COMPLEX_NOISE,
- nfft,
- navg,
- fs,
- fsr,
- res,
- noise_pwr_lvl,
- update_fsample,
- update_fdata,
- update_fshift);
\ No newline at end of file
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+// configuration
+config_noise_meas (&c, COMPLEX_NOISE, nfft, navg, fs, fsr, res, noise_pwr_lvl,
+ update_fsample, update_fdata, update_fshift);
\ No newline at end of file
diff --git a/doc/general_example_ramp_configuration.c b/doc/general_example_ramp_configuration.c
index 8d7adc3..b7e381a 100644
--- a/doc/general_example_ramp_configuration.c
+++ b/doc/general_example_ramp_configuration.c
@@ -1,10 +1,10 @@
- // configuration
- config_ramp_nl_meas(&c,
- npts, // # of data points
- fs, // sample rate
- fsr, // full-scale range
- res, // ADC resolution: unused configuration setting
- start,
- stop,
- 0.0
- );
\ No newline at end of file
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+// configuration
+config_ramp_nl_meas (&c,
+ npts, // # of data points
+ fs, // sample rate
+ fsr, // full-scale range
+ res, // ADC resolution: unused configuration setting
+ start, stop, 0.0);
\ No newline at end of file
diff --git a/doc/general_example_skelton1.c b/doc/general_example_skelton1.c
index 9d9de87..a14753a 100644
--- a/doc/general_example_skelton1.c
+++ b/doc/general_example_skelton1.c
@@ -1,18 +1,23 @@
-#include "cgenalyzer.h"
-
-int main(int argc, char *argv[]) {
- // opaque config struct that will contain config settings
- // config c = NULL;
-
- /* configuration */
- // config_tone_meas(...);
-
- /* waveform generation and quantize */
- // gen_tone(...);
- // quantize(...);
-
- /* compute metrics */
- // fsnr_val = metric(..., "FSNR");
-
- return 0;
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+#include "cgenalyzer.h"
+
+int
+main (int argc, char *argv[])
+{
+ // opaque config struct that will contain config settings
+ // config c = NULL;
+
+ /* configuration */
+ // config_tone_meas(...);
+
+ /* waveform generation and quantize */
+ // gen_tone(...);
+ // quantize(...);
+
+ /* compute metrics */
+ // fsnr_val = metric(..., "FSNR");
+
+ return 0;
}
\ No newline at end of file
diff --git a/doc/general_example_skelton2.c b/doc/general_example_skelton2.c
index df6eaff..5ea2c46 100644
--- a/doc/general_example_skelton2.c
+++ b/doc/general_example_skelton2.c
@@ -1,17 +1,22 @@
-#include "cgenalyzer.h"
-
-int main(int argc, char *argv[]) {
- // opaque config struct that will contain config settings
- // config c = NULL;
-
- /* configuration */
- // config_tone_meas(...);
-
- /* load waveform generation*/
- // read_file_to_array(...);
-
- /* compute metrics */
- // fsnr_val = metric(..., "FSNR");
-
- return 0;
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+#include "cgenalyzer.h"
+
+int
+main (int argc, char *argv[])
+{
+ // opaque config struct that will contain config settings
+ // config c = NULL;
+
+ /* configuration */
+ // config_tone_meas(...);
+
+ /* load waveform generation*/
+ // read_file_to_array(...);
+
+ /* compute metrics */
+ // fsnr_val = metric(..., "FSNR");
+
+ return 0;
}
\ No newline at end of file
diff --git a/doc/general_example_skelton3.c b/doc/general_example_skelton3.c
index d20558b..fe79497 100644
--- a/doc/general_example_skelton3.c
+++ b/doc/general_example_skelton3.c
@@ -1,21 +1,26 @@
-#include
-#include
-#include
-#include "genalyzer_cwrapper.h"
-
-int main(int argc, char *argv[]) {
- // opaque config struct that will contain config settings
- // config c = NULL;
-
- /* configuration */
- // config_tone_meas(&c, FREQ, ...);
- // config_tone_meas(&c, TIME,...);
-
- /* load waveform generation*/
- // read_file_to_array(...);
-
- /* compute metrics */
- // fsnr_val = metric(..., "FSNR");
-
- return 0;
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+#include "genalyzer_cwrapper.h"
+#include
+#include
+#include
+
+int
+main (int argc, char *argv[])
+{
+ // opaque config struct that will contain config settings
+ // config c = NULL;
+
+ /* configuration */
+ // config_tone_meas(&c, FREQ, ...);
+ // config_tone_meas(&c, TIME,...);
+
+ /* load waveform generation*/
+ // read_file_to_array(...);
+
+ /* compute metrics */
+ // fsnr_val = metric(..., "FSNR");
+
+ return 0;
}
\ No newline at end of file
diff --git a/doc/general_example_tone_configuration.c b/doc/general_example_tone_configuration.c
index a1c0f87..7aebe39 100644
--- a/doc/general_example_tone_configuration.c
+++ b/doc/general_example_tone_configuration.c
@@ -1,18 +1,16 @@
-
- // configuration
- config_tone_meas(&c,
- domain_wf,
- type_wf,
- nfft, // FFT order
- navg, // # of FFTs averaged
- fs, // sample rate
- fsr, // full-scale range
- 0, // ADC resolution: unused configuration setting
- freq, // tone frequency, # of array elements = num_tones
- scale, // tone scale, # of array elements = num_tones
- phase, // tone phase, # of array elements = num_tones
- num_tones, // # of tones
- false,
- false,
- false
- );
\ No newline at end of file
+
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+// configuration
+config_tone_meas (&c, domain_wf, type_wf,
+ nfft, // FFT order
+ navg, // # of FFTs averaged
+ fs, // sample rate
+ fsr, // full-scale range
+ 0, // ADC resolution: unused configuration setting
+ freq, // tone frequency, # of array elements = num_tones
+ scale, // tone scale, # of array elements = num_tones
+ phase, // tone phase, # of array elements = num_tones
+ num_tones, // # of tones
+ false, false, false);
\ No newline at end of file
diff --git a/doc/working_example_tone_instr.c b/doc/working_example_tone_instr.c
index 275eb70..94c63ec 100644
--- a/doc/working_example_tone_instr.c
+++ b/doc/working_example_tone_instr.c
@@ -1,68 +1,70 @@
-#include
-#include
-#include
-#include "test_genalyzer.h"
-#include "cgenalyzer.h"
-
-int main(int argc, char *argv[]) {
- // read test waveform
- const char *test_filename_ip = argv[1];
- printf("%s\n", test_filename_ip);
-
- meas_domain domain_wf = atoll(extract_token(test_filename_ip, "domain_wf"));
- waveform_type type_wf = atoll(extract_token(test_filename_ip, "type_wf"));
- size_t nfft = atoll(extract_token(test_filename_ip, "nfft"));
- size_t num_tones = atoll(extract_token(test_filename_ip, "num_tones"));
- int res = atoi(extract_token(test_filename_ip, "res"));
- int navg = atoi(extract_token(test_filename_ip, "navg"));
- double fs = atof(extract_token(test_filename_ip, "fs"));
- double fdata = fs, fshift = fs;
- double fsr = atof(extract_token(test_filename_ip, "fsr"));
- double *freq = (double *)calloc(num_tones, sizeof(double));
- double *scale = (double *)calloc(num_tones, sizeof(double));
- double *phase = (double *)calloc(num_tones, sizeof(double));
-
- char tmp_token[10];
- for (int n = 0; n < num_tones; n++) {
- sprintf(tmp_token, "freq%d", n);
- freq[n] = atof(extract_token(test_filename_ip, tmp_token));
- sprintf(tmp_token, "scale%d", n);
- scale[n] = atof(extract_token(test_filename_ip, tmp_token));
- sprintf(tmp_token, "phase%d", n);
- phase[n] = atof(extract_token(test_filename_ip, tmp_token));
- }
-
- size_t npts = 2*nfft*navg;
- int qwf[npts];
- config c = NULL;
-
- // configuration
- config_tone_meas(&c,
- domain_wf,
- type_wf,
- nfft, // FFT order
- navg, // # of FFTs averaged
- fs, // sample rate
- fsr, // full-scale range
- res, // ADC resolution: unused configuration setting
- freq, // tone frequency, # of array elements = num_tones
- scale, // tone scale, # of array elements = num_tones
- phase, // tone phase, # of array elements = num_tones
- num_tones, // # of tones
- false,
- false,
- false
- );
-
- // read quantized input waveform
- read_file_to_array(test_filename_ip, (void *) qwf, INT32);
-
- // compute metrics
- fsnr_val = metric(c, qwf, "FSNR");
- sfdr_val = metric(c, qwf, "SFDR");
- sinad_val = metric(c, qwf, "SINAD");
-
- free(awf);
- free(qwf);
- return 0;
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+#include "cgenalyzer.h"
+#include "test_genalyzer.h"
+#include
+#include
+#include
+
+int
+main (int argc, char *argv[])
+{
+ // read test waveform
+ const char *test_filename_ip = argv[1];
+ printf ("%s\n", test_filename_ip);
+
+ meas_domain domain_wf
+ = atoll (extract_token (test_filename_ip, "domain_wf"));
+ waveform_type type_wf = atoll (extract_token (test_filename_ip, "type_wf"));
+ size_t nfft = atoll (extract_token (test_filename_ip, "nfft"));
+ size_t num_tones = atoll (extract_token (test_filename_ip, "num_tones"));
+ int res = atoi (extract_token (test_filename_ip, "res"));
+ int navg = atoi (extract_token (test_filename_ip, "navg"));
+ double fs = atof (extract_token (test_filename_ip, "fs"));
+ double fdata = fs, fshift = fs;
+ double fsr = atof (extract_token (test_filename_ip, "fsr"));
+ double *freq = (double *)calloc (num_tones, sizeof (double));
+ double *scale = (double *)calloc (num_tones, sizeof (double));
+ double *phase = (double *)calloc (num_tones, sizeof (double));
+
+ char tmp_token[10];
+ for (int n = 0; n < num_tones; n++)
+ {
+ sprintf (tmp_token, "freq%d", n);
+ freq[n] = atof (extract_token (test_filename_ip, tmp_token));
+ sprintf (tmp_token, "scale%d", n);
+ scale[n] = atof (extract_token (test_filename_ip, tmp_token));
+ sprintf (tmp_token, "phase%d", n);
+ phase[n] = atof (extract_token (test_filename_ip, tmp_token));
+ }
+
+ size_t npts = 2 * nfft * navg;
+ int qwf[npts];
+ config c = NULL;
+
+ // configuration
+ config_tone_meas (&c, domain_wf, type_wf,
+ nfft, // FFT order
+ navg, // # of FFTs averaged
+ fs, // sample rate
+ fsr, // full-scale range
+ res, // ADC resolution: unused configuration setting
+ freq, // tone frequency, # of array elements = num_tones
+ scale, // tone scale, # of array elements = num_tones
+ phase, // tone phase, # of array elements = num_tones
+ num_tones, // # of tones
+ false, false, false);
+
+ // read quantized input waveform
+ read_file_to_array (test_filename_ip, (void *)qwf, INT32);
+
+ // compute metrics
+ fsnr_val = metric (c, qwf, "FSNR");
+ sfdr_val = metric (c, qwf, "SFDR");
+ sinad_val = metric (c, qwf, "SINAD");
+
+ free (awf);
+ free (qwf);
+ return 0;
}
\ No newline at end of file
diff --git a/doc/working_example_tone_sim.c b/doc/working_example_tone_sim.c
index be7639e..edfffcb 100644
--- a/doc/working_example_tone_sim.c
+++ b/doc/working_example_tone_sim.c
@@ -1,66 +1,60 @@
-#include
-#include
-#include
-#include "cgenalyzer.h"
-
-int main(int argc, char *argv[]) {
- // read configuration settings from a file
- const char *test_filename = argv[1];
- printf("%s\n", test_filename);
-
- // variables to hold configuration settings
- double *awf;
- int *qwf;
- size_t nfft = atoll(extract_token(test_filename, "nfft"));
- size_t num_tones = atoll(extract_token(test_filename, "num_tones"));
- int navg = atoi(extract_token(test_filename, "navg"));
- double fs = atof(extract_token(test_filename, "fs"));
- double fdata = fs, fshift = fs;
- double fsr = atof(extract_token(test_filename, "fsr"));
- double *freq = (double *)calloc(num_tones, sizeof(double));
- double *scale = (double *)calloc(num_tones, sizeof(double));
- double *phase = (double *)calloc(num_tones, sizeof(double));
-
- char tmp_token[10];
- for (int n = 0; n < num_tones; n++) {
- sprintf(tmp_token, "freq%d", n);
- freq[n] = atof(extract_token(test_filename, tmp_token));
- sprintf(tmp_token, "scale%d", n);
- scale[n] = atof(extract_token(test_filename, tmp_token));
- sprintf(tmp_token, "phase%d", n);
- phase[n] = atof(extract_token(test_filename, tmp_token));
- }
-
- // opaque config struct that will contain config settings
- config c = NULL;
-
- // configuration
- config_tone_meas(&c,
- FREQ,
- COMPLEX_EXP,
- nfft,
- navg,
- fs,
- fsr,
- res,
- &freq,
- &scale,
- &phase,
- 1,
- update_fsample,
- update_fdata,
- update_fshift);
-
- // waveform generation
- gen_tone(c, &awf);
- quantize(c, awf, &qwf);
-
- // compute metrics
- fsnr_val = metric(c, qwf, "FSNR");
- sfdr_val = metric(c, qwf, "SFDR");
- sinad_val = metric(c, qwf, "SINAD");
-
- free(awf);
- free(qwf);
- return 0;
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
+#include "cgenalyzer.h"
+#include
+#include
+#include
+
+int
+main (int argc, char *argv[])
+{
+ // read configuration settings from a file
+ const char *test_filename = argv[1];
+ printf ("%s\n", test_filename);
+
+ // variables to hold configuration settings
+ double *awf;
+ int *qwf;
+ size_t nfft = atoll (extract_token (test_filename, "nfft"));
+ size_t num_tones = atoll (extract_token (test_filename, "num_tones"));
+ int navg = atoi (extract_token (test_filename, "navg"));
+ double fs = atof (extract_token (test_filename, "fs"));
+ double fdata = fs, fshift = fs;
+ double fsr = atof (extract_token (test_filename, "fsr"));
+ double *freq = (double *)calloc (num_tones, sizeof (double));
+ double *scale = (double *)calloc (num_tones, sizeof (double));
+ double *phase = (double *)calloc (num_tones, sizeof (double));
+
+ char tmp_token[10];
+ for (int n = 0; n < num_tones; n++)
+ {
+ sprintf (tmp_token, "freq%d", n);
+ freq[n] = atof (extract_token (test_filename, tmp_token));
+ sprintf (tmp_token, "scale%d", n);
+ scale[n] = atof (extract_token (test_filename, tmp_token));
+ sprintf (tmp_token, "phase%d", n);
+ phase[n] = atof (extract_token (test_filename, tmp_token));
+ }
+
+ // opaque config struct that will contain config settings
+ config c = NULL;
+
+ // configuration
+ config_tone_meas (&c, FREQ, COMPLEX_EXP, nfft, navg, fs, fsr, res, &freq,
+ &scale, &phase, 1, update_fsample, update_fdata,
+ update_fshift);
+
+ // waveform generation
+ gen_tone (c, &awf);
+ quantize (c, awf, &qwf);
+
+ // compute metrics
+ fsnr_val = metric (c, qwf, "FSNR");
+ sfdr_val = metric (c, qwf, "SFDR");
+ sinad_val = metric (c, qwf, "SINAD");
+
+ free (awf);
+ free (qwf);
+ return 0;
}
\ No newline at end of file
diff --git a/examples/do_fa_pluto_example.c b/examples/do_fa_pluto_example.c
index ed96e51..9e98f7b 100644
--- a/examples/do_fa_pluto_example.c
+++ b/examples/do_fa_pluto_example.c
@@ -1,64 +1,75 @@
-#include "cgenalyzer_simplified_beta.h"
-#include "../tests/test_genalyzer.h"
#include "../tests/cJSON.h"
+#include "../tests/test_genalyzer.h"
+#include "cgenalyzer_simplified_beta.h"
#include
-int main(int argc, const char* argv[])
+int
+main (int argc, const char *argv[])
{
- // read test waveform filename
- const char* test_filename = "../tests/test_vectors/test_Pluto_DDS_data_1658159639196.json";
-
- int err_code;
- int32_t *ref_qwfi, *ref_qwfq;
- double *fft_out;
- double sfdr;
+ // read test waveform filename
+ const char *test_filename
+ = "../tests/test_vectors/test_Pluto_DDS_data_1658159639196.json";
+
+ int err_code;
+ int32_t *ref_qwfi, *ref_qwfq;
+ double *fft_out;
+ double sfdr;
+
+ // read parameters
+ tone_type ttype;
+ int qres;
+ unsigned long long npts, navg, nfft, tmp_win;
+ double fs;
+ GnWindow win;
+ uint8_t ssb_width = 100;
+ err_code = read_scalar_from_json_file (test_filename, "wf_type",
+ (void *)(&ttype), UINT64);
+ err_code = read_scalar_from_json_file (test_filename, "qres",
+ (void *)(&qres), INT32);
+ err_code = read_scalar_from_json_file (test_filename, "npts",
+ (void *)(&npts), UINT64);
+ err_code = read_scalar_from_json_file (test_filename, "navg",
+ (void *)(&navg), UINT64);
+ err_code = read_scalar_from_json_file (test_filename, "fs", (void *)(&fs),
+ DOUBLE);
+ err_code = read_scalar_from_json_file (test_filename, "nfft",
+ (void *)(&nfft), UINT64);
+ err_code = read_scalar_from_json_file (test_filename, "win",
+ (void *)(&tmp_win), UINT64);
+ if (tmp_win == 1)
+ win = GnWindowBlackmanHarris;
+ else if (tmp_win == 2)
+ win = GnWindowHann;
+ else if (tmp_win == 3)
+ win = GnWindowNoWindow;
+
+ // read reference waveforms
+ ref_qwfi = (int32_t *)malloc (npts * sizeof (int32_t));
+ err_code = read_array_from_json_file (test_filename, "test_vec_i", ref_qwfi,
+ INT32, npts);
+ ref_qwfq = (int32_t *)malloc (npts * sizeof (int32_t));
+ err_code = read_array_from_json_file (test_filename, "test_vec_q", ref_qwfq,
+ INT32, npts);
+
+ // configuration
+ gn_config c = NULL;
+ err_code = gn_config_fftz (npts, qres, navg, nfft, win, &c);
- // read parameters
- tone_type ttype;
- int qres;
- unsigned long long npts, navg, nfft, tmp_win;
- double fs;
- GnWindow win;
- uint8_t ssb_width = 100;
- err_code = read_scalar_from_json_file(test_filename, "wf_type", (void*)(&ttype), UINT64);
- err_code = read_scalar_from_json_file(test_filename, "qres", (void*)(&qres), INT32);
- err_code = read_scalar_from_json_file(test_filename, "npts", (void*)(&npts), UINT64);
- err_code = read_scalar_from_json_file(test_filename, "navg", (void*)(&navg), UINT64);
- err_code = read_scalar_from_json_file(test_filename, "fs", (void*)(&fs), DOUBLE);
- err_code = read_scalar_from_json_file(test_filename, "nfft", (void*)(&nfft), UINT64);
- err_code = read_scalar_from_json_file(test_filename, "win", (void*)(&tmp_win), UINT64);
- if (tmp_win==1)
- win = GnWindowBlackmanHarris;
- else if (tmp_win==2)
- win = GnWindowHann;
- else if (tmp_win==3)
- win = GnWindowNoWindow;
+ // FFT of waveform
+ err_code = gn_fftz (&fft_out, ref_qwfi, ref_qwfq, &c);
+ err_code = gn_config_set_sample_rate (fs, &c);
- // read reference waveforms
- ref_qwfi = (int32_t*)malloc(npts*sizeof(int32_t));
- err_code = read_array_from_json_file(test_filename, "test_vec_i", ref_qwfi, INT32, npts);
- ref_qwfq = (int32_t*)malloc(npts*sizeof(int32_t));
- err_code = read_array_from_json_file(test_filename, "test_vec_q", ref_qwfq, INT32, npts);
+ // Configure Fourier analysis
+ err_code = gn_config_fa_auto (120, &c);
- // configuration
- gn_config c = NULL;
- err_code = gn_config_fftz(npts, qres, navg, nfft, win, &c);
+ err_code = gn_get_fa_single_result (&sfdr, "sfdr", fft_out, &c);
+ printf ("SFDR - %20.6f\n", sfdr);
- // FFT of waveform
- err_code = gn_fftz(&fft_out, ref_qwfi, ref_qwfq, &c);
- err_code = gn_config_set_sample_rate(fs, &c);
+ // free memory
+ free (ref_qwfi);
+ free (ref_qwfq);
+ free (fft_out);
+ gn_config_free (&c);
- // Configure Fourier analysis
- err_code = gn_config_fa_auto(120, &c);
-
- err_code = gn_get_fa_single_result(&sfdr, "sfdr", fft_out, &c);
- printf("SFDR - %20.6f\n", sfdr);
-
- // free memory
- free(ref_qwfi);
- free(ref_qwfq);
- free(fft_out);
- gn_config_free(&c);
-
- return 0;
+ return 0;
}
diff --git a/examples/do_fa_pluto_example_all_results.c b/examples/do_fa_pluto_example_all_results.c
index 4fef108..2ea8061 100644
--- a/examples/do_fa_pluto_example_all_results.c
+++ b/examples/do_fa_pluto_example_all_results.c
@@ -1,72 +1,83 @@
-#include "cgenalyzer_simplified_beta.h"
-#include "../tests/test_genalyzer.h"
#include "../tests/cJSON.h"
+#include "../tests/test_genalyzer.h"
+#include "cgenalyzer_simplified_beta.h"
#include
-int main(int argc, const char* argv[])
+int
+main (int argc, const char *argv[])
{
- // read test waveform filename
- const char* test_filename = "../tests/test_vectors/test_Pluto_DDS_data_1658159639196.json";
-
- int err_code;
- int32_t *ref_qwfi, *ref_qwfq;
- double *fft_out;
-
- size_t results_size;
- char **rkeys;
- double *rvalues;
+ // read test waveform filename
+ const char *test_filename
+ = "../tests/test_vectors/test_Pluto_DDS_data_1658159639196.json";
+
+ int err_code;
+ int32_t *ref_qwfi, *ref_qwfq;
+ double *fft_out;
+
+ size_t results_size;
+ char **rkeys;
+ double *rvalues;
+
+ // read parameters
+ tone_type ttype;
+ int qres;
+ unsigned long long npts, navg, nfft, tmp_win;
+ double fs;
+ GnWindow win;
+ uint8_t ssb_width = 100;
+ err_code = read_scalar_from_json_file (test_filename, "wf_type",
+ (void *)(&ttype), UINT64);
+ err_code = read_scalar_from_json_file (test_filename, "qres",
+ (void *)(&qres), INT32);
+ err_code = read_scalar_from_json_file (test_filename, "npts",
+ (void *)(&npts), UINT64);
+ err_code = read_scalar_from_json_file (test_filename, "navg",
+ (void *)(&navg), UINT64);
+ err_code = read_scalar_from_json_file (test_filename, "fs", (void *)(&fs),
+ DOUBLE);
+ err_code = read_scalar_from_json_file (test_filename, "nfft",
+ (void *)(&nfft), UINT64);
+ err_code = read_scalar_from_json_file (test_filename, "win",
+ (void *)(&tmp_win), UINT64);
+ if (tmp_win == 1)
+ win = GnWindowBlackmanHarris;
+ else if (tmp_win == 2)
+ win = GnWindowHann;
+ else if (tmp_win == 3)
+ win = GnWindowNoWindow;
+
+ // read reference waveforms
+ ref_qwfi = (int32_t *)malloc (npts * sizeof (int32_t));
+ err_code = read_array_from_json_file (test_filename, "test_vec_i", ref_qwfi,
+ INT32, npts);
+ ref_qwfq = (int32_t *)malloc (npts * sizeof (int32_t));
+ err_code = read_array_from_json_file (test_filename, "test_vec_q", ref_qwfq,
+ INT32, npts);
+
+ // configuration
+ gn_config c = NULL;
+ err_code = gn_config_fftz (npts, qres, navg, nfft, win, &c);
+
+ // FFT of waveform
+ err_code = gn_fftz (&fft_out, ref_qwfi, ref_qwfq, &c);
+ err_code = gn_config_set_sample_rate (fs, &c);
- // read parameters
- tone_type ttype;
- int qres;
- unsigned long long npts, navg, nfft, tmp_win;
- double fs;
- GnWindow win;
- uint8_t ssb_width = 100;
- err_code = read_scalar_from_json_file(test_filename, "wf_type", (void*)(&ttype), UINT64);
- err_code = read_scalar_from_json_file(test_filename, "qres", (void*)(&qres), INT32);
- err_code = read_scalar_from_json_file(test_filename, "npts", (void*)(&npts), UINT64);
- err_code = read_scalar_from_json_file(test_filename, "navg", (void*)(&navg), UINT64);
- err_code = read_scalar_from_json_file(test_filename, "fs", (void*)(&fs), DOUBLE);
- err_code = read_scalar_from_json_file(test_filename, "nfft", (void*)(&nfft), UINT64);
- err_code = read_scalar_from_json_file(test_filename, "win", (void*)(&tmp_win), UINT64);
- if (tmp_win==1)
- win = GnWindowBlackmanHarris;
- else if (tmp_win==2)
- win = GnWindowHann;
- else if (tmp_win==3)
- win = GnWindowNoWindow;
+ // Configure Fourier analysis
+ err_code = gn_config_fa_auto (120, &c);
- // read reference waveforms
- ref_qwfi = (int32_t*)malloc(npts*sizeof(int32_t));
- err_code = read_array_from_json_file(test_filename, "test_vec_i", ref_qwfi, INT32, npts);
- ref_qwfq = (int32_t*)malloc(npts*sizeof(int32_t));
- err_code = read_array_from_json_file(test_filename, "test_vec_q", ref_qwfq, INT32, npts);
+ err_code = gn_get_fa_results (&rkeys, &rvalues, &results_size, fft_out, &c);
+ if (err_code != 0)
+ return err_code;
- // configuration
- gn_config c = NULL;
- err_code = gn_config_fftz(npts, qres, navg, nfft, win, &c);
+ printf ("\nAll Fourier Analysis Results:\n");
+ for (size_t i = 0; i < results_size; i++)
+ printf ("%4zu%20s%20.6f\n", i, rkeys[i], rvalues[i]);
- // FFT of waveform
- err_code = gn_fftz(&fft_out, ref_qwfi, ref_qwfq, &c);
- err_code = gn_config_set_sample_rate(fs, &c);
+ // free memory
+ free (ref_qwfi);
+ free (ref_qwfq);
+ free (fft_out);
+ gn_config_free (&c);
- // Configure Fourier analysis
- err_code = gn_config_fa_auto(120, &c);
-
- err_code = gn_get_fa_results(&rkeys, &rvalues, &results_size, fft_out, &c);
- if (err_code != 0)
- return err_code;
-
- printf("\nAll Fourier Analysis Results:\n");
- for (size_t i = 0; i < results_size; i++)
- printf("%4zu%20s%20.6f\n", i, rkeys[i], rvalues[i]);
-
- // free memory
- free(ref_qwfi);
- free(ref_qwfq);
- free(fft_out);
- gn_config_free(&c);
-
- return 0;
+ return 0;
}
diff --git a/examples/do_ha_sim_example.c b/examples/do_ha_sim_example.c
index 8e92451..c8cb646 100644
--- a/examples/do_ha_sim_example.c
+++ b/examples/do_ha_sim_example.c
@@ -1,54 +1,56 @@
#include "cgenalyzer_simplified_beta.h"
-#include
#include
+#include
-int main(int argc, const char* argv[])
+int
+main (int argc, const char *argv[])
{
- // parameters
- double fsr = 3.0, qnoise = pow(10.0, -60.0 / 20.0), ramp_start = 0, ramp_stop = 2;
- int qres = 12;
- unsigned long long npts = 8192;
-
- // waveforms
- double *awf;
- int32_t *qwf;
-
- // results
- uint64_t *hist;
- size_t results_size, hist_len;
- char **rkeys;
- double *rvalues;
-
- // configuration
- int err_code;
- gn_config c = NULL;
- err_code = gn_config_gen_ramp(npts, ramp_start, ramp_stop, &c);
- err_code = gn_config_quantize(npts, fsr, qres, qnoise, &c);
-
- // generate waveform
- err_code = gn_gen_ramp(&awf, &c);
-
- // quantize waveform
- err_code = gn_quantize(&qwf, awf, &c);
-
- // compute histogram
- err_code = gn_histz(&hist, &hist_len, qwf, &c);
-
- // do waveform analysis
- err_code = gn_get_ha_results(&rkeys, &rvalues, &results_size, hist, &c);
-
- // print results
- printf("All Waveform Analysis Results:\n");
- for (size_t i = 0; i < results_size; i++)
- printf("%4zu%20s%20.6f\n", i, rkeys[i], rvalues[i]);
-
- // free memory
- free(qwf);
- free(awf);
- for (size_t i = 0; i < results_size; i++)
- free(rkeys[i]);
- free(rkeys);
- gn_config_free(&c);
-
- return 0;
+ // parameters
+ double fsr = 3.0, qnoise = pow (10.0, -60.0 / 20.0), ramp_start = 0,
+ ramp_stop = 2;
+ int qres = 12;
+ unsigned long long npts = 8192;
+
+ // waveforms
+ double *awf;
+ int32_t *qwf;
+
+ // results
+ uint64_t *hist;
+ size_t results_size, hist_len;
+ char **rkeys;
+ double *rvalues;
+
+ // configuration
+ int err_code;
+ gn_config c = NULL;
+ err_code = gn_config_gen_ramp (npts, ramp_start, ramp_stop, &c);
+ err_code = gn_config_quantize (npts, fsr, qres, qnoise, &c);
+
+ // generate waveform
+ err_code = gn_gen_ramp (&awf, &c);
+
+ // quantize waveform
+ err_code = gn_quantize (&qwf, awf, &c);
+
+ // compute histogram
+ err_code = gn_histz (&hist, &hist_len, qwf, &c);
+
+ // do waveform analysis
+ err_code = gn_get_ha_results (&rkeys, &rvalues, &results_size, hist, &c);
+
+ // print results
+ printf ("All Waveform Analysis Results:\n");
+ for (size_t i = 0; i < results_size; i++)
+ printf ("%4zu%20s%20.6f\n", i, rkeys[i], rvalues[i]);
+
+ // free memory
+ free (qwf);
+ free (awf);
+ for (size_t i = 0; i < results_size; i++)
+ free (rkeys[i]);
+ free (rkeys);
+ gn_config_free (&c);
+
+ return 0;
}
\ No newline at end of file
diff --git a/examples/do_wfa_sim_example.c b/examples/do_wfa_sim_example.c
index 8f24277..348cc17 100644
--- a/examples/do_wfa_sim_example.c
+++ b/examples/do_wfa_sim_example.c
@@ -1,53 +1,55 @@
#include "cgenalyzer_simplified_beta.h"
-#include
#include
+#include
-int main(int argc, const char* argv[])
+int
+main (int argc, const char *argv[])
{
- // parameters
- tone_type ttype = REAL_COSINE;
- double fsr = 3.0, qnoise = pow(10.0, -60.0 / 20.0);
- int qres = 12;
- double fs = 5000000.0;
- unsigned long long npts = 8192, num_tones = 1;
- double freq[] = {50000.0}, scale[] = {0.5}, phase[] = {0.2};
-
- // waveforms
- double *awf;
- int32_t *qwf;
-
- // results
- size_t results_size;
- char **rkeys;
- double *rvalues;
-
- // configuration
- int err_code;
- gn_config c = NULL;
- err_code = gn_config_gen_tone(ttype, npts, fs, num_tones, freq, scale, phase, &c);
- err_code = gn_config_quantize(npts, fsr, qres, qnoise, &c);
-
- // generate waveform
- err_code = gn_gen_real_tone(&awf, &c);
-
- // quantize waveform
- err_code = gn_quantize(&qwf, awf, &c);
-
- // do waveform analysis
- err_code = gn_get_wfa_results(&rkeys, &rvalues, &results_size, qwf, &c);
-
- // print results
- printf("All Waveform Analysis Results:\n");
- for (size_t i = 0; i < results_size; i++)
- printf("%4zu%20s%20.6f\n", i, rkeys[i], rvalues[i]);
-
- // free memory
- free(qwf);
- free(awf);
- for (size_t i = 0; i < results_size; i++)
- free(rkeys[i]);
- free(rkeys);
- gn_config_free(&c);
-
- return 0;
+ // parameters
+ tone_type ttype = REAL_COSINE;
+ double fsr = 3.0, qnoise = pow (10.0, -60.0 / 20.0);
+ int qres = 12;
+ double fs = 5000000.0;
+ unsigned long long npts = 8192, num_tones = 1;
+ double freq[] = { 50000.0 }, scale[] = { 0.5 }, phase[] = { 0.2 };
+
+ // waveforms
+ double *awf;
+ int32_t *qwf;
+
+ // results
+ size_t results_size;
+ char **rkeys;
+ double *rvalues;
+
+ // configuration
+ int err_code;
+ gn_config c = NULL;
+ err_code = gn_config_gen_tone (ttype, npts, fs, num_tones, freq, scale,
+ phase, &c);
+ err_code = gn_config_quantize (npts, fsr, qres, qnoise, &c);
+
+ // generate waveform
+ err_code = gn_gen_real_tone (&awf, &c);
+
+ // quantize waveform
+ err_code = gn_quantize (&qwf, awf, &c);
+
+ // do waveform analysis
+ err_code = gn_get_wfa_results (&rkeys, &rvalues, &results_size, qwf, &c);
+
+ // print results
+ printf ("All Waveform Analysis Results:\n");
+ for (size_t i = 0; i < results_size; i++)
+ printf ("%4zu%20s%20.6f\n", i, rkeys[i], rvalues[i]);
+
+ // free memory
+ free (qwf);
+ free (awf);
+ for (size_t i = 0; i < results_size; i++)
+ free (rkeys[i]);
+ free (rkeys);
+ gn_config_free (&c);
+
+ return 0;
}
diff --git a/examples/fft_analysis_genalyzer_advanced.c b/examples/fft_analysis_genalyzer_advanced.c
index 42b0a42..899c1ea 100644
--- a/examples/fft_analysis_genalyzer_advanced.c
+++ b/examples/fft_analysis_genalyzer_advanced.c
@@ -1,299 +1,337 @@
-#include
#include
+#include
-#include
#include
+#include
#include
#include
#include
#define ERROR_BUFFER_SIZE 256
-#define HANDLE_ERROR(x) \
- do { \
- if (0 != x) { \
- gn_error_string(error_buffer, ERROR_BUFFER_SIZE); \
- printf("%s\n", error_buffer); \
- goto cleanup; \
- } \
- } while (0)
+#define HANDLE_ERROR(x) \
+ do \
+ { \
+ if (0 != x) \
+ { \
+ gn_error_string (error_buffer, ERROR_BUFFER_SIZE); \
+ printf ("%s\n", error_buffer); \
+ goto cleanup; \
+ } \
+ } \
+ while (0)
-int main(int argc, char* argv[])
+int
+main (int argc, char *argv[])
{
- bool save_data = false;
- if (1 < argc) {
- save_data = !((bool) strcmp(argv[1], "--save-data"));
+ bool save_data = false;
+ if (1 < argc)
+ {
+ save_data = !((bool)strcmp (argv[1], "--save-data"));
}
- /*
- * Setup
- */
- gn_set_string_termination(true);
- char error_buffer[ERROR_BUFFER_SIZE];
- bool error_occurred = true;
- int result = 0;
+ /*
+ * Setup
+ */
+ gn_set_string_termination (true);
+ char error_buffer[ERROR_BUFFER_SIZE];
+ bool error_occurred = true;
+ int result = 0;
- size_t navg = 2; // FFT averaging
- size_t nfft = 1024 * 16; // FFT size
- double fs = 1e9; // sample rate
- double fdata = fs / 1; // data rate
- double fshift = 0e6; // shift frequency
- double fsr = 2.0; // full-scale range
- double ampl_dbfs = -1.0; // input amplitude (dBFS)
- double freq = 70e6; // input frequency (Hz)
- double phase = 0.110; // input phase (rad)
- double td = 0.0; // input delay (s)
- double tj = 0.0; // RMS aperature uncertainty (s)
- double qpe = (atan(1.0) * 2) * 1e-5; // quadrature phase error (pi/2 * x)
- double poco[] = {0.0, 1.0, 0.0, 0.003}; // distortion polynomial coefficients
- int qres = 12; // quantizer resolution
- double qnoise_dbfs = -63.0; // quantizer noise (dBFS)
- GnCodeFormat code_fmt = GnCodeFormatTwosComplement;
- GnFreqAxisFormat axis_fmt = GnFreqAxisFormatFreq;
- GnFreqAxisType axis_type = GnFreqAxisTypeDcCenter;
- GnWindow window = GnWindowNoWindow;
+ size_t navg = 2; // FFT averaging
+ size_t nfft = 1024 * 16; // FFT size
+ double fs = 1e9; // sample rate
+ double fdata = fs / 1; // data rate
+ double fshift = 0e6; // shift frequency
+ double fsr = 2.0; // full-scale range
+ double ampl_dbfs = -1.0; // input amplitude (dBFS)
+ double freq = 70e6; // input frequency (Hz)
+ double phase = 0.110; // input phase (rad)
+ double td = 0.0; // input delay (s)
+ double tj = 0.0; // RMS aperature uncertainty (s)
+ double qpe = (atan (1.0) * 2) * 1e-5; // quadrature phase error (pi/2 * x)
+ double poco[]
+ = { 0.0, 1.0, 0.0, 0.003 }; // distortion polynomial coefficients
+ int qres = 12; // quantizer resolution
+ double qnoise_dbfs = -63.0; // quantizer noise (dBFS)
+ GnCodeFormat code_fmt = GnCodeFormatTwosComplement;
+ GnFreqAxisFormat axis_fmt = GnFreqAxisFormatFreq;
+ GnFreqAxisType axis_type = GnFreqAxisTypeDcCenter;
+ GnWindow window = GnWindowNoWindow;
- int dsr = (int) (fs / fdata);
- size_t npts = navg * nfft * dsr;
- double ampl = (fsr / 2) * pow(10.0, ampl_dbfs / 20.0);
- double qnoise = pow(10.0, qnoise_dbfs / 20.0);
- int ssb_fund = 4;
- int ssb_rest = 3;
+ int dsr = (int)(fs / fdata);
+ size_t npts = navg * nfft * dsr;
+ double ampl = (fsr / 2) * pow (10.0, ampl_dbfs / 20.0);
+ double qnoise = pow (10.0, qnoise_dbfs / 20.0);
+ int ssb_fund = 4;
+ int ssb_rest = 3;
- /*
- * Pointers for allocated memory
- */
- double* awfi = NULL; // in-phase analog waveform
- double* awfq = NULL; // quadrature analog waveform
- int16_t* qwfi = NULL; // in-phase quantized waveform
- int16_t* qwfq = NULL; // quadrature quantized waveform
- int16_t* xwf = NULL; // frequency-shifted waveform
- int16_t* ywf = NULL; // downsampled waveform
- double* fft_cplx = NULL; // FFT complex data
- double* fft_db = NULL; // FFT magnitude data
- double* freq_axis = NULL; // frequency axis
- char* fa_preview = NULL; // FFT analysis configuration preview
- char* fa_carrier = NULL; // FFT analysis carrier key
- char* fa_maxspur = NULL; // FFT analysis maxspur key
- char** fft_rkeys = NULL; // FFT analysis keys
- double* fft_rvalues = NULL; // FFT analysis values
- size_t* fft_rkey_sizes = NULL; // FFT analysis key sizes
- double* fft_select_rvalues = NULL; // FFT analysis select values
+ /*
+ * Pointers for allocated memory
+ */
+ double *awfi = NULL; // in-phase analog waveform
+ double *awfq = NULL; // quadrature analog waveform
+ int16_t *qwfi = NULL; // in-phase quantized waveform
+ int16_t *qwfq = NULL; // quadrature quantized waveform
+ int16_t *xwf = NULL; // frequency-shifted waveform
+ int16_t *ywf = NULL; // downsampled waveform
+ double *fft_cplx = NULL; // FFT complex data
+ double *fft_db = NULL; // FFT magnitude data
+ double *freq_axis = NULL; // frequency axis
+ char *fa_preview = NULL; // FFT analysis configuration preview
+ char *fa_carrier = NULL; // FFT analysis carrier key
+ char *fa_maxspur = NULL; // FFT analysis maxspur key
+ char **fft_rkeys = NULL; // FFT analysis keys
+ double *fft_rvalues = NULL; // FFT analysis values
+ size_t *fft_rkey_sizes = NULL; // FFT analysis key sizes
+ double *fft_select_rvalues = NULL; // FFT analysis select values
- size_t fft_results_size = 0;
+ size_t fft_results_size = 0;
- /*
- * Allocate memory
- */
- size_t xwf_size = npts * 2;
- size_t ywf_size = 0;
- size_t fft_cplx_size = nfft * 2;
- result += gn_downsample_size(&ywf_size, xwf_size, dsr, true);
- HANDLE_ERROR(result);
- awfi = malloc(npts * sizeof(double));
- awfq = malloc(npts * sizeof(double));
- qwfi = malloc(npts * sizeof(int16_t));
- qwfq = malloc(npts * sizeof(int16_t));
- xwf = malloc(xwf_size * sizeof(int16_t));
- ywf = malloc(ywf_size * sizeof(int16_t));
- fft_cplx = malloc(fft_cplx_size * sizeof(double));
+ /*
+ * Allocate memory
+ */
+ size_t xwf_size = npts * 2;
+ size_t ywf_size = 0;
+ size_t fft_cplx_size = nfft * 2;
+ result += gn_downsample_size (&ywf_size, xwf_size, dsr, true);
+ HANDLE_ERROR (result);
+ awfi = malloc (npts * sizeof (double));
+ awfq = malloc (npts * sizeof (double));
+ qwfi = malloc (npts * sizeof (int16_t));
+ qwfq = malloc (npts * sizeof (int16_t));
+ xwf = malloc (xwf_size * sizeof (int16_t));
+ ywf = malloc (ywf_size * sizeof (int16_t));
+ fft_cplx = malloc (fft_cplx_size * sizeof (double));
- /*
- * Signal generation and processing
- */
- if (GnWindowNoWindow == window) {
- result += gn_coherent(&freq, nfft, fdata, freq);
- HANDLE_ERROR(result);
- double fbin = fdata / nfft;
- fshift = round(fshift / fbin) * fbin;
- ssb_fund = 0;
- ssb_rest = 0;
+ /*
+ * Signal generation and processing
+ */
+ if (GnWindowNoWindow == window)
+ {
+ result += gn_coherent (&freq, nfft, fdata, freq);
+ HANDLE_ERROR (result);
+ double fbin = fdata / nfft;
+ fshift = round (fshift / fbin) * fbin;
+ ssb_fund = 0;
+ ssb_rest = 0;
}
- result += gn_cos(awfi, npts, fs, ampl, freq, phase, td, tj);
- result += gn_sin(awfq, npts, fs, ampl, freq, phase + qpe, td, tj);
- result += gn_polyval(awfi, npts, awfi, npts, poco, (sizeof poco) / sizeof(double));
- result += gn_polyval(awfq, npts, awfq, npts, poco, (sizeof poco) / sizeof(double));
- result += gn_quantize16(qwfi, npts, awfi, npts, fsr, qres, qnoise, code_fmt);
- result += gn_quantize16(qwfq, npts, awfq, npts, fsr, qres, qnoise, code_fmt);
- result += gn_fshift16(xwf, xwf_size, qwfi, npts, qwfq, npts, qres, fs, fshift, code_fmt);
- result += gn_downsample16(ywf, ywf_size, xwf, xwf_size, dsr, true);
- result += gn_fft16(fft_cplx, fft_cplx_size, ywf, ywf_size, NULL, 0, qres, navg, nfft, window, code_fmt);
- HANDLE_ERROR(result);
+ result += gn_cos (awfi, npts, fs, ampl, freq, phase, td, tj);
+ result += gn_sin (awfq, npts, fs, ampl, freq, phase + qpe, td, tj);
+ result += gn_polyval (awfi, npts, awfi, npts, poco,
+ (sizeof poco) / sizeof (double));
+ result += gn_polyval (awfq, npts, awfq, npts, poco,
+ (sizeof poco) / sizeof (double));
+ result
+ += gn_quantize16 (qwfi, npts, awfi, npts, fsr, qres, qnoise, code_fmt);
+ result
+ += gn_quantize16 (qwfq, npts, awfq, npts, fsr, qres, qnoise, code_fmt);
+ result += gn_fshift16 (xwf, xwf_size, qwfi, npts, qwfq, npts, qres, fs,
+ fshift, code_fmt);
+ result += gn_downsample16 (ywf, ywf_size, xwf, xwf_size, dsr, true);
+ result += gn_fft16 (fft_cplx, fft_cplx_size, ywf, ywf_size, NULL, 0, qres,
+ navg, nfft, window, code_fmt);
+ HANDLE_ERROR (result);
- /*
- * Fourier analysis configuration
- */
- char* key = "fa";
- result += gn_fa_create(key);
- result += gn_fa_fixed_tone(key, "A", GnFACompTagSignal, freq, ssb_fund);
- result += gn_fa_hd(key, 3);
- result += gn_fa_ssb(key, GnFASsbDefault, ssb_rest);
- result += gn_fa_ssb(key, GnFASsbDC, -1);
- result += gn_fa_ssb(key, GnFASsbSignal, -1);
- result += gn_fa_ssb(key, GnFASsbWO, -1);
- result += gn_fa_fsample(key, fs);
- result += gn_fa_fdata(key, fdata);
- result += gn_fa_fshift(key, fshift);
- result += gn_fa_conv_offset(key, 0.0 != fshift);
- HANDLE_ERROR(result);
- size_t fa_preview_size = 0;
- result += gn_fa_preview_size(&fa_preview_size, key, true);
- fa_preview = malloc(fa_preview_size);
- result += gn_fa_preview(fa_preview, fa_preview_size, key, true);
- HANDLE_ERROR(result);
- printf("%s\n", fa_preview);
+ /*
+ * Fourier analysis configuration
+ */
+ char *key = "fa";
+ result += gn_fa_create (key);
+ result += gn_fa_fixed_tone (key, "A", GnFACompTagSignal, freq, ssb_fund);
+ result += gn_fa_hd (key, 3);
+ result += gn_fa_ssb (key, GnFASsbDefault, ssb_rest);
+ result += gn_fa_ssb (key, GnFASsbDC, -1);
+ result += gn_fa_ssb (key, GnFASsbSignal, -1);
+ result += gn_fa_ssb (key, GnFASsbWO, -1);
+ result += gn_fa_fsample (key, fs);
+ result += gn_fa_fdata (key, fdata);
+ result += gn_fa_fshift (key, fshift);
+ result += gn_fa_conv_offset (key, 0.0 != fshift);
+ HANDLE_ERROR (result);
+ size_t fa_preview_size = 0;
+ result += gn_fa_preview_size (&fa_preview_size, key, true);
+ fa_preview = malloc (fa_preview_size);
+ result += gn_fa_preview (fa_preview, fa_preview_size, key, true);
+ HANDLE_ERROR (result);
+ printf ("%s\n", fa_preview);
- /*
- * Fourier analysis with all results
- */
- // 1. Get results size
- result += gn_fft_analysis_results_size(&fft_results_size, key, fft_cplx_size, nfft);
- // 2. Allocate memory for result keys and values
- fft_rkeys = malloc(fft_results_size * sizeof(char*));
- fft_rvalues = malloc(fft_results_size * sizeof(double));
- // 3. Get result key sizes
- fft_rkey_sizes = malloc(fft_results_size * sizeof(size_t));
- result += gn_fft_analysis_results_key_sizes(fft_rkey_sizes, fft_results_size, key, fft_cplx_size, nfft);
- HANDLE_ERROR(result);
- // 4. Allocate memory for each result key
- for (size_t i = 0; i < fft_results_size; ++i) {
- fft_rkeys[i] = malloc(fft_rkey_sizes[i]);
+ /*
+ * Fourier analysis with all results
+ */
+ // 1. Get results size
+ result += gn_fft_analysis_results_size (&fft_results_size, key,
+ fft_cplx_size, nfft);
+ // 2. Allocate memory for result keys and values
+ fft_rkeys = malloc (fft_results_size * sizeof (char *));
+ fft_rvalues = malloc (fft_results_size * sizeof (double));
+ // 3. Get result key sizes
+ fft_rkey_sizes = malloc (fft_results_size * sizeof (size_t));
+ result += gn_fft_analysis_results_key_sizes (
+ fft_rkey_sizes, fft_results_size, key, fft_cplx_size, nfft);
+ HANDLE_ERROR (result);
+ // 4. Allocate memory for each result key
+ for (size_t i = 0; i < fft_results_size; ++i)
+ {
+ fft_rkeys[i] = malloc (fft_rkey_sizes[i]);
}
- // 5. Execute analysis
- result += gn_fft_analysis(fft_rkeys, fft_results_size, fft_rvalues, fft_results_size,
- key, fft_cplx, fft_cplx_size, nfft, axis_type);
- HANDLE_ERROR(result);
+ // 5. Execute analysis
+ result += gn_fft_analysis (fft_rkeys, fft_results_size, fft_rvalues,
+ fft_results_size, key, fft_cplx, fft_cplx_size,
+ nfft, axis_type);
+ HANDLE_ERROR (result);
- /*
- * Fourier analysis with single result
- */
- double fsnr = 0.0;
- double a_mag_dbfs = 0.0;
- result += gn_fft_analysis_single(&fsnr, key, "fsnr", fft_cplx, fft_cplx_size, nfft, axis_type);
- result += gn_fft_analysis_single(&a_mag_dbfs, key, "A:mag_dbfs", fft_cplx, fft_cplx_size, nfft, axis_type);
- HANDLE_ERROR(result);
+ /*
+ * Fourier analysis with single result
+ */
+ double fsnr = 0.0;
+ double a_mag_dbfs = 0.0;
+ result += gn_fft_analysis_single (&fsnr, key, "fsnr", fft_cplx,
+ fft_cplx_size, nfft, axis_type);
+ result += gn_fft_analysis_single (&a_mag_dbfs, key, "A:mag_dbfs", fft_cplx,
+ fft_cplx_size, nfft, axis_type);
+ HANDLE_ERROR (result);
- /*
- * Fourier analysis with select results
- */
- const char* fft_select_rkeys[] = {"sfdr", "-3A:mag_dbc"};
- size_t fft_select_results_size = (sizeof fft_select_rkeys) / sizeof(char*);
- fft_select_rvalues = malloc(fft_select_results_size * sizeof(double));
- result = gn_fft_analysis_select(fft_select_rvalues, fft_select_results_size,
- key, fft_select_rkeys, fft_select_results_size, fft_cplx, fft_cplx_size, nfft, axis_type);
- HANDLE_ERROR(result);
+ /*
+ * Fourier analysis with select results
+ */
+ const char *fft_select_rkeys[] = { "sfdr", "-3A:mag_dbc" };
+ size_t fft_select_results_size = (sizeof fft_select_rkeys) / sizeof (char *);
+ fft_select_rvalues = malloc (fft_select_results_size * sizeof (double));
+ result = gn_fft_analysis_select (
+ fft_select_rvalues, fft_select_results_size, key, fft_select_rkeys,
+ fft_select_results_size, fft_cplx, fft_cplx_size, nfft, axis_type);
+ HANDLE_ERROR (result);
- /*
- * Carrier and MaxSpur keys (requires all results)
- */
- size_t fa_result_string_size = 0;
- result = gn_fa_result_string_size(&fa_result_string_size,
- (const char**)fft_rkeys, fft_results_size, fft_rvalues, fft_results_size, "carrierindex");
- HANDLE_ERROR(result);
- fa_carrier = malloc(fa_result_string_size);
- result = gn_fa_result_string(fa_carrier, fa_result_string_size,
- (const char**)fft_rkeys, fft_results_size, fft_rvalues, fft_results_size, "carrierindex");
- HANDLE_ERROR(result);
- result = gn_fa_result_string_size(&fa_result_string_size,
- (const char**)fft_rkeys, fft_results_size, fft_rvalues, fft_results_size, "maxspurindex");
- HANDLE_ERROR(result);
- fa_maxspur = malloc(fa_result_string_size);
- result = gn_fa_result_string(fa_maxspur, fa_result_string_size,
- (const char**)fft_rkeys, fft_results_size, fft_rvalues, fft_results_size, "maxspurindex");
- HANDLE_ERROR(result);
+ /*
+ * Carrier and MaxSpur keys (requires all results)
+ */
+ size_t fa_result_string_size = 0;
+ result = gn_fa_result_string_size (
+ &fa_result_string_size, (const char **)fft_rkeys, fft_results_size,
+ fft_rvalues, fft_results_size, "carrierindex");
+ HANDLE_ERROR (result);
+ fa_carrier = malloc (fa_result_string_size);
+ result = gn_fa_result_string (fa_carrier, fa_result_string_size,
+ (const char **)fft_rkeys, fft_results_size,
+ fft_rvalues, fft_results_size, "carrierindex");
+ HANDLE_ERROR (result);
+ result = gn_fa_result_string_size (
+ &fa_result_string_size, (const char **)fft_rkeys, fft_results_size,
+ fft_rvalues, fft_results_size, "maxspurindex");
+ HANDLE_ERROR (result);
+ fa_maxspur = malloc (fa_result_string_size);
+ result = gn_fa_result_string (fa_maxspur, fa_result_string_size,
+ (const char **)fft_rkeys, fft_results_size,
+ fft_rvalues, fft_results_size, "maxspurindex");
+ HANDLE_ERROR (result);
- /*
- * Print results
- */
- printf("\nAll Fourier Analysis Results:\n");
- for (size_t i = 0; i < fft_results_size; ++i) {
- printf("%4zu%20s%20.6f\n", i, fft_rkeys[i], fft_rvalues[i]);
+ /*
+ * Print results
+ */
+ printf ("\nAll Fourier Analysis Results:\n");
+ for (size_t i = 0; i < fft_results_size; ++i)
+ {
+ printf ("%4zu%20s%20.6f\n", i, fft_rkeys[i], fft_rvalues[i]);
}
- // gn_fa_result extracts specified result from key-value arrays
- double snr = 0.0;
- double a_freq = 0.0;
- double a_ffinal = 0.0;
- result = gn_fa_result(&snr,
- (const char**)fft_rkeys, fft_results_size, fft_rvalues, fft_results_size, "snr");
- result = gn_fa_result(&a_freq,
- (const char**)fft_rkeys, fft_results_size, fft_rvalues, fft_results_size, "A:freq");
- result = gn_fa_result(&a_ffinal,
- (const char**)fft_rkeys, fft_results_size, fft_rvalues, fft_results_size, "A:ffinal");
- HANDLE_ERROR(result);
- printf(" %s = %.3f\n", "snr", snr);
- printf(" %s = %.3f MHz\n", "A:freq", a_freq / 1e6);
- printf(" %s = %.3f MHz\n", "A:ffinal", a_ffinal / 1e6);
- printf(" %s = %s\n", "Carrier", fa_carrier);
- printf(" %s = %s\n", "MaxSpur", fa_maxspur);
+ // gn_fa_result extracts specified result from key-value arrays
+ double snr = 0.0;
+ double a_freq = 0.0;
+ double a_ffinal = 0.0;
+ result = gn_fa_result (&snr, (const char **)fft_rkeys, fft_results_size,
+ fft_rvalues, fft_results_size, "snr");
+ result = gn_fa_result (&a_freq, (const char **)fft_rkeys, fft_results_size,
+ fft_rvalues, fft_results_size, "A:freq");
+ result = gn_fa_result (&a_ffinal, (const char **)fft_rkeys, fft_results_size,
+ fft_rvalues, fft_results_size, "A:ffinal");
+ HANDLE_ERROR (result);
+ printf (" %s = %.3f\n", "snr", snr);
+ printf (" %s = %.3f MHz\n", "A:freq", a_freq / 1e6);
+ printf (" %s = %.3f MHz\n", "A:ffinal", a_ffinal / 1e6);
+ printf (" %s = %s\n", "Carrier", fa_carrier);
+ printf (" %s = %s\n", "MaxSpur", fa_maxspur);
- printf("\nSingle Fourier Analysis Results:\n");
- printf("%20s = %20.6f\n", "fsnr", fsnr);
- printf("%20s = %20.6f\n", "A::mag_dbfs", a_mag_dbfs);
+ printf ("\nSingle Fourier Analysis Results:\n");
+ printf ("%20s = %20.6f\n", "fsnr", fsnr);
+ printf ("%20s = %20.6f\n", "A::mag_dbfs", a_mag_dbfs);
- printf("\nSelect Fourier Analysis Results:\n");
- for (size_t i = 0; i < fft_select_results_size; ++i) {
- printf("%20s = %20.6f\n", fft_select_rkeys[i], fft_select_rvalues[i]);
+ printf ("\nSelect Fourier Analysis Results:\n");
+ for (size_t i = 0; i < fft_select_results_size; ++i)
+ {
+ printf ("%20s = %20.6f\n", fft_select_rkeys[i], fft_select_rvalues[i]);
}
- /*
- * Save data
- */
- if (save_data) {
- const char* fn = "fft.txt";
- FILE* fp = fopen(fn, "w");
- if (fp) {
- fft_db = malloc(nfft * sizeof(double));
- result += gn_db(fft_db, nfft, fft_cplx, fft_cplx_size);
- if (GnFreqAxisTypeDcCenter == axis_type) {
- gn_fftshift(fft_db, nfft, fft_db, nfft);
+ /*
+ * Save data
+ */
+ if (save_data)
+ {
+ const char *fn = "fft.txt";
+ FILE *fp = fopen (fn, "w");
+ if (fp)
+ {
+ fft_db = malloc (nfft * sizeof (double));
+ result += gn_db (fft_db, nfft, fft_cplx, fft_cplx_size);
+ if (GnFreqAxisTypeDcCenter == axis_type)
+ {
+ gn_fftshift (fft_db, nfft, fft_db, nfft);
}
- for (size_t i = 0; i < nfft; ++i) {
- fprintf(fp, "%.6f\n", fft_db[i]);
+ for (size_t i = 0; i < nfft; ++i)
+ {
+ fprintf (fp, "%.6f\n", fft_db[i]);
}
- fclose(fp);
- printf("\nWrote FFT magnitude data to %s\n", fn);
+ fclose (fp);
+ printf ("\nWrote FFT magnitude data to %s\n", fn);
}
- fn = "fft_axis.txt";
- fp = fopen(fn, "w");
- if (fp) {
- freq_axis = malloc(nfft * sizeof(double));
- result += gn_freq_axis(freq_axis, nfft, nfft, axis_type, fdata, axis_fmt);
- for (size_t i = 0; i < nfft; ++i) {
- fprintf(fp, "%.6f\n", freq_axis[i]);
+ fn = "fft_axis.txt";
+ fp = fopen (fn, "w");
+ if (fp)
+ {
+ freq_axis = malloc (nfft * sizeof (double));
+ result += gn_freq_axis (freq_axis, nfft, nfft, axis_type, fdata,
+ axis_fmt);
+ for (size_t i = 0; i < nfft; ++i)
+ {
+ fprintf (fp, "%.6f\n", freq_axis[i]);
}
- fclose(fp);
- printf("Wrote FFT x-axis data to %s\n", fn);
+ fclose (fp);
+ printf ("Wrote FFT x-axis data to %s\n", fn);
}
}
- error_occurred = false;
+ error_occurred = false;
cleanup:
- if (error_occurred) {
- printf("\nError occurred, freeing memory\n");
- } else {
- printf("\nFreeing memory\n");
+ if (error_occurred)
+ {
+ printf ("\nError occurred, freeing memory\n");
+ }
+ else
+ {
+ printf ("\nFreeing memory\n");
}
- free(fft_select_rvalues);
- if (fft_rkeys) {
- for (size_t i = 0; i < fft_results_size; ++i) {
- free(fft_rkeys[i]);
+ free (fft_select_rvalues);
+ if (fft_rkeys)
+ {
+ for (size_t i = 0; i < fft_results_size; ++i)
+ {
+ free (fft_rkeys[i]);
}
}
- free(fft_rkey_sizes);
- free(fft_rvalues);
- free(fft_rkeys);
- free(fa_maxspur);
- free(fa_carrier);
- free(fa_preview);
- free(freq_axis);
- free(fft_db);
- free(fft_cplx);
- free(ywf);
- free(xwf);
- free(qwfq);
- free(qwfi);
- free(awfq);
- free(awfi);
+ free (fft_rkey_sizes);
+ free (fft_rvalues);
+ free (fft_rkeys);
+ free (fa_maxspur);
+ free (fa_carrier);
+ free (fa_preview);
+ free (freq_axis);
+ free (fft_db);
+ free (fft_cplx);
+ free (ywf);
+ free (xwf);
+ free (qwfq);
+ free (qwfi);
+ free (awfq);
+ free (awfi);
- return 0;
+ return 0;
}
\ No newline at end of file
diff --git a/examples/fft_analysis_genalyzer_advanced_debug.c b/examples/fft_analysis_genalyzer_advanced_debug.c
new file mode 100644
index 0000000..7cd505c
--- /dev/null
+++ b/examples/fft_analysis_genalyzer_advanced_debug.c
@@ -0,0 +1,251 @@
+#include "../tests/cJSON.h"
+#include "../tests/test_genalyzer.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define ERROR_BUFFER_SIZE 256
+
+#define HANDLE_ERROR(x) \
+ do \
+ { \
+ if (0 != x) \
+ { \
+ gn_error_string (error_buffer, ERROR_BUFFER_SIZE); \
+ printf ("%s\n", error_buffer); \
+ goto cleanup; \
+ } \
+ } \
+ while (0)
+
+int
+main (int argc, char *argv[])
+{
+ bool save_data = false;
+ if (1 < argc)
+ {
+ save_data = !((bool)strcmp (argv[1], "--save-data"));
+ }
+
+ /*
+ * Setup
+ */
+ gn_set_string_termination (true);
+ char error_buffer[ERROR_BUFFER_SIZE];
+ bool error_occurred = true;
+ int result = 0;
+
+ size_t navg = 1; // FFT averaging
+ size_t nfft = 32768; // FFT size
+ double fs = 3e6; // sample rate
+ double fdata = fs / 1; // data rate
+ double fshift = 0e6; // shift frequency
+ double fsr = 2.0; // full-scale range
+ double ampl_dbfs = -1.0; // input amplitude (dBFS)
+ double freq = 100000; // input frequency (Hz)
+ double phase = 0.0; // input phase (rad)
+ double td = 0.0; // input delay (s)
+ double tj = 0.0; // RMS aperature uncertainty (s)
+ double qpe = 0.0; // (atan(1.0) * 2) * 1e-5; // quadrature phase error
+ // (pi/2 * x)
+ double poco[]
+ = { 0.0, 1.0, 0.0, 0.003 }; // distortion polynomial coefficients
+ int qres = 12; // quantizer resolution
+ double qnoise_dbfs = -63.0; // quantizer noise (dBFS)
+ GnCodeFormat code_fmt = GnCodeFormatTwosComplement;
+ GnFreqAxisFormat axis_fmt = GnFreqAxisFormatFreq;
+ GnFreqAxisType axis_type = GnFreqAxisTypeDcCenter;
+ GnWindow window = GnWindowNoWindow;
+
+ int dsr = (int)(fs / fdata);
+ size_t npts = navg * nfft * dsr;
+ double ampl = (fsr / 2) * pow (10.0, ampl_dbfs / 20.0);
+ double qnoise = pow (10.0, qnoise_dbfs / 20.0);
+ int ssb_fund = 4;
+ int ssb_rest = 3;
+ const char *test_filename
+ = "../tests/test_vectors/test_Pluto_DDS_data_1658159639196.json";
+
+ /*
+ * Pointers for allocated memory
+ */
+ double *awfi = NULL; // in-phase analog waveform
+ double *awfq = NULL; // quadrature analog waveform
+ int16_t *qwfi = NULL; // in-phase quantized waveform
+ int16_t *qwfq = NULL; // quadrature quantized waveform
+ int16_t *xwf = NULL; // frequency-shifted waveform
+ int16_t *ywf = NULL; // downsampled waveform
+ double *fft_cplx = NULL; // FFT complex data
+ double *fft_db = NULL; // FFT magnitude data
+ double *freq_axis = NULL; // frequency axis
+ char *fa_preview = NULL; // FFT analysis configuration preview
+ char *fa_carrier = NULL; // FFT analysis carrier key
+ char *fa_maxspur = NULL; // FFT analysis maxspur key
+ char **fft_rkeys = NULL; // FFT analysis keys
+ double *fft_rvalues = NULL; // FFT analysis values
+ size_t *fft_rkey_sizes = NULL; // FFT analysis key sizes
+ double *fft_select_rvalues = NULL; // FFT analysis select values
+
+ size_t fft_results_size = 0;
+
+ /*
+ * Allocate memory
+ */
+ size_t xwf_size = npts * 2;
+ size_t ywf_size = 0;
+ size_t fft_cplx_size = nfft * 2;
+ result += gn_downsample_size (&ywf_size, xwf_size, dsr, true);
+ HANDLE_ERROR (result);
+ awfi = malloc (npts * sizeof (double));
+ awfq = malloc (npts * sizeof (double));
+ qwfi = malloc (npts * sizeof (int16_t));
+ qwfq = malloc (npts * sizeof (int16_t));
+ xwf = malloc (xwf_size * sizeof (int16_t));
+ ywf = malloc (ywf_size * sizeof (int16_t));
+ fft_cplx = malloc (fft_cplx_size * sizeof (double));
+
+ /*
+ * Signal generation and processing
+ */
+ if (GnWindowNoWindow == window)
+ {
+ result += gn_coherent (&freq, nfft, fdata, freq);
+ HANDLE_ERROR (result);
+ double fbin = fdata / nfft;
+ fshift = round (fshift / fbin) * fbin;
+ ssb_fund = 50;
+ ssb_rest = 3;
+ }
+
+ /*
+ result += gn_cos(awfi, npts, fs, ampl, freq, phase, td, tj);
+ result += gn_sin(awfq, npts, fs, ampl, freq, phase + qpe, td, tj);
+ result += gn_polyval(awfi, npts, awfi, npts, poco, (sizeof poco) /
+ sizeof(double)); result += gn_polyval(awfq, npts, awfq, npts, poco, (sizeof
+ poco) / sizeof(double)); result += gn_quantize16(qwfi, npts, awfi, npts, fsr,
+ qres, qnoise, code_fmt); result += gn_quantize16(qwfq, npts, awfq, npts, fsr,
+ qres, qnoise, code_fmt);
+ */
+ result += read_array_from_json_file (test_filename, "test_vec_i", qwfi,
+ INT16, npts);
+ result += read_array_from_json_file (test_filename, "test_vec_q", qwfq,
+ INT16, npts);
+ // result += read_array_from_json_file_int32(test_filename, "test_vec_i",
+ // qwfi, npts); result += read_array_from_json_file_int32(test_filename,
+ // "test_vec_q", qwfq, npts); result += gn_fshift16(xwf, xwf_size, qwfi,
+ // npts, qwfq, npts, qres, fs, fshift, code_fmt); result +=
+ // gn_downsample16(ywf, ywf_size, xwf, xwf_size, dsr, true);
+ /*
+ printf("qwf---------\n");
+ for (int ii = 0; ii < 10; ii++)
+ printf("%d\t%d\n", qwfi[ii], qwfq[ii]);
+ */
+ ProfilerStart ("profile.log");
+ result += gn_fft16 (fft_cplx, fft_cplx_size, qwfi, npts, qwfq, npts, qres,
+ navg, nfft, window, code_fmt);
+ /*
+ printf("xwf---------\n");
+ for (int ii = 0; ii < 10; ii++)
+ printf("%d\n", xwf[ii]);
+ */
+ // result += gn_fft16(fft_cplx, fft_cplx_size, xwf, 2*npts, NULL, 0, qres,
+ // navg, nfft, window, code_fmt); return 0;
+
+ /*
+ FILE *fp1 = fopen("fft_data_debug.txt", "w");
+ for (int i =0; i < fft_cplx_size; i++)
+ fprintf(fp1, "%f\n", fft_cplx[i]);
+ fclose(fp1);
+ HANDLE_ERROR(result);
+ */
+
+ /*
+ * Fourier analysis configuration
+ */
+ char *key = "fa";
+ result += gn_fa_create (key);
+ result += gn_fa_fixed_tone (key, "A", GnFACompTagSignal, freq, ssb_fund);
+ result += gn_fa_hd (key, 3);
+ result += gn_fa_ssb (key, GnFASsbDefault, ssb_rest);
+ result += gn_fa_ssb (key, GnFASsbDC, -1);
+ result += gn_fa_ssb (key, GnFASsbSignal, -1);
+ result += gn_fa_ssb (key, GnFASsbWO, -1);
+ result += gn_fa_fsample (key, fs);
+ result += gn_fa_fdata (key, fdata);
+ result += gn_fa_fshift (key, fshift);
+ result += gn_fa_conv_offset (key, 0.0 != fshift);
+ HANDLE_ERROR (result);
+ size_t fa_preview_size = 0;
+ result += gn_fa_preview_size (&fa_preview_size, key, true);
+ fa_preview = malloc (fa_preview_size);
+ result += gn_fa_preview (fa_preview, fa_preview_size, key, true);
+ HANDLE_ERROR (result);
+ // printf("%s\n", fa_preview);
+
+ /*
+ * Fourier analysis with all results
+ */
+ // 1. Get results size
+ result += gn_fft_analysis_results_size (&fft_results_size, key,
+ fft_cplx_size, nfft);
+ // 2. Allocate memory for result keys and values
+ fft_rkeys = malloc (fft_results_size * sizeof (char *));
+ fft_rvalues = malloc (fft_results_size * sizeof (double));
+ // 3. Get result key sizes
+ fft_rkey_sizes = malloc (fft_results_size * sizeof (size_t));
+ result += gn_fft_analysis_results_key_sizes (
+ fft_rkey_sizes, fft_results_size, key, fft_cplx_size, nfft);
+ HANDLE_ERROR (result);
+ // 4. Allocate memory for each result key
+ for (size_t i = 0; i < fft_results_size; ++i)
+ {
+ fft_rkeys[i] = malloc (fft_rkey_sizes[i]);
+ }
+ // 5. Execute analysis
+ result += gn_fft_analysis (fft_rkeys, fft_results_size, fft_rvalues,
+ fft_results_size, key, fft_cplx, fft_cplx_size,
+ nfft, axis_type);
+ HANDLE_ERROR (result);
+ // return 0;
+ ProfilerStop ();
+
+cleanup:
+ if (error_occurred)
+ {
+ printf ("\nError occurred, freeing memory\n");
+ }
+ else
+ {
+ printf ("\nFreeing memory\n");
+ }
+ free (fft_select_rvalues);
+ if (fft_rkeys)
+ {
+ for (size_t i = 0; i < fft_results_size; ++i)
+ {
+ free (fft_rkeys[i]);
+ }
+ }
+ free (fft_rkey_sizes);
+ free (fft_rvalues);
+ free (fft_rkeys);
+ free (fa_maxspur);
+ free (fa_carrier);
+ free (fa_preview);
+ free (freq_axis);
+ free (fft_db);
+ free (fft_cplx);
+ free (ywf);
+ free (xwf);
+ // free(qwfq);
+ // free(qwfi);
+ // free(awfq);
+ // free(awfi);
+
+ return 0;
+}
\ No newline at end of file
diff --git a/examples/real_analysis_genalyzer_advanced.c b/examples/real_analysis_genalyzer_advanced.c
index 74c0c1f..6644ef1 100644
--- a/examples/real_analysis_genalyzer_advanced.c
+++ b/examples/real_analysis_genalyzer_advanced.c
@@ -1,395 +1,457 @@
-#include
#include
+#include
-#include
#include
+#include
#include
#include
#include
#define ERROR_BUFFER_SIZE 256
-#define HANDLE_ERROR(x) \
- do { \
- if (0 != x) { \
- gn_error_string(error_buffer, ERROR_BUFFER_SIZE); \
- printf("%s\n", error_buffer); \
- goto cleanup; \
- } \
- } while (0)
+#define HANDLE_ERROR(x) \
+ do \
+ { \
+ if (0 != x) \
+ { \
+ gn_error_string (error_buffer, ERROR_BUFFER_SIZE); \
+ printf ("%s\n", error_buffer); \
+ goto cleanup; \
+ } \
+ } \
+ while (0)
-int main(int argc, char* argv[])
+int
+main (int argc, char *argv[])
{
- bool save_data = false;
- if (1 < argc) {
- save_data = !((bool) strcmp(argv[1], "--save-data"));
+ bool save_data = false;
+ if (1 < argc)
+ {
+ save_data = !((bool)strcmp (argv[1], "--save-data"));
}
- /*
- * Setup
- */
- gn_set_string_termination(true);
- char error_buffer[ERROR_BUFFER_SIZE];
- bool error_occurred = true;
- int result = 0;
+ /*
+ * Setup
+ */
+ gn_set_string_termination (true);
+ char error_buffer[ERROR_BUFFER_SIZE];
+ bool error_occurred = true;
+ int result = 0;
- size_t navg = 2; // FFT averaging
- size_t nfft = 1024 * 256; // FFT size
- double fs = 1e9; // sample rate
- double fsr = 2.0; // full-scale range
- double ampl_dbfs = -1.0; // input amplitude (dBFS)
- double freq = 10e6; // input frequency (Hz)
- double phase = 0.110; // input phase (rad)
- double td = 0.0; // input delay (s)
- double tj = 0.0; // RMS aperature uncertainty (s)
- double poco[] = {0.0, 1.0, 0.0, 0.003}; // distortion polynomial coefficients
- int qres = 12; // quantizer resolution
- double qnoise_dbfs = -63.0; // quantizer noise (dBFS)
- GnCodeFormat code_fmt = GnCodeFormatTwosComplement;
- GnDnlSignal sig_type = GnDnlSignalTone;
- GnInlLineFit inl_fit = GnInlLineFitBestFit;
- GnRfftScale rfft_scale = GnRfftScaleDbfsSin;
- GnWindow window = GnWindowNoWindow;
+ size_t navg = 2; // FFT averaging
+ size_t nfft = 1024 * 256; // FFT size
+ double fs = 1e9; // sample rate
+ double fsr = 2.0; // full-scale range
+ double ampl_dbfs = -1.0; // input amplitude (dBFS)
+ double freq = 10e6; // input frequency (Hz)
+ double phase = 0.110; // input phase (rad)
+ double td = 0.0; // input delay (s)
+ double tj = 0.0; // RMS aperature uncertainty (s)
+ double poco[]
+ = { 0.0, 1.0, 0.0, 0.003 }; // distortion polynomial coefficients
+ int qres = 12; // quantizer resolution
+ double qnoise_dbfs = -63.0; // quantizer noise (dBFS)
+ GnCodeFormat code_fmt = GnCodeFormatTwosComplement;
+ GnDnlSignal sig_type = GnDnlSignalTone;
+ GnInlLineFit inl_fit = GnInlLineFitBestFit;
+ GnRfftScale rfft_scale = GnRfftScaleDbfsSin;
+ GnWindow window = GnWindowNoWindow;
- size_t npts = navg * nfft;
- double ampl = (fsr / 2) * pow(10.0, ampl_dbfs / 20.0);
- double qnoise = pow(10.0, qnoise_dbfs / 20.0);
- int ssb_fund = 4;
- int ssb_rest = 3;
+ size_t npts = navg * nfft;
+ double ampl = (fsr / 2) * pow (10.0, ampl_dbfs / 20.0);
+ double qnoise = pow (10.0, qnoise_dbfs / 20.0);
+ int ssb_fund = 4;
+ int ssb_rest = 3;
- /*
- * Pointers for allocated memory
- */
- double* awf = NULL; // analog waveform
- int16_t* qwf = NULL; // quantized waveform
- uint64_t* hist = NULL; // histogram data
- double* dnl = NULL; // DNL data
- double* inl = NULL; // INL data
- double* code_axis = NULL; // code density axis
- double* fft_cplx = NULL; // FFT complex data
- double* fft_db = NULL; // FFT magnitude data
- double* freq_axis = NULL; // frequency axis
- char* fa_preview = NULL; // FFT configuration preview
- char** wf_rkeys = NULL; // waveform analysis keys
- double* wf_rvalues = NULL; // waveform analysis values
- size_t* wf_rkey_sizes = NULL; // waveform analysis key sizes
- char** hist_rkeys = NULL; // histogram analysis keys
- double* hist_rvalues = NULL; // histogram analysis values
- size_t* hist_rkey_sizes = NULL; // histogram analysis key sizes
- char** dnl_rkeys = NULL; // DNL analysis keys
- double* dnl_rvalues = NULL; // DNL analysis values
- size_t* dnl_rkey_sizes = NULL; // DNL analysis key sizes
- char** inl_rkeys = NULL; // INL analysis keys
- double* inl_rvalues = NULL; // INL analysis values
- size_t* inl_rkey_sizes = NULL; // INL analysis key sizes
- char** fft_rkeys = NULL; // FFT analysis keys
- double* fft_rvalues = NULL; // FFT analysis values
- size_t* fft_rkey_sizes = NULL; // FFT analysis key sizes
+ /*
+ * Pointers for allocated memory
+ */
+ double *awf = NULL; // analog waveform
+ int16_t *qwf = NULL; // quantized waveform
+ uint64_t *hist = NULL; // histogram data
+ double *dnl = NULL; // DNL data
+ double *inl = NULL; // INL data
+ double *code_axis = NULL; // code density axis
+ double *fft_cplx = NULL; // FFT complex data
+ double *fft_db = NULL; // FFT magnitude data
+ double *freq_axis = NULL; // frequency axis
+ char *fa_preview = NULL; // FFT configuration preview
+ char **wf_rkeys = NULL; // waveform analysis keys
+ double *wf_rvalues = NULL; // waveform analysis values
+ size_t *wf_rkey_sizes = NULL; // waveform analysis key sizes
+ char **hist_rkeys = NULL; // histogram analysis keys
+ double *hist_rvalues = NULL; // histogram analysis values
+ size_t *hist_rkey_sizes = NULL; // histogram analysis key sizes
+ char **dnl_rkeys = NULL; // DNL analysis keys
+ double *dnl_rvalues = NULL; // DNL analysis values
+ size_t *dnl_rkey_sizes = NULL; // DNL analysis key sizes
+ char **inl_rkeys = NULL; // INL analysis keys
+ double *inl_rvalues = NULL; // INL analysis values
+ size_t *inl_rkey_sizes = NULL; // INL analysis key sizes
+ char **fft_rkeys = NULL; // FFT analysis keys
+ double *fft_rvalues = NULL; // FFT analysis values
+ size_t *fft_rkey_sizes = NULL; // FFT analysis key sizes
- size_t wf_results_size = 0;
- size_t hist_results_size = 0;
- size_t dnl_results_size = 0;
- size_t inl_results_size = 0;
- size_t fft_results_size = 0;
+ size_t wf_results_size = 0;
+ size_t hist_results_size = 0;
+ size_t dnl_results_size = 0;
+ size_t inl_results_size = 0;
+ size_t fft_results_size = 0;
- /*
- * Allocate memory
- */
- size_t cd_size = 0; // cd = code density
- size_t fft_cplx_size = 0;
- result += gn_code_density_size(&cd_size, qres, code_fmt);
- result += gn_rfft_size(&fft_cplx_size, npts, navg, nfft);
- HANDLE_ERROR(result);
- awf = malloc(npts * sizeof(double));
- qwf = malloc(npts * sizeof(int16_t));
- hist = malloc(cd_size * sizeof(uint64_t));
- dnl = malloc(cd_size * sizeof(double));
- inl = malloc(cd_size * sizeof(double));
- fft_cplx = malloc(fft_cplx_size * sizeof(double));
+ /*
+ * Allocate memory
+ */
+ size_t cd_size = 0; // cd = code density
+ size_t fft_cplx_size = 0;
+ result += gn_code_density_size (&cd_size, qres, code_fmt);
+ result += gn_rfft_size (&fft_cplx_size, npts, navg, nfft);
+ HANDLE_ERROR (result);
+ awf = malloc (npts * sizeof (double));
+ qwf = malloc (npts * sizeof (int16_t));
+ hist = malloc (cd_size * sizeof (uint64_t));
+ dnl = malloc (cd_size * sizeof (double));
+ inl = malloc (cd_size * sizeof (double));
+ fft_cplx = malloc (fft_cplx_size * sizeof (double));
- /*
- * Signal generation and processing
- */
- if (GnWindowNoWindow == window) {
- result += gn_coherent(&freq, nfft, fs, freq);
- HANDLE_ERROR(result);
- ssb_fund = 0;
- ssb_rest = 0;
+ /*
+ * Signal generation and processing
+ */
+ if (GnWindowNoWindow == window)
+ {
+ result += gn_coherent (&freq, nfft, fs, freq);
+ HANDLE_ERROR (result);
+ ssb_fund = 0;
+ ssb_rest = 0;
}
- result += gn_cos(awf, npts, fs, ampl, freq, phase, td, tj);
- result += gn_polyval(awf, npts, awf, npts, poco, (sizeof poco) / sizeof(double));
- result += gn_quantize16(qwf, npts, awf, npts, fsr, qres, qnoise, code_fmt);
- result += gn_hist16(hist, cd_size, qwf, npts, qres, code_fmt, false);
- result += gn_dnl(dnl, cd_size, hist, cd_size, sig_type);
- result += gn_inl(inl, cd_size, dnl, cd_size, inl_fit);
- result += gn_rfft16(fft_cplx, fft_cplx_size, qwf, npts, qres, navg, nfft, window, code_fmt, rfft_scale);
- HANDLE_ERROR(result);
+ result += gn_cos (awf, npts, fs, ampl, freq, phase, td, tj);
+ result += gn_polyval (awf, npts, awf, npts, poco,
+ (sizeof poco) / sizeof (double));
+ result += gn_quantize16 (qwf, npts, awf, npts, fsr, qres, qnoise, code_fmt);
+ result += gn_hist16 (hist, cd_size, qwf, npts, qres, code_fmt, false);
+ result += gn_dnl (dnl, cd_size, hist, cd_size, sig_type);
+ result += gn_inl (inl, cd_size, dnl, cd_size, inl_fit);
+ result += gn_rfft16 (fft_cplx, fft_cplx_size, qwf, npts, qres, navg, nfft,
+ window, code_fmt, rfft_scale);
+ HANDLE_ERROR (result);
- /*
- * Fourier analysis configuration
- */
- char* key = "fa";
- result += gn_fa_create(key);
- result += gn_fa_fixed_tone(key, "A", GnFACompTagSignal, freq, ssb_fund);
- result += gn_fa_hd(key, 3);
- result += gn_fa_ssb(key, GnFASsbDefault, ssb_rest);
- result += gn_fa_ssb(key, GnFASsbDC, -1);
- result += gn_fa_ssb(key, GnFASsbSignal, -1);
- result += gn_fa_ssb(key, GnFASsbWO, -1);
- result += gn_fa_fsample(key, fs);
- HANDLE_ERROR(result);
- size_t fa_preview_size = 0;
- result += gn_fa_preview_size(&fa_preview_size, key, false);
- fa_preview = malloc(fa_preview_size);
- result += gn_fa_preview(fa_preview, fa_preview_size, key, false);
- HANDLE_ERROR(result);
- printf("%s\n", fa_preview);
+ /*
+ * Fourier analysis configuration
+ */
+ char *key = "fa";
+ result += gn_fa_create (key);
+ result += gn_fa_fixed_tone (key, "A", GnFACompTagSignal, freq, ssb_fund);
+ result += gn_fa_hd (key, 3);
+ result += gn_fa_ssb (key, GnFASsbDefault, ssb_rest);
+ result += gn_fa_ssb (key, GnFASsbDC, -1);
+ result += gn_fa_ssb (key, GnFASsbSignal, -1);
+ result += gn_fa_ssb (key, GnFASsbWO, -1);
+ result += gn_fa_fsample (key, fs);
+ HANDLE_ERROR (result);
+ size_t fa_preview_size = 0;
+ result += gn_fa_preview_size (&fa_preview_size, key, false);
+ fa_preview = malloc (fa_preview_size);
+ result += gn_fa_preview (fa_preview, fa_preview_size, key, false);
+ HANDLE_ERROR (result);
+ printf ("%s\n", fa_preview);
- // To do an analysis:
- // 1. Get results size
- // 2. Allocate memory for result keys and values
- // 3. Get result key sizes
- // 4. Allocate memory for each result key
- // 5. Execute analysis
+ // To do an analysis:
+ // 1. Get results size
+ // 2. Allocate memory for result keys and values
+ // 3. Get result key sizes
+ // 4. Allocate memory for each result key
+ // 5. Execute analysis
- /*
- * Waveform analysis
- */
- // 1.
- result += gn_analysis_results_size(&wf_results_size, GnAnalysisTypeWaveform);
- // 2.
- wf_rkeys = malloc(wf_results_size * sizeof(char*));
- wf_rvalues = malloc(wf_results_size * sizeof(double));
- // 3.
- wf_rkey_sizes = malloc(wf_results_size * sizeof(size_t));
- result += gn_analysis_results_key_sizes(wf_rkey_sizes, wf_results_size, GnAnalysisTypeWaveform);
- HANDLE_ERROR(result);
- // 4.
- for (size_t i = 0; i < wf_results_size; ++i) {
- wf_rkeys[i] = malloc(wf_rkey_sizes[i]);
+ /*
+ * Waveform analysis
+ */
+ // 1.
+ result
+ += gn_analysis_results_size (&wf_results_size, GnAnalysisTypeWaveform);
+ // 2.
+ wf_rkeys = malloc (wf_results_size * sizeof (char *));
+ wf_rvalues = malloc (wf_results_size * sizeof (double));
+ // 3.
+ wf_rkey_sizes = malloc (wf_results_size * sizeof (size_t));
+ result += gn_analysis_results_key_sizes (wf_rkey_sizes, wf_results_size,
+ GnAnalysisTypeWaveform);
+ HANDLE_ERROR (result);
+ // 4.
+ for (size_t i = 0; i < wf_results_size; ++i)
+ {
+ wf_rkeys[i] = malloc (wf_rkey_sizes[i]);
}
- // 5.
- result += gn_wf_analysis16(wf_rkeys, wf_results_size, wf_rvalues, wf_results_size, qwf, npts);
- HANDLE_ERROR(result);
+ // 5.
+ result += gn_wf_analysis16 (wf_rkeys, wf_results_size, wf_rvalues,
+ wf_results_size, qwf, npts);
+ HANDLE_ERROR (result);
- /*
- * Histogram analysis
- */
- result += gn_analysis_results_size(&hist_results_size, GnAnalysisTypeHistogram);
- hist_rkeys = malloc(hist_results_size * sizeof(char*));
- hist_rvalues = malloc(hist_results_size * sizeof(double));
- hist_rkey_sizes = malloc(hist_results_size * sizeof(size_t));
- result += gn_analysis_results_key_sizes(hist_rkey_sizes, hist_results_size, GnAnalysisTypeHistogram);
- HANDLE_ERROR(result);
- for (size_t i = 0; i < hist_results_size; ++i) {
- hist_rkeys[i] = malloc(hist_rkey_sizes[i]);
+ /*
+ * Histogram analysis
+ */
+ result += gn_analysis_results_size (&hist_results_size,
+ GnAnalysisTypeHistogram);
+ hist_rkeys = malloc (hist_results_size * sizeof (char *));
+ hist_rvalues = malloc (hist_results_size * sizeof (double));
+ hist_rkey_sizes = malloc (hist_results_size * sizeof (size_t));
+ result += gn_analysis_results_key_sizes (hist_rkey_sizes, hist_results_size,
+ GnAnalysisTypeHistogram);
+ HANDLE_ERROR (result);
+ for (size_t i = 0; i < hist_results_size; ++i)
+ {
+ hist_rkeys[i] = malloc (hist_rkey_sizes[i]);
}
- result += gn_hist_analysis(hist_rkeys, hist_results_size, hist_rvalues, hist_results_size, hist, cd_size);
- HANDLE_ERROR(result);
+ result += gn_hist_analysis (hist_rkeys, hist_results_size, hist_rvalues,
+ hist_results_size, hist, cd_size);
+ HANDLE_ERROR (result);
- /*
- * DNL analysis
- */
- result += gn_analysis_results_size(&dnl_results_size, GnAnalysisTypeDNL);
- dnl_rkeys = malloc(dnl_results_size * sizeof(char*));
- dnl_rvalues = malloc(dnl_results_size * sizeof(double));
- dnl_rkey_sizes = malloc(dnl_results_size * sizeof(size_t));
- result += gn_analysis_results_key_sizes(dnl_rkey_sizes, dnl_results_size, GnAnalysisTypeDNL);
- HANDLE_ERROR(result);
- for (size_t i = 0; i < dnl_results_size; ++i) {
- dnl_rkeys[i] = malloc(dnl_rkey_sizes[i]);
+ /*
+ * DNL analysis
+ */
+ result += gn_analysis_results_size (&dnl_results_size, GnAnalysisTypeDNL);
+ dnl_rkeys = malloc (dnl_results_size * sizeof (char *));
+ dnl_rvalues = malloc (dnl_results_size * sizeof (double));
+ dnl_rkey_sizes = malloc (dnl_results_size * sizeof (size_t));
+ result += gn_analysis_results_key_sizes (dnl_rkey_sizes, dnl_results_size,
+ GnAnalysisTypeDNL);
+ HANDLE_ERROR (result);
+ for (size_t i = 0; i < dnl_results_size; ++i)
+ {
+ dnl_rkeys[i] = malloc (dnl_rkey_sizes[i]);
}
- result += gn_dnl_analysis(dnl_rkeys, dnl_results_size, dnl_rvalues, dnl_results_size, dnl, cd_size);
- HANDLE_ERROR(result);
+ result += gn_dnl_analysis (dnl_rkeys, dnl_results_size, dnl_rvalues,
+ dnl_results_size, dnl, cd_size);
+ HANDLE_ERROR (result);
- /*
- * INL analysis
- */
- result += gn_analysis_results_size(&inl_results_size, GnAnalysisTypeINL);
- inl_rkeys = malloc(inl_results_size * sizeof(char*));
- inl_rvalues = malloc(inl_results_size * sizeof(double));
- inl_rkey_sizes = malloc(inl_results_size * sizeof(size_t));
- result += gn_analysis_results_key_sizes(inl_rkey_sizes, inl_results_size, GnAnalysisTypeINL);
- HANDLE_ERROR(result);
- for (size_t i = 0; i < inl_results_size; ++i) {
- inl_rkeys[i] = malloc(inl_rkey_sizes[i]);
+ /*
+ * INL analysis
+ */
+ result += gn_analysis_results_size (&inl_results_size, GnAnalysisTypeINL);
+ inl_rkeys = malloc (inl_results_size * sizeof (char *));
+ inl_rvalues = malloc (inl_results_size * sizeof (double));
+ inl_rkey_sizes = malloc (inl_results_size * sizeof (size_t));
+ result += gn_analysis_results_key_sizes (inl_rkey_sizes, inl_results_size,
+ GnAnalysisTypeINL);
+ HANDLE_ERROR (result);
+ for (size_t i = 0; i < inl_results_size; ++i)
+ {
+ inl_rkeys[i] = malloc (inl_rkey_sizes[i]);
}
- result += gn_inl_analysis(inl_rkeys, inl_results_size, inl_rvalues, inl_results_size, inl, cd_size);
- HANDLE_ERROR(result);
+ result += gn_inl_analysis (inl_rkeys, inl_results_size, inl_rvalues,
+ inl_results_size, inl, cd_size);
+ HANDLE_ERROR (result);
- /*
- * Fourier analysis
- */
- result += gn_fft_analysis_results_size(&fft_results_size, key, fft_cplx_size, nfft);
- HANDLE_ERROR(result);
- fft_rkeys = malloc(fft_results_size * sizeof(char*));
- fft_rvalues = malloc(fft_results_size * sizeof(double));
- fft_rkey_sizes = malloc(fft_results_size * sizeof(size_t));
- result += gn_fft_analysis_results_key_sizes(fft_rkey_sizes, fft_results_size, key, fft_cplx_size, nfft);
- HANDLE_ERROR(result);
- for (size_t i = 0; i < fft_results_size; ++i) {
- fft_rkeys[i] = malloc(fft_rkey_sizes[i]);
+ /*
+ * Fourier analysis
+ */
+ result += gn_fft_analysis_results_size (&fft_results_size, key,
+ fft_cplx_size, nfft);
+ HANDLE_ERROR (result);
+ fft_rkeys = malloc (fft_results_size * sizeof (char *));
+ fft_rvalues = malloc (fft_results_size * sizeof (double));
+ fft_rkey_sizes = malloc (fft_results_size * sizeof (size_t));
+ result += gn_fft_analysis_results_key_sizes (
+ fft_rkey_sizes, fft_results_size, key, fft_cplx_size, nfft);
+ HANDLE_ERROR (result);
+ for (size_t i = 0; i < fft_results_size; ++i)
+ {
+ fft_rkeys[i] = malloc (fft_rkey_sizes[i]);
}
- result += gn_fft_analysis(fft_rkeys, fft_results_size, fft_rvalues, fft_results_size,
- key, fft_cplx, fft_cplx_size, nfft, GnFreqAxisTypeReal);
- HANDLE_ERROR(result);
+ result += gn_fft_analysis (fft_rkeys, fft_results_size, fft_rvalues,
+ fft_results_size, key, fft_cplx, fft_cplx_size,
+ nfft, GnFreqAxisTypeReal);
+ HANDLE_ERROR (result);
- /*
- * Print results
- */
- printf("\nWaveform Analysis Results:\n");
- for (size_t i = 0; i < wf_results_size; ++i) {
- printf("%4zu%16s%16.6f\n", i, wf_rkeys[i], wf_rvalues[i]);
+ /*
+ * Print results
+ */
+ printf ("\nWaveform Analysis Results:\n");
+ for (size_t i = 0; i < wf_results_size; ++i)
+ {
+ printf ("%4zu%16s%16.6f\n", i, wf_rkeys[i], wf_rvalues[i]);
}
- printf("\nHistogram Analysis Results:\n");
- for (size_t i = 0; i < hist_results_size; ++i) {
- printf("%4zu%16s%16.6f\n", i, hist_rkeys[i], hist_rvalues[i]);
+ printf ("\nHistogram Analysis Results:\n");
+ for (size_t i = 0; i < hist_results_size; ++i)
+ {
+ printf ("%4zu%16s%16.6f\n", i, hist_rkeys[i], hist_rvalues[i]);
}
- printf("\nDNL Analysis Results:\n");
- for (size_t i = 0; i < dnl_results_size; ++i) {
- printf("%4zu%16s%16.6f\n", i, dnl_rkeys[i], dnl_rvalues[i]);
+ printf ("\nDNL Analysis Results:\n");
+ for (size_t i = 0; i < dnl_results_size; ++i)
+ {
+ printf ("%4zu%16s%16.6f\n", i, dnl_rkeys[i], dnl_rvalues[i]);
}
- printf("\nINL Analysis Results:\n");
- for (size_t i = 0; i < inl_results_size; ++i) {
- printf("%4zu%16s%16.6f\n", i, inl_rkeys[i], inl_rvalues[i]);
+ printf ("\nINL Analysis Results:\n");
+ for (size_t i = 0; i < inl_results_size; ++i)
+ {
+ printf ("%4zu%16s%16.6f\n", i, inl_rkeys[i], inl_rvalues[i]);
}
- printf("\nFourier Analysis Results:\n");
- for (size_t i = 0; i < fft_results_size; ++i) {
- printf("%4zu%20s%20.6f\n", i, fft_rkeys[i], fft_rvalues[i]);
+ printf ("\nFourier Analysis Results:\n");
+ for (size_t i = 0; i < fft_results_size; ++i)
+ {
+ printf ("%4zu%20s%20.6f\n", i, fft_rkeys[i], fft_rvalues[i]);
}
- /*
- * Save data
- */
- if (save_data) {
- const char* fn = "qwf.txt";
- FILE* fp = fopen(fn, "w");
- if (fp) {
- for (size_t i = 0; i < npts; ++i) {
- fprintf(fp, "%d\n", qwf[i]);
+ /*
+ * Save data
+ */
+ if (save_data)
+ {
+ const char *fn = "qwf.txt";
+ FILE *fp = fopen (fn, "w");
+ if (fp)
+ {
+ for (size_t i = 0; i < npts; ++i)
+ {
+ fprintf (fp, "%d\n", qwf[i]);
}
- fclose(fp);
- printf("\nWrote quantized waveform data to %s\n", fn);
+ fclose (fp);
+ printf ("\nWrote quantized waveform data to %s\n", fn);
}
- fn = "hist.txt";
- fp = fopen(fn, "w");
- if (fp) {
- for (size_t i = 0; i < cd_size; ++i) {
- fprintf(fp, "%zu\n", hist[i]);
+ fn = "hist.txt";
+ fp = fopen (fn, "w");
+ if (fp)
+ {
+ for (size_t i = 0; i < cd_size; ++i)
+ {
+ fprintf (fp, "%zu\n", hist[i]);
}
- fclose(fp);
- printf("Wrote histogram data to %s\n", fn);
+ fclose (fp);
+ printf ("Wrote histogram data to %s\n", fn);
}
- fn = "dnl.txt";
- fp = fopen(fn, "w");
- if (fp) {
- for (size_t i = 0; i < cd_size; ++i) {
- fprintf(fp, "%.9f\n", dnl[i]);
+ fn = "dnl.txt";
+ fp = fopen (fn, "w");
+ if (fp)
+ {
+ for (size_t i = 0; i < cd_size; ++i)
+ {
+ fprintf (fp, "%.9f\n", dnl[i]);
}
- fclose(fp);
- printf("Wrote DNL data to %s\n", fn);
+ fclose (fp);
+ printf ("Wrote DNL data to %s\n", fn);
}
- fn = "inl.txt";
- fp = fopen(fn, "w");
- if (fp) {
- for (size_t i = 0; i < cd_size; ++i) {
- fprintf(fp, "%.9f\n", inl[i]);
+ fn = "inl.txt";
+ fp = fopen (fn, "w");
+ if (fp)
+ {
+ for (size_t i = 0; i < cd_size; ++i)
+ {
+ fprintf (fp, "%.9f\n", inl[i]);
}
- fclose(fp);
- printf("Wrote INL data to %s\n", fn);
+ fclose (fp);
+ printf ("Wrote INL data to %s\n", fn);
}
- fn = "code_axis.txt";
- fp = fopen(fn, "w");
- if (fp) {
- code_axis = malloc(cd_size * sizeof(double));
- result += gn_code_axis(code_axis, cd_size, qres, code_fmt);
- for (size_t i = 0; i < cd_size; ++i) {
- fprintf(fp, "%.0f\n", code_axis[i]);
+ fn = "code_axis.txt";
+ fp = fopen (fn, "w");
+ if (fp)
+ {
+ code_axis = malloc (cd_size * sizeof (double));
+ result += gn_code_axis (code_axis, cd_size, qres, code_fmt);
+ for (size_t i = 0; i < cd_size; ++i)
+ {
+ fprintf (fp, "%.0f\n", code_axis[i]);
}
- fclose(fp);
- printf("Wrote code density axis data to %s\n", fn);
+ fclose (fp);
+ printf ("Wrote code density axis data to %s\n", fn);
}
- fn = "rfft.txt";
- fp = fopen(fn, "w");
- if (fp) {
- fft_db = malloc((fft_cplx_size / 2) * sizeof(double));
- result += gn_db(fft_db, (fft_cplx_size / 2), fft_cplx, fft_cplx_size);
- for (size_t i = 0; i < (fft_cplx_size / 2); ++i) {
- fprintf(fp, "%.9f\n", fft_db[i]);
+ fn = "rfft.txt";
+ fp = fopen (fn, "w");
+ if (fp)
+ {
+ fft_db = malloc ((fft_cplx_size / 2) * sizeof (double));
+ result
+ += gn_db (fft_db, (fft_cplx_size / 2), fft_cplx, fft_cplx_size);
+ for (size_t i = 0; i < (fft_cplx_size / 2); ++i)
+ {
+ fprintf (fp, "%.9f\n", fft_db[i]);
}
- fclose(fp);
- printf("Wrote FFT magnitude data to %s\n", fn);
+ fclose (fp);
+ printf ("Wrote FFT magnitude data to %s\n", fn);
}
- fn = "rfft_axis.txt";
- fp = fopen(fn, "w");
- if (fp) {
- freq_axis = malloc((fft_cplx_size / 2) * sizeof(double));
- result = gn_freq_axis(freq_axis, (fft_cplx_size / 2), nfft, GnFreqAxisTypeReal, fs, GnFreqAxisFormatFreq);
- for (size_t i = 0; i < (fft_cplx_size / 2); ++i) {
- fprintf(fp, "%.6f\n", freq_axis[i]);
+ fn = "rfft_axis.txt";
+ fp = fopen (fn, "w");
+ if (fp)
+ {
+ freq_axis = malloc ((fft_cplx_size / 2) * sizeof (double));
+ result = gn_freq_axis (freq_axis, (fft_cplx_size / 2), nfft,
+ GnFreqAxisTypeReal, fs, GnFreqAxisFormatFreq);
+ for (size_t i = 0; i < (fft_cplx_size / 2); ++i)
+ {
+ fprintf (fp, "%.6f\n", freq_axis[i]);
}
- fclose(fp);
- printf("Wrote FFT x-axis data to %s\n", fn);
+ fclose (fp);
+ printf ("Wrote FFT x-axis data to %s\n", fn);
}
}
- error_occurred = false;
+ error_occurred = false;
cleanup:
- if (error_occurred) {
- printf("\nError occurred, freeing memory\n");
- } else {
- printf("\nFreeing memory\n");
+ if (error_occurred)
+ {
+ printf ("\nError occurred, freeing memory\n");
+ }
+ else
+ {
+ printf ("\nFreeing memory\n");
}
- if (fft_rkeys) {
- for (size_t i = 0; i < fft_results_size; ++i) {
- free(fft_rkeys[i]);
+ if (fft_rkeys)
+ {
+ for (size_t i = 0; i < fft_results_size; ++i)
+ {
+ free (fft_rkeys[i]);
}
}
- free(fft_rkey_sizes);
- free(fft_rvalues);
- free(fft_rkeys);
- if (inl_rkeys) {
- for (size_t i = 0; i < inl_results_size; ++i) {
- free(inl_rkeys[i]);
+ free (fft_rkey_sizes);
+ free (fft_rvalues);
+ free (fft_rkeys);
+ if (inl_rkeys)
+ {
+ for (size_t i = 0; i < inl_results_size; ++i)
+ {
+ free (inl_rkeys[i]);
}
}
- free(inl_rkey_sizes);
- free(inl_rvalues);
- free(inl_rkeys);
- if (dnl_rkeys) {
- for (size_t i = 0; i < dnl_results_size; ++i) {
- free(dnl_rkeys[i]);
+ free (inl_rkey_sizes);
+ free (inl_rvalues);
+ free (inl_rkeys);
+ if (dnl_rkeys)
+ {
+ for (size_t i = 0; i < dnl_results_size; ++i)
+ {
+ free (dnl_rkeys[i]);
}
}
- free(dnl_rkey_sizes);
- free(dnl_rvalues);
- free(dnl_rkeys);
- if (hist_rkeys) {
- for (size_t i = 0; i < hist_results_size; ++i) {
- free(hist_rkeys[i]);
+ free (dnl_rkey_sizes);
+ free (dnl_rvalues);
+ free (dnl_rkeys);
+ if (hist_rkeys)
+ {
+ for (size_t i = 0; i < hist_results_size; ++i)
+ {
+ free (hist_rkeys[i]);
}
}
- free(hist_rkey_sizes);
- free(hist_rvalues);
- free(hist_rkeys);
- if (wf_rkeys) {
- for (size_t i = 0; i < wf_results_size; ++i) {
- free(wf_rkeys[i]);
+ free (hist_rkey_sizes);
+ free (hist_rvalues);
+ free (hist_rkeys);
+ if (wf_rkeys)
+ {
+ for (size_t i = 0; i < wf_results_size; ++i)
+ {
+ free (wf_rkeys[i]);
}
}
- free(wf_rkey_sizes);
- free(wf_rvalues);
- free(wf_rkeys);
- free(fa_preview);
- free(freq_axis);
- free(fft_db);
- free(fft_cplx);
- free(code_axis);
- free(inl);
- free(dnl);
- free(hist);
- free(qwf);
- free(awf);
+ free (wf_rkey_sizes);
+ free (wf_rvalues);
+ free (wf_rkeys);
+ free (fa_preview);
+ free (freq_axis);
+ free (fft_db);
+ free (fft_cplx);
+ free (code_axis);
+ free (inl);
+ free (dnl);
+ free (hist);
+ free (qwf);
+ free (awf);
- return 0;
+ return 0;
}
\ No newline at end of file
diff --git a/include/array_ops.hpp b/include/array_ops.hpp
index 5f24aa5..a687100 100644
--- a/include/array_ops.hpp
+++ b/include/array_ops.hpp
@@ -1,21 +1,31 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_ARRAY_OPS_HPP
#define GENALYZER_IMPL_ARRAY_OPS_HPP
#include "type_aliases.hpp"
-namespace genalyzer_impl {
+namespace genalyzer_impl
+{
- void abs(const real_t* in_data, size_t in_size, real_t* out_data, size_t out_size);
+void abs (const real_t *in_data, size_t in_size, real_t *out_data,
+ size_t out_size);
- void angle(const real_t* in_data, size_t in_size, real_t* out_data, size_t out_size);
+void angle (const real_t *in_data, size_t in_size, real_t *out_data,
+ size_t out_size);
- void db(const real_t* in_data, size_t in_size, real_t* out_data, size_t out_size);
+void db (const real_t *in_data, size_t in_size, real_t *out_data,
+ size_t out_size);
- void db10(const real_t* in_data, size_t in_size, real_t* out_data, size_t out_size);
+void db10 (const real_t *in_data, size_t in_size, real_t *out_data,
+ size_t out_size);
- void db20(const real_t* in_data, size_t in_size, real_t* out_data, size_t out_size);
+void db20 (const real_t *in_data, size_t in_size, real_t *out_data,
+ size_t out_size);
- void norm(const real_t* in_data, size_t in_size, real_t* out_data, size_t out_size);
+void norm (const real_t *in_data, size_t in_size, real_t *out_data,
+ size_t out_size);
} // namespace genalyzer_impl
diff --git a/include/code_density.hpp b/include/code_density.hpp
index 9cb1fa2..9bfe4b5 100644
--- a/include/code_density.hpp
+++ b/include/code_density.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_CODE_DENSITY_HPP
#define GENALYZER_IMPL_CODE_DENSITY_HPP
@@ -6,65 +9,42 @@
#include