Tudat/Astrodynamics/OrbitDetermination/RotationalDynamicsPartials/inertialTorquePartial.cpp
//! Function for setting up and retrieving a function returning a partial w.r.t. a vector parameter.

Function for setting up and retrieving a function returning a partial w.r.t. a vector parameter.
Function for setting up and retrieving a function returning a partial w . r . t . a vector parameter .
std::pair< std::function< void( Eigen::MatrixXd& ) >, int > InertialTorquePartial::getParameterPartialFunction(
        std::shared_ptr< estimatable_parameters::EstimatableParameter< Eigen::VectorXd > > parameter )
{
    using namespace estimatable_parameters;
    std::pair< std::function< void( Eigen::MatrixXd& ) >, int >  partialFunction = std::make_pair(
                std::function< void( Eigen::MatrixXd& ) >( ), 0 );
    if( parameter->getParameterName( ).second.first == bodyUndergoingTorque_ )
    {
        switch( parameter->getParameterName( ).first )
        {
        case spherical_harmonics_cosine_coefficient_block:
        {
            std::shared_ptr< SphericalHarmonicsCosineCoefficients > coefficientsParameter =
                    std::dynamic_pointer_cast< SphericalHarmonicsCosineCoefficients >( parameter );
            int c20Index, c21Index, c22Index;
            coefficientsParameter->getDegreeTwoEntries( c20Index, c21Index, c22Index );
            if( c20Index >= 0 || c21Index >= 0 || c22Index >= 0 )
            {
                if( getInertiaTensorNormalizationFactor_ == nullptr )
                {
                    throw std::runtime_error( "Error when getting partial of inertial torque w.r.t. cosine sh parameters, inertia tensor normalization function not found." );
                }
                partialFunction = std::make_pair(
                            std::bind( &InertialTorquePartial::
                                         wrtCosineSphericalHarmonicCoefficientsOfCentralBody, this,
                                         std::placeholders::_1, c20Index, c21Index, c22Index ), coefficientsParameter->getParameterSize( ) );
            }
            break;
        }
        case spherical_harmonics_sine_coefficient_block:
        {
            std::shared_ptr< SphericalHarmonicsSineCoefficients > coefficientsParameter =
                    std::dynamic_pointer_cast< SphericalHarmonicsSineCoefficients >( parameter );
            int s21Index, s22Index;
            coefficientsParameter->getDegreeTwoEntries( s21Index, s22Index );
            if( s21Index >= 0 || s22Index >= 0 )
            {
                if( ( getInertiaTensorNormalizationFactor_ == nullptr ) )
                {
                    throw std::runtime_error( "Error when getting partial of inertial torque w.r.t. sine sh parameters, inertia tensor normalization function not found." );
                }
                partialFunction = std::make_pair(
                            std::bind( &InertialTorquePartial::
                                         wrtSineSphericalHarmonicCoefficientsOfCentralBody, this,
                                         std::placeholders::_1, s21Index, s22Index ), coefficientsParameter->getParameterSize( ) );
            }
            break;
        }
        default:
            break;
        }
    }
    return partialFunction;
}
std :: pair < std :: function < void ( Eigen :: MatrixXd & ) > , int > InertialTorquePartial :: getParameterPartialFunction ( std :: shared_ptr < estimatable_parameters :: EstimatableParameter < Eigen :: VectorXd > > parameter ) { using namespace estimatable_parameters ; std :: pair < std :: function < void ( Eigen :: MatrixXd & ) > , int > partialFunction = std :: make_pair ( std :: function < void ( Eigen :: MatrixXd & ) > ( ) , 0 ) ; if ( parameter -> getParameterName ( ) . second . first == bodyUndergoingTorque_ ) { switch ( parameter -> getParameterName ( ) . first ) { case spherical_harmonics_cosine_coefficient_block : { std :: shared_ptr < SphericalHarmonicsCosineCoefficients > coefficientsParameter = std :: dynamic_pointer_cast < SphericalHarmonicsCosineCoefficients > ( parameter ) ; int c20Index , c21Index , c22Index ; coefficientsParameter -> getDegreeTwoEntries ( c20Index , c21Index , c22Index ) ; if ( c20Index >= 0 || c21Index >= 0 || c22Index >= 0 ) { if ( getInertiaTensorNormalizationFactor_ == nullptr ) { throw std :: runtime_error ( " " ) ; } partialFunction = std :: make_pair ( std :: bind ( & InertialTorquePartial :: wrtCosineSphericalHarmonicCoefficientsOfCentralBody , this , std :: placeholders :: _1 , c20Index , c21Index , c22Index ) , coefficientsParameter -> getParameterSize ( ) ) ; } break ; } case spherical_harmonics_sine_coefficient_block : { std :: shared_ptr < SphericalHarmonicsSineCoefficients > coefficientsParameter = std :: dynamic_pointer_cast < SphericalHarmonicsSineCoefficients > ( parameter ) ; int s21Index , s22Index ; coefficientsParameter -> getDegreeTwoEntries ( s21Index , s22Index ) ; if ( s21Index >= 0 || s22Index >= 0 ) { if ( ( getInertiaTensorNormalizationFactor_ == nullptr ) ) { throw std :: runtime_error ( " " ) ; } partialFunction = std :: make_pair ( std :: bind ( & InertialTorquePartial :: wrtSineSphericalHarmonicCoefficientsOfCentralBody , this , std :: placeholders :: _1 , s21Index , s22Index ) , coefficientsParameter -> getParameterSize ( ) ) ; } break ; } default : break ; } } return partialFunction ; }
Function for setting up and retrieving a function returning a partial w.r.t.
Function for setting up and retrieving a function returning a partial w . r . t .
// Cast parameter object to required type.
 // Cast parameter object to required type.
