/*    Copyright (c) 2010-2015, Delft University of Technology
   *    All rights reserved.
   *
   *    Redistribution and use in source and binary forms, with or without modification, are
   *    permitted provided that the following conditions are met:
   *      - Redistributions of source code must retain the above copyright notice, this list of
   *        conditions and the following disclaimer.
   *      - Redistributions in binary form must reproduce the above copyright notice, this list of
   *        conditions and the following disclaimer in the documentation and/or other materials
   *        provided with the distribution.
   *      - Neither the name of the Delft University of Technology nor the names of its contributors
   *        may be used to endorse or promote products derived from this software without specific
   *        prior written permission.
   *
   *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
   *    OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   *    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   *    COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   *    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   *    GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
   *    AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   *    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   *    OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   *    Changelog
   *      YYMMDD    Author              Comment
   *      130219    D. Dirkx            File created.
   *      130227    R.C.A. Boon         Removed using directives (using namespace), added necessary
   *                                    using declarations (using ...::member), removed obsolete
   *                                    include statements
   *      130302    D. Dirkx            Updated file by putting tests in local scope;
   *                                    expanded tests.
   *
   *    References
   *
   *    Notes
   *      The unit tests use rotation matrices generated by spice, the code for the spice interface
   *      used to generate these testing values are included in this file, but commented.
   */

#define BOOST_TEST_MAIN

#include <limits>
#include <iostream>

#include <boost/test/floating_point_comparison.hpp>
#include <boost/test/unit_test.hpp>

#include <Eigen/Core>

#include "Tudat/Basics/testMacros.h"
#include "Tudat/Mathematics/BasicMathematics/linearAlgebra.h"
#include "Tudat/Astrodynamics/BasicAstrodynamics/timeConversions.h"
#include "Tudat/Astrodynamics/Ephemerides/simpleRotationalEphemeris.h"
//#include "Tudat/External/SpiceInterface/spiceInterface.h"
//#include "Tudat/InputOutput/basicInputOutput.h"

namespace tudat
{
namespace unit_tests
{

using namespace ephemerides;

BOOST_AUTO_TEST_SUITE( test_rotational_ephemeris )

// Test functions to calculate rotation matrix derivative from angular velocity vector and vice
// versa.
BOOST_AUTO_TEST_CASE( testRotationalEphemeris )
{
    // Define names of frames.
    const std::string baseFrame = "J2000";
    const std::string targetFrame = "IAU_VENUS";

    // Set time at which rotational ephemeris it to be called for subsequent tests.

    // Test rotation to target frame at specified time.
    {

        // The following code block can be used to retrieve the benchmark data from Spice.
        //        spice_interface::loadSpiceKernelInTudat( input_output::getSpiceKernelPath( ) +
        // "pck00010.tpc" );
        //        const double secondsSinceJ2000 = 1.0E6;
        //        Eigen::Quaterniond spiceRotationMatrix =
        //                spice_interface::computeRotationQuaternionBetweenFrames(
        // baseFrame, targetFrame, secondsSinceJ2000 );
        //        Eigen::Matrix3d spiceRotationMatrixDerivative =
        //                spice_interface::computeRotationMatrixDerivativeBetweenFrames(
        // baseFrame, targetFrame, secondsSinceJ2000 );
        //        Eigen::Vector3d spiceRotationalVelocityVector =
        //                spice_interface::getAngularVelocityVectorOfFrameInOriginalFrame(
        // baseFrame, targetFrame, secondsSinceJ2000 );

        // Set rotational characteristics at given time, as calculated with Spice
        // (see above commented lines).
        Eigen::Matrix3d spiceRotationMatrixDerivative;
        spiceRotationMatrixDerivative <<
                1.690407961416589e-07, 2.288121921543265e-07, 9.283170431475241e-08,
                -2.468632444964533e-07, 1.540516111965609e-07, 6.981529179974795e-08,
                0.0,           0.0,          0.0;

        Eigen::Matrix3d spiceRotationMatrix;
        spiceRotationMatrix << -0.8249537745726603, 0.5148010526833556, 0.2333048348715243,
                -0.5648910720519699, -0.7646317780963481, -0.3102197940834743,
                0.01869081416890206, -0.3877088083617987, 0.9215923900425707;

        Eigen::Vector3d spiceRotationalVelocityVector;
        spiceRotationalVelocityVector << -5.593131603532092e-09,
                1.160198999048488e-07,
                -2.75781861386115e-07;

        // Calculate rotational velocity from SPICE rotation matrix derivative.
        Eigen::Vector3d rotationalVelocityVector =
                getRotationalVelocityVectorInBaseFrameFromMatrices(
                    spiceRotationMatrix, spiceRotationMatrixDerivative.transpose( ) );

        // Calculate rotation matrix derivative from SPICE rotational velocity vector.
        Eigen::Matrix3d rotationMatrixDerivative = getDerivativeOfRotationMatrixToFrame(
                    spiceRotationMatrix, spiceRotationalVelocityVector );

        // Calculate rotational velocity from previously calculated rotation matrix derivative.
        Eigen::Matrix3d backCalculatedRotationMatrixDerivative =
                getDerivativeOfRotationMatrixToFrame(
                    spiceRotationMatrix, rotationalVelocityVector );

        // Calculate rotation matrix derivative from previously calculated rotational velocity
        // vector.
        Eigen::Vector3d backCalculatedRotationalVelocityVector =
                getRotationalVelocityVectorInBaseFrameFromMatrices(
                    spiceRotationMatrix, rotationMatrixDerivative.transpose( ) );

        // Check equivalence of results.
        for( int i = 0; i < 3; i++ )
        {
            BOOST_CHECK_SMALL( rotationalVelocityVector( i ) -
                               backCalculatedRotationalVelocityVector( i ), 2.0E-22 );
            BOOST_CHECK_SMALL( rotationalVelocityVector( i ) -
                               spiceRotationalVelocityVector( i ), 2.0E-22 );

            for( int j = 0; j < 3; j++ )
            {
                BOOST_CHECK_SMALL( rotationMatrixDerivative( i, j ) -
                                   backCalculatedRotationMatrixDerivative( i, j ), 2.0E-22 );
                BOOST_CHECK_SMALL( rotationMatrixDerivative( i, j ) -
                                   spiceRotationMatrixDerivative( i, j ), 2.0E-22 );
            }
        }
    }
}

BOOST_AUTO_TEST_SUITE_END( )

} // namespace unit_tests
} // namespace tudat


#include <boost/test/unit_test.hpp>

#include "PhotonSystematic/DataStore.h"
#include "PlotFunctions/RobustMinimize.h"

#include "TH1D.h"
#include "RooRealVar.h"
#include "RooDataHist.h"
#include "RooArgSet.h"
#include "RooGaussian.h"

// The name of the suite must be a different name to your class
BOOST_AUTO_TEST_SUITE( DataStoreSuite )

BOOST_AUTO_TEST_CASE( FitTest ) {
  // TH1D hist("hist", "hist", 100,-5, 5 );
  // hist.FillRandom( "gaus", 1e6 );

  // RooRealVar mass( "mass", "mass", 0, -5, 5 );
  // RooRealVar mean( "mean", "mean", 0, -5, 5 );
  // RooRealVar sigma( "sigma", "sigma", 1, 0, 3 );

  // RooDataHist dataHist( "datahist", "datahist", RooArgSet(mass), &hist );
  // RooGaussian pdf( "gaus", "gaus", mass, mean, sigma );

  // FitData( &dataHist, &pdf, -1 );

}

BOOST_AUTO_TEST_SUITE_END()


#include "mainwindow1.h"
#include <QApplication>
#include "Eigen/Dense"
//#include "robot.h"
#include <Eigen/Geometry>
#include <iostream>
#include <cstdlib>
#include <qdebug.h>
#include <qmath.h>
#include <QMainWindow>
    #include <QLabel>
#include <QLineEdit>
#include <QHBoxLayout>
//#include <taskspace.h>
//#include<taskspaceoffline.h>
using namespace Eigen;
using namespace std;
int main(int argc, char *argv[])
{
    //QApplication a(argc, argv);

// MainWindow w;

    // SQDTaskSpace Forwardwalking();
    //    MatrixXd PelvisTrajectory;
    // PelvisTrajectory.setLinSpaced(81,0,0.4);
    // MatrixXd AnkleTrajectory;
    //AnkleTrajectory.setLinSpaced(81,0,0.4);
    //Robot Milad;
//TaskSpaceOffline offline;
//   TaskSpace Pelvis;
//    QApplication a(argc, argv);
//    MainWindow w;
     //QList<Link> temp = Surena4.GetLinks();
    //w.show();
    //MatrixXd temp(2,3);
    //temp<< 1,2,3,4,5,6;
    //return a.exec();
//uncomment below
   // w.show();
    //w.Plot(Pelvis);
   // return a.exec();

    QApplication app(argc, argv);
    QWidget window;
    QLabel *label = new QLabel(QApplication::translate("windowlayout", "Name:"));
    QLineEdit *lineEdit = new QLineEdit();

    QHBoxLayout *layout = new QHBoxLayout();
    layout->addWidget(label);
    layout->addWidget(lineEdit);
    window.setLayout(layout);
    window.setWindowTitle(
        QApplication::translate("windowlayout", "Window layout"));
    window.show();
    return app.exec();

}


// ====================================================================
// This file is part of FlexibleSUSY.
//
// FlexibleSUSY 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 3 of the License,
// or (at your option) any later version.
//
// FlexibleSUSY 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 FlexibleSUSY.  If not, see
// <http://www.gnu.org/licenses/>.
// ====================================================================

// File generated at Thu 10 May 2018 14:41:56

#ifndef MSSMEFTHiggs_PHYSICAL_H
#define MSSMEFTHiggs_PHYSICAL_H

#include <Eigen/Core>

#include <iosfwd>

namespace flexiblesusy {

struct MSSMEFTHiggs_physical {
   void clear();
   void convert_to_hk();   ///< converts pole masses to HK convention
   void convert_to_slha(); ///< converts pole masses to SLHA convention
   Eigen::ArrayXd get() const; ///< returns array with all masses and mixings
   void set(const Eigen::ArrayXd&); ///< set all masses and mixings
   Eigen::ArrayXd get_masses() const; ///< returns array with all masses
   void set_masses(const Eigen::ArrayXd&); ///< set all masses
   void print(std::ostream&) const;

   double MVG{};
   double MGlu{};
   Eigen::Array<double,3,1> MFv{Eigen::Array<double,3,1>::Zero()};
   Eigen::Array<double,6,1> MSd{Eigen::Array<double,6,1>::Zero()};
   Eigen::Array<double,3,1> MSv{Eigen::Array<double,3,1>::Zero()};
   Eigen::Array<double,6,1> MSu{Eigen::Array<double,6,1>::Zero()};
   Eigen::Array<double,6,1> MSe{Eigen::Array<double,6,1>::Zero()};
   Eigen::Array<double,2,1> Mhh{Eigen::Array<double,2,1>::Zero()};
   Eigen::Array<double,2,1> MAh{Eigen::Array<double,2,1>::Zero()};
   Eigen::Array<double,2,1> MHpm{Eigen::Array<double,2,1>::Zero()};
   Eigen::Array<double,4,1> MChi{Eigen::Array<double,4,1>::Zero()};
   Eigen::Array<double,2,1> MCha{Eigen::Array<double,2,1>::Zero()};
   Eigen::Array<double,3,1> MFe{Eigen::Array<double,3,1>::Zero()};
   Eigen::Array<double,3,1> MFd{Eigen::Array<double,3,1>::Zero()};
   Eigen::Array<double,3,1> MFu{Eigen::Array<double,3,1>::Zero()};
   double MVWm{};
   double MVP{};
   double MVZ{};

   Eigen::Matrix<double,6,6> ZD{Eigen::Matrix<double,6,6>::Zero()};
   Eigen::Matrix<double,3,3> ZV{Eigen::Matrix<double,3,3>::Zero()};
   Eigen::Matrix<double,6,6> ZU{Eigen::Matrix<double,6,6>::Zero()};
   Eigen::Matrix<double,6,6> ZE{Eigen::Matrix<double,6,6>::Zero()};
   Eigen::Matrix<double,2,2> ZH{Eigen::Matrix<double,2,2>::Zero()};
   Eigen::Matrix<double,2,2> ZA{Eigen::Matrix<double,2,2>::Zero()};
   Eigen::Matrix<double,2,2> ZP{Eigen::Matrix<double,2,2>::Zero()};
   Eigen::Matrix<std::complex<double>,4,4> ZN{Eigen::Matrix<std::complex<double>,4,4>::Zero()};
   Eigen::Matrix<std::complex<double>,2,2> UM{Eigen::Matrix<std::complex<double>,2,2>::Zero()};
   Eigen::Matrix<std::complex<double>,2,2> UP{Eigen::Matrix<std::complex<double>,2,2>::Zero()};
   Eigen::Matrix<std::complex<double>,3,3> ZEL{Eigen::Matrix<std::complex<double>,3,3>::Zero()};
   Eigen::Matrix<std::complex<double>,3,3> ZER{Eigen::Matrix<std::complex<double>,3,3>::Zero()};
   Eigen::Matrix<std::complex<double>,3,3> ZDL{Eigen::Matrix<std::complex<double>,3,3>::Zero()};
   Eigen::Matrix<std::complex<double>,3,3> ZDR{Eigen::Matrix<std::complex<double>,3,3>::Zero()};
   Eigen::Matrix<std::complex<double>,3,3> ZUL{Eigen::Matrix<std::complex<double>,3,3>::Zero()};
   Eigen::Matrix<std::complex<double>,3,3> ZUR{Eigen::Matrix<std::complex<double>,3,3>::Zero()};
   Eigen::Matrix<double,2,2> ZZ{Eigen::Matrix<double,2,2>::Zero()};

};

std::ostream& operator<<(std::ostream&, const MSSMEFTHiggs_physical&);

} // namespace flexiblesusy

#endif