/*
 * Automatically Generated from Mathematica.
 * Sat 13 Nov 2021 15:03:43 GMT-05:00
 */

#ifdef MATLAB_MEX_FILE
#include <stdexcept>
#include <cmath>
#include<math.h>
/**
 * Copied from Wolfram Mathematica C Definitions file mdefs.hpp
 * Changed marcos to inline functions (Eric Cousineau)
 */
inline double Power(double x, double y) { return pow(x, y); }
inline double Sqrt(double x) { return sqrt(x); }

inline double Abs(double x) { return fabs(x); }

inline double Exp(double x) { return exp(x); }
inline double Log(double x) { return log(x); }

inline double Sin(double x) { return sin(x); }
inline double Cos(double x) { return cos(x); }
inline double Tan(double x) { return tan(x); }

inline double ArcSin(double x) { return asin(x); }
inline double ArcCos(double x) { return acos(x); }
inline double ArcTan(double x) { return atan(x); }

/* update ArcTan function to use atan2 instead. */
inline double ArcTan(double x, double y) { return atan2(y,x); }

inline double Sinh(double x) { return sinh(x); }
inline double Cosh(double x) { return cosh(x); }
inline double Tanh(double x) { return tanh(x); }

const double E	= 2.71828182845904523536029;
const double Pi = 3.14159265358979323846264;
const double Degree = 0.01745329251994329576924;

inline double Sec(double x) { return 1/cos(x); }
inline double Csc(double x) { return 1/sin(x); }

#endif

/*
 * Sub functions
 */
static void output1(double *p_output1,const double *var1)
{
  double t3202;
  double t3323;
  double t3335;
  double t3324;
  double t3340;
  double t3311;
  double t3312;
  double t3314;
  double t3316;
  double t3322;
  double t3330;
  double t3346;
  double t3347;
  double t3350;
  double t3362;
  double t3367;
  double t3372;
  double t3262;
  double t3414;
  double t3417;
  double t3420;
  double t3424;
  double t3426;
  double t3427;
  double t3430;
  double t3434;
  double t3435;
  double t3440;
  double t3472;
  double t3478;
  double t3483;
  double t3494;
  double t3499;
  double t3500;
  double t3502;
  double t3505;
  double t3506;
  double t3507;
  double t3512;
  double t3513;
  double t3514;
  double t3516;
  double t3520;
  double t3523;
  double t3524;
  double t3525;
  double t3531;
  double t3532;
  double t3533;
  double t3535;
  double t3536;
  double t3537;
  double t3539;
  double t3542;
  double t3543;
  double t3544;
  double t3549;
  double t3550;
  double t3551;
  double t3553;
  double t3554;
  double t3556;
  double t3558;
  double t3561;
  double t3562;
  double t3563;
  double t3568;
  double t3569;
  double t3570;
  double t3315;
  double t3318;
  double t3319;
  double t3320;
  double t3348;
  double t3351;
  double t3356;
  double t3380;
  double t3389;
  double t3398;
  double t3405;
  double t3421;
  double t3428;
  double t3431;
  double t3432;
  double t3446;
  double t3447;
  double t3448;
  double t3450;
  double t3456;
  double t3462;
  double t3467;
  double t3488;
  double t3501;
  double t3503;
  double t3504;
  double t3508;
  double t3509;
  double t3510;
  double t3511;
  double t3515;
  double t3517;
  double t3518;
  double t3519;
  double t3521;
  double t3522;
  double t3526;
  double t3527;
  double t3528;
  double t3529;
  double t3530;
  double t3534;
  double t3538;
  double t3540;
  double t3541;
  double t3545;
  double t3546;
  double t3547;
  double t3548;
  double t3552;
  double t3557;
  double t3559;
  double t3560;
  double t3564;
  double t3565;
  double t3566;
  double t3567;
  double t3571;
  double t3572;
  double t3573;
  double t3574;
  double t3576;
  double t3577;
  double t3578;
  double t3582;
  double t3583;
  double t3585;
  double t3581;
  double t3587;
  double t3588;
  double t3592;
  double t3593;
  double t3594;
  double t3596;
  double t3597;
  double t3598;
  double t3600;
  double t3601;
  double t3602;
  double t3604;
  double t3605;
  double t3606;
  double t3613;
  double t3614;
  double t3615;
  double t3617;
  double t3618;
  double t3619;
  double t3621;
  double t3622;
  double t3623;
  double t3625;
  double t3626;
  double t3627;
  double t3629;
  double t3630;
  double t3631;
  double t3633;
  double t3634;
  double t3635;
  double t3637;
  double t3638;
  double t3639;
  double t3641;
  double t3642;
  double t3643;
  double t3645;
  double t3646;
  double t3647;
  double t3591;
  double t3595;
  double t3599;
  double t3603;
  double t3607;
  double t3608;
  double t3609;
  double t3610;
  double t3616;
  double t3620;
  double t3624;
  double t3628;
  double t3632;
  double t3636;
  double t3640;
  double t3644;
  double t3648;
  double t3649;
  double t3650;
  double t3651;
  double t3653;
  double t3654;
  double t3655;
  double t3659;
  double t3660;
  double t3662;
  double t3658;
  double t3664;
  double t3665;
  double t3671;
  double t3672;
  double t3673;
  double t3675;
  double t3676;
  double t3677;
  double t3683;
  double t3684;
  double t3685;
  double t3687;
  double t3688;
  double t3689;
  double t3691;
  double t3692;
  double t3693;
  double t3695;
  double t3696;
  double t3697;
  double t3699;
  double t3700;
  double t3701;
  double t3703;
  double t3704;
  double t3705;
  double t3707;
  double t3708;
  double t3709;
  double t3711;
  double t3712;
  double t3713;
  double t3715;
  double t3716;
  double t3717;
  double t3668;
  double t3669;
  double t3670;
  double t3674;
  double t3678;
  double t3679;
  double t3680;
  double t3681;
  double t3686;
  double t3690;
  double t3694;
  double t3698;
  double t3702;
  double t3706;
  double t3710;
  double t3714;
  double t3718;
  double t3719;
  double t3720;
  double t3721;
  double t3723;
  double t3724;
  double t3725;
  double t3729;
  double t3730;
  double t3732;
  double t3728;
  double t3734;
  double t3735;
  t3202 = Cos(var1[3]);
  t3323 = Cos(var1[5]);
  t3335 = Sin(var1[3]);
  t3324 = Sin(var1[4]);
  t3340 = Sin(var1[5]);
  t3311 = Cos(var1[14]);
  t3312 = -1.*t3311;
  t3314 = 1. + t3312;
  t3316 = Sin(var1[14]);
  t3322 = Sin(var1[13]);
  t3330 = t3202*t3323*t3324;
  t3346 = t3335*t3340;
  t3347 = t3330 + t3346;
  t3350 = Cos(var1[13]);
  t3362 = -1.*t3323*t3335;
  t3367 = t3202*t3324*t3340;
  t3372 = t3362 + t3367;
  t3262 = Cos(var1[4]);
  t3414 = t3322*t3347;
  t3417 = t3350*t3372;
  t3420 = t3414 + t3417;
  t3424 = Cos(var1[15]);
  t3426 = -1.*t3424;
  t3427 = 1. + t3426;
  t3430 = Sin(var1[15]);
  t3434 = t3350*t3347;
  t3435 = -1.*t3322*t3372;
  t3440 = t3434 + t3435;
  t3472 = t3311*t3202*t3262;
  t3478 = t3316*t3420;
  t3483 = t3472 + t3478;
  t3494 = Cos(var1[16]);
  t3499 = -1.*t3494;
  t3500 = 1. + t3499;
  t3502 = Sin(var1[16]);
  t3505 = t3430*t3440;
  t3506 = t3424*t3483;
  t3507 = t3505 + t3506;
  t3512 = t3424*t3440;
  t3513 = -1.*t3430*t3483;
  t3514 = t3512 + t3513;
  t3516 = Cos(var1[17]);
  t3520 = Sin(var1[17]);
  t3523 = -1.*t3502*t3507;
  t3524 = t3494*t3514;
  t3525 = t3523 + t3524;
  t3531 = t3494*t3507;
  t3532 = t3502*t3514;
  t3533 = t3531 + t3532;
  t3535 = Cos(var1[18]);
  t3536 = -1.*t3535;
  t3537 = 1. + t3536;
  t3539 = Sin(var1[18]);
  t3542 = t3520*t3525;
  t3543 = t3516*t3533;
  t3544 = t3542 + t3543;
  t3549 = t3516*t3525;
  t3550 = -1.*t3520*t3533;
  t3551 = t3549 + t3550;
  t3553 = Cos(var1[19]);
  t3554 = -1.*t3553;
  t3556 = 1. + t3554;
  t3558 = Sin(var1[19]);
  t3561 = -1.*t3539*t3544;
  t3562 = t3535*t3551;
  t3563 = t3561 + t3562;
  t3568 = t3535*t3544;
  t3569 = t3539*t3551;
  t3570 = t3568 + t3569;
  t3315 = -0.049*t3314;
  t3318 = -0.135*t3316;
  t3319 = t3315 + t3318;
  t3320 = t3202*t3262*t3319;
  t3348 = 0.135*t3322*t3347;
  t3351 = -1.*t3350;
  t3356 = 1. + t3351;
  t3380 = -0.135*t3356*t3372;
  t3389 = -0.135*t3314;
  t3398 = 0.049*t3316;
  t3405 = t3389 + t3398;
  t3421 = t3405*t3420;
  t3428 = -0.09*t3427;
  t3431 = 0.049*t3430;
  t3432 = t3428 + t3431;
  t3446 = t3432*t3440;
  t3447 = -1.*t3202*t3262*t3316;
  t3448 = t3311*t3420;
  t3450 = t3447 + t3448;
  t3456 = -0.049*t3427;
  t3462 = -0.09*t3430;
  t3467 = t3456 + t3462;
  t3488 = t3467*t3483;
  t3501 = -0.049*t3500;
  t3503 = -0.21*t3502;
  t3504 = t3501 + t3503;
  t3508 = t3504*t3507;
  t3509 = -0.21*t3500;
  t3510 = 0.049*t3502;
  t3511 = t3509 + t3510;
  t3515 = t3511*t3514;
  t3517 = -1.*t3516;
  t3518 = 1. + t3517;
  t3519 = -0.2707*t3518;
  t3521 = 0.0016*t3520;
  t3522 = t3519 + t3521;
  t3526 = t3522*t3525;
  t3527 = -1. + t3516;
  t3528 = 0.0016*t3527;
  t3529 = -0.2707*t3520;
  t3530 = t3528 + t3529;
  t3534 = t3530*t3533;
  t3538 = 0.0184*t3537;
  t3540 = -0.7055*t3539;
  t3541 = t3538 + t3540;
  t3545 = t3541*t3544;
  t3546 = -0.7055*t3537;
  t3547 = -0.0184*t3539;
  t3548 = t3546 + t3547;
  t3552 = t3548*t3551;
  t3557 = -1.1135*t3556;
  t3559 = 0.0216*t3558;
  t3560 = t3557 + t3559;
  t3564 = t3560*t3563;
  t3565 = -0.0216*t3556;
  t3566 = -1.1135*t3558;
  t3567 = t3565 + t3566;
  t3571 = t3567*t3570;
  t3572 = t3558*t3563;
  t3573 = t3553*t3570;
  t3574 = t3572 + t3573;
  t3576 = t3553*t3563;
  t3577 = -1.*t3558*t3570;
  t3578 = t3576 + t3577;
  t3582 = 0.078809*t3574;
  t3583 = -1.073747*t3578;
  t3585 = -0.1055*t3450;
  t3581 = -0.1555*t3450;
  t3587 = -0.017609*t3574;
  t3588 = -1.188653*t3578;
  t3592 = t3323*t3335*t3324;
  t3593 = -1.*t3202*t3340;
  t3594 = t3592 + t3593;
  t3596 = t3202*t3323;
  t3597 = t3335*t3324*t3340;
  t3598 = t3596 + t3597;
  t3600 = t3322*t3594;
  t3601 = t3350*t3598;
  t3602 = t3600 + t3601;
  t3604 = t3350*t3594;
  t3605 = -1.*t3322*t3598;
  t3606 = t3604 + t3605;
  t3613 = t3311*t3262*t3335;
  t3614 = t3316*t3602;
  t3615 = t3613 + t3614;
  t3617 = t3430*t3606;
  t3618 = t3424*t3615;
  t3619 = t3617 + t3618;
  t3621 = t3424*t3606;
  t3622 = -1.*t3430*t3615;
  t3623 = t3621 + t3622;
  t3625 = -1.*t3502*t3619;
  t3626 = t3494*t3623;
  t3627 = t3625 + t3626;
  t3629 = t3494*t3619;
  t3630 = t3502*t3623;
  t3631 = t3629 + t3630;
  t3633 = t3520*t3627;
  t3634 = t3516*t3631;
  t3635 = t3633 + t3634;
  t3637 = t3516*t3627;
  t3638 = -1.*t3520*t3631;
  t3639 = t3637 + t3638;
  t3641 = -1.*t3539*t3635;
  t3642 = t3535*t3639;
  t3643 = t3641 + t3642;
  t3645 = t3535*t3635;
  t3646 = t3539*t3639;
  t3647 = t3645 + t3646;
  t3591 = t3262*t3319*t3335;
  t3595 = 0.135*t3322*t3594;
  t3599 = -0.135*t3356*t3598;
  t3603 = t3405*t3602;
  t3607 = t3432*t3606;
  t3608 = -1.*t3262*t3316*t3335;
  t3609 = t3311*t3602;
  t3610 = t3608 + t3609;
  t3616 = t3467*t3615;
  t3620 = t3504*t3619;
  t3624 = t3511*t3623;
  t3628 = t3522*t3627;
  t3632 = t3530*t3631;
  t3636 = t3541*t3635;
  t3640 = t3548*t3639;
  t3644 = t3560*t3643;
  t3648 = t3567*t3647;
  t3649 = t3558*t3643;
  t3650 = t3553*t3647;
  t3651 = t3649 + t3650;
  t3653 = t3553*t3643;
  t3654 = -1.*t3558*t3647;
  t3655 = t3653 + t3654;
  t3659 = 0.078809*t3651;
  t3660 = -1.073747*t3655;
  t3662 = -0.1055*t3610;
  t3658 = -0.1555*t3610;
  t3664 = -0.017609*t3651;
  t3665 = -1.188653*t3655;
  t3671 = t3262*t3323*t3322;
  t3672 = t3350*t3262*t3340;
  t3673 = t3671 + t3672;
  t3675 = t3350*t3262*t3323;
  t3676 = -1.*t3262*t3322*t3340;
  t3677 = t3675 + t3676;
  t3683 = -1.*t3311*t3324;
  t3684 = t3316*t3673;
  t3685 = t3683 + t3684;
  t3687 = t3430*t3677;
  t3688 = t3424*t3685;
  t3689 = t3687 + t3688;
  t3691 = t3424*t3677;
  t3692 = -1.*t3430*t3685;
  t3693 = t3691 + t3692;
  t3695 = -1.*t3502*t3689;
  t3696 = t3494*t3693;
  t3697 = t3695 + t3696;
  t3699 = t3494*t3689;
  t3700 = t3502*t3693;
  t3701 = t3699 + t3700;
  t3703 = t3520*t3697;
  t3704 = t3516*t3701;
  t3705 = t3703 + t3704;
  t3707 = t3516*t3697;
  t3708 = -1.*t3520*t3701;
  t3709 = t3707 + t3708;
  t3711 = -1.*t3539*t3705;
  t3712 = t3535*t3709;
  t3713 = t3711 + t3712;
  t3715 = t3535*t3705;
  t3716 = t3539*t3709;
  t3717 = t3715 + t3716;
  t3668 = 0.135*t3262*t3323*t3322;
  t3669 = -1.*t3319*t3324;
  t3670 = -0.135*t3356*t3262*t3340;
  t3674 = t3405*t3673;
  t3678 = t3432*t3677;
  t3679 = t3316*t3324;
  t3680 = t3311*t3673;
  t3681 = t3679 + t3680;
  t3686 = t3467*t3685;
  t3690 = t3504*t3689;
  t3694 = t3511*t3693;
  t3698 = t3522*t3697;
  t3702 = t3530*t3701;
  t3706 = t3541*t3705;
  t3710 = t3548*t3709;
  t3714 = t3560*t3713;
  t3718 = t3567*t3717;
  t3719 = t3558*t3713;
  t3720 = t3553*t3717;
  t3721 = t3719 + t3720;
  t3723 = t3553*t3713;
  t3724 = -1.*t3558*t3717;
  t3725 = t3723 + t3724;
  t3729 = 0.078809*t3721;
  t3730 = -1.073747*t3725;
  t3732 = -0.1055*t3681;
  t3728 = -0.1555*t3681;
  t3734 = -0.017609*t3721;
  t3735 = -1.188653*t3725;
  p_output1[0]=t3320 + t3348 + t3380 + t3421 + t3446 - 0.1305*t3450 + t3488 + t3508 + t3515 + t3526 + t3534 + t3545 + t3552 + t3564 + t3571 - 0.007702*t3574 - 1.099061*t3578 + var1[0];
  p_output1[1]=t3320 + t3348 + t3380 + t3421 + t3446 + t3488 + t3508 + t3515 + t3526 + t3534 + t3545 + t3552 + t3564 + t3571 + t3581 + t3582 + t3583 + var1[0];
  p_output1[2]=t3320 + t3348 + t3380 + t3421 + t3446 + t3488 + t3508 + t3515 + t3526 + t3534 + t3545 + t3552 + t3564 + t3571 + t3582 + t3583 + t3585 + var1[0];
  p_output1[3]=t3320 + t3348 + t3380 + t3421 + t3446 + t3488 + t3508 + t3515 + t3526 + t3534 + t3545 + t3552 + t3564 + t3571 + t3585 + t3587 + t3588 + var1[0];
  p_output1[4]=t3320 + t3348 + t3380 + t3421 + t3446 + t3488 + t3508 + t3515 + t3526 + t3534 + t3545 + t3552 + t3564 + t3571 + t3581 + t3587 + t3588 + var1[0];
  p_output1[5]=t3591 + t3595 + t3599 + t3603 + t3607 - 0.1305*t3610 + t3616 + t3620 + t3624 + t3628 + t3632 + t3636 + t3640 + t3644 + t3648 - 0.007702*t3651 - 1.099061*t3655 + var1[1];
  p_output1[6]=t3591 + t3595 + t3599 + t3603 + t3607 + t3616 + t3620 + t3624 + t3628 + t3632 + t3636 + t3640 + t3644 + t3648 + t3658 + t3659 + t3660 + var1[1];
  p_output1[7]=t3591 + t3595 + t3599 + t3603 + t3607 + t3616 + t3620 + t3624 + t3628 + t3632 + t3636 + t3640 + t3644 + t3648 + t3659 + t3660 + t3662 + var1[1];
  p_output1[8]=t3591 + t3595 + t3599 + t3603 + t3607 + t3616 + t3620 + t3624 + t3628 + t3632 + t3636 + t3640 + t3644 + t3648 + t3662 + t3664 + t3665 + var1[1];
  p_output1[9]=t3591 + t3595 + t3599 + t3603 + t3607 + t3616 + t3620 + t3624 + t3628 + t3632 + t3636 + t3640 + t3644 + t3648 + t3658 + t3664 + t3665 + var1[1];
  p_output1[10]=t3668 + t3669 + t3670 + t3674 + t3678 - 0.1305*t3681 + t3686 + t3690 + t3694 + t3698 + t3702 + t3706 + t3710 + t3714 + t3718 - 0.007702*t3721 - 1.099061*t3725 + var1[2];
  p_output1[11]=t3668 + t3669 + t3670 + t3674 + t3678 + t3686 + t3690 + t3694 + t3698 + t3702 + t3706 + t3710 + t3714 + t3718 + t3728 + t3729 + t3730 + var1[2];
  p_output1[12]=t3668 + t3669 + t3670 + t3674 + t3678 + t3686 + t3690 + t3694 + t3698 + t3702 + t3706 + t3710 + t3714 + t3718 + t3729 + t3730 + t3732 + var1[2];
  p_output1[13]=t3668 + t3669 + t3670 + t3674 + t3678 + t3686 + t3690 + t3694 + t3698 + t3702 + t3706 + t3710 + t3714 + t3718 + t3732 + t3734 + t3735 + var1[2];
  p_output1[14]=t3668 + t3669 + t3670 + t3674 + t3678 + t3686 + t3690 + t3694 + t3698 + t3702 + t3706 + t3710 + t3714 + t3718 + t3728 + t3734 + t3735 + var1[2];
}



#ifdef MATLAB_MEX_FILE

#include "mex.h"
/*
 * Main function
 */
void mexFunction( int nlhs, mxArray *plhs[],
                  int nrhs, const mxArray *prhs[] )
{
  size_t mrows, ncols;

  double *var1;
  double *p_output1;

  /*  Check for proper number of arguments.  */ 
  if( nrhs != 1)
    {
      mexErrMsgIdAndTxt("MATLAB:MShaped:invalidNumInputs", "One input(s) required (var1).");
    }
  else if( nlhs > 1)
    {
      mexErrMsgIdAndTxt("MATLAB:MShaped:maxlhs", "Too many output arguments.");
    }

  /*  The input must be a noncomplex double vector or scaler.  */
  mrows = mxGetM(prhs[0]);
  ncols = mxGetN(prhs[0]);
  if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) ||
    ( !(mrows == 20 && ncols == 1) && 
      !(mrows == 1 && ncols == 20))) 
    {
      mexErrMsgIdAndTxt( "MATLAB:MShaped:inputNotRealVector", "var1 is wrong.");
    }

  /*  Assign pointers to each input.  */
  var1 = mxGetPr(prhs[0]);
   


   
  /*  Create matrices for return arguments.  */
  plhs[0] = mxCreateDoubleMatrix((mwSize) 5, (mwSize) 3, mxREAL);
  p_output1 = mxGetPr(plhs[0]);


  /* Call the calculation subroutine. */
  output1(p_output1,var1);


}

#else // MATLAB_MEX_FILE

#include "RightToe_patch.hh"

namespace SymFunction
{

void RightToe_patch_raw(double *p_output1, const double *var1)
{
  // Call Subroutines
  output1(p_output1, var1);

}

}

#endif // MATLAB_MEX_FILE
