Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • f99a844
  • /
  • lib
  • /
  • OxSignCalculatorRealImag.h
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:951601c173a8bc1f1b067dda98695e1b8214dda2
directory badge Iframe embedding
swh:1:dir:7f21c9a4b7dfafd29925be862d8bd559b684364d
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
OxSignCalculatorRealImag.h
/*!
 * \file OxSignCalculatorRealImag.h
 * \author Konrad Werys
 * \date 2018/08/01
 */

#ifndef Tomato_OXSIGNCALCULATORRealImag_H
#define Tomato_OXSIGNCALCULATORRealImag_H

#include "OxSignCalculator.h"
#include "KWUtil.h"

namespace Ox {

    /**
     * \class SignCalculatorRealImag
     * \brief
     * \details
     * @tparam MeasureType
     */
    template< typename MeasureType >
    class SignCalculatorRealImag : public SignCalculator<MeasureType> {

    public:
        virtual int calculateSign(){
            return RealMagPhase2Signs(
                    this->getNSamples(),
                    this->getSigMag(),
                    this->getSigPha(),
                    this->getSignal(),
                    this->getSigns());
        };

        static int RealMagPhase2Signs(
                int nSamples,
                const MeasureType* sigMag,
                const MeasureType* sigPha,
                MeasureType* signal,
                MeasureType* signs);

        /**
         * cloning
         * @return
         */
        virtual SignCalculator<MeasureType> *newByCloning() { return new SignCalculatorRealImag<MeasureType>(*this); }

    };

    template<typename MeasureType>
    int
    SignCalculatorRealImag<MeasureType>
    ::RealMagPhase2Signs(
            int nSamples,
            const MeasureType* sigMag,
            const MeasureType* sigPha,
            MeasureType* signal,
            MeasureType* signs) {

//        for (int i = 0; i < nSamples; ++i) {
//            signal[i] = sigMag[i];
//            signs[i] = 0;
//        }
        //TODO: introduce arbitrary scaling, not only /4096

        if (sigPha) { // if phase available

            double sigPhaRefPi = M_PI * sigPha[nSamples - 1] / 4096; //get REFERENCE phase

            for (int i = 0; i < nSamples; ++i) {

                double sigPhaPi = M_PI * sigPha[i] / 4096; //get phase
                double pha = sigPhaPi - sigPhaRefPi;
                double realSig = sigMag[i] * cos(pha); //get real
                double imagSig = -sigMag[i] * sin(pha); //get imag
                //signal[i] = realSig;
                if (realSig < 0) {
                    signal[i] = -sigMag[i];
                    signs[i] = -1;
                } else {
                    signal[i] = sigMag[i];
                    signs[i] = 1;
                }
            }
        } else {
            return 1; // failure
        }
        return 0; // success
    }
} //namespace Ox

#endif //Tomato_OXSIGNCALCULATOR_H

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top