diff --git a/.clang-format b/.clang-format
index dcbe69f..46923aa 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,137 +1,238 @@
----
-Language: Cpp
-# BasedOnStyle: GNU
-AccessModifierOffset: -2
-AlignAfterOpenBracket: Align
-AlignConsecutiveMacros: false
-AlignConsecutiveAssignments: false
-AlignConsecutiveDeclarations: false
-AlignEscapedNewlines: Right
-AlignOperands: true
-AlignTrailingComments: true
-AllowAllArgumentsOnNextLine: true
-AllowAllConstructorInitializersOnNextLine: true
-AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: Never
-AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: All
-AllowShortLambdasOnASingleLine: All
-AllowShortIfStatementsOnASingleLine: Never
-AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterDefinitionReturnType: All
-AlwaysBreakAfterReturnType: AllDefinitions
-AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: MultiLine
-BinPackArguments: true
-BinPackParameters: true
-BraceWrapping:
- AfterCaseLabel: true
- AfterClass: true
- AfterControlStatement: true
- AfterEnum: true
- AfterFunction: true
- AfterNamespace: true
- AfterObjCDeclaration: true
- AfterStruct: true
- AfterUnion: true
- AfterExternBlock: true
- BeforeCatch: true
- BeforeElse: true
- IndentBraces: true
- SplitEmptyFunction: true
- SplitEmptyRecord: true
- SplitEmptyNamespace: true
-BreakBeforeBinaryOperators: All
-BreakBeforeBraces: GNU
-BreakBeforeInheritanceComma: false
-BreakInheritanceList: BeforeColon
-BreakBeforeTernaryOperators: true
-BreakConstructorInitializersBeforeComma: false
-BreakConstructorInitializers: BeforeColon
-BreakAfterJavaFieldAnnotations: false
-BreakStringLiterals: true
-ColumnLimit: 79
-CommentPragmas: '^ IWYU pragma:'
-CompactNamespaces: false
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
-ConstructorInitializerIndentWidth: 4
-ContinuationIndentWidth: 4
+# Commented out parameters are those with the same value as base LLVM style.
+# We can uncomment them if we want to change their value, or enforce the
+# chosen value in case the base style changes (last sync: Clang 17.0.6).
+BasedOnStyle: LLVM
+AccessModifierOffset: -4
+AlignAfterOpenBracket: DontAlign
+# AlignArrayOfStructures: None
+# AlignConsecutiveAssignments:
+# Enabled: false
+# AcrossEmptyLines: false
+# AcrossComments: false
+# AlignCompound: false
+# PadOperators: true
+# AlignConsecutiveBitFields:
+# Enabled: false
+# AcrossEmptyLines: false
+# AcrossComments: false
+# AlignCompound: false
+# PadOperators: false
+# AlignConsecutiveDeclarations:
+# Enabled: false
+# AcrossEmptyLines: false
+# AcrossComments: false
+# AlignCompound: false
+# PadOperators: false
+# AlignConsecutiveMacros:
+# Enabled: false
+# AcrossEmptyLines: false
+# AcrossComments: false
+# AlignCompound: false
+# PadOperators: false
+# AlignConsecutiveShortCaseStatements:
+# Enabled: false
+# AcrossEmptyLines: false
+# AcrossComments: false
+# AlignCaseColons: false
+# AlignEscapedNewlines: Right
+AlignOperands: DontAlign
+AlignTrailingComments:
+ Kind: Never
+ OverEmptyLines: 0
+# AllowAllArgumentsOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: false
+# AllowShortBlocksOnASingleLine: Never
+# AllowShortCaseLabelsOnASingleLine: false
+# AllowShortEnumsOnASingleLine: true
+# AllowShortFunctionsOnASingleLine: All
+# AllowShortIfStatementsOnASingleLine: Never
+# AllowShortLambdasOnASingleLine: All
+# AllowShortLoopsOnASingleLine: false
+# AlwaysBreakAfterDefinitionReturnType: None
+# AlwaysBreakAfterReturnType: None
+# AlwaysBreakBeforeMultilineStrings: false
+# AlwaysBreakTemplateDeclarations: MultiLine
+# AttributeMacros:
+# - __capability
+# BinPackArguments: true
+# BinPackParameters: true
+# BitFieldColonSpacing: Both
+# BraceWrapping:
+# AfterCaseLabel: false
+# AfterClass: false
+# AfterControlStatement: Never
+# AfterEnum: false
+# AfterFunction: false
+# AfterNamespace: false
+# AfterObjCDeclaration: false
+# AfterStruct: false
+# AfterUnion: false
+# AfterExternBlock: false
+# BeforeCatch: false
+# BeforeElse: false
+# BeforeLambdaBody: false
+# BeforeWhile: false
+# IndentBraces: false
+# SplitEmptyFunction: true
+# SplitEmptyRecord: true
+# SplitEmptyNamespace: true
+# BreakAfterAttributes: Never
+# BreakAfterJavaFieldAnnotations: false
+# BreakArrays: true
+# BreakBeforeBinaryOperators: None
+# BreakBeforeBraces: Attach
+# BreakBeforeConceptDeclarations: Always
+# BreakBeforeInlineASMColon: OnlyMultiline
+# BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+# BreakInheritanceList: BeforeColon
+# BreakStringLiterals: true
+ColumnLimit: 0
+# CommentPragmas: '^ IWYU pragma:'
+# CompactNamespaces: false
+ConstructorInitializerIndentWidth: 8
+ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
-DeriveLineEnding: true
-DerivePointerAlignment: false
-DisableFormat: false
-ExperimentalAutoDetectBinPacking: false
-FixNamespaceComments: false
-ForEachMacros:
- - foreach
- - Q_FOREACH
- - BOOST_FOREACH
-IncludeBlocks: Preserve
+# DerivePointerAlignment: false
+# DisableFormat: false
+# EmptyLineAfterAccessModifier: Never
+# EmptyLineBeforeAccessModifier: LogicalBlock
+# ExperimentalAutoDetectBinPacking: false
+# FixNamespaceComments: true
+# ForEachMacros:
+# - foreach
+# - Q_FOREACH
+# - BOOST_FOREACH
+# IfMacros:
+# - KJ_IF_MAYBE
+# IncludeBlocks: Preserve
IncludeCategories:
- - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
- Priority: 2
- SortPriority: 0
- - Regex: '^(<|"(gtest|gmock|isl|json)/)'
- Priority: 3
- SortPriority: 0
- - Regex: '.*'
- Priority: 1
- SortPriority: 0
-IncludeIsMainRegex: '(Test)?$'
-IncludeIsMainSourceRegex: ''
-IndentCaseLabels: false
-IndentGotoLabels: true
-IndentPPDirectives: None
-IndentWidth: 2
-IndentWrappedFunctionNames: false
-JavaScriptQuotes: Leave
-JavaScriptWrapImports: true
-KeepEmptyLinesAtTheStartOfBlocks: true
-MacroBlockBegin: ''
-MacroBlockEnd: ''
-MaxEmptyLinesToKeep: 1
-NamespaceIndentation: None
-ObjCBinPackProtocolList: Auto
-ObjCBlockIndentWidth: 2
-ObjCSpaceAfterProperty: false
-ObjCSpaceBeforeProtocolList: true
-PenaltyBreakAssignment: 2
-PenaltyBreakBeforeFirstCallParameter: 19
-PenaltyBreakComment: 300
-PenaltyBreakFirstLessLess: 120
-PenaltyBreakString: 1000
-PenaltyBreakTemplateDeclaration: 10
-PenaltyExcessCharacter: 1000000
-PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Right
-ReflowComments: true
-SortIncludes: true
-SortUsingDeclarations: true
-SpaceAfterCStyleCast: false
-SpaceAfterLogicalNot: false
-SpaceAfterTemplateKeyword: true
-SpaceBeforeAssignmentOperators: true
-SpaceBeforeCpp11BracedList: false
-SpaceBeforeCtorInitializerColon: true
-SpaceBeforeInheritanceColon: true
-SpaceBeforeParens: Always
-SpaceBeforeRangeBasedForLoopColon: true
-SpaceInEmptyBlock: false
-SpaceInEmptyParentheses: false
-SpacesBeforeTrailingComments: 1
-SpacesInAngles: false
-SpacesInConditionalStatement: false
-SpacesInContainerLiterals: true
-SpacesInCStyleCastParentheses: false
-SpacesInParentheses: false
-SpacesInSquareBrackets: false
-SpaceBeforeSquareBrackets: false
-Standard: c++03
-StatementMacros:
- - Q_UNUSED
- - QT_REQUIRE_VERSION
-TabWidth: 8
-UseCRLF: false
-UseTab: Never
-...
-
+ - Regex: ^".*"$
+ Priority: 1
+ - Regex: ^<.*\.h>$
+ Priority: 2
+ - Regex: ^<.*>$
+ Priority: 3
+# IncludeIsMainRegex: (Test)?$
+# IncludeIsMainSourceRegex: ''
+# IndentAccessModifiers: false
+# IndentCaseBlocks: false
+IndentCaseLabels: true
+# IndentExternBlock: AfterExternBlock
+# IndentGotoLabels: true
+# IndentPPDirectives: None
+# IndentRequiresClause: true
+IndentWidth: 4
+# IndentWrappedFunctionNames: false
+# InsertBraces: false
+# InsertNewlineAtEOF: false
+# InsertTrailingCommas: None
+# IntegerLiteralSeparator:
+# Binary: 0
+# BinaryMinDigits: 0
+# Decimal: 0
+# DecimalMinDigits: 0
+# Hex: 0
+# HexMinDigits: 0
+JavaImportGroups:
+ - org.godotengine
+ - android
+ - androidx
+ - com.android
+ - com.google
+ - java
+ - javax
+# JavaScriptQuotes: Leave
+# JavaScriptWrapImports: true
+# KeepEmptyLinesAtEOF: false
+KeepEmptyLinesAtTheStartOfBlocks: false
+# LambdaBodyIndentation: Signature
+# Language: Cpp
+# LineEnding: DeriveLF
+# MacroBlockBegin: ''
+# MacroBlockEnd: ''
+# MaxEmptyLinesToKeep: 1
+# NamespaceIndentation: None
+# ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 4
+# ObjCBreakBeforeNestedBlockParam: true
+# ObjCSpaceAfterProperty: false
+# ObjCSpaceBeforeProtocolList: true
+# PPIndentWidth: -1
+PackConstructorInitializers: NextLine
+# PenaltyBreakAssignment: 2
+# PenaltyBreakBeforeFirstCallParameter: 19
+# PenaltyBreakComment: 300
+# PenaltyBreakFirstLessLess: 120
+# PenaltyBreakOpenParenthesis: 0
+# PenaltyBreakString: 1000
+# PenaltyBreakTemplateDeclaration: 10
+# PenaltyExcessCharacter: 1000000
+# PenaltyIndentedWhitespace: 0
+# PenaltyReturnTypeOnItsOwnLine: 60
+# PointerAlignment: Right
+# QualifierAlignment: Leave
+# ReferenceAlignment: Pointer
+# ReflowComments: true
+# RemoveBracesLLVM: false
+# RemoveParentheses: Leave
+RemoveSemicolon: true
+# RequiresClausePosition: OwnLine
+# RequiresExpressionIndentation: OuterScope
+# SeparateDefinitionBlocks: Leave
+# ShortNamespaceLines: 1
+# SortIncludes: CaseSensitive
+# SortJavaStaticImport: Before
+# SortUsingDeclarations: LexicographicNumeric
+# SpaceAfterCStyleCast: false
+# SpaceAfterLogicalNot: false
+# SpaceAfterTemplateKeyword: true
+# SpaceAroundPointerQualifiers: Default
+# SpaceBeforeAssignmentOperators: true
+# SpaceBeforeCaseColon: false
+# SpaceBeforeCpp11BracedList: false
+# SpaceBeforeCtorInitializerColon: true
+# SpaceBeforeInheritanceColon: true
+# SpaceBeforeJsonColon: false
+# SpaceBeforeParens: ControlStatements
+# SpaceBeforeParensOptions:
+# AfterControlStatements: true
+# AfterForeachMacros: true
+# AfterFunctionDeclarationName: false
+# AfterFunctionDefinitionName: false
+# AfterIfMacros: true
+# AfterOverloadedOperator: false
+# AfterRequiresInClause: false
+# AfterRequiresInExpression: false
+# BeforeNonEmptyParentheses: false
+# SpaceBeforeRangeBasedForLoopColon: true
+# SpaceBeforeSquareBrackets: false
+# SpaceInEmptyBlock: false
+# SpacesBeforeTrailingComments: 1
+# SpacesInAngles: Never
+# SpacesInContainerLiterals: true
+SpacesInLineCommentPrefix:
+ Minimum: 0 # We want a minimum of 1 for comments, but allow 0 for disabled code.
+ Maximum: -1
+# SpacesInParens: Never
+# SpacesInParensOptions:
+# InConditionalStatements: false
+# InCStyleCasts: false
+# InEmptyParentheses: false
+# Other: false
+# SpacesInSquareBrackets: false
+Standard: c++20
+# StatementAttributeLikeMacros:
+# - Q_EMIT
+# StatementMacros:
+# - Q_UNUSED
+# - QT_REQUIRE_VERSION
+TabWidth: 4
+UseTab: Always
+# VerilogBreakBetweenInstancePorts: true
+# WhitespaceSensitiveMacros:
+# - BOOST_PP_STRINGIZE
+# - CF_SWIFT_NAME
+# - NS_SWIFT_NAME
+# - PP_STRINGIZE
+# - STRINGIZE
diff --git a/.clang-format-ignore b/.clang-format-ignore
new file mode 100644
index 0000000..428102f
--- /dev/null
+++ b/.clang-format-ignore
@@ -0,0 +1,4 @@
+*/*/*.json
+*/*/*.m
+*/*/*/*.m
+include/json.hpp
\ No newline at end of file
diff --git a/.github/license_header.txt b/.github/license_header.txt
new file mode 100644
index 0000000..c4807b3
--- /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
\ No newline at end of file
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/.github/workflows/test.yml b/.github/workflows/test.yml
index fce8567..034f019 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -161,3 +161,29 @@ jobs:
pip install ".[tools]"
python -m pytest -vs tests
for f in examples/*.py; do python "$f"; done
+
+ Lint:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ python-version: [3.8, 3.9, "3.10"]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Install dependencies
+ run: |
+ bash ./.github/scripts/install_dependencies.sh
+ pip install -r requirements_test.txt
+
+ - name: Lint
+ run: |
+ pre-commit run --all-files 2> /dev/null
+ ec=$?
+ git diff -U0 > log.txt && cat log.txt
+ exit $ec
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..7ed4f6c
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,34 @@
+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: ^(?!doc\/|tests\/|examples\/|include\/json\.hpp$).*\.((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
+ files: ^(?!doc\/|tests\/|examples\/).*\.((hpp|h|cpp|c))$
\ No newline at end of file
diff --git a/bindings/c/include/cgenalyzer.h b/bindings/c/include/cgenalyzer.h
index 4881829..f43d6e4 100644
--- a/bindings/c/include/cgenalyzer.h
+++ b/bindings/c/include/cgenalyzer.h
@@ -1,25 +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 +11,10 @@
/**
* \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,10 +22,11 @@
* \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 */
@@ -61,99 +43,100 @@ extern "C" {
* @brief GnAnalysisType enumerates analysis types
*/
typedef enum GnAnalysisType {
- GnAnalysisTypeDNL, ///< DNL (differential nonlinearity)
- GnAnalysisTypeFourier, ///< Fourier (FFT)
- GnAnalysisTypeHistogram, ///< Histogram
- GnAnalysisTypeINL, ///< INL (integral nonlinearity)
- GnAnalysisTypeWaveform ///< Waveform
- } 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;
+ 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;
+ 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;
+ 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
+ * @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;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ GnWindowBlackmanHarris, ///< Blackman-Harris
+ GnWindowHann, ///< Hann ("Hanning")
+ GnWindowNoWindow ///< No window (Rectangular)
+} GnWindow;
/** @} Enumerations */
@@ -172,9 +155,8 @@ extern "C" {
#else
#define __api __declspec(dllimport)
#endif
-#elif __GNUC__ >= 4 && !defined(MATLAB_MEX_FILE) \
- && !defined(MATLAB_LOADLIBRARY)
-#define __api __attribute__ ((visibility ("default")))
+#elif __GNUC__ >= 4 && !defined(MATLAB_MEX_FILE) && !defined(MATLAB_LOADLIBRARY)
+#define __api __attribute__((visibility("default")))
#else
#define __api
#endif
@@ -187,40 +169,41 @@ extern "C" {
/**
* @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.
+ * @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
- );
+ 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
- );
+ 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
- );
+__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
+ bool *error ///< [out] true if an error has occurred; false otherwise
);
/**
@@ -233,32 +216,31 @@ __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
- );
+__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.
+ * @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'
+ 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
- );
+__api int gn_version_string(char *buf, ///< [in,out] Pointer to character array
+ size_t size ///< [in] Size of character array
+);
/**
* \defgroup APIUtilityHelpers Helpers
@@ -268,21 +250,21 @@ __api int gn_version_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.
+ * @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
+ 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.
+ * @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
+ size_t *size ///< [out] Number of characters in version string
);
/** @} APIUtilityHelpers */
@@ -307,67 +289,61 @@ extern "C" {
* @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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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 */
@@ -389,40 +365,38 @@ extern "C" {
* @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
- );
+__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
- );
+__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
- );
+__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
+ * @details The results contain the following key-value pairs (see general
+ * description of
* \ref AnalysisRoutines "Analysis Routines").
*
* Key | Description
@@ -434,140 +408,149 @@ __api int gn_dnl(
* |
---|
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))
+ * |
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
- );
+__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
- );
+ 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
- );
+ 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
- );
+ 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
- );
+ 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
- );
+ 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
- );
+ 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
+ * @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))
+ * |
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
- );
+__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
- );
+__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
+ * @details The results contain the following key-value pairs (see general
+ * description of
* \ref AnalysisRoutines "Analysis Routines").
*
* Key | Description
@@ -577,14 +560,14 @@ __api int gn_inl(
* |
---|
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
- );
+__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
@@ -595,21 +578,19 @@ __api int gn_inl_analysis(
* @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
- );
+__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
- );
+__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 */
@@ -632,86 +613,91 @@ extern "C" {
/**
* @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
+ * @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
+ * |
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
- );
+ 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
- );
+ 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
- );
+ 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
@@ -722,263 +708,245 @@ __api int gn_fft_analysis_single(
* @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
- );
+__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
- );
+ 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
- );
+ 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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+ 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
- );
+ 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
- );
+__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
- );
+__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
- );
+__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
- );
+ 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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__api int gn_fa_wo(const char *obj_key, ///< [in] Object key
+ int n ///< [in] Number of worst others
+);
/** @} FourierAnalysisConfiguration */
@@ -991,27 +959,27 @@ __api int gn_fa_wo(
* @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
+__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
+__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 */
@@ -1024,66 +992,70 @@ __api int gn_fa_result_string(
/**
* @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.
+ * @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
- );
+__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.
+ * @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
- );
+ 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.
+ * @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
- );
+ 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.
+ * @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
- );
+ 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
- );
+ 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 */
@@ -1103,142 +1075,140 @@ extern "C" {
* @{
*/
- /**
+/**
* @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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
@@ -1249,24 +1219,22 @@ __api int gn_rfft64(
* @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
- );
+__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
- );
+__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 */
@@ -1290,58 +1258,54 @@ extern "C" {
* @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
- );
+__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)
- );
+__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
- );
+__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
- );
+__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
- );
+__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
@@ -1352,11 +1316,11 @@ __api int gn_ifftshift(
* @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
- );
+__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 */
@@ -1387,67 +1351,63 @@ __api int gn_mgr_clear();
* @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
- );
+ 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
- );
+ 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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
@@ -1457,36 +1417,36 @@ __api int gn_mgr_type(
/**
* @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.
+ * @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
- );
+ 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.
+ * @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
- );
+ 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.
+ * @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
- );
+ size_t *size, ///< [out] Number of characters in object type string
+ const char *obj_key ///< [in] Object key
+);
/** @} ManagerHelpers */
@@ -1510,215 +1470,204 @@ extern "C" {
* @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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
- );
+__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
+__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
+__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
+__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
);
/**
@@ -1731,21 +1680,20 @@ __api int gn_quantize64(
* @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
- );
+ 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
- );
+__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 */
@@ -1769,59 +1717,56 @@ extern "C" {
* @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)
- );
+__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
- );
+__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
- );
+__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)
- );
+__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
+ * @details The results contain the following key-value pairs (see general
+ * description of
* \ref AnalysisRoutines "Analysis Routines").
*
* Key | Description
@@ -1836,56 +1781,55 @@ __api int gn_sin(
* |
---|
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
- );
+__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
- );
+__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
- );
+__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
- );
+__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 */
diff --git a/bindings/c/include/cgenalyzer_private.h b/bindings/c/include/cgenalyzer_private.h
index 1d0e41a..76619e8 100644
--- a/bindings/c/include/cgenalyzer_private.h
+++ b/bindings/c/include/cgenalyzer_private.h
@@ -1,25 +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
#include "cgenalyzer_simplified_beta.h"
@@ -33,10 +14,10 @@
#include
#include
#include
+#include
#include
#include
#include
-#include
#include
#include
#include
@@ -62,170 +43,158 @@ 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;
- }
-
- template
- int check_pointer(const T* p)
- {
- if (nullptr == p) {
- 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);
+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) {
+ if (nullptr == p) {
+ 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);
+} // namespace util
+
#ifdef __cplusplus
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..3e7529f 100644
--- a/bindings/c/include/cgenalyzer_simplified_beta.h
+++ b/bindings/c/include/cgenalyzer_simplified_beta.h
@@ -1,25 +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
#include "cgenalyzer.h"
@@ -27,8 +8,7 @@
#include
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
#ifdef _WIN32
@@ -37,587 +17,475 @@ extern "C"
#else
#define __api __declspec(dllimport)
#endif
-#elif __GNUC__ >= 4 && !defined(MATLAB_MEX_FILE) \
- && !defined(MATLAB_LOADLIBRARY)
-#define __api __attribute__ ((visibility ("default")))
+#elif __GNUC__ >= 4 && !defined(MATLAB_MEX_FILE) && !defined(MATLAB_LOADLIBRARY)
+#define __api __attribute__((visibility("default")))
#else
#define __api
#endif
-
- // opaque pointer
- typedef struct gn_config_private *gn_config;
-
- typedef enum tone_type
- {
- REAL_COSINE,
- REAL_SINE,
- COMPLEX_EXP
- } tone_type;
-
- /**
- * @brief free memory for configuration struct
- * @return 0 on success, non-zero otherwise
- * @param c genalyzer Configuration struct
- */
- __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 c genalyzer Configuration struct
- */
- __api int gn_config_set_ttype(
- tone_type ttype,
- gn_config *c
- );
-
- /**
- * @brief set configuration struct member: npts
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief get configuration struct member: npts
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: sample_rate
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief get configuration struct member: sample_rate
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: data_rate
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: shift_freq
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: num_tones
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: tone_freq
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: tone_ampl
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: tone_phase
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: fsr
- * @return 0 on success, non-zero otherwise
- * @param fsr Full-scale range of the waveform
- * @param c genalyzer Configuration struct
- */
- __api int gn_config_set_fsr(
- double fsr,
- gn_config *c
- );
-
- /**
- * @brief set configuration struct member: qres
- * @return 0 on success, non-zero otherwise
- * @param qres Quantization resolution
- * @param c genalyzer Configuration struct
- */
- __api int gn_config_set_qres(
- int qres,
- gn_config *c
- );
-
- /**
- * @brief set configuration struct member: noise_rms
- * @return 0 on success, non-zero otherwise
- * @param noise_rms RMS Noise
- * @param c genalyzer Configuration struct
- */
- __api int gn_config_set_noise_rms(
- double noise_rms,
- gn_config *c
- );
-
- /**
- * @brief set configuration struct member: code_format
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: nfft
- * @return 0 on success, non-zero otherwise
- * @param nfft FFT order
- * @param c genalyzer Configuration struct
- */
- __api int gn_config_set_nfft(
- size_t nfft,
- gn_config *c
- );
-
- /**
- * @brief get configuration struct member: nfft
- * @return 0 on success, non-zero otherwise
- * @param nfft FFT order
- * @param c genalyzer Configuration struct
- */
- __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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @brief set configuration struct member: ssb_rest
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: max_harm_order
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: dnla_signal_type
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: inla_fit
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @brief set configuration struct member: ramp_start
- * @return 0 on success, non-zero otherwise
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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 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 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
- );
-
- /**
- * @brief Configure tone parameters to be used in measurement
- * @return 0 on success, non-zero otherwise
- * @param npts Number of sample points in the generated waveform
- * @param ramp_start Input start value of ramp
- * @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
- );
-
- /**
- * @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 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
- );
-
- /**
- * @brief Configure parameters to compute histogram
- * @return 0 on success, non-zero otherwise
- * @param npts Number of sample points in the generated waveform
- * @param qres Quantization resolution
- * @param c Configuration structure
- */
- __api int gn_config_histz_nla(
- size_t npts,
- int qres,
- gn_config *c
- );
-
- /**
- * @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
- );
-
- /**
- * @brief Generate sinusoidal tone based on supplied configuration.
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @brief Generate sinusoidal tone based on supplied configuration.
- * @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
- );
-
- /**
- * @brief Generate sinusoidal tone based on supplied configuration.
- * @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
- );
-
- /**
- * @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
- );
- /**
+
+// opaque pointer
+typedef struct gn_config_private *gn_config;
+
+typedef enum tone_type { REAL_COSINE,
+ REAL_SINE,
+ COMPLEX_EXP } tone_type;
+
+/**
+ * @brief free memory for configuration struct
+ * @return 0 on success, non-zero otherwise
+ * @param c genalyzer Configuration struct
+ */
+__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 c genalyzer Configuration struct
+ */
+__api int gn_config_set_ttype(tone_type ttype, gn_config *c);
+
+/**
+ * @brief set configuration struct member: npts
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief get configuration struct member: npts
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: sample_rate
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief get configuration struct member: sample_rate
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: data_rate
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: shift_freq
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: num_tones
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: tone_freq
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: tone_ampl
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: tone_phase
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: fsr
+ * @return 0 on success, non-zero otherwise
+ * @param fsr Full-scale range of the waveform
+ * @param c genalyzer Configuration struct
+ */
+__api int gn_config_set_fsr(double fsr, gn_config *c);
+
+/**
+ * @brief set configuration struct member: qres
+ * @return 0 on success, non-zero otherwise
+ * @param qres Quantization resolution
+ * @param c genalyzer Configuration struct
+ */
+__api int gn_config_set_qres(int qres, gn_config *c);
+
+/**
+ * @brief set configuration struct member: noise_rms
+ * @return 0 on success, non-zero otherwise
+ * @param noise_rms RMS Noise
+ * @param c genalyzer Configuration struct
+ */
+__api int gn_config_set_noise_rms(double noise_rms, gn_config *c);
+
+/**
+ * @brief set configuration struct member: code_format
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: nfft
+ * @return 0 on success, non-zero otherwise
+ * @param nfft FFT order
+ * @param c genalyzer Configuration struct
+ */
+__api int gn_config_set_nfft(size_t nfft, gn_config *c);
+
+/**
+ * @brief get configuration struct member: nfft
+ * @return 0 on success, non-zero otherwise
+ * @param nfft FFT order
+ * @param c genalyzer Configuration struct
+ */
+__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);
+
+/**
+ * @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);
+
+/**
+ * @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);
+
+/**
+ * @brief set configuration struct member: ssb_rest
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: max_harm_order
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: dnla_signal_type
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: inla_fit
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @brief set configuration struct member: ramp_start
+ * @return 0 on success, non-zero otherwise
+ * @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);
+
+/**
+ * @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);
+
+/**
+ * @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);
+
+/**
+ * @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 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 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);
+
+/**
+ * @brief Configure tone parameters to be used in measurement
+ * @return 0 on success, non-zero otherwise
+ * @param npts Number of sample points in the generated waveform
+ * @param ramp_start Input start value of ramp
+ * @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);
+
+/**
+ * @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 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);
+
+/**
+ * @brief Configure parameters to compute histogram
+ * @return 0 on success, non-zero otherwise
+ * @param npts Number of sample points in the generated waveform
+ * @param qres Quantization resolution
+ * @param c Configuration structure
+ */
+__api int gn_config_histz_nla(size_t npts, int qres, gn_config *c);
+
+/**
+ * @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
+);
+
+/**
+ * @brief Generate sinusoidal tone based on supplied configuration.
+ * @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
+);
+
+/**
+ * @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
+);
+
+/**
+ * @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);
+
+/**
+ * @brief Generate sinusoidal tone based on supplied configuration.
+ * @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);
+
+/**
+ * @brief Generate sinusoidal tone based on supplied configuration.
+ * @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);
+
+/**
+ * @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
+);
+/**
* @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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
- );
-
- /**
- * @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_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
+);
+
+/**
+ * @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);
+
+/**
+ * @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);
+
+/**
+ * @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
+);
+
+/**
+ * @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
+);
+
+/**
+ * @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
+);
+
+/**
+ * @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
+);
+
+/**
+ * @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
+);
+
+/**
+ * @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
+);
+
#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..9024dcf 100644
--- a/bindings/c/src/cgenalyzer.cpp
+++ b/bindings/c/src/cgenalyzer.cpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#include "cgenalyzer.h"
#include "cgenalyzer_private.h"
@@ -5,50 +8,54 @@ using namespace util;
namespace util {
- static bool gn_null_terminate = true;
-
- size_t terminated_size(size_t string_size)
- {
- return string_size + (util::gn_null_terminate ? 1 : 0);
- }
-
- 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) {
- 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';
- }
- }
-
- 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)) {
- 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 + "'");
- }
- }
+static bool gn_null_terminate = true;
+
+size_t terminated_size(size_t string_size) {
+ return string_size + (util::gn_null_terminate ? 1 : 0);
+}
+
+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) {
+ 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';
+ }
+}
+
+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)) {
+ 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,213 +63,202 @@ namespace util {
/* API Utilities */
/**************************************************************************/
-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))
- {
- 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");
- }
- 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());
- }
-}
-
-int gn_analysis_results_size(size_t* size, GnAnalysisType 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");
- }
- 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)
-{
- 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)
-{
- 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()
-{
- util::gn_error_log.clear();
- return gn_success;
-}
-
-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;
- }
- return gn_success;
-}
-
-int gn_set_string_termination(bool null_terminated)
-{
- util::gn_null_terminate = null_terminated;
- return gn_success;
-}
-
-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());
- }
- return gn_success;
+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)) {
+ 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");
+ }
+ 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());
+ }
+}
+
+int gn_analysis_results_size(size_t *size, GnAnalysisType 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");
+ }
+ 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) {
+ 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) {
+ 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() {
+ util::gn_error_log.clear();
+ return gn_success;
+}
+
+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;
+ }
+ return gn_success;
+}
+
+int gn_set_string_termination(bool null_terminated) {
+ util::gn_null_terminate = null_terminated;
+ return gn_success;
+}
+
+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());
+ }
+ return gn_success;
}
/**************************************************************************/
/* API Utility Helpers */
/**************************************************************************/
-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());
- }
+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());
+ }
}
-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());
- }
+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());
+ }
}
/**************************************************************************/
/* Array Operations */
/**************************************************************************/
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
}
/**************************************************************************/
@@ -271,220 +267,228 @@ int gn_norm(double* out, size_t out_size, const double* in, size_t in_size)
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)
- {
- 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());
- }
- }
-
- 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 {
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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");
- }
- 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());
- }
-}
-
-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);
-}
-
-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);
-}
-
-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);
-}
-
-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);
-}
-
-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);
-}
-
-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);
-}
-
-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");
- }
- 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);
- }
- 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)
-{
- 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)
-{
- 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");
- }
- 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());
- }
+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 {
+ 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) {
+ 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());
+ }
+}
+
+} // namespace
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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");
+ }
+ 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);
+ }
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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");
+ }
+ 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());
+ }
+}
+
+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());
+ }
+}
+
+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");
+ }
+ 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);
+ }
+ return gn_success;
+ } catch (const std::exception &e) {
+ return util::return_on_exception("gn_inl_analysis : ",
+ e.what());
+ }
}
/**************************************************************************/
/* Code Density Helpers */
/**************************************************************************/
-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());
- }
-}
-
-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());
- }
+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());
+ }
+}
+
+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());
+ }
}
/**************************************************************************/
@@ -493,630 +497,659 @@ int gn_code_densityx_size(size_t* size, int64_t min, int64_t max)
namespace {
- using fa_ptr = std::shared_ptr;
-
- 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()) {
- 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)
- {
- if (gn::manager::contains(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 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");
- }
- 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)
- {
- 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;
- }
- }
- }
- 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.
- }
- 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)
- {
- *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;
- }
- }
- }
- }
- 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)
-{
- 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;
- }
- 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());
- }
-}
-
-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");
- }
- 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]) + "'");
- }
- }
- 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());
- }
-}
-
-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");
- }
- return gn_success;
- } catch (const std::exception& e) {
- return util::return_on_exception("gn_fa_execute1 : ", e.what());
- }
+using fa_ptr = std::shared_ptr;
+
+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()) {
+ 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) {
+ if (gn::manager::contains(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 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");
+ }
+ 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) {
+ 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;
+ }
+ }
+ }
+ 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.
+ }
+ 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) {
+ *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;
+ }
+ }
+ }
+ }
+ return gn_failure;
+}
+
+} // namespace
+
+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");
+ }
+ 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;
+ }
+ }
+ 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) {
+ 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 += ", ";
+ }
+ missing_keys.append(
+ "'" + std::string(rkeys[i]) + "'");
+ }
+ }
+ 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());
+ }
+}
+
+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");
+ }
+ return gn_success;
+ } catch (const std::exception &e) {
+ return util::return_on_exception("gn_fa_execute1 : ", e.what());
+ }
}
/**************************************************************************/
/* Fourier Analysis Configuration */
/**************************************************************************/
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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);
- }
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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());
- }
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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);
+ }
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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());
+ }
}
/**************************************************************************/
/* 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)
-{
- 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());
- }
-}
-
-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());
- }
+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");
+ }
+ 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) {
+ 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());
+ }
}
/**************************************************************************/
/* Fourier Analysis Helpers */
/**************************************************************************/
-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);
- }
- *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)
-{
- 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)
-{
- 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)
-{
- 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]);
- }
- 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)
-{
- 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());
- }
+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);
+ }
+ *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) {
+ 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) {
+ 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) {
+ 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]);
+ }
+ 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) {
+ 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());
+ }
}
/**************************************************************************/
@@ -1125,320 +1158,317 @@ int gn_fft_analysis_results_size(size_t* size, const char* cfg_id, size_t in_siz
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)
- {
- 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());
- }
- }
-
- 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 {
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- return gn_rfftxx("64", out, out_size, in, in_size, n, navg, nfft, window, format, scale);
+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 {
+ 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) {
+ 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());
+ }
+}
+
+} // namespace
+
+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());
+ }
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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());
+ }
+}
+
+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);
+}
+
+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);
+}
+
+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);
}
/**************************************************************************/
/* 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)
-{
- 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)
-{
- 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());
- }
+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());
+ }
+}
+
+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());
+ }
}
/**************************************************************************/
/* Fourier Utilities */
/**************************************************************************/
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
}
/**************************************************************************/
/* Fourier Utility Helpers */
/**************************************************************************/
-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());
- }
+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());
+ }
}
/**************************************************************************/
/* Manager */
/**************************************************************************/
-int gn_mgr_clear()
-{
- gn::manager::clear();
- return gn_success;
+int gn_mgr_clear() {
+ gn::manager::clear();
+ return gn_success;
}
-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());
- }
+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());
+ }
}
-int gn_mgr_contains(bool* result, const char* obj_key)
-{
- *result = gn::manager::contains(obj_key);
- return gn_success;
+int gn_mgr_contains(bool *result, const char *obj_key) {
+ *result = gn::manager::contains(obj_key);
+ return gn_success;
}
-int gn_mgr_remove(const char* obj_key)
-{
- gn::manager::remove(obj_key);
- return gn_success;
+int gn_mgr_remove(const char *obj_key) {
+ gn::manager::remove(obj_key);
+ return gn_success;
}
-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());
- }
+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());
+ }
}
-int gn_mgr_size(size_t* size)
-{
- *size = gn::manager::size();
- return gn_success;
+int gn_mgr_size(size_t *size) {
+ *size = gn::manager::size();
+ return gn_success;
}
-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());
- }
+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());
+ }
}
-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());
- }
+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());
+ }
}
/**************************************************************************/
/* Manager Helpers */
/**************************************************************************/
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
}
/**************************************************************************/
@@ -1447,189 +1477,189 @@ int gn_mgr_type_size(size_t* size, const char* obj_key)
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)
- {
- 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());
- }
- }
-
- 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 {
- 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)
- {
- 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());
- }
- }
-
- 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 {
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- return gn_normalize("32", out, out_size, in, in_size, n, format);
+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 {
+ 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) {
+ 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());
+ }
+}
+
+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 {
+ 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) {
+ 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());
+ }
+}
+
+} // namespace
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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());
+ }
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
}
-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);
+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);
}
-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());
- }
+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());
+ }
}
-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);
+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);
}
-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);
+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);
}
-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);
+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);
}
/**************************************************************************/
/* Signal Processing Helpers */
/**************************************************************************/
-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());
- }
-}
-
-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());
- }
+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());
+ }
+}
+
+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());
+ }
}
/**************************************************************************/
@@ -1638,99 +1668,100 @@ int gn_fshift_size(size_t* out_size, size_t i_size, size_t q_size)
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)
- {
- 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());
- }
- }
-
-} // namespace anonymous
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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());
- }
-}
-
-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);
-}
-
-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);
-}
-
-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);
-}
-
-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);
+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 {
+ 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
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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());
+ }
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
}
\ 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..b38e435 100644
--- a/bindings/c/src/cgenalyzer_simplified_beta.cpp
+++ b/bindings/c/src/cgenalyzer_simplified_beta.cpp
@@ -1,1169 +1,1108 @@
+// 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);
- }
+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..2ffaeda 100644
--- a/bindings/python/genalyzer/__init__.py
+++ b/bindings/python/genalyzer/__init__.py
@@ -1,6 +1,8 @@
+# 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..2d572aa 100644
--- a/bindings/python/genalyzer/helpers/__init__.py
+++ b/bindings/python/genalyzer/helpers/__init__.py
@@ -1,3 +1,6 @@
+# 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..64e94a8 100644
--- a/bindings/python/genalyzer/helpers/waveform_gen.py
+++ b/bindings/python/genalyzer/helpers/waveform_gen.py
@@ -1,3 +1,6 @@
+# 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..10b392f 100644
--- a/bindings/python/genalyzer/pygenalyzer.py
+++ b/bindings/python/genalyzer/pygenalyzer.py
@@ -1,23 +1,6 @@
-"""
-* 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)
diff --git a/bindings/python/genalyzer/simplified_beta/__init__.py b/bindings/python/genalyzer/simplified_beta/__init__.py
index 89a94fb..e720414 100644
--- a/bindings/python/genalyzer/simplified_beta/__init__.py
+++ b/bindings/python/genalyzer/simplified_beta/__init__.py
@@ -1,3 +1,6 @@
+# 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..af52847 100644
--- a/cmake/FindFFTW.cmake
+++ b/cmake/FindFFTW.cmake
@@ -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..4c74c31 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -10,14 +10,14 @@ 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})
-find_package(Sphinx REQUIRED)
+find_package(SPHINX REQUIRED)
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR})
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
diff --git a/include/array_ops.hpp b/include/array_ops.hpp
index 5f24aa5..761de33 100644
--- a/include/array_ops.hpp
+++ b/include/array_ops.hpp
@@ -1,3 +1,6 @@
+// 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
@@ -5,17 +8,23 @@
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..c0e17cb 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
@@ -8,63 +11,39 @@
namespace genalyzer_impl {
- size_t code_density_size(int n, CodeFormat format);
-
- size_t code_densityx_size(int64_t min, int64_t max);
-
- void code_axis(real_t* data, size_t size, int n, CodeFormat format);
-
- void code_axisx(real_t* data, size_t size, int64_t min, int64_t max);
-
- void dnl(
- real_t* dnl_data,
- size_t dnl_size,
- const uint64_t* hist_data,
- size_t hist_size,
- DnlSignal type
- );
-
- std::map dnl_analysis(const real_t* data, size_t size);
-
- const std::vector& dnl_analysis_ordered_keys();
-
- template
- void hist(
- uint64_t* hist_data,
- size_t hist_size,
- const T* wf_data,
- size_t wf_size,
- int n,
- CodeFormat format,
- bool preserve
- );
-
- template
- void histx(
- uint64_t* hist_data,
- size_t hist_size,
- const T* wf_data,
- size_t wf_size,
- int64_t min,
- int64_t max,
- bool preserve
- );
-
- std::map hist_analysis(const uint64_t* data, size_t size);
-
- const std::vector& hist_analysis_ordered_keys();
-
- void inl(
- real_t* inl_data,
- size_t inl_size,
- const real_t* dnl_data,
- size_t dnl_size,
- InlLineFit fit
- );
-
- std::map inl_analysis(const real_t* data, size_t size);
-
- const std::vector& inl_analysis_ordered_keys();
+size_t code_density_size(int n, CodeFormat format);
+
+size_t code_densityx_size(int64_t min, int64_t max);
+
+void code_axis(real_t *data, size_t size, int n, CodeFormat format);
+
+void code_axisx(real_t *data, size_t size, int64_t min, int64_t max);
+
+void dnl(real_t *dnl_data, size_t dnl_size, const uint64_t *hist_data,
+ size_t hist_size, DnlSignal type);
+
+std::map dnl_analysis(const real_t *data, size_t size);
+
+const std::vector &dnl_analysis_ordered_keys();
+
+template
+void hist(uint64_t *hist_data, size_t hist_size, const T *wf_data,
+ size_t wf_size, int n, CodeFormat format, bool preserve);
+
+template
+void histx(uint64_t *hist_data, size_t hist_size, const T *wf_data,
+ size_t wf_size, int64_t min, int64_t max, bool preserve);
+
+std::map hist_analysis(const uint64_t *data, size_t size);
+
+const std::vector &hist_analysis_ordered_keys();
+
+void inl(real_t *inl_data, size_t inl_size, const real_t *dnl_data,
+ size_t dnl_size, InlLineFit fit);
+
+std::map inl_analysis(const real_t *data, size_t size);
+
+const std::vector &inl_analysis_ordered_keys();
} // namespace genalyzer_impl
diff --git a/include/constants.hpp b/include/constants.hpp
index 500f65d..0989819 100644
--- a/include/constants.hpp
+++ b/include/constants.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_CONSTANTS_HPP
#define GENALYZER_IMPL_CONSTANTS_HPP
@@ -7,27 +10,27 @@
namespace genalyzer_impl {
- const real_t k_half = 0.5;
- const real_t k_one = 1.0;
- const real_t k_two = 2.0;
- const real_t k_sqrt2 = std::sqrt(k_two);
- const real_t k_inv_sqrt2 = std::sqrt(k_half);
- const real_t k_pi4 = std::atan(k_one);
- const real_t k_pi2 = k_two * k_pi4;
- const real_t k_pi = k_two * k_pi2;
- const real_t k_2pi = k_two * k_pi;
-
- const int k_abs_min_code_width = 1;
- const int k_abs_max_code_width = 30;
-
- const size_t k_abs_max_fft_navg = 256;
-
- const real_t k_abs_max_db = 400.0;
- const real_t k_abs_min_db = -400.0;
- const real_t k_abs_max_rms = std::pow(10.0, k_abs_max_db / 20.0);
- const real_t k_abs_min_rms = std::pow(10.0, k_abs_min_db / 20.0);
- const real_t k_abs_max_msq = k_abs_max_rms * k_abs_max_rms;
- const real_t k_abs_min_msq = k_abs_min_rms * k_abs_min_rms;
+const real_t k_half = 0.5;
+const real_t k_one = 1.0;
+const real_t k_two = 2.0;
+const real_t k_sqrt2 = std::sqrt(k_two);
+const real_t k_inv_sqrt2 = std::sqrt(k_half);
+const real_t k_pi4 = std::atan(k_one);
+const real_t k_pi2 = k_two * k_pi4;
+const real_t k_pi = k_two * k_pi2;
+const real_t k_2pi = k_two * k_pi;
+
+const int k_abs_min_code_width = 1;
+const int k_abs_max_code_width = 30;
+
+const size_t k_abs_max_fft_navg = 256;
+
+const real_t k_abs_max_db = 400.0;
+const real_t k_abs_min_db = -400.0;
+const real_t k_abs_max_rms = std::pow(10.0, k_abs_max_db / 20.0);
+const real_t k_abs_min_rms = std::pow(10.0, k_abs_min_db / 20.0);
+const real_t k_abs_max_msq = k_abs_max_rms * k_abs_max_rms;
+const real_t k_abs_min_msq = k_abs_min_rms * k_abs_min_rms;
} // namespace genalyzer_impl
diff --git a/include/enum_map.hpp b/include/enum_map.hpp
index b71861b..568a7f8 100644
--- a/include/enum_map.hpp
+++ b/include/enum_map.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_ENUM_MAP_HPP
#define GENALYZER_IMPL_ENUM_MAP_HPP
@@ -9,73 +12,59 @@
namespace genalyzer_impl {
- class enum_map
- {
- public:
+class enum_map {
+public:
+ using itos_map_t = std::map;
+ using stoi_map_t = std::map;
+ using const_iterator = itos_map_t::const_iterator;
- using itos_map_t = std::map;
- using stoi_map_t = std::map;
- using const_iterator = itos_map_t::const_iterator;
+public:
+ enum_map(const char *name,
+ std::initializer_list> list);
- public:
+public:
+ ~enum_map() = default;
- enum_map(const char* name, std::initializer_list> list);
+public: // Element Access
+ const str_t &at(int i) const {
+ contains(i, true);
+ return m_itos.at(i);
+ }
- public:
+ int at(const str_t &s) const {
+ contains(s, true);
+ return m_stoi.at(s);
+ }
- ~enum_map() = default;
+public: // Iterators
+ const_iterator begin() const {
+ return m_itos.begin();
+ }
- public: // Element Access
+ const_iterator end() const {
+ return m_itos.end();
+ }
- const str_t& at(int i) const
- {
- contains(i, true);
- return m_itos.at(i);
- }
+public: // Lookup
+ bool contains(int i, bool throw_if_not_found = false) const;
- int at(const str_t& s) const
- {
- contains(s, true);
- return m_stoi.at(s);
- }
+ bool contains(const str_t &s, bool throw_if_not_found = false) const;
- public: // Iterators
+public: // Other Member Functions
+ const str_t &name() const {
+ return m_name;
+ }
- const_iterator begin() const
- {
- return m_itos.begin();
- }
+ size_t size() const {
+ return m_itos.size();
+ }
- const_iterator end() const
- {
- return m_itos.end();
- }
+private:
+ str_t m_name;
+ itos_map_t m_itos; // int to string
+ stoi_map_t m_stoi; // string to int
- public: // Lookup
-
- bool contains(int i, bool throw_if_not_found = false) const;
-
- bool contains(const str_t& s, bool throw_if_not_found = false) const;
-
- public: // Other Member Functions
-
- const str_t& name() const
- {
- return m_name;
- }
-
- size_t size() const
- {
- return m_itos.size();
- }
-
- private:
-
- str_t m_name;
- itos_map_t m_itos; // int to string
- stoi_map_t m_stoi; // string to int
-
- }; // class enum_map
+}; // class enum_map
} // namespace genalyzer_impl
diff --git a/include/enum_maps.hpp b/include/enum_maps.hpp
index 889bfbd..5ed9487 100644
--- a/include/enum_maps.hpp
+++ b/include/enum_maps.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_ENUM_MAPS_HPP
#define GENALYZER_IMPL_ENUM_MAPS_HPP
@@ -7,158 +10,145 @@
namespace genalyzer_impl {
- int enum_value(const str_t& enumeration, const str_t& enumerator);
-
- template
- E get_enum(int);
-
- const enum_map analysis_type_map ("AnalysisType", {
- { to_int(AnalysisType::DNL) , "DNL" },
- { to_int(AnalysisType::Fourier) , "Fourier" },
- { to_int(AnalysisType::Histogram) , "Histogram" },
- { to_int(AnalysisType::INL) , "INL" },
- { to_int(AnalysisType::Waveform) , "Waveform" }}
- );
-
- const enum_map code_format_map ("CodeFormat", {
- { to_int(CodeFormat::OffsetBinary) , "OffsetBinary" },
- { to_int(CodeFormat::TwosComplement) , "TwosComplement" }}
- );
-
- const enum_map dnl_signal_map ("DnlSignal", {
- { to_int(DnlSignal::Ramp) , "Ramp" },
- { to_int(DnlSignal::Tone) , "Tone" }}
- );
-
- const enum_map fa_comp_tag_map ("FACompTag", {
- { to_int(FACompTag::DC) , "DC" },
- { to_int(FACompTag::Signal) , "Signal" },
- { to_int(FACompTag::HD) , "HD" },
- { to_int(FACompTag::IMD) , "IMD" },
- { to_int(FACompTag::ILOS) , "ILOS" },
- { to_int(FACompTag::ILGT) , "ILGT" },
- { to_int(FACompTag::CLK) , "CLK" },
- { to_int(FACompTag::UserDist) , "UserDist" },
- { to_int(FACompTag::Noise) , "Noise" }}
- );
-
- const enum_map fa_ssb_map ("FASsb", {
- { to_int(FASsb::Default) , "Default" },
- { to_int(FASsb::DC) , "DC" },
- { to_int(FASsb::Signal) , "Signal" },
- { to_int(FASsb::WO) , "WO" }}
- );
-
- const enum_map freq_axis_format_map ("FreqAxisFormat", {
- { to_int(FreqAxisFormat::Bins) , "Bins" },
- { to_int(FreqAxisFormat::Freq) , "Freq" },
- { to_int(FreqAxisFormat::Norm) , "Norm" }}
- );
-
- const enum_map freq_axis_type_map ("FreqAxisType", {
- { to_int(FreqAxisType::DcCenter) , "DcCenter" },
- { to_int(FreqAxisType::DcLeft) , "DcLeft" },
- { to_int(FreqAxisType::Real) , "Real" }}
- );
-
- const enum_map inl_line_fit_map ("InlLineFit", {
- { to_int(InlLineFit::NoFit) , "NoFit" },
- { to_int(InlLineFit::BestFit) , "BestFit" },
- { to_int(InlLineFit::EndFit) , "EndFit" }}
- );
-
- const enum_map rfft_scale_map ("RfftScale", {
- { to_int(RfftScale::DbfsDc) , "DbfsDc" },
- { to_int(RfftScale::DbfsSin) , "DbfsSin" },
- { to_int(RfftScale::Native) , "Native" }}
- );
-
- const enum_map window_map ("Window", {
- { to_int(Window::NoWindow) , "NoWindow" },
- { to_int(Window::BlackmanHarris) , "BlackmanHarris" },
- { to_int(Window::Hann) , "Hann" }}
- );
-
+int enum_value(const str_t &enumeration, const str_t &enumerator);
+
+template
+E get_enum(int);
+
+const enum_map
+ analysis_type_map("AnalysisType",
+ { { to_int(AnalysisType::DNL), "DNL" },
+ { to_int(AnalysisType::Fourier), "Fourier" },
+ { to_int(AnalysisType::Histogram), "Histogram" },
+ { to_int(AnalysisType::INL), "INL" },
+ { to_int(AnalysisType::Waveform), "Waveform" } });
+
+const enum_map code_format_map(
+ "CodeFormat",
+ { { to_int(CodeFormat::OffsetBinary), "OffsetBinary" },
+ { to_int(CodeFormat::TwosComplement), "TwosComplement" } });
+
+const enum_map dnl_signal_map("DnlSignal",
+ { { to_int(DnlSignal::Ramp), "Ramp" },
+ { to_int(DnlSignal::Tone), "Tone" } });
+
+const enum_map fa_comp_tag_map("FACompTag",
+ { { to_int(FACompTag::DC), "DC" },
+ { to_int(FACompTag::Signal), "Signal" },
+ { to_int(FACompTag::HD), "HD" },
+ { to_int(FACompTag::IMD), "IMD" },
+ { to_int(FACompTag::ILOS), "ILOS" },
+ { to_int(FACompTag::ILGT), "ILGT" },
+ { to_int(FACompTag::CLK), "CLK" },
+ { to_int(FACompTag::UserDist), "UserDist" },
+ { to_int(FACompTag::Noise), "Noise" } });
+
+const enum_map fa_ssb_map("FASsb", { { to_int(FASsb::Default), "Default" }, { to_int(FASsb::DC), "DC" }, { to_int(FASsb::Signal), "Signal" }, { to_int(FASsb::WO), "WO" } });
+
+const enum_map
+ freq_axis_format_map("FreqAxisFormat",
+ { { to_int(FreqAxisFormat::Bins), "Bins" },
+ { to_int(FreqAxisFormat::Freq), "Freq" },
+ { to_int(FreqAxisFormat::Norm), "Norm" } });
+
+const enum_map
+ freq_axis_type_map("FreqAxisType",
+ { { to_int(FreqAxisType::DcCenter), "DcCenter" },
+ { to_int(FreqAxisType::DcLeft), "DcLeft" },
+ { to_int(FreqAxisType::Real), "Real" } });
+
+const enum_map inl_line_fit_map("InlLineFit",
+ { { to_int(InlLineFit::NoFit), "NoFit" },
+ { to_int(InlLineFit::BestFit), "BestFit" },
+ { to_int(InlLineFit::EndFit), "EndFit" } });
+
+const enum_map rfft_scale_map("RfftScale",
+ { { to_int(RfftScale::DbfsDc), "DbfsDc" },
+ { to_int(RfftScale::DbfsSin), "DbfsSin" },
+ { to_int(RfftScale::Native), "Native" } });
+
+const enum_map window_map("Window", { { to_int(Window::NoWindow), "NoWindow" }, { to_int(Window::BlackmanHarris), "BlackmanHarris" }, { to_int(Window::Hann), "Hann" } });
+
} // namespace genalyzer_impl
namespace genalyzer_impl {
- const enum_map fa_comp_type_map ("FACompType", {
- { to_int(FACompType::DC) , "DC" },
- { to_int(FACompType::FixedTone) , "FixedTone" },
- { to_int(FACompType::MaxTone) , "MaxTone" },
- { to_int(FACompType::WOTone) , "WOTone" }}
- );
-
- const enum_map fa_result_map ("FAResult", {
- { to_int(FAResult::AnalysisType) , "analysistype" },
- { to_int(FAResult::SignalType) , "signaltype" },
- { to_int(FAResult::NFFT) , "nfft" },
- { to_int(FAResult::DataSize) , "datasize" },
- { to_int(FAResult::FBin) , "fbin" },
- { to_int(FAResult::FData) , "fdata" },
- { to_int(FAResult::FSample) , "fsample" },
- { to_int(FAResult::FShift) , "fshift" },
- { to_int(FAResult::FSNR) , "fsnr" },
- { to_int(FAResult::SNR) , "snr" },
- { to_int(FAResult::SINAD) , "sinad" },
- { to_int(FAResult::SFDR) , "sfdr" },
- { to_int(FAResult::ABN) , "abn" },
- { to_int(FAResult::NSD) , "nsd" },
- { to_int(FAResult::CarrierIndex) , "carrierindex" },
- { to_int(FAResult::MaxSpurIndex) , "maxspurindex" },
- { to_int(FAResult::AB_Width) , "ab_width" },
- { to_int(FAResult::AB_I1) , "ab_i1" },
- { to_int(FAResult::AB_I2) , "ab_i2" },
- { to_int(FAResult::AB_NBins) , "ab_nbins" },
- { to_int(FAResult::AB_RSS) , "ab_rss" },
- { to_int(FAResult::Signal_NBins) , "signal_nbins" },
- { to_int(FAResult::Signal_RSS) , "signal_rss" },
- { to_int(FAResult::CLK_NBins) , "clk_nbins" },
- { to_int(FAResult::CLK_RSS) , "clk_rss" },
- { to_int(FAResult::HD_NBins) , "hd_nbins" },
- { to_int(FAResult::HD_RSS) , "hd_rss" },
- { to_int(FAResult::ILOS_NBins) , "ilos_nbins" },
- { to_int(FAResult::ILOS_RSS) , "ilos_rss" },
- { to_int(FAResult::ILGT_NBins) , "ilgt_nbins" },
- { to_int(FAResult::ILGT_RSS) , "ilgt_rss" },
- { to_int(FAResult::IMD_NBins) , "imd_nbins" },
- { to_int(FAResult::IMD_RSS) , "imd_rss" },
- { to_int(FAResult::UserDist_NBins) , "userdist_nbins" },
- { to_int(FAResult::UserDist_RSS) , "userdist_rss" },
- { to_int(FAResult::THD_NBins) , "thd_nbins" },
- { to_int(FAResult::THD_RSS) , "thd_rss" },
- { to_int(FAResult::ILV_NBins) , "ilv_nbins" },
- { to_int(FAResult::ILV_RSS) , "ilv_rss" },
- { to_int(FAResult::Dist_NBins) , "dist_nbins" },
- { to_int(FAResult::Dist_RSS) , "dist_rss" },
- { to_int(FAResult::Noise_NBins) , "noise_nbins" },
- { to_int(FAResult::Noise_RSS) , "noise_rss" },
- { to_int(FAResult::NAD_NBins) , "nad_nbins" },
- { to_int(FAResult::NAD_RSS) , "nad_rss" }}
- );
-
- const enum_map fa_tone_result_map ("FAToneResult", {
- { to_int(FAToneResult::OrderIndex) , "orderindex" },
- { to_int(FAToneResult::Tag) , "tag" },
- { to_int(FAToneResult::Freq) , "freq" },
- { to_int(FAToneResult::FFinal) , "ffinal" },
- { to_int(FAToneResult::FWAvg) , "fwavg" },
- { to_int(FAToneResult::I1) , "i1" },
- { to_int(FAToneResult::I2) , "i2" },
- { to_int(FAToneResult::NBins) , "nbins" },
- { to_int(FAToneResult::InBand) , "inband" },
- { to_int(FAToneResult::Mag) , "mag" },
- { to_int(FAToneResult::Mag_dBFS) , "mag_dbfs" },
- { to_int(FAToneResult::Mag_dBc) , "mag_dbc" },
- { to_int(FAToneResult::Phase) , "phase" },
- { to_int(FAToneResult::Phase_c) , "phase_c" }}
- );
-
- const enum_map object_type_map ("ObjectType", {
- { to_int(ObjectType::FourierAnalysis) , "FourierAnalysis" }}
- );
-
+const enum_map
+ fa_comp_type_map("FACompType",
+ { { to_int(FACompType::DC), "DC" },
+ { to_int(FACompType::FixedTone), "FixedTone" },
+ { to_int(FACompType::MaxTone), "MaxTone" },
+ { to_int(FACompType::WOTone), "WOTone" } });
+
+const enum_map
+ fa_result_map("FAResult",
+ { { to_int(FAResult::AnalysisType), "analysistype" },
+ { to_int(FAResult::SignalType), "signaltype" },
+ { to_int(FAResult::NFFT), "nfft" },
+ { to_int(FAResult::DataSize), "datasize" },
+ { to_int(FAResult::FBin), "fbin" },
+ { to_int(FAResult::FData), "fdata" },
+ { to_int(FAResult::FSample), "fsample" },
+ { to_int(FAResult::FShift), "fshift" },
+ { to_int(FAResult::FSNR), "fsnr" },
+ { to_int(FAResult::SNR), "snr" },
+ { to_int(FAResult::SINAD), "sinad" },
+ { to_int(FAResult::SFDR), "sfdr" },
+ { to_int(FAResult::ABN), "abn" },
+ { to_int(FAResult::NSD), "nsd" },
+ { to_int(FAResult::CarrierIndex), "carrierindex" },
+ { to_int(FAResult::MaxSpurIndex), "maxspurindex" },
+ { to_int(FAResult::AB_Width), "ab_width" },
+ { to_int(FAResult::AB_I1), "ab_i1" },
+ { to_int(FAResult::AB_I2), "ab_i2" },
+ { to_int(FAResult::AB_NBins), "ab_nbins" },
+ { to_int(FAResult::AB_RSS), "ab_rss" },
+ { to_int(FAResult::Signal_NBins), "signal_nbins" },
+ { to_int(FAResult::Signal_RSS), "signal_rss" },
+ { to_int(FAResult::CLK_NBins), "clk_nbins" },
+ { to_int(FAResult::CLK_RSS), "clk_rss" },
+ { to_int(FAResult::HD_NBins), "hd_nbins" },
+ { to_int(FAResult::HD_RSS), "hd_rss" },
+ { to_int(FAResult::ILOS_NBins), "ilos_nbins" },
+ { to_int(FAResult::ILOS_RSS), "ilos_rss" },
+ { to_int(FAResult::ILGT_NBins), "ilgt_nbins" },
+ { to_int(FAResult::ILGT_RSS), "ilgt_rss" },
+ { to_int(FAResult::IMD_NBins), "imd_nbins" },
+ { to_int(FAResult::IMD_RSS), "imd_rss" },
+ { to_int(FAResult::UserDist_NBins), "userdist_nbins" },
+ { to_int(FAResult::UserDist_RSS), "userdist_rss" },
+ { to_int(FAResult::THD_NBins), "thd_nbins" },
+ { to_int(FAResult::THD_RSS), "thd_rss" },
+ { to_int(FAResult::ILV_NBins), "ilv_nbins" },
+ { to_int(FAResult::ILV_RSS), "ilv_rss" },
+ { to_int(FAResult::Dist_NBins), "dist_nbins" },
+ { to_int(FAResult::Dist_RSS), "dist_rss" },
+ { to_int(FAResult::Noise_NBins), "noise_nbins" },
+ { to_int(FAResult::Noise_RSS), "noise_rss" },
+ { to_int(FAResult::NAD_NBins), "nad_nbins" },
+ { to_int(FAResult::NAD_RSS), "nad_rss" } });
+
+const enum_map
+ fa_tone_result_map("FAToneResult",
+ { { to_int(FAToneResult::OrderIndex), "orderindex" },
+ { to_int(FAToneResult::Tag), "tag" },
+ { to_int(FAToneResult::Freq), "freq" },
+ { to_int(FAToneResult::FFinal), "ffinal" },
+ { to_int(FAToneResult::FWAvg), "fwavg" },
+ { to_int(FAToneResult::I1), "i1" },
+ { to_int(FAToneResult::I2), "i2" },
+ { to_int(FAToneResult::NBins), "nbins" },
+ { to_int(FAToneResult::InBand), "inband" },
+ { to_int(FAToneResult::Mag), "mag" },
+ { to_int(FAToneResult::Mag_dBFS), "mag_dbfs" },
+ { to_int(FAToneResult::Mag_dBc), "mag_dbc" },
+ { to_int(FAToneResult::Phase), "phase" },
+ { to_int(FAToneResult::Phase_c), "phase_c" } });
+
+const enum_map object_type_map("ObjectType",
+ { { to_int(ObjectType::FourierAnalysis),
+ "FourierAnalysis" } });
+
} // namespace genalyzer_impl
#endif // GENALYZER_IMPL_ENUM_MAPS_HPP
\ No newline at end of file
diff --git a/include/enums.hpp b/include/enums.hpp
index c56bc1e..96f44c6 100644
--- a/include/enums.hpp
+++ b/include/enums.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_ENUMS_HPP
#define GENALYZER_IMPL_ENUMS_HPP
@@ -6,73 +9,59 @@
*/
namespace genalyzer_impl {
- enum class AnalysisType : int {
- DNL,
- Fourier,
- Histogram,
- INL,
- Waveform
- };
-
- enum class CodeFormat : int {
- OffsetBinary,
- TwosComplement
- };
-
- enum class DnlSignal : int {
- Ramp,
- Tone
- };
-
- // Noise means not DC and not Signal and not Distortion
- enum class FACompTag : int { // Fourier Analysis Component Tag
- DC, // DC component (always Bin 0)
- Signal, // Signal component
- HD, // Harmonic distortion
- IMD, // Intermodulation distortion
- ILOS, // Interleaving offset component
- ILGT, // Interleaving gain/timing/BW component
- CLK, // Clock component
- UserDist, // User-designated distortion
- Noise // Noise component (e.g. WorstOther)
- };
-
- enum class FASsb : int {
- Default, // Default SSB (applies to auto-generated components)
- DC, // SSB for DC component
- Signal, // SSB for Signal components
- WO, // SSB for WorstOther components
- };
-
- enum class FreqAxisFormat : int {
- Bins,
- Freq,
- Norm
- };
-
- enum class FreqAxisType : int {
- DcCenter,
- DcLeft,
- Real
- };
-
- enum class InlLineFit : int {
- BestFit,
- EndFit,
- NoFit
- };
-
- enum class RfftScale : int {
- DbfsDc, // Full-scale sinusoid measures -3 dBFS
- DbfsSin, // Full-scale sinusoid measures 0 dBFS
- Native // Full-scale sinusoid measures -6 dBFS
- };
-
- enum class Window : int {
- BlackmanHarris,
- Hann,
- NoWindow
- };
+enum class AnalysisType : int { DNL,
+ Fourier,
+ Histogram,
+ INL,
+ Waveform };
+
+enum class CodeFormat : int { OffsetBinary,
+ TwosComplement };
+
+enum class DnlSignal : int { Ramp,
+ Tone };
+
+// Noise means not DC and not Signal and not Distortion
+enum class FACompTag : int { // Fourier Analysis Component Tag
+ DC, // DC component (always Bin 0)
+ Signal, // Signal component
+ HD, // Harmonic distortion
+ IMD, // Intermodulation distortion
+ ILOS, // Interleaving offset component
+ ILGT, // Interleaving gain/timing/BW component
+ CLK, // Clock component
+ UserDist, // User-designated distortion
+ Noise // Noise component (e.g. WorstOther)
+};
+
+enum class FASsb : int {
+ Default, // Default SSB (applies to auto-generated components)
+ DC, // SSB for DC component
+ Signal, // SSB for Signal components
+ WO, // SSB for WorstOther components
+};
+
+enum class FreqAxisFormat : int { Bins,
+ Freq,
+ Norm };
+
+enum class FreqAxisType : int { DcCenter,
+ DcLeft,
+ Real };
+
+enum class InlLineFit : int { BestFit,
+ EndFit,
+ NoFit };
+
+enum class RfftScale : int {
+ DbfsDc, // Full-scale sinusoid measures -3 dBFS
+ DbfsSin, // Full-scale sinusoid measures 0 dBFS
+ Native // Full-scale sinusoid measures -6 dBFS
+};
+
+enum class Window : int { BlackmanHarris,
+ Hann,
+ NoWindow };
} // namespace genalyzer_impl
@@ -81,98 +70,96 @@ namespace genalyzer_impl {
*/
namespace genalyzer_impl {
- enum class FACompType : int { // Fourier Analysis Component Type
- DC, // DC component (always Bin 0)
- FixedTone, // Tone with fixed, user-defined location
- MaxTone, // Next largest tone
- WOTone // Worst other tone
- };
-
- enum class FAResult : int { // Fourier Analysis Results
- // Meta Data
- AnalysisType = 0, // Analysis type
- SignalType, // Signal type: 0=Real, 1=Cplx
- NFFT, // FFT size
- DataSize, // Data size
- FBin, // Frequency resolution (Hz)
- FData, // Data rate (S/s)
- FSample, // Sample rate (S/s)
- FShift, // Shift frequency (Hz)
- // Primary Measurements
- 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)
- // Carrier and MaxSpur
- CarrierIndex, // Order index of Carrier tone
- MaxSpurIndex, // Order index of MaxSpur tone
- // Analysis Band Info
- AB_Width, // Width (Hz)
- AB_I1, // Index 1
- AB_I2, // Index 2
- AB_NBins, // Number of bins
- AB_RSS, // Root-sum-square
- // In-Band Tag Info
- Signal_NBins,
- Signal_RSS,
- CLK_NBins,
- CLK_RSS,
- HD_NBins,
- HD_RSS,
- ILOS_NBins,
- ILOS_RSS,
- ILGT_NBins,
- ILGT_RSS,
- IMD_NBins,
- IMD_RSS,
- UserDist_NBins,
- UserDist_RSS,
- // In-Band Composite Info
- THD_NBins, // HD + IMD (total harmonic distortion)
- THD_RSS,
- ILV_NBins, // ILOS + ILGT (total interleaving)
- ILV_RSS,
- Dist_NBins, // Distortion
- Dist_RSS,
- Noise_NBins, // Noise
- Noise_RSS,
- NAD_NBins, // Noise + Distortion
- NAD_RSS,
- //
- __SIZE__
- };
-
- enum class FAToneResult : int { // Fourier Analysis Tone Results
- OrderIndex = 0,
- Tag,
- Freq,
- FFinal,
- FWAvg,
- I1,
- I2,
- NBins,
- InBand,
- Mag,
- Mag_dBFS,
- Mag_dBc,
- Phase,
- Phase_c,
- //
- __SIZE__
- };
-
- enum class FPFormat { // Floating-point format
- Auto,
- Eng,
- Fix,
- Sci
- };
-
- enum class ObjectType {
- FourierAnalysis
- };
+enum class FACompType : int { // Fourier Analysis Component Type
+ DC, // DC component (always Bin 0)
+ FixedTone, // Tone with fixed, user-defined location
+ MaxTone, // Next largest tone
+ WOTone // Worst other tone
+};
+
+enum class FAResult : int { // Fourier Analysis Results
+ // Meta Data
+ AnalysisType = 0, // Analysis type
+ SignalType, // Signal type: 0=Real, 1=Cplx
+ NFFT, // FFT size
+ DataSize, // Data size
+ FBin, // Frequency resolution (Hz)
+ FData, // Data rate (S/s)
+ FSample, // Sample rate (S/s)
+ FShift, // Shift frequency (Hz)
+ // Primary Measurements
+ 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)
+ // Carrier and MaxSpur
+ CarrierIndex, // Order index of Carrier tone
+ MaxSpurIndex, // Order index of MaxSpur tone
+ // Analysis Band Info
+ AB_Width, // Width (Hz)
+ AB_I1, // Index 1
+ AB_I2, // Index 2
+ AB_NBins, // Number of bins
+ AB_RSS, // Root-sum-square
+ // In-Band Tag Info
+ Signal_NBins,
+ Signal_RSS,
+ CLK_NBins,
+ CLK_RSS,
+ HD_NBins,
+ HD_RSS,
+ ILOS_NBins,
+ ILOS_RSS,
+ ILGT_NBins,
+ ILGT_RSS,
+ IMD_NBins,
+ IMD_RSS,
+ UserDist_NBins,
+ UserDist_RSS,
+ // In-Band Composite Info
+ THD_NBins, // HD + IMD (total harmonic distortion)
+ THD_RSS,
+ ILV_NBins, // ILOS + ILGT (total interleaving)
+ ILV_RSS,
+ Dist_NBins, // Distortion
+ Dist_RSS,
+ Noise_NBins, // Noise
+ Noise_RSS,
+ NAD_NBins, // Noise + Distortion
+ NAD_RSS,
+ //
+ __SIZE__
+};
+
+enum class FAToneResult : int { // Fourier Analysis Tone Results
+ OrderIndex = 0,
+ Tag,
+ Freq,
+ FFinal,
+ FWAvg,
+ I1,
+ I2,
+ NBins,
+ InBand,
+ Mag,
+ Mag_dBFS,
+ Mag_dBc,
+ Phase,
+ Phase_c,
+ //
+ __SIZE__
+};
+
+enum class FPFormat { // Floating-point format
+ Auto,
+ Eng,
+ Fix,
+ Sci
+};
+
+enum class ObjectType { FourierAnalysis };
} // namespace genalyzer_impl
diff --git a/include/exceptions.hpp b/include/exceptions.hpp
index 9eb2006..1170615 100644
--- a/include/exceptions.hpp
+++ b/include/exceptions.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_EXCEPTIONS_HPP
#define GENALYZER_IMPL_EXCEPTIONS_HPP
@@ -5,15 +8,13 @@
namespace genalyzer_impl {
- class logic_error final : public std::logic_error
- {
- using std::logic_error::logic_error;
- };
+class logic_error final : public std::logic_error {
+ using std::logic_error::logic_error;
+};
- class runtime_error final : public std::runtime_error
- {
- using std::runtime_error::runtime_error;
- };
+class runtime_error final : public std::runtime_error {
+ using std::runtime_error::runtime_error;
+};
} // namespace genalyzer_impl
diff --git a/include/expression.hpp b/include/expression.hpp
index 1f95228..0f6d00d 100644
--- a/include/expression.hpp
+++ b/include/expression.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_EXPRESSION_HPP
#define GENALYZER_IMPL_EXPRESSION_HPP
@@ -10,45 +13,41 @@
namespace genalyzer_impl {
- struct expression_token;
+struct expression_token;
- class expression
- {
- public:
+class expression {
+public:
+ using token_ptr = std::unique_ptr;
+ using token_vector = std::vector;
+ using var_map = std::map;
+ using var_set = std::set;
- using token_ptr = std::unique_ptr;
- using token_vector = std::vector;
- using var_map = std::map;
- using var_set = std::set;
+public:
+ expression(const str_t &infix_string);
- public:
+ ~expression();
- expression(const str_t& infix_string);
+public:
+ // Returns true if expression depends on one or more variables in vars
+ bool depends_on(const var_set &vars) const;
- ~expression();
-
- public:
+ real_t evaluate(const var_map &vars = var_map()) const;
- // Returns true if expression depends on one or more variables in vars
- bool depends_on(const var_set& vars) const;
+ str_t to_postfix_string(FPFormat fmt = FPFormat::Auto,
+ int max_prec = -1) const;
- real_t evaluate(const var_map& vars = var_map()) const;
+ str_t to_string(FPFormat fmt = FPFormat::Auto, int max_prec = -1) const;
- str_t to_postfix_string(FPFormat fmt = FPFormat::Auto, int max_prec = -1) const;
-
- str_t to_string(FPFormat fmt = FPFormat::Auto, int max_prec = -1) const;
+ // Returns the variables expression depends on
+ var_set vars() const;
- // Returns the variables expression depends on
- var_set vars() const;
+ // Returns the first expression variable not found in vars
+ str_t vars_defined(const var_map &vars) const;
- // Returns the first expression variable not found in vars
- str_t vars_defined(const var_map& vars) const;
-
- private:
+private:
+ token_vector m_infix_tokens;
- token_vector m_infix_tokens;
-
- }; // class expression
+}; // class expression
} // namespace genalyzer_impl
diff --git a/include/formatted_data.hpp b/include/formatted_data.hpp
index 1032b27..70ce826 100644
--- a/include/formatted_data.hpp
+++ b/include/formatted_data.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_FORMATTED_DATA_HPP
#define GENALYZER_IMPL_FORMATTED_DATA_HPP
@@ -5,13 +8,9 @@
namespace genalyzer_impl {
- str_t table(
- const std::vector& header_rows,
- const std::vector& data_rows,
- int col_margin,
- bool show_border,
- bool show_col_sep
- );
+str_t table(const std::vector &header_rows,
+ const std::vector &data_rows, int col_margin,
+ bool show_border, bool show_col_sep);
} // namespace genalyzer_impl
diff --git a/include/fourier_analysis.hpp b/include/fourier_analysis.hpp
index 0e8d0ae..ae6d446 100644
--- a/include/fourier_analysis.hpp
+++ b/include/fourier_analysis.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_FOURIER_ANALYSIS_HPP
#define GENALYZER_IMPL_FOURIER_ANALYSIS_HPP
@@ -16,215 +19,225 @@
namespace genalyzer_impl {
- class fourier_analysis final : public object
- {
- public:
+class fourier_analysis final : public object {
+public:
+ using mask_map = std::map;
+ using min_max_def_t = std::tuple;
+ using var_map = expression::var_map;
- using mask_map = std::map;
- using min_max_def_t = std::tuple;
- using var_map = expression::var_map;
+public:
+ static std::shared_ptr create() {
+ return std::make_shared();
+ }
- public:
+ static std::shared_ptr load(const str_t &filename);
- static std::shared_ptr create()
- {
- return std::make_shared();
- }
+ static const min_max_def_t mmd_hd;
+ static const min_max_def_t mmd_imd;
+ static const min_max_def_t mmd_wo;
+ static const min_max_def_t mmd_ssb;
- static std::shared_ptr load(const str_t& filename);
+public: // Constructors, Destructor, and Assignment
+ fourier_analysis();
- static const min_max_def_t mmd_hd;
- static const min_max_def_t mmd_imd;
- static const min_max_def_t mmd_wo;
- static const min_max_def_t mmd_ssb;
+ fourier_analysis(const fourier_analysis &);
- public: // Constructors, Destructor, and Assignment
+ fourier_analysis(fourier_analysis &&);
- fourier_analysis();
+ ~fourier_analysis() = default;
- fourier_analysis(const fourier_analysis&);
+ fourier_analysis &operator=(const fourier_analysis &);
- fourier_analysis(fourier_analysis&&);
+ fourier_analysis &operator=(fourier_analysis &&);
- ~fourier_analysis() = default;
+public: // Analysis
+ fourier_analysis_results analyze(const real_t *in_data,
+ const size_t in_size,
+ const size_t nfft,
+ FreqAxisType axis_type) const;
- fourier_analysis& operator=(const fourier_analysis&);
+public: // Component Definition
+ void add_fixed_tone(const str_t &key, FACompTag tag, const str_t &freq,
+ int ssb);
- fourier_analysis& operator=(fourier_analysis&&);
+ void add_max_tone(const str_t &key, FACompTag tag, const str_t ¢er,
+ const str_t &width, int ssb);
- public: // Analysis
+ void remove_comp(const str_t &key);
- fourier_analysis_results analyze(const real_t* in_data, const size_t in_size,
- const size_t nfft, FreqAxisType axis_type) const;
+public: // Configuration Getters
+ str_t ab_center() const {
+ return m_ab_center;
+ }
+ str_t ab_width() const {
+ return m_ab_width;
+ }
+ std::set clk() const {
+ return m_clk;
+ }
+ str_t fdata() const {
+ return m_fdata;
+ }
+ str_t fsample() const {
+ return m_fdata;
+ }
+ str_t fshift() const {
+ return m_fdata;
+ }
+ int hd() const {
+ return m_hd;
+ }
+ std::set ilv() const {
+ return m_ilv;
+ }
+ int imd() const {
+ return m_imd;
+ }
+ int wo() const {
+ return m_wo;
+ }
- public: // Component Definition
+ int ssb(FASsb group) const;
- void add_fixed_tone(const str_t& key, FACompTag tag, const str_t& freq, int ssb);
+public: // Configuration Setters
+ void set_analysis_band(const str_t ¢er, const str_t &width);
- void add_max_tone(const str_t& key, FACompTag tag, const str_t& center, const str_t& width, int ssb);
+ void set_clk(const std::set &clk);
- void remove_comp(const str_t& key);
+ void set_fdata(const str_t &expr);
- public: // Configuration Getters
+ void set_fsample(const str_t &expr);
- str_t ab_center() const { return m_ab_center; };
- str_t ab_width() const { return m_ab_width; };
- std::set clk() const { return m_clk; };
- str_t fdata() const { return m_fdata; };
- str_t fsample() const { return m_fdata; };
- str_t fshift() const { return m_fdata; };
- int hd() const { return m_hd; };
- std::set ilv() const { return m_ilv; };
- int imd() const { return m_imd; };
- int wo() const { return m_wo; };
+ void set_fshift(const str_t &expr);
- int ssb(FASsb group) const;
+ void set_hd(int n);
- public: // Configuration Setters
+ void set_ilv(const std::set &ilv);
- void set_analysis_band(const str_t& center, const str_t& width);
+ void set_imd(int n);
- void set_clk(const std::set& clk);
+ void set_ssb(FASsb group, int ssb);
- void set_fdata(const str_t& expr);
+ void set_var(const str_t &key, real_t x);
- void set_fsample(const str_t& expr);
+ void set_wo(int n);
- void set_fshift(const str_t& expr);
+public: // Key Queries
+ static bool is_reserved(const str_t &key);
- void set_hd(int n);
+ static bool is_valid(const str_t &key);
- void set_ilv(const std::set& ilv);
+ bool is_available(const str_t &key) const {
+ return !is_reserved(key) && !is_comp(key) && !is_var(key) &&
+ is_valid(key);
+ }
- void set_imd(int n);
+ bool is_comp(const str_t &key) const {
+ return !(m_user_comps.find(key) == m_user_comps.end());
+ }
- void set_ssb(FASsb group, int ssb);
+ bool is_var(const str_t &key) const {
+ return !(m_user_vars.find(key) == m_user_vars.end());
+ }
- void set_var(const str_t& key, real_t x);
+public: // Other Member Functions
+ static str_t flat_tone_key(const str_t &key, int result_index);
- void set_wo(int n);
+ static std::pair split_key(const str_t &key);
- public: // Key Queries
+ str_t preview(bool cplx) const;
- static bool is_reserved(const str_t& key);
+ void reset();
- static bool is_valid(const str_t& key);
+ std::vector result_key_lengths(size_t in_size,
+ size_t nfft) const;
- bool is_available(const str_t& key) const
- {
- return !is_reserved(key) && !is_comp(key) && !is_var(key) && is_valid(key);
- }
+ size_t results_size(size_t in_size, size_t nfft) const;
- bool is_comp(const str_t& key) const
- {
- return !(m_user_comps.find(key) == m_user_comps.end());
- }
+private:
+ static const str_t key_pattern;
+ static const str_t wo_pattern;
+ static const std::set reserved_keys;
+ static const str_vector reserved_patterns;
+ static const str_t flat_key_coupler;
- bool is_var(const str_t& key) const
- {
- return !(m_user_vars.find(key) == m_user_vars.end());
- }
+private: // Virtual Function Overrides
+ bool equals_impl(const object &that) const override;
- public: // Other Member Functions
+ ObjectType object_type_impl() const override {
+ return ObjectType::FourierAnalysis;
+ }
- static str_t flat_tone_key(const str_t& key, int result_index);
+ void save_impl(const str_t &filename) const override;
- static std::pair split_key(const str_t& key);
+ str_t to_string_impl() const override;
- str_t preview(bool cplx) const;
+private:
+ using comp_ptr = std::unique_ptr;
+ using comp_map = std::map;
+ using comp_data_t = std::tuple>;
- void reset();
+ static void add_comp(str_vector &keys, comp_map &comps, const str_t &k,
+ comp_ptr c);
- std::vector result_key_lengths(size_t in_size, size_t nfft) const;
+ static int limit_ssb(int ssb, int lower_limit);
- size_t results_size(size_t in_size, size_t nfft) const;
+ comp_data_t generate_comps(bool cplx) const;
- private:
+ void if_key_not_available_throw(const str_t &key) const;
- static const str_t key_pattern;
- static const str_t wo_pattern;
- static const std::set reserved_keys;
- static const str_vector reserved_patterns;
- static const str_t flat_key_coupler;
+private: // Analysis and related subroutines
+ static mask_map initialize_masks(bool cplx, size_t size);
- private: // Virtual Function Overrides
+ fourier_analysis_results analyze_impl(
+ const real_t *msq_data, // mean-square FFT magnitude data
+ const size_t msq_size, // size of ms_data
+ const size_t nfft, // FFT size
+ FreqAxisType axis_type, //
+ const cplx_t *fft_data =
+ nullptr, // complex FFT data; if provided, results include phase
+ const size_t fft_size =
+ 0 // size of fft_data; if fft_data is not Null,
+ ) const; // fft_size should equal msq_size
- bool equals_impl(const object& that) const override;
+ void finalize_masks(mask_map &masks) const;
- ObjectType object_type_impl() const override
- {
- return ObjectType::FourierAnalysis;
- }
+ var_map initialize_vars(size_t nfft) const;
- void save_impl(const str_t& filename) const override;
+ void setup_analysis_band(bool cplx, fourier_analysis_comp_mask &mask,
+ var_map &vars) const;
- str_t to_string_impl() const override;
+public: // Public configuration parameters
+ bool clk_as_noise; // Treat CLK components as noise
+ bool dc_as_dist; // Treat DC component as distortion
+ bool en_conv_offset; // Enable converter offset component
+ bool en_fund_images; // Enable fundamental image component(s)
+ bool en_quad_errors; // Enable quadrature error tone components
+ bool ilv_as_noise; // Treat ILV components as noise
- private:
+private: // Private configuration parameters
+ int m_hd; // Order of harmonic distortion
+ int m_imd; // Order of intermodulation distortion
+ int m_wo; // Number of worst others
+ int m_ssb_def; // Default SSB (for auto-generated tone components)
+ int m_ssb_dc; // SSB for DC
+ int m_ssb_sig; // SSB for Signals
+ int m_ssb_wo; // SSB for WO
+ str_t m_ab_center; // Analysis band center
+ str_t m_ab_width; // Analysis band width
+ str_t m_fdata; // Data rate
+ str_t m_fsample; // Sample rate
+ str_t m_fshift; // Shift frequency (sum of frequency translations after
+ // sampling)
+ std::set m_clk; // Clock sub-harmonic divisors
+ std::set m_ilv; // Interleaving factors
- using comp_ptr = std::unique_ptr;
- using comp_map = std::map;
- using comp_data_t = std::tuple>;
+ // User-defined components and variables
+ str_vector m_user_keys;
+ comp_map m_user_comps;
+ var_map m_user_vars;
- static void add_comp(str_vector& keys, comp_map& comps, const str_t& k, comp_ptr c);
-
- static int limit_ssb(int ssb, int lower_limit);
-
- comp_data_t generate_comps(bool cplx) const;
-
- void if_key_not_available_throw(const str_t& key) const;
-
- private: // Analysis and related subroutines
-
- static mask_map initialize_masks(bool cplx, size_t size);
-
- fourier_analysis_results analyze_impl(
- const real_t* msq_data, // mean-square FFT magnitude data
- const size_t msq_size, // size of ms_data
- const size_t nfft, // FFT size
- FreqAxisType axis_type, //
- const cplx_t* fft_data = nullptr, // complex FFT data; if provided, results include phase
- const size_t fft_size = 0 // size of fft_data; if fft_data is not Null,
- ) const; // fft_size should equal msq_size
-
- void finalize_masks(mask_map& masks) const;
-
- var_map initialize_vars(size_t nfft) const;
-
- void setup_analysis_band(bool cplx, fourier_analysis_comp_mask& mask, var_map& vars) const;
-
- public: // Public configuration parameters
-
- bool clk_as_noise; // Treat CLK components as noise
- bool dc_as_dist; // Treat DC component as distortion
- bool en_conv_offset; // Enable converter offset component
- bool en_fund_images; // Enable fundamental image component(s)
- bool en_quad_errors; // Enable quadrature error tone components
- bool ilv_as_noise; // Treat ILV components as noise
-
- private: // Private configuration parameters
-
- int m_hd; // Order of harmonic distortion
- int m_imd; // Order of intermodulation distortion
- int m_wo; // Number of worst others
- int m_ssb_def; // Default SSB (for auto-generated tone components)
- int m_ssb_dc; // SSB for DC
- int m_ssb_sig; // SSB for Signals
- int m_ssb_wo; // SSB for WO
- str_t m_ab_center; // Analysis band center
- str_t m_ab_width; // Analysis band width
- str_t m_fdata; // Data rate
- str_t m_fsample; // Sample rate
- str_t m_fshift; // Shift frequency (sum of frequency translations after sampling)
- std::set m_clk; // Clock sub-harmonic divisors
- std::set m_ilv; // Interleaving factors
-
- // User-defined components and variables
- str_vector m_user_keys;
- comp_map m_user_comps;
- var_map m_user_vars;
-
- }; // class fourier_analysis
+}; // class fourier_analysis
} // namespace genalyzer_impl
diff --git a/include/fourier_analysis_comp_mask.hpp b/include/fourier_analysis_comp_mask.hpp
index cd6cd39..cfa8129 100644
--- a/include/fourier_analysis_comp_mask.hpp
+++ b/include/fourier_analysis_comp_mask.hpp
@@ -1,194 +1,164 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_FOURIER_ANALYSIS_COMP_MASK_HPP
#define GENALYZER_IMPL_FOURIER_ANALYSIS_COMP_MASK_HPP
-#include
#include "type_aliases.hpp"
+#include
namespace genalyzer_impl {
- // Ranges are set as [first, last], i.e., inclusive-inclusive,
- // but are stored [first, last+1) like STL, i.e., inclusive-exclusive
- class fourier_analysis_comp_mask
- {
- public:
-
- enum BoundaryMode { Stop, Wrap };
-
- public:
-
- fourier_analysis_comp_mask(bool cplx, size_t array_size)
- : m_mode {cplx ? Wrap : Stop},
- m_ufirst {0},
- m_ulast {array_size - 1},
- m_usize {array_size},
- m_first {0},
- m_last {static_cast(array_size - 1)},
- m_size {static_cast(array_size)},
- m_data {}
- {}
-
- fourier_analysis_comp_mask(bool cplx, size_t array_size, const std::vector& init);
-
- fourier_analysis_comp_mask(const fourier_analysis_comp_mask& m)
- : m_mode {m.m_mode},
- m_ufirst {m.m_ufirst},
- m_ulast {m.m_ulast},
- m_usize {m.m_usize},
- m_first {m.m_first},
- m_last {m.m_last},
- m_size {m.m_size},
- m_data (m.m_data)
- {}
-
- fourier_analysis_comp_mask(fourier_analysis_comp_mask&& m)
- : m_mode {m.m_mode},
- m_ufirst {m.m_ufirst},
- m_ulast {m.m_ulast},
- m_usize {m.m_usize},
- m_first {m.m_first},
- m_last {m.m_last},
- m_size {m.m_size},
- m_data (std::move(m.m_data))
- {}
-
- ~fourier_analysis_comp_mask() = default;
-
- public:
-
- fourier_analysis_comp_mask& operator=(const fourier_analysis_comp_mask& m)
- {
- if (&m != this) {
- fourier_analysis_comp_mask the_copy (m);
- std::swap(the_copy, *this);
- }
- return *this;
- }
-
- fourier_analysis_comp_mask& operator=(fourier_analysis_comp_mask&& m)
- {
- std::swap(this->m_mode , m.m_mode);
- std::swap(this->m_ufirst , m.m_ufirst);
- std::swap(this->m_ulast , m.m_ulast);
- std::swap(this->m_usize , m.m_usize);
- std::swap(this->m_first , m.m_first);
- std::swap(this->m_last , m.m_last);
- std::swap(this->m_size , m.m_size);
- std::swap(this->m_data , m.m_data);
- return *this;
- }
-
- fourier_analysis_comp_mask& operator&=(fourier_analysis_comp_mask m);
-
- fourier_analysis_comp_mask& operator|=(const fourier_analysis_comp_mask& m);
-
- public:
-
- void clear()
- {
- m_data.clear();
- }
-
- // Returns the number of elements in the ranges
- size_t count() const;
-
- real_t count_r() const
- {
- return static_cast(count());
- }
-
- const std::vector& data() const
- {
- return m_data;
- }
-
- bool equals(const fourier_analysis_comp_mask& that) const
- {
- return (this->m_usize == that.m_usize) && (this->m_data == that.m_data);
- }
-
- // <0> = index of max element (-1 if not found)
- // <1> = last contiguous free index to the left
- // <2> = last contiguous free index to the right
- std::tuple find_max_index(const real_t* data, size_t size) const;
-
- // Returns Index1, Index2, Number of Bins
- std::tuple get_indexes() const;
-
- void invert();
-
- BoundaryMode mode() const
- {
- return m_mode;
- }
-
- size_t num_ranges() const
- {
- return m_data.size() / 2;
- }
-
- // Returns true if [left, right] overlaps any ranges
- bool overlaps(size_t left, size_t right) const; // inclusive-inclusive
-
- void set(std::vector init)
- {
- fourier_analysis_comp_mask new_mask ((Wrap == this->m_mode), this->m_usize, init);
- std::swap(new_mask, *this);
- }
-
- void set_all()
- {
- m_data = {0, m_usize};
- }
-
- void set_range(diff_t left, diff_t right); // inclusive-inclusive
-
- size_t size() const
- {
- return m_usize;
- }
-
- real_t root_sum(const real_t* data, size_t size) const
- {
- return std::sqrt(sum(data, size));
- }
-
- // Returns the sum of the data in the ranges
- real_t sum(const real_t* data, size_t size) const;
-
- void unset_ranges(const fourier_analysis_comp_mask& m);
-
- private:
-
- // Returns the index of the first element greater than 'value'
- size_t get_index(size_t value) const;
-
- void if_not_compat_then_throw(const fourier_analysis_comp_mask& m);
-
- // Document the pre-conditions that make this 'safe'
- void set_range_safe(size_t left, size_t right); // inclusive-inclusive
-
- private:
-
- BoundaryMode m_mode;
- size_t m_ufirst;
- size_t m_ulast;
- size_t m_usize;
- diff_t m_first;
- diff_t m_last;
- diff_t m_size;
- std::vector m_data;
-
- }; // class fourier_analysis_comp_mask
+// Ranges are set as [first, last], i.e., inclusive-inclusive,
+// but are stored [first, last+1) like STL, i.e., inclusive-exclusive
+class fourier_analysis_comp_mask {
+public:
+ enum BoundaryMode { Stop,
+ Wrap };
+
+public:
+ fourier_analysis_comp_mask(bool cplx, size_t array_size) :
+ m_mode{ cplx ? Wrap : Stop }, m_ufirst{ 0 }, m_ulast{ array_size - 1 }, m_usize{ array_size }, m_first{ 0 }, m_last{ static_cast(array_size - 1) }, m_size{ static_cast(array_size) }, m_data{} {
+ }
+
+ fourier_analysis_comp_mask(bool cplx, size_t array_size,
+ const std::vector &init);
+
+ fourier_analysis_comp_mask(const fourier_analysis_comp_mask &m) :
+ m_mode{ m.m_mode }, m_ufirst{ m.m_ufirst }, m_ulast{ m.m_ulast }, m_usize{ m.m_usize }, m_first{ m.m_first }, m_last{ m.m_last }, m_size{ m.m_size }, m_data(m.m_data) {
+ }
+
+ fourier_analysis_comp_mask(fourier_analysis_comp_mask &&m) :
+ m_mode{ m.m_mode }, m_ufirst{ m.m_ufirst }, m_ulast{ m.m_ulast }, m_usize{ m.m_usize }, m_first{ m.m_first }, m_last{ m.m_last }, m_size{ m.m_size }, m_data(std::move(m.m_data)) {
+ }
+
+ ~fourier_analysis_comp_mask() = default;
+
+public:
+ fourier_analysis_comp_mask &
+ operator=(const fourier_analysis_comp_mask &m) {
+ if (&m != this) {
+ fourier_analysis_comp_mask the_copy(m);
+ std::swap(the_copy, *this);
+ }
+ return *this;
+ }
+
+ fourier_analysis_comp_mask &operator=(fourier_analysis_comp_mask &&m) {
+ std::swap(this->m_mode, m.m_mode);
+ std::swap(this->m_ufirst, m.m_ufirst);
+ std::swap(this->m_ulast, m.m_ulast);
+ std::swap(this->m_usize, m.m_usize);
+ std::swap(this->m_first, m.m_first);
+ std::swap(this->m_last, m.m_last);
+ std::swap(this->m_size, m.m_size);
+ std::swap(this->m_data, m.m_data);
+ return *this;
+ }
+
+ fourier_analysis_comp_mask &operator&=(fourier_analysis_comp_mask m);
+
+ fourier_analysis_comp_mask &
+ operator|=(const fourier_analysis_comp_mask &m);
+
+public:
+ void clear() {
+ m_data.clear();
+ }
+
+ // Returns the number of elements in the ranges
+ size_t count() const;
+
+ real_t count_r() const {
+ return static_cast(count());
+ }
+
+ const std::vector &data() const {
+ return m_data;
+ }
+
+ bool equals(const fourier_analysis_comp_mask &that) const {
+ return (this->m_usize == that.m_usize) &&
+ (this->m_data == that.m_data);
+ }
+
+ // <0> = index of max element (-1 if not found)
+ // <1> = last contiguous free index to the left
+ // <2> = last contiguous free index to the right
+ std::tuple find_max_index(const real_t *data,
+ size_t size) const;
+
+ // Returns Index1, Index2, Number of Bins
+ std::tuple get_indexes() const;
+
+ void invert();
+
+ BoundaryMode mode() const {
+ return m_mode;
+ }
+
+ size_t num_ranges() const {
+ return m_data.size() / 2;
+ }
+
+ // Returns true if [left, right] overlaps any ranges
+ bool overlaps(size_t left, size_t right) const; // inclusive-inclusive
+
+ void set(std::vector init) {
+ fourier_analysis_comp_mask new_mask((Wrap == this->m_mode),
+ this->m_usize, init);
+ std::swap(new_mask, *this);
+ }
+
+ void set_all() {
+ m_data = { 0, m_usize };
+ }
+
+ void set_range(diff_t left, diff_t right); // inclusive-inclusive
+
+ size_t size() const {
+ return m_usize;
+ }
+
+ real_t root_sum(const real_t *data, size_t size) const {
+ return std::sqrt(sum(data, size));
+ }
+
+ // Returns the sum of the data in the ranges
+ real_t sum(const real_t *data, size_t size) const;
+
+ void unset_ranges(const fourier_analysis_comp_mask &m);
+
+private:
+ // Returns the index of the first element greater than 'value'
+ size_t get_index(size_t value) const;
+
+ void if_not_compat_then_throw(const fourier_analysis_comp_mask &m);
+
+ // Document the pre-conditions that make this 'safe'
+ void set_range_safe(size_t left, size_t right); // inclusive-inclusive
+
+private:
+ BoundaryMode m_mode;
+ size_t m_ufirst;
+ size_t m_ulast;
+ size_t m_usize;
+ diff_t m_first;
+ diff_t m_last;
+ diff_t m_size;
+ std::vector m_data;
+
+}; // class fourier_analysis_comp_mask
- inline bool operator==(const fourier_analysis_comp_mask& a, const fourier_analysis_comp_mask& b)
- {
- return a.equals(b);
- }
+inline bool operator==(const fourier_analysis_comp_mask &a,
+ const fourier_analysis_comp_mask &b) {
+ return a.equals(b);
+}
- inline bool operator!=(const fourier_analysis_comp_mask& a, const fourier_analysis_comp_mask& b)
- {
- return !a.equals(b);
- }
+inline bool operator!=(const fourier_analysis_comp_mask &a,
+ const fourier_analysis_comp_mask &b) {
+ return !a.equals(b);
+}
} // namespace genalyzer_impl
diff --git a/include/fourier_analysis_component.hpp b/include/fourier_analysis_component.hpp
index db4f56c..28ee181 100644
--- a/include/fourier_analysis_component.hpp
+++ b/include/fourier_analysis_component.hpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2024 Analog Devices, Inc.
+//
+// SPDX short identifier: ADIBSD OR GPL-2.0-or-later
#ifndef GENALYZER_IMPL_FOURIER_ANALYSIS_COMPONENT_HPP
#define GENALYZER_IMPL_FOURIER_ANALYSIS_COMPONENT_HPP
@@ -8,214 +11,190 @@
namespace genalyzer_impl {
- struct fourier_analysis_component
- {
- using pointer = std::unique_ptr;
-
- fourier_analysis_component(FACompType _type, FACompTag _tag)
- : type (_type),
- tag (_tag)
- {}
-
- virtual ~fourier_analysis_component() = default;
-
- pointer clone() const
- {
- return clone_impl();
- }
-
- bool equals(const fourier_analysis_component& that) const
- {
- return this->equals_impl(that);
- }
-
- str_t spec() const
- {
- return spec_impl();
- }
-
- const FACompType type;
- const FACompTag tag;
-
- private:
-
- virtual pointer clone_impl() const = 0;
-
- virtual bool equals_impl(const fourier_analysis_component& that) const = 0;
-
- virtual str_t spec_impl() const = 0;
-
- }; // class fourier_analysis_component
-
- struct fa_dc final : public fourier_analysis_component
- {
- static pointer create(int ssb)
- {
- return std::make_unique(ssb);
- }
-
- fa_dc(int _ssb)
- : fourier_analysis_component(FACompType::DC, FACompTag::DC),
- ssb (_ssb)
- {}
-
- ~fa_dc() = default;
-
- const int ssb;
-
- private:
-
- pointer clone_impl() const override
- {
- return std::make_unique(*this);
- }
-
- bool equals_impl(const fourier_analysis_component& that_obj) const override
- {
- bool equal = (this->type == that_obj.type) && (this->tag == that_obj.tag);
- if (!equal) {
- return false;
- }
- auto& that = static_cast(that_obj);
- return this->ssb == that.ssb;
- }
-
- str_t spec_impl() const override
- {
- return "SSB= " + std::to_string(ssb);
- }
-
- }; // class fa_dc
-
- struct fa_fixed_tone final : public fourier_analysis_component
- {
- static pointer create(FACompTag tag, const str_t& freq, int ssb)
- {
- return std::make_unique(tag, freq, ssb);
- }
-
- fa_fixed_tone(FACompTag tag, const str_t& _freq, int _ssb)
- : fourier_analysis_component(FACompType::FixedTone, tag),
- freq (_freq),
- ssb (_ssb)
- {}
-
- ~fa_fixed_tone() = default;
-
- const str_t freq;
- const int ssb;
-
- private:
-
- pointer clone_impl() const override
- {
- return std::make_unique(*this);
- }
-
- bool equals_impl(const fourier_analysis_component& that_obj) const override
- {
- bool equal = (this->type == that_obj.type) && (this->tag == that_obj.tag);
- if (!equal) {
- return false;
- }
- auto& that = static_cast(that_obj);
- return (this->freq == that.freq) && (this->ssb == that.ssb);
- }
-
- str_t spec_impl() const override
- {
- return "F= " + freq + " , SSB= " + std::to_string(ssb);
- }
-
- }; // class fa_fixed_tone
-
- struct fa_max_tone final : public fourier_analysis_component
- {
- static pointer create(FACompTag tag, const str_t& center, const str_t& width, int ssb)
- {
- return std::make_unique(tag, center, width, ssb);
- }
-
- fa_max_tone(FACompTag tag, const str_t& _center, const str_t& _width, int _ssb)
- : fourier_analysis_component(FACompType::MaxTone, tag),
- center (_center),
- width (_width),
- ssb (_ssb)
- {}
-
- ~fa_max_tone() = default;
-
- const str_t center;
- const str_t width;
- const int ssb;
-
- private:
-
- pointer clone_impl() const override
- {
- return std::make_unique(*this);
- }
-
- bool equals_impl(const fourier_analysis_component& that_obj) const override
- {
- bool equal = (this->type == that_obj.type) && (this->tag == that_obj.tag);
- if (!equal) {
- return false;
- }
- auto& that = static_cast(that_obj);
- return (this->center == that.center) &&
- (this->width == that.width ) &&
- (this->ssb == that.ssb );
- }
-
- str_t spec_impl() const override
- {
- // May implement search band in the future.
- // return "C= " + center + " , W= " + width + " , SSB= " + std::to_string(ssb);
- return "SSB= " + std::to_string(ssb);
- }
-
- }; // class fa_max_tone
-
- struct fa_wo_tone final : public fourier_analysis_component
- {
- static pointer create(int ssb)
- {
- return std::make_unique(ssb);
- }
-
- fa_wo_tone(int _ssb)
- : fourier_analysis_component(FACompType::WOTone, FACompTag::Noise),
- ssb (_ssb)
- {}
-
- ~fa_wo_tone() = default;
-
- const int ssb;
-
- private:
-
- pointer clone_impl() const override
- {
- return std::make_unique(*this);
- }
-
- bool equals_impl(const fourier_analysis_component& that_obj) const override
- {
- bool equal = (this->type == that_obj.type) && (this->tag == that_obj.tag);
- if (!equal) {
- return false;
- }
- auto& that = static_cast(that_obj);
- return this->ssb == that.ssb;
- }
-
- str_t spec_impl() const override
- {
- return "SSB= " + std::to_string(ssb);
- }
-
- }; // class fa_wo_tone
+struct fourier_analysis_component {
+ using pointer = std::unique_ptr