/*
  Generated from python/mgga_exc/hyb_mgga_x_dldf.py via
  python/libxc_codegen.py with Python 3.9.25, SymPy 1.14.0.
  Do not edit -- regenerate via
  scripts/sympy2c/compile.py hyb_mgga_x_dldf
*/

#ifndef _HYB_MGGA_X_DLDF_KERNEL_BODY
#define maple2c_order 4
#define MAPLE2C_FLAGS (XC_FLAGS_I_HAVE_EXC | XC_FLAGS_I_HAVE_VXC | XC_FLAGS_I_HAVE_FXC | XC_FLAGS_I_HAVE_KXC | XC_FLAGS_I_HAVE_LXC)

/* ---- top-level dispatch ---- */

#define _HYB_MGGA_X_DLDF_KERNEL_BODY
#define _KMAX 0
#define _HYB_MGGA_X_DLDF_HELPER_BODIES
#include "hyb_mgga_x_dldf.c"
#undef _HYB_MGGA_X_DLDF_HELPER_BODIES
#undef _KMAX
#if XC_MAXORDER >= 1
#define _KMAX 1
#define _HYB_MGGA_X_DLDF_HELPER_BODIES
#include "hyb_mgga_x_dldf.c"
#undef _HYB_MGGA_X_DLDF_HELPER_BODIES
#undef _KMAX
#endif
#if XC_MAXORDER >= 2
#define _KMAX 2
#define _HYB_MGGA_X_DLDF_HELPER_BODIES
#include "hyb_mgga_x_dldf.c"
#undef _HYB_MGGA_X_DLDF_HELPER_BODIES
#undef _KMAX
#endif
#if XC_MAXORDER >= 3
#define _KMAX 3
#define _HYB_MGGA_X_DLDF_HELPER_BODIES
#include "hyb_mgga_x_dldf.c"
#undef _HYB_MGGA_X_DLDF_HELPER_BODIES
#undef _KMAX
#endif
#if XC_MAXORDER >= 4
#define _KMAX 4
#define _HYB_MGGA_X_DLDF_HELPER_BODIES
#include "hyb_mgga_x_dldf.c"
#undef _HYB_MGGA_X_DLDF_HELPER_BODIES
#undef _KMAX
#endif
#define _KMAX 0
#define _SPIN_UNPOL 1
#define FUNC_NAME func_exc_unpol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#define _KMAX 0
#define _SPIN_UNPOL 0
#define FUNC_NAME func_exc_pol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#if XC_MAXORDER >= 1
#define _KMAX 1
#define _SPIN_UNPOL 1
#define FUNC_NAME func_vxc_unpol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 1
#define _KMAX 1
#define _SPIN_UNPOL 0
#define FUNC_NAME func_vxc_pol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 2
#define _KMAX 2
#define _SPIN_UNPOL 1
#define FUNC_NAME func_fxc_unpol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 2
#define _KMAX 2
#define _SPIN_UNPOL 0
#define FUNC_NAME func_fxc_pol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 3
#define _KMAX 3
#define _SPIN_UNPOL 1
#define FUNC_NAME func_kxc_unpol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 3
#define _KMAX 3
#define _SPIN_UNPOL 0
#define FUNC_NAME func_kxc_pol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 4
#define _KMAX 4
#define _SPIN_UNPOL 1
#define FUNC_NAME func_lxc_unpol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 4
#define _KMAX 4
#define _SPIN_UNPOL 0
#define FUNC_NAME func_lxc_pol
#include "hyb_mgga_x_dldf.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#elif defined(_HYB_MGGA_X_DLDF_HELPER_BODIES)

/* ---- helpers (one graded body -> <name>_k<order>) ---- */

GPU_DEVICE_FUNCTION static inline void XC_CAT(opz_pow_n_4_3_k, _KMAX)(const xc_func_type *p, double z, double *out) {

  const double _t1 = z + 0.1e1;
  const double _t2 = _t1 <= p->zeta_threshold;

  const double f = my_piecewise3(_t2, xc_powr(p->zeta_threshold, 4, 3), xc_powr(_t1, 4, 3));
  out[0] = f;
#if _KMAX >= 1
  const double df_dz = my_piecewise3(_t2, 0, (0.4e1 / 0.3e1)*xc_powr(_t1, 1, 3));
  out[1] = df_dz;
#endif
#if _KMAX >= 2
  const double d2f_dz2 = my_piecewise3(_t2, 0, (0.4e1 / 0.9e1)/xc_powr(_t1, 2, 3));
  out[2] = d2f_dz2;
#endif
#if _KMAX >= 3
  const double d3f_dz3 = my_piecewise3(_t2, 0, -(0.8e1 / 0.27e2)/xc_powr(_t1, 5, 3));
  out[3] = d3f_dz3;
#endif
#if _KMAX >= 4
  const double d4f_dz4 = my_piecewise3(_t2, 0, (0.40e2 / 0.81e2)/xc_powr(_t1, 8, 3));
  out[4] = d4f_dz4;
#endif
}

GPU_DEVICE_FUNCTION static inline void XC_CAT(lda_x_spin_k, _KMAX)(const xc_func_type *p, double rs, double z, double *out) {

  double _hc0[(_KMAX) >= 4 ? 5 : (_KMAX) >= 3 ? 4 : (_KMAX) >= 2 ? 3 : (_KMAX) >= 1 ? 2 : 1];
  XC_CAT(opz_pow_n_4_3_k, _KMAX)(p, z, _hc0);
  const double _t1 = xc_powr(0.6e1, 1, 3)*M_CBRT3/(M_CBRTPI*M_CBRTPI);
  const double _t2 = (0.3e1 / 0.16e2)*_t1;
  const double _t3 = _t2/rs;
#if _KMAX >= 1
  const double _t4 = _t2/(rs * rs);
#endif
#if _KMAX >= 2
  const double _t5 = _hc0[0]*_t1;
  const double _t6 = (0.3e1 / 0.8e1)/(rs * rs * rs);
#endif
#if _KMAX >= 3
  const double _t7 = _t1*_t6;
  const double _t8 = (0.9e1 / 0.8e1)/(rs * rs * rs * rs);
#endif

  const double f = -_hc0[0]*_t3;
  out[0] = f;
#if _KMAX >= 1
  const double df_dz = -_hc0[1]*_t3;
  out[1] = df_dz;
  const double df_drs = _hc0[0]*_t4;
  out[2] = df_drs;
#endif
#if _KMAX >= 2
  const double d2f_dz2 = -_hc0[2]*_t3;
  out[3] = d2f_dz2;
  const double d2f_drs_dz = _hc0[1]*_t4;
  out[4] = d2f_drs_dz;
  const double d2f_drs2 = -_t5*_t6;
  out[5] = d2f_drs2;
#endif
#if _KMAX >= 3
  const double d3f_dz3 = -_hc0[3]*_t3;
  out[6] = d3f_dz3;
  const double d3f_drs_dz2 = _hc0[2]*_t4;
  out[7] = d3f_drs_dz2;
  const double d3f_drs2_dz = -_hc0[1]*_t7;
  out[8] = d3f_drs2_dz;
  const double d3f_drs3 = _t5*_t8;
  out[9] = d3f_drs3;
#endif
#if _KMAX >= 4
  const double d4f_dz4 = -_hc0[4]*_t3;
  out[10] = d4f_dz4;
  const double d4f_drs_dz3 = _hc0[3]*_t4;
  out[11] = d4f_drs_dz3;
  const double d4f_drs2_dz2 = -_hc0[2]*_t7;
  out[12] = d4f_drs2_dz2;
  const double d4f_drs3_dz = _hc0[1]*_t1*_t8;
  out[13] = d4f_drs3_dz;
  const double d4f_drs4 = -0.9e1 / 0.2e1*_t5/xc_powi(rs, 5);
  out[14] = d4f_drs4;
#endif
}

GPU_DEVICE_FUNCTION static inline void XC_CAT(xchan_k, _KMAX)(const xc_func_type *p, double n_s, double sigma_ss, double lapl_s, double tau_s, double *out) {

  const double _t1 = xc_powr(0.6e1, 1, 3);
  const double _t2 = _t1/M_CBRTPI;
  const double _t3 = -p->dens_threshold + n_s <= 0;
  const double _t5 = xc_powr(n_s, -8, 3);
  const double _t6 = (M_PI * M_CBRTPI);
  const double _t7 = _t1/_t6;
  const double _t8 = _t5*_t7;
  const double _t9 = _t8*sigma_ss;
  const double _t10 = 0.014629699999999999*_t9 + 4.8827322999999998;
  const double _t11 = (0.1e1 / _t10);
  const double _t12 = 0.071432908729309991*_t11;
  const double _t13 = _t12*_t9 + 0.1e1;
  const double _t14 = xc_powr(n_s, -5, 3);
  const double _t15 = _t14*tau_s;
  const double _t16 = xc_powr(0.6e1, 2, 3);
  const double _t17 = (0.3e1 / 0.10e2)*_t16*_t6;
  const double _t18 = -_t15 + _t17;
  const double _t19 = _t15 + _t17;
  const double _t20 = (0.1e1 / _t19);
  const double _t21 = 0.16375709999999999*_t20;
  const double _t22 = (0.1e1 / (_t19 * _t19));
  const double _t23 = (_t18 * _t18);
  const double _t24 = (0.1e1 / (_t19 * _t19 * _t19));
  const double _t25 = (_t18 * _t18 * _t18);
  const double _t26 = (0.1e1 / (_t19 * _t19 * _t19 * _t19));
  const double _t27 = (_t18 * _t18 * _t18 * _t18);
  const double _t28 = -_t18*_t21 - 0.1880028*_t22*_t23 - 0.44906089999999999*_t24*_t25 - 0.0082359000000000009*_t26*_t27 + 0.1e1;
  const double _t29 = _t13*_t28;
#if _KMAX >= 1
  const double _t31 = _t18*_t22;
  const double _t32 = _t23*_t24;
  const double _t33 = _t25*_t26;
  const double _t34 = xc_powi(_t19, -5);
  const double _t35 = _t27*_t34;
  const double _t36 = _t14*_t21 + 0.53976270000000004*_t14*_t31 + 1.7231882999999999*_t14*_t32 + 1.3801262999999999*_t14*_t33 + 0.032943600000000003*_t14*_t35;
  const double _t39 = xc_powr(n_s, -16, 3);
  const double _t40 = (0.1e1 / (M_PI * M_PI * M_CBRTPI * M_CBRTPI));
  const double _t41 = (0.1e1 / (_t10 * _t10));
  const double _t42 = _t16*_t40*_t41;
  const double _t43 = _t39*_t42;
  const double _t44 = _t12*_t8 - 0.0010450420248371863*_t43*sigma_ss;
  const double _t50 = xc_powr(n_s, -11, 3);
  const double _t51 = _t11*_t7;
  const double _t52 = 0.19048775661149331*_t50*_t51;
  const double _t53 = xc_powr(n_s, -19, 3);
  const double _t54 = (sigma_ss * sigma_ss);
  const double _t55 = 0.0027867787328991634*_t16*_t40*_t41*_t53*_t54 - _t52*sigma_ss;
  const double _t56 = 0.27292850000000002*_t20*_t5;
  const double _t57 = 0.89960450000000003*_t31*_t5;
  const double _t58 = 2.8719805000000003*_t32*_t5;
  const double _t59 = 2.3002104999999999*_t33*_t5;
  const double _t60 = 0.05490600000000001*_t35*_t5;
  const double _t61 = -_t56*tau_s - _t57*tau_s - _t58*tau_s - _t59*tau_s - _t60*tau_s;
#endif
#if _KMAX >= 2
  const double _t63 = xc_powr(n_s, -10, 3);
  const double _t64 = _t18*_t24;
  const double _t65 = _t23*_t26;
  const double _t66 = _t25*_t34;
  const double _t67 = xc_powi(_t19, -6);
  const double _t68 = _t27*_t67;
  const double _t69 = -0.70351980000000003*_t22*_t63 - 4.5259020000000003*_t63*_t64 - 9.3099437999999992*_t63*_t65 - 5.6522796*_t63*_t66 - 0.16471800000000003*_t63*_t68;
  const double _t73 = xc_powi(n_s, -8);
  const double _t74 = 0.1e1/((M_PI * M_PI * M_PI * M_PI)*(_t10 * _t10 * _t10));
  const double _t75 = _t73*_t74;
  const double _t76 = -0.0020900840496743726*_t43 + 0.00018346381572912702*_t75*sigma_ss;
  const double _t78 = _t13*_t36;
  const double _t79 = xc_powr(n_s, -13, 3);
  const double _t80 = 7.5431700000000008*_t18*_t24*_t79*tau_s + 1.172533*_t22*_t79*tau_s + 15.516573000000001*_t23*_t26*_t79*tau_s + 9.4204659999999993*_t25*_t34*_t79*tau_s + 0.27453000000000005*_t27*_t67*_t79*tau_s - _t56 - _t57 - _t58 - _t59 - _t60;
  const double _t82 = _t28*_t44;
  const double _t83 = xc_powi(n_s, -9);
  const double _t84 = _t74*_t83;
  const double _t85 = 0.0083603361986974902*_t16*_t40*_t41*_t53*sigma_ss - _t52 - 0.00048923684194433867*_t54*_t84;
  const double _t88 = 0.085686022222222213*_t29;
  const double _t90 = 0.010710752777777777*_t29;
  const double _t93 = _t28*_t55;
  const double _t95 = _t13*_t61;
  const double _t96 = (sigma_ss * sigma_ss * sigma_ss);
  const double _t97 = _t74/xc_powi(n_s, 10);
  const double _t98 = xc_powr(n_s, -14, 3);
  const double _t99 = 0.69845510757547546*_t51*_t98;
  const double _t100 = xc_powr(n_s, -22, 3);
  const double _t101 = _t100*_t42;
  const double _t102 = -0.025081008596092469*_t101*_t54 + 0.0013046315785182362*_t96*_t97 + _t99*sigma_ss;
  const double _t104 = 0.77117419999999992*_t61;
  const double _t105 = 0.72780933333333331*_t20*_t50;
  const double _t106 = (tau_s * tau_s);
  const double _t107 = _t22*_t39;
  const double _t108 = 2.3989453333333333*_t31*_t50;
  const double _t109 = _t39*_t64;
  const double _t110 = 7.6586146666666668*_t32*_t50;
  const double _t111 = 6.1338946666666665*_t33*_t50;
  const double _t112 = 0.14641600000000002*_t35*_t50;
  const double _t113 = _t39*_t65;
  const double _t114 = _t39*_t66;
  const double _t115 = _t39*_t68;
  const double _t116 = _t105*tau_s - 1.9542216666666667*_t106*_t107 - 12.571950000000001*_t106*_t109 - 25.860955000000001*_t106*_t113 - 15.700776666666666*_t106*_t114 - 0.45755000000000012*_t106*_t115 + _t108*tau_s + _t110*tau_s + _t111*tau_s + _t112*tau_s;
#endif
#if _KMAX >= 3
  const double _t118 = xc_powi(n_s, -5);
  const double _t119 = _t18*_t26;
  const double _t120 = _t23*_t34;
  const double _t121 = _t25*_t67;
  const double _t122 = xc_powi(_t19, -7);
  const double _t123 = _t122*_t27;
  const double _t124 = 32.197593599999998*_t118*_t119 + 54.196613999999997*_t118*_t120 + 28.920269999999999*_t118*_t121 + 0.98830800000000019*_t118*_t123 + 5.9329416000000004*_t118*_t24;
  const double _t128 = xc_powr(n_s, -32, 3);
  const double _t129 = (0.1e1 / (M_PI * M_PI * M_PI * M_PI * M_PI * M_CBRTPI));
  const double _t130 = (0.1e1 / (_t10 * _t10 * _t10 * _t10));
  const double _t131 = _t1*_t129*_t130;
  const double _t132 = _t128*_t131;
  const double _t133 = -8.0520617549172286e-6*_t132*sigma_ss + 0.00055039144718738099*_t75;
  const double _t137 = xc_powi(n_s, -6);
  const double _t138 = _t137*_t24;
  const double _t139 = _t119*_t137;
  const double _t140 = _t120*_t137;
  const double _t141 = _t121*_t137;
  const double _t142 = _t123*_t137;
  const double _t143 = 1.6471800000000003*tau_s;
  const double _t144 = -9.8882360000000009*_t138*tau_s - 53.662656000000005*_t139*tau_s - 90.327690000000004*_t140*tau_s - 48.200449999999996*_t141*tau_s - _t142*_t143 + 15.086340000000002*_t18*_t24*_t79 + 2.3450660000000001*_t22*_t79 + 31.033146000000002*_t23*_t26*_t79 + 18.840931999999999*_t25*_t34*_t79 + 0.5490600000000001*_t27*_t67*_t79;
  const double _t149 = xc_powr(n_s, -35, 3);
  const double _t150 = 2.1472164679779274e-5*_t131*_t149*_t54 + 0.011147114931596654*_t42*_t53 - 0.0024461842097216937*_t84*sigma_ss;
  const double _t158 = xc_powi(n_s, -7);
  const double _t159 = _t106*_t158;
  const double _t160 = _t105 + 16.480393333333335*_t106*_t158*_t24 - 7.0351979999999994*_t107*tau_s + _t108 - 45.259020000000007*_t109*tau_s + _t110 + _t111 + _t112 - 93.099437999999992*_t113*tau_s - 56.522796*_t114*tau_s - _t115*_t143 + 89.437759999999997*_t119*_t159 + 150.54615000000001*_t120*_t159 + 80.334083333333339*_t121*_t159 + 2.7453000000000007*_t123*_t159;
  const double _t164 = _t131/xc_powr(n_s, 38, 3);
  const double _t165 = -0.060380205879481869*_t101*sigma_ss - 5.7259105812744724e-5*_t164*_t96 + 0.0083170263130537565*_t54*_t97 + _t99;
  const double _t171 = 0.19993405185185184*_t63;
  const double _t173 = 0.042843011111111107*_t50;
  const double _t178 = _t55*_t61;
  const double _t180 = _t74/xc_powi(n_s, 11);
  const double _t181 = xc_powr(n_s, -17, 3);
  const double _t182 = 3.2594571686855525*_t181*_t51;
  const double _t183 = xc_powr(n_s, -41, 3);
  const double _t184 = (sigma_ss * sigma_ss * sigma_ss * sigma_ss);
  const double _t185 = xc_powr(n_s, -25, 3);
  const double _t186 = 0.00015269094883398591*_t1*_t129*_t130*_t183*_t184 + 0.2111758995374699*_t16*_t185*_t40*_t41*_t54 - 0.024787999991846488*_t180*_t96 - _t182*sigma_ss;
  const double _t188 = 1.1567612999999999*_t102;
  const double _t189 = _t116*_t13;
  const double _t191 = 2.6686342222222219*_t20*_t98;
  const double _t192 = (tau_s * tau_s * tau_s);
  const double _t193 = _t24*_t73;
  const double _t194 = 8.7961328888888879*_t31*_t98;
  const double _t195 = _t192*_t73;
  const double _t196 = 28.081587111111112*_t32*_t98;
  const double _t197 = 22.490947111111108*_t33*_t98;
  const double _t198 = 0.53685866666666671*_t35*_t98;
  const double _t199 = 100.57559999999999*_t106*_t18*_t24*_t53 + 15.633773333333334*_t106*_t22*_t53 + 206.88764*_t106*_t23*_t26*_t53 + 125.60621333333333*_t106*_t25*_t34*_t53 + 3.6604000000000005*_t106*_t27*_t53*_t67 - 149.06293333333335*_t119*_t195 - 250.91025000000002*_t120*_t195 - 133.89013888888888*_t121*_t195 - 4.5755000000000017*_t123*_t195 - _t191*tau_s - 27.467322222222226*_t192*_t193 - _t194*tau_s - _t196*tau_s - _t197*tau_s - _t198*tau_s;
#endif
#if _KMAX >= 4
  const double _t201 = xc_powr(n_s, -20, 3);
  const double _t202 = _t18*_t34;
  const double _t203 = _t23*_t67;
  const double _t204 = _t122*_t25;
  const double _t205 = xc_powi(_t19, -8);
  const double _t206 = _t205*_t27;
  const double _t207 = (0.1e1 / (M_PI * M_PI * M_PI * M_PI * M_PI * M_PI * M_CBRTPI * M_CBRTPI));
  const double _t208 = xc_powi(_t10, -5);
  const double _t209 = xc_powr(n_s, -23, 3);
  const double _t210 = _t16*_t207*_t208;
  const double _t211 = _t13*_t69;
  const double _t212 = _t106/xc_powr(n_s, 26, 3);
  const double _t213 = _t36*_t44;
  const double _t214 = _t28*_t76;
  const double _t218 = _t36*_t55;
  const double _t219 = _t13*_t80;
  const double _t220 = xc_powr(n_s, -29, 3);
  const double _t221 = _t106*_t73;
  const double _t222 = _t28*_t85;
  const double _t223 = _t44*_t61;
  const double _t227 = _t102*_t28;
  const double _t231 = _t181*tau_s;
  const double _t232 = _t128*(tau_s * tau_s * tau_s * tau_s);
  const double _t233 = _t192*_t83;
  const double _t234 = _t100*_t106;
#endif
  double _hc0[(_KMAX) >= 4 ? 15 : (_KMAX) >= 3 ? 10 : (_KMAX) >= 2 ? 6 : (_KMAX) >= 1 ? 3 : 1] = {0.};
  if(!(_t3)) XC_CAT(lda_x_spin_k, _KMAX)(p, (0.1e1 / 0.2e1)*_t2/xc_powr(n_s, 1, 3), 0.1e1 - p->zeta_threshold, _hc0);
  const double _t4 = 0.38558709999999996*_hc0[0];
  const double _t30 = my_piecewise3(_t3, 0, _t29*_t4);
#if _KMAX >= 1
  const double _t37 = _t13*_t4;
  const double _t38 = my_piecewise3(_t3, 0, _t36*_t37);
  const double _t45 = _t28*_t4;
  const double _t46 = my_piecewise3(_t3, 0, _t44*_t45);
  const double _t47 = _hc0[2]*_t2;
  const double _t48 = _t47/xc_powr(n_s, 4, 3);
  const double _t49 = 0.06426451666666666*_t48;
  const double _t62 = my_piecewise3(_t3, 0, -_t29*_t49 + _t37*_t61 + _t45*_t55);
#endif
#if _KMAX >= 2
  const double _t70 = my_piecewise3(_t3, 0, _t37*_t69);
  const double _t71 = _t36*_t4;
  const double _t72 = my_piecewise3(_t3, 0, _t44*_t71);
  const double _t77 = my_piecewise3(_t3, 0, _t45*_t76);
  const double _t81 = my_piecewise3(_t3, 0, _t37*_t80 - _t49*_t78 + _t55*_t71);
  const double _t86 = _t4*_t44;
  const double _t87 = my_piecewise3(_t3, 0, _t45*_t85 - _t49*_t82 + _t61*_t86);
  const double _t89 = _t47/xc_powr(n_s, 7, 3);
  const double _t91 = _hc0[5]*_t16/(M_CBRTPI * M_CBRTPI);
  const double _t92 = _t5*_t91;
  const double _t94 = 0.12852903333333332*_t48;
  const double _t103 = _hc0[0]*_t55;
  const double _t117 = my_piecewise3(_t3, 0, _t102*_t45 + _t103*_t104 + _t116*_t37 + _t88*_t89 + _t90*_t92 - _t93*_t94 - _t94*_t95);
#endif
#if _KMAX >= 3
  const double _t125 = my_piecewise3(_t3, 0, _t124*_t37);
  const double _t126 = my_piecewise3(_t3, 0, _t69*_t86);
  const double _t127 = my_piecewise3(_t3, 0, _t71*_t76);
  const double _t134 = my_piecewise3(_t3, 0, _t133*_t45);
  const double _t135 = _t13*_t49;
  const double _t136 = _t4*_t69;
  const double _t145 = my_piecewise3(_t3, 0, -_t135*_t69 + _t136*_t55 + _t144*_t37);
  const double _t146 = _t44*_t49;
  const double _t147 = my_piecewise3(_t3, 0, -_t146*_t36 + _t71*_t85 + _t80*_t86);
  const double _t148 = _t49*_t76;
  const double _t151 = _t4*_t76;
  const double _t152 = my_piecewise3(_t3, 0, -_t148*_t28 + _t150*_t45 + _t151*_t61);
  const double _t153 = 0.085686022222222213*_t89;
  const double _t154 = 0.010710752777777777*_t92;
  const double _t155 = _t55*_t94;
  const double _t156 = _t13*_t94;
  const double _t157 = 0.77117419999999992*_t103;
  const double _t161 = my_piecewise3(_t3, 0, _t102*_t71 + _t153*_t78 + _t154*_t78 - _t155*_t36 - _t156*_t80 + _t157*_t80 + _t160*_t37);
  const double _t162 = _t85*_t94;
  const double _t163 = _t44*_t94;
  const double _t166 = _hc0[0]*_t85;
  const double _t167 = my_piecewise3(_t3, 0, _t104*_t166 + _t116*_t86 + _t153*_t82 + _t154*_t82 - _t162*_t28 - _t163*_t61 + _t165*_t45);
  const double _t168 = _hc0[9]/M_PI;
  const double _t169 = _t168/(n_s * n_s * n_s * n_s);
  const double _t170 = _t29*_t47;
  const double _t172 = _t29*_t91;
  const double _t174 = 0.25705806666666664*_t89;
  const double _t175 = 0.03213225833333333*_t92;
  const double _t176 = 0.19279354999999998*_t48;
  const double _t177 = _t102*_t176;
  const double _t179 = 0.38558709999999996*_t48;
  const double _t187 = _hc0[0]*_t61;
  const double _t190 = 1.1567612999999999*_t103;
  const double _t200 = my_piecewise3(_t3, 0, _t116*_t190 - _t169*_t90 - _t170*_t171 - _t172*_t173 + _t174*_t93 + _t174*_t95 + _t175*_t93 + _t175*_t95 - _t176*_t189 - _t177*_t28 - _t178*_t179 + _t186*_t45 + _t187*_t188 + _t199*_t37);
#endif
#if _KMAX >= 4
  const double _t215 = 0.010710752777777777*_t169;
  const double _t216 = _t171*_t47;
  const double _t217 = _t173*_t91;
  const double _t224 = 0.042843011111111107*_t169;
  const double _t225 = 0.79973620740740736*_t47*_t63;
  const double _t226 = 0.17137204444444443*_t50*_t91;
  const double _t228 = 0.51411613333333328*_t89;
  const double _t229 = 0.06426451666666666*_t92;
  const double _t230 = 0.25705806666666664*_t48;
#endif

  const double f = my_piecewise3(_t3, 0, _t30*n_s);
  out[0] = f;
#if _KMAX >= 1
  const double df_dtau_s = my_piecewise3(_t3, 0, _t38*n_s);
  out[1] = df_dtau_s;
  const double df_dlapl_s = 0;
  out[2] = df_dlapl_s;
  const double df_dsigma_ss = my_piecewise3(_t3, 0, _t46*n_s);
  out[3] = df_dsigma_ss;
  const double df_dn_s = my_piecewise3(_t3, 0, _t30 + _t62*n_s);
  out[4] = df_dn_s;
#endif
#if _KMAX >= 2
  const double d2f_dtau_s2 = my_piecewise3(_t3, 0, _t70*n_s);
  out[5] = d2f_dtau_s2;
  const double d2f_dlapl_s_dtau_s = 0;
  out[6] = d2f_dlapl_s_dtau_s;
  const double d2f_dlapl_s2 = 0;
  out[7] = d2f_dlapl_s2;
  const double d2f_dsigma_ss_dtau_s = my_piecewise3(_t3, 0, _t72*n_s);
  out[8] = d2f_dsigma_ss_dtau_s;
  const double d2f_dsigma_ss_dlapl_s = 0;
  out[9] = d2f_dsigma_ss_dlapl_s;
  const double d2f_dsigma_ss2 = my_piecewise3(_t3, 0, _t77*n_s);
  out[10] = d2f_dsigma_ss2;
  const double d2f_dn_s_dtau_s = my_piecewise3(_t3, 0, _t38 + _t81*n_s);
  out[11] = d2f_dn_s_dtau_s;
  const double d2f_dn_s_dlapl_s = 0;
  out[12] = d2f_dn_s_dlapl_s;
  const double d2f_dn_s_dsigma_ss = my_piecewise3(_t3, 0, _t46 + _t87*n_s);
  out[13] = d2f_dn_s_dsigma_ss;
  const double d2f_dn_s2 = my_piecewise3(_t3, 0, _t117*n_s + 0.2e1*_t62);
  out[14] = d2f_dn_s2;
#endif
#if _KMAX >= 3
  const double d3f_dtau_s3 = my_piecewise3(_t3, 0, _t125*n_s);
  out[15] = d3f_dtau_s3;
  const double d3f_dlapl_s_dtau_s2 = 0;
  out[16] = d3f_dlapl_s_dtau_s2;
  const double d3f_dlapl_s2_dtau_s = 0;
  out[17] = d3f_dlapl_s2_dtau_s;
  const double d3f_dlapl_s3 = 0;
  out[18] = d3f_dlapl_s3;
  const double d3f_dsigma_ss_dtau_s2 = my_piecewise3(_t3, 0, _t126*n_s);
  out[19] = d3f_dsigma_ss_dtau_s2;
  const double d3f_dsigma_ss_dlapl_s_dtau_s = 0;
  out[20] = d3f_dsigma_ss_dlapl_s_dtau_s;
  const double d3f_dsigma_ss_dlapl_s2 = 0;
  out[21] = d3f_dsigma_ss_dlapl_s2;
  const double d3f_dsigma_ss2_dtau_s = my_piecewise3(_t3, 0, _t127*n_s);
  out[22] = d3f_dsigma_ss2_dtau_s;
  const double d3f_dsigma_ss2_dlapl_s = 0;
  out[23] = d3f_dsigma_ss2_dlapl_s;
  const double d3f_dsigma_ss3 = my_piecewise3(_t3, 0, _t134*n_s);
  out[24] = d3f_dsigma_ss3;
  const double d3f_dn_s_dtau_s2 = my_piecewise3(_t3, 0, _t145*n_s + _t70);
  out[25] = d3f_dn_s_dtau_s2;
  const double d3f_dn_s_dlapl_s_dtau_s = 0;
  out[26] = d3f_dn_s_dlapl_s_dtau_s;
  const double d3f_dn_s_dlapl_s2 = 0;
  out[27] = d3f_dn_s_dlapl_s2;
  const double d3f_dn_s_dsigma_ss_dtau_s = my_piecewise3(_t3, 0, _t147*n_s + _t72);
  out[28] = d3f_dn_s_dsigma_ss_dtau_s;
  const double d3f_dn_s_dsigma_ss_dlapl_s = 0;
  out[29] = d3f_dn_s_dsigma_ss_dlapl_s;
  const double d3f_dn_s_dsigma_ss2 = my_piecewise3(_t3, 0, _t152*n_s + _t77);
  out[30] = d3f_dn_s_dsigma_ss2;
  const double d3f_dn_s2_dtau_s = my_piecewise3(_t3, 0, _t161*n_s + 0.2e1*_t81);
  out[31] = d3f_dn_s2_dtau_s;
  const double d3f_dn_s2_dlapl_s = 0;
  out[32] = d3f_dn_s2_dlapl_s;
  const double d3f_dn_s2_dsigma_ss = my_piecewise3(_t3, 0, _t167*n_s + 0.2e1*_t87);
  out[33] = d3f_dn_s2_dsigma_ss;
  const double d3f_dn_s3 = my_piecewise3(_t3, 0, 0.3e1*_t117 + _t200*n_s);
  out[34] = d3f_dn_s3;
#endif
#if _KMAX >= 4
  const double d4f_dtau_s4 = my_piecewise3(_t3, 0, n_s*my_piecewise3(_t3, 0, _t37*(-237.18360239999998*_t201*_t202 - 357.74387999999999*_t201*_t203 - 177.474852*_t201*_t204 - 6.9181560000000015*_t201*_t206 - 49.996418399999996*_t201*_t26)));
  out[35] = d4f_dtau_s4;
  const double d4f_dlapl_s_dtau_s3 = 0;
  out[36] = d4f_dlapl_s_dtau_s3;
  const double d4f_dlapl_s2_dtau_s2 = 0;
  out[37] = d4f_dlapl_s2_dtau_s2;
  const double d4f_dlapl_s3_dtau_s = 0;
  out[38] = d4f_dlapl_s3_dtau_s;
  const double d4f_dlapl_s4 = 0;
  out[39] = d4f_dlapl_s4;
  const double d4f_dsigma_ss_dtau_s3 = my_piecewise3(_t3, 0, n_s*my_piecewise3(_t3, 0, _t124*_t86));
  out[40] = d4f_dsigma_ss_dtau_s3;
  const double d4f_dsigma_ss_dlapl_s_dtau_s2 = 0;
  out[41] = d4f_dsigma_ss_dlapl_s_dtau_s2;
  const double d4f_dsigma_ss_dlapl_s2_dtau_s = 0;
  out[42] = d4f_dsigma_ss_dlapl_s2_dtau_s;
  const double d4f_dsigma_ss_dlapl_s3 = 0;
  out[43] = d4f_dsigma_ss_dlapl_s3;
  const double d4f_dsigma_ss2_dtau_s2 = my_piecewise3(_t3, 0, n_s*my_piecewise3(_t3, 0, _t136*_t76));
  out[44] = d4f_dsigma_ss2_dtau_s2;
  const double d4f_dsigma_ss2_dlapl_s_dtau_s = 0;
  out[45] = d4f_dsigma_ss2_dlapl_s_dtau_s;
  const double d4f_dsigma_ss2_dlapl_s2 = 0;
  out[46] = d4f_dsigma_ss2_dlapl_s2;
  const double d4f_dsigma_ss3_dtau_s = my_piecewise3(_t3, 0, n_s*my_piecewise3(_t3, 0, _t133*_t71));
  out[47] = d4f_dsigma_ss3_dtau_s;
  const double d4f_dsigma_ss3_dlapl_s = 0;
  out[48] = d4f_dsigma_ss3_dlapl_s;
  const double d4f_dsigma_ss4 = my_piecewise3(_t3, 0, n_s*my_piecewise3(_t3, 0, _t45*(-3.2208247019668914e-5*_t132 + 4.7119699142365028e-7*_t16*_t207*_t208*sigma_ss/xc_powr(n_s, 40, 3))));
  out[49] = d4f_dsigma_ss4;
  const double d4f_dn_s_dtau_s3 = my_piecewise3(_t3, 0, _t125 + n_s*my_piecewise3(_t3, 0, -_t124*_t135 + _t124*_t4*_t55 + _t37*(295.79142000000002*_t122*_t209*_t25*tau_s - 29.664708000000005*_t138 - 160.98796800000002*_t139 - 270.98307*_t140 - 144.60135*_t141 - 4.9415400000000007*_t142 + 395.30600400000003*_t18*_t209*_t34*tau_s + 11.530260000000002*_t205*_t209*_t27*tau_s + 596.23980000000006*_t209*_t23*_t67*tau_s + 83.327364000000017*_t209*_t26*tau_s)));
  out[50] = d4f_dn_s_dtau_s3;
  const double d4f_dn_s_dlapl_s_dtau_s2 = 0;
  out[51] = d4f_dn_s_dlapl_s_dtau_s2;
  const double d4f_dn_s_dlapl_s2_dtau_s = 0;
  out[52] = d4f_dn_s_dlapl_s2_dtau_s;
  const double d4f_dn_s_dlapl_s3 = 0;
  out[53] = d4f_dn_s_dlapl_s3;
  const double d4f_dn_s_dsigma_ss_dtau_s2 = my_piecewise3(_t3, 0, _t126 + n_s*my_piecewise3(_t3, 0, _t136*_t85 + _t144*_t86 - _t146*_t69));
  out[54] = d4f_dn_s_dsigma_ss_dtau_s2;
  const double d4f_dn_s_dsigma_ss_dlapl_s_dtau_s = 0;
  out[55] = d4f_dn_s_dsigma_ss_dlapl_s_dtau_s;
  const double d4f_dn_s_dsigma_ss_dlapl_s2 = 0;
  out[56] = d4f_dn_s_dsigma_ss_dlapl_s2;
  const double d4f_dn_s_dsigma_ss2_dtau_s = my_piecewise3(_t3, 0, _t127 + n_s*my_piecewise3(_t3, 0, -_t148*_t36 + _t150*_t71 + _t151*_t80));
  out[57] = d4f_dn_s_dsigma_ss2_dtau_s;
  const double d4f_dn_s_dsigma_ss2_dlapl_s = 0;
  out[58] = d4f_dn_s_dsigma_ss2_dlapl_s;
  const double d4f_dn_s_dsigma_ss3 = my_piecewise3(_t3, 0, _t134 + n_s*my_piecewise3(_t3, 0, -_t133*_t28*_t49 + _t133*_t4*_t61 + _t45*(0.00015030515275845494*_t1*_t129*_t130*_t149*sigma_ss - 1.2565253104630673e-6*_t210*_t54/xc_powr(n_s, 43, 3) - 0.0044031315774990479*_t84)));
  out[59] = d4f_dn_s_dsigma_ss3;
  const double d4f_dn_s2_dtau_s2 = my_piecewise3(_t3, 0, 0.2e1*_t145 + n_s*my_piecewise3(_t3, 0, _t102*_t136 - _t144*_t156 + _t144*_t157 + _t153*_t211 + _t154*_t211 - _t155*_t69 + _t37*(-10.161952666666666*_t107 - 65.374140000000011*_t109 - 134.476966*_t113 - 81.64403866666666*_t114 - 2.3792600000000004*_t115 + 15.373680000000004*_t122*_t158*_t27*tau_s + 500.85145599999998*_t158*_t18*_t26*tau_s + 843.05844000000002*_t158*_t23*_t34*tau_s + 92.290202666666673*_t158*_t24*tau_s + 449.8708666666667*_t158*_t25*_t67*tau_s - 658.84334000000001*_t202*_t212 - 993.73300000000006*_t203*_t212 - 492.98570000000001*_t204*_t212 - 19.217100000000006*_t206*_t212 - 138.87894*_t212*_t26)));
  out[60] = d4f_dn_s2_dtau_s2;
  const double d4f_dn_s2_dlapl_s_dtau_s = 0;
  out[61] = d4f_dn_s2_dlapl_s_dtau_s;
  const double d4f_dn_s2_dlapl_s2 = 0;
  out[62] = d4f_dn_s2_dlapl_s2;
  const double d4f_dn_s2_dsigma_ss_dtau_s = my_piecewise3(_t3, 0, 0.2e1*_t147 + n_s*my_piecewise3(_t3, 0, _t153*_t213 + _t154*_t213 + _t160*_t86 - _t162*_t36 - _t163*_t80 + _t165*_t71 + 0.77117419999999992*_t166*_t80));
  out[63] = d4f_dn_s2_dsigma_ss_dtau_s;
  const double d4f_dn_s2_dsigma_ss_dlapl_s = 0;
  out[64] = d4f_dn_s2_dsigma_ss_dlapl_s;
  const double d4f_dn_s2_dsigma_ss2 = my_piecewise3(_t3, 0, 0.2e1*_t152 + n_s*my_piecewise3(_t3, 0, _hc0[0]*_t104*_t150 + _t116*_t151 - _t150*_t28*_t94 + _t153*_t214 + _t154*_t214 + _t45*(-0.070598394566778799*_t101 - 0.0005368041169944818*_t164*_t54 + 3.3507341612348459e-6*_t210*_t96/xc_powr(n_s, 46, 3) + 0.02723418420156818*_t97*sigma_ss) - _t61*_t76*_t94));
  out[65] = d4f_dn_s2_dsigma_ss2;
  const double d4f_dn_s3_dtau_s = my_piecewise3(_t3, 0, 0.3e1*_t161 + n_s*my_piecewise3(_t3, 0, _hc0[0]*_t188*_t80 - _t13*_t160*_t176 + _t160*_t190 + _t174*_t218 + _t174*_t219 + _t175*_t218 + _t175*_t219 - _t177*_t36 - _t179*_t55*_t80 + _t186*_t71 - _t215*_t78 - _t216*_t78 - _t217*_t78 + _t37*(-214.24511333333334*_t106*_t193 - 1162.6908800000001*_t119*_t221 - 1957.0999500000003*_t120*_t221 - 1044.3430833333334*_t121*_t221 + 821.64283333333333*_t122*_t192*_t220*_t25 - 35.688900000000004*_t123*_t221 + 1098.0722333333333*_t18*_t192*_t220*_t34 + 274.90663999999998*_t18*_t24*_t53*tau_s - _t191 + 32.028500000000008*_t192*_t205*_t220*_t27 + 1656.2216666666666*_t192*_t220*_t23*_t67 + 231.46490000000003*_t192*_t220*_t26 - _t194 - _t196 - _t197 - _t198 + 42.732313777777776*_t22*_t53*tau_s + 565.49288266666667*_t23*_t26*_t53*tau_s + 343.32364977777775*_t25*_t34*_t53*tau_s + 10.005093333333335*_t27*_t53*_t67*tau_s)));
  out[66] = d4f_dn_s3_dtau_s;
  const double d4f_dn_s3_dlapl_s = 0;
  out[67] = d4f_dn_s3_dlapl_s;
  const double d4f_dn_s3_dsigma_ss = my_piecewise3(_t3, 0, 0.3e1*_t167 + n_s*my_piecewise3(_t3, 0, 1.1567612999999999*_t116*_t166 - _t116*_t176*_t44 - _t165*_t176*_t28 + 1.1567612999999999*_t165*_t187 + _t174*_t222 + _t174*_t223 + _t175*_t222 + _t175*_t223 - _t179*_t61*_t85 + _t199*_t86 - _t215*_t82 - _t216*_t82 - _t217*_t82 + _t45*(0.0016986868057780934*_t1*_t129*_t130*_t183*_t96 + 0.47003667961565881*_t16*_t185*_t40*_t41*sigma_ss - 0.11143728066509935*_t180*_t54 - _t182 - 8.9352910966262535e-6*_t184*_t210/xc_powr(n_s, 49, 3))));
  out[68] = d4f_dn_s3_dsigma_ss;
  const double d4f_dn_s4 = my_piecewise3(_t3, 0, 0.4e1*_t200 + n_s*my_piecewise3(_t3, 0, 2.3135225999999998*_hc0[0]*_t102*_t116 + 0.0017851254629629627*_hc0[14]*_t29*_t39*_t7 - _t102*_t104*_t48 + 1.5423483999999998*_t103*_t199 - 0.77117419999999992*_t116*_t48*_t55 + _t118*_t168*_t88 - _t13*_t199*_t230 + 0.66644683950617278*_t170*_t79 + 0.19041338271604935*_t172*_t98 + 1.0282322666666666*_t178*_t89 + 0.12852903333333332*_t178*_t92 + 1.5423483999999998*_t186*_t187 - _t186*_t230*_t28 + _t189*_t228 + _t189*_t229 - _t224*_t93 - _t224*_t95 - _t225*_t93 - _t225*_t95 - _t226*_t93 - _t226*_t95 + _t227*_t228 + _t227*_t229 + _t37*(2385.0069333333336*_t119*_t233 + 4014.5640000000003*_t120*_t233 + 2142.2422222222222*_t121*_t233 + 73.208000000000027*_t123*_t233 + 12.453626370370369*_t20*_t231 - 1830.120388888889*_t202*_t232 - 2760.3694444444445*_t203*_t232 - 1369.4047222222223*_t204*_t232 - 53.380833333333349*_t206*_t232 - 118.12184296296296*_t22*_t234 + 41.048620148148146*_t231*_t31 + 131.04740651851853*_t231*_t32 + 104.95775318518518*_t231*_t33 + 2.5053404444444447*_t231*_t35 - 385.77483333333339*_t232*_t26 + 439.47715555555556*_t233*_t24 - 759.90453333333335*_t234*_t64 - 1563.1510577777776*_t234*_t65 - 949.02472296296287*_t234*_t66 - 27.656355555555557*_t234*_t68) + _t45*(-0.0049879043285768736*_t131*_t184/xc_powr(n_s, 44, 3) + 18.470257289218132*_t201*_t51*sigma_ss + 2.3827442924336677e-5*_t210*xc_powi(sigma_ss, 5)/xc_powr(n_s, 52, 3) - 1.8869588442541667*_t42*_t54/xc_powr(n_s, 28, 3) + 0.37153008174913771*_t74*_t96/xc_powi(n_s, 12))));
  out[69] = d4f_dn_s4;
#endif
}

#else  /* re-inclusion: one graded body -> func_<order>_<spin> */
GPU_DEVICE_FUNCTION static inline void
FUNC_NAME(const xc_func_type *p, size_t ip, const double *rho, const double *sigma, const double *lapl, const double *tau, xc_mgga_out_params *out)
{
#if _SPIN_UNPOL
  const double na = rho[0];
  const double gaa = sigma[0];
  const double ta = tau[0];

  double _hc0[(_KMAX) >= 4 ? 70 : (_KMAX) >= 3 ? 35 : (_KMAX) >= 2 ? 15 : (_KMAX) >= 1 ? 5 : 1];
  XC_CAT(xchan_k, _KMAX)(p, (0.1e1 / 0.2e1)*na, (0.1e1 / 0.4e1)*gaa, 0, (0.1e1 / 0.2e1)*ta, _hc0);
  const double zk = 0.2e1*_hc0[0]/na;
  if(out->zk != NULL) out->zk[ip*p->dim.zk + 0] += zk;
#if _KMAX >= 1
  const double dF_dna = _hc0[4];
  const double dF_dgaa = (0.1e1 / 0.2e1)*_hc0[3];
  const double dF_dta = _hc0[1];
  if(out->vrho != NULL) out->vrho[ip*p->dim.vrho + 0] += dF_dna;
  if(out->vsigma != NULL) out->vsigma[ip*p->dim.vsigma + 0] += dF_dgaa;
  if(out->vtau != NULL) out->vtau[ip*p->dim.vtau + 0] += dF_dta;
#endif
#if _KMAX >= 2
  const double d2F_dna2 = (0.1e1 / 0.2e1)*_hc0[14];
  const double d2F_dna_dgaa = (0.1e1 / 0.4e1)*_hc0[13];
  const double d2F_dna_dta = (0.1e1 / 0.2e1)*_hc0[11];
  const double d2F_dgaa2 = (0.1e1 / 0.8e1)*_hc0[10];
  const double d2F_dgaa_dta = (0.1e1 / 0.4e1)*_hc0[8];
  const double d2F_dta2 = (0.1e1 / 0.2e1)*_hc0[5];
  if(out->v2rho2 != NULL) out->v2rho2[ip*p->dim.v2rho2 + 0] += d2F_dna2;
  if(out->v2rhosigma != NULL) out->v2rhosigma[ip*p->dim.v2rhosigma + 0] += d2F_dna_dgaa;
  if(out->v2rhotau != NULL) out->v2rhotau[ip*p->dim.v2rhotau + 0] += d2F_dna_dta;
  if(out->v2sigma2 != NULL) out->v2sigma2[ip*p->dim.v2sigma2 + 0] += d2F_dgaa2;
  if(out->v2sigmatau != NULL) out->v2sigmatau[ip*p->dim.v2sigmatau + 0] += d2F_dgaa_dta;
  if(out->v2tau2 != NULL) out->v2tau2[ip*p->dim.v2tau2 + 0] += d2F_dta2;
#endif
#if _KMAX >= 3
  const double d3F_dna3 = (0.1e1 / 0.4e1)*_hc0[34];
  const double d3F_dna2_dgaa = (0.1e1 / 0.8e1)*_hc0[33];
  const double d3F_dna2_dta = (0.1e1 / 0.4e1)*_hc0[31];
  const double d3F_dna_dgaa2 = (0.1e1 / 0.16e2)*_hc0[30];
  const double d3F_dna_dgaa_dta = (0.1e1 / 0.8e1)*_hc0[28];
  const double d3F_dna_dta2 = (0.1e1 / 0.4e1)*_hc0[25];
  const double d3F_dgaa3 = (0.1e1 / 0.32e2)*_hc0[24];
  const double d3F_dgaa2_dta = (0.1e1 / 0.16e2)*_hc0[22];
  const double d3F_dgaa_dta2 = (0.1e1 / 0.8e1)*_hc0[19];
  const double d3F_dta3 = (0.1e1 / 0.4e1)*_hc0[15];
  if(out->v3rho3 != NULL) out->v3rho3[ip*p->dim.v3rho3 + 0] += d3F_dna3;
  if(out->v3rho2sigma != NULL) out->v3rho2sigma[ip*p->dim.v3rho2sigma + 0] += d3F_dna2_dgaa;
  if(out->v3rho2tau != NULL) out->v3rho2tau[ip*p->dim.v3rho2tau + 0] += d3F_dna2_dta;
  if(out->v3rhosigma2 != NULL) out->v3rhosigma2[ip*p->dim.v3rhosigma2 + 0] += d3F_dna_dgaa2;
  if(out->v3rhosigmatau != NULL) out->v3rhosigmatau[ip*p->dim.v3rhosigmatau + 0] += d3F_dna_dgaa_dta;
  if(out->v3rhotau2 != NULL) out->v3rhotau2[ip*p->dim.v3rhotau2 + 0] += d3F_dna_dta2;
  if(out->v3sigma3 != NULL) out->v3sigma3[ip*p->dim.v3sigma3 + 0] += d3F_dgaa3;
  if(out->v3sigma2tau != NULL) out->v3sigma2tau[ip*p->dim.v3sigma2tau + 0] += d3F_dgaa2_dta;
  if(out->v3sigmatau2 != NULL) out->v3sigmatau2[ip*p->dim.v3sigmatau2 + 0] += d3F_dgaa_dta2;
  if(out->v3tau3 != NULL) out->v3tau3[ip*p->dim.v3tau3 + 0] += d3F_dta3;
#endif
#if _KMAX >= 4
  const double d4F_dna4 = (0.1e1 / 0.8e1)*_hc0[69];
  const double d4F_dna3_dgaa = (0.1e1 / 0.16e2)*_hc0[68];
  const double d4F_dna3_dta = (0.1e1 / 0.8e1)*_hc0[66];
  const double d4F_dna2_dgaa2 = (0.1e1 / 0.32e2)*_hc0[65];
  const double d4F_dna2_dgaa_dta = (0.1e1 / 0.16e2)*_hc0[63];
  const double d4F_dna2_dta2 = (0.1e1 / 0.8e1)*_hc0[60];
  const double d4F_dna_dgaa3 = (0.1e1 / 0.64e2)*_hc0[59];
  const double d4F_dna_dgaa2_dta = (0.1e1 / 0.32e2)*_hc0[57];
  const double d4F_dna_dgaa_dta2 = (0.1e1 / 0.16e2)*_hc0[54];
  const double d4F_dna_dta3 = (0.1e1 / 0.8e1)*_hc0[50];
  const double d4F_dgaa4 = (0.1e1 / 0.128e3)*_hc0[49];
  const double d4F_dgaa3_dta = (0.1e1 / 0.64e2)*_hc0[47];
  const double d4F_dgaa2_dta2 = (0.1e1 / 0.32e2)*_hc0[44];
  const double d4F_dgaa_dta3 = (0.1e1 / 0.16e2)*_hc0[40];
  const double d4F_dta4 = (0.1e1 / 0.8e1)*_hc0[35];
  if(out->v4rho4 != NULL) out->v4rho4[ip*p->dim.v4rho4 + 0] += d4F_dna4;
  if(out->v4rho3sigma != NULL) out->v4rho3sigma[ip*p->dim.v4rho3sigma + 0] += d4F_dna3_dgaa;
  if(out->v4rho3tau != NULL) out->v4rho3tau[ip*p->dim.v4rho3tau + 0] += d4F_dna3_dta;
  if(out->v4rho2sigma2 != NULL) out->v4rho2sigma2[ip*p->dim.v4rho2sigma2 + 0] += d4F_dna2_dgaa2;
  if(out->v4rho2sigmatau != NULL) out->v4rho2sigmatau[ip*p->dim.v4rho2sigmatau + 0] += d4F_dna2_dgaa_dta;
  if(out->v4rho2tau2 != NULL) out->v4rho2tau2[ip*p->dim.v4rho2tau2 + 0] += d4F_dna2_dta2;
  if(out->v4rhosigma3 != NULL) out->v4rhosigma3[ip*p->dim.v4rhosigma3 + 0] += d4F_dna_dgaa3;
  if(out->v4rhosigma2tau != NULL) out->v4rhosigma2tau[ip*p->dim.v4rhosigma2tau + 0] += d4F_dna_dgaa2_dta;
  if(out->v4rhosigmatau2 != NULL) out->v4rhosigmatau2[ip*p->dim.v4rhosigmatau2 + 0] += d4F_dna_dgaa_dta2;
  if(out->v4rhotau3 != NULL) out->v4rhotau3[ip*p->dim.v4rhotau3 + 0] += d4F_dna_dta3;
  if(out->v4sigma4 != NULL) out->v4sigma4[ip*p->dim.v4sigma4 + 0] += d4F_dgaa4;
  if(out->v4sigma3tau != NULL) out->v4sigma3tau[ip*p->dim.v4sigma3tau + 0] += d4F_dgaa3_dta;
  if(out->v4sigma2tau2 != NULL) out->v4sigma2tau2[ip*p->dim.v4sigma2tau2 + 0] += d4F_dgaa2_dta2;
  if(out->v4sigmatau3 != NULL) out->v4sigmatau3[ip*p->dim.v4sigmatau3 + 0] += d4F_dgaa_dta3;
  if(out->v4tau4 != NULL) out->v4tau4[ip*p->dim.v4tau4 + 0] += d4F_dta4;
#endif
#else
  const double na = rho[0];
  const double nb = rho[1];
  const double gaa = sigma[0];
  const double gbb = sigma[2];
  const double ta = tau[0];
  const double tb = tau[1];

  double _hc0[(_KMAX) >= 4 ? 70 : (_KMAX) >= 3 ? 35 : (_KMAX) >= 2 ? 15 : (_KMAX) >= 1 ? 5 : 1];
  XC_CAT(xchan_k, _KMAX)(p, na, gaa, 0, ta, _hc0);
  double _hc1[(_KMAX) >= 4 ? 70 : (_KMAX) >= 3 ? 35 : (_KMAX) >= 2 ? 15 : (_KMAX) >= 1 ? 5 : 1];
  XC_CAT(xchan_k, _KMAX)(p, nb, gbb, 0, tb, _hc1);
  const double zk = (_hc0[0] + _hc1[0])/(na + nb);
  if(out->zk != NULL) out->zk[ip*p->dim.zk + 0] += zk;
#if _KMAX >= 1
  const double dF_dna = _hc0[4];
  const double dF_dnb = _hc1[4];
  const double dF_dgaa = _hc0[3];
  const double dF_dgbb = _hc1[3];
  const double dF_dta = _hc0[1];
  const double dF_dtb = _hc1[1];
  if(out->vrho != NULL) out->vrho[ip*p->dim.vrho + 0] += dF_dna;
  if(out->vrho != NULL) out->vrho[ip*p->dim.vrho + 1] += dF_dnb;
  if(out->vsigma != NULL) out->vsigma[ip*p->dim.vsigma + 0] += dF_dgaa;
  if(out->vsigma != NULL) out->vsigma[ip*p->dim.vsigma + 2] += dF_dgbb;
  if(out->vtau != NULL) out->vtau[ip*p->dim.vtau + 0] += dF_dta;
  if(out->vtau != NULL) out->vtau[ip*p->dim.vtau + 1] += dF_dtb;
#endif
#if _KMAX >= 2
  const double d2F_dna2 = _hc0[14];
  const double d2F_dnb2 = _hc1[14];
  const double d2F_dna_dgaa = _hc0[13];
  const double d2F_dnb_dgbb = _hc1[13];
  const double d2F_dna_dta = _hc0[11];
  const double d2F_dnb_dtb = _hc1[11];
  const double d2F_dgaa2 = _hc0[10];
  const double d2F_dgbb2 = _hc1[10];
  const double d2F_dgaa_dta = _hc0[8];
  const double d2F_dgbb_dtb = _hc1[8];
  const double d2F_dta2 = _hc0[5];
  const double d2F_dtb2 = _hc1[5];
  if(out->v2rho2 != NULL) out->v2rho2[ip*p->dim.v2rho2 + 0] += d2F_dna2;
  if(out->v2rho2 != NULL) out->v2rho2[ip*p->dim.v2rho2 + 2] += d2F_dnb2;
  if(out->v2rhosigma != NULL) out->v2rhosigma[ip*p->dim.v2rhosigma + 0] += d2F_dna_dgaa;
  if(out->v2rhosigma != NULL) out->v2rhosigma[ip*p->dim.v2rhosigma + 5] += d2F_dnb_dgbb;
  if(out->v2rhotau != NULL) out->v2rhotau[ip*p->dim.v2rhotau + 0] += d2F_dna_dta;
  if(out->v2rhotau != NULL) out->v2rhotau[ip*p->dim.v2rhotau + 3] += d2F_dnb_dtb;
  if(out->v2sigma2 != NULL) out->v2sigma2[ip*p->dim.v2sigma2 + 0] += d2F_dgaa2;
  if(out->v2sigma2 != NULL) out->v2sigma2[ip*p->dim.v2sigma2 + 5] += d2F_dgbb2;
  if(out->v2sigmatau != NULL) out->v2sigmatau[ip*p->dim.v2sigmatau + 0] += d2F_dgaa_dta;
  if(out->v2sigmatau != NULL) out->v2sigmatau[ip*p->dim.v2sigmatau + 5] += d2F_dgbb_dtb;
  if(out->v2tau2 != NULL) out->v2tau2[ip*p->dim.v2tau2 + 0] += d2F_dta2;
  if(out->v2tau2 != NULL) out->v2tau2[ip*p->dim.v2tau2 + 2] += d2F_dtb2;
#endif
#if _KMAX >= 3
  const double d3F_dna3 = _hc0[34];
  const double d3F_dnb3 = _hc1[34];
  const double d3F_dna2_dgaa = _hc0[33];
  const double d3F_dnb2_dgbb = _hc1[33];
  const double d3F_dna2_dta = _hc0[31];
  const double d3F_dnb2_dtb = _hc1[31];
  const double d3F_dna_dgaa2 = _hc0[30];
  const double d3F_dnb_dgbb2 = _hc1[30];
  const double d3F_dna_dgaa_dta = _hc0[28];
  const double d3F_dnb_dgbb_dtb = _hc1[28];
  const double d3F_dna_dta2 = _hc0[25];
  const double d3F_dnb_dtb2 = _hc1[25];
  const double d3F_dgaa3 = _hc0[24];
  const double d3F_dgbb3 = _hc1[24];
  const double d3F_dgaa2_dta = _hc0[22];
  const double d3F_dgbb2_dtb = _hc1[22];
  const double d3F_dgaa_dta2 = _hc0[19];
  const double d3F_dgbb_dtb2 = _hc1[19];
  const double d3F_dta3 = _hc0[15];
  const double d3F_dtb3 = _hc1[15];
  if(out->v3rho3 != NULL) out->v3rho3[ip*p->dim.v3rho3 + 0] += d3F_dna3;
  if(out->v3rho3 != NULL) out->v3rho3[ip*p->dim.v3rho3 + 3] += d3F_dnb3;
  if(out->v3rho2sigma != NULL) out->v3rho2sigma[ip*p->dim.v3rho2sigma + 0] += d3F_dna2_dgaa;
  if(out->v3rho2sigma != NULL) out->v3rho2sigma[ip*p->dim.v3rho2sigma + 8] += d3F_dnb2_dgbb;
  if(out->v3rho2tau != NULL) out->v3rho2tau[ip*p->dim.v3rho2tau + 0] += d3F_dna2_dta;
  if(out->v3rho2tau != NULL) out->v3rho2tau[ip*p->dim.v3rho2tau + 5] += d3F_dnb2_dtb;
  if(out->v3rhosigma2 != NULL) out->v3rhosigma2[ip*p->dim.v3rhosigma2 + 0] += d3F_dna_dgaa2;
  if(out->v3rhosigma2 != NULL) out->v3rhosigma2[ip*p->dim.v3rhosigma2 + 11] += d3F_dnb_dgbb2;
  if(out->v3rhosigmatau != NULL) out->v3rhosigmatau[ip*p->dim.v3rhosigmatau + 0] += d3F_dna_dgaa_dta;
  if(out->v3rhosigmatau != NULL) out->v3rhosigmatau[ip*p->dim.v3rhosigmatau + 11] += d3F_dnb_dgbb_dtb;
  if(out->v3rhotau2 != NULL) out->v3rhotau2[ip*p->dim.v3rhotau2 + 0] += d3F_dna_dta2;
  if(out->v3rhotau2 != NULL) out->v3rhotau2[ip*p->dim.v3rhotau2 + 5] += d3F_dnb_dtb2;
  if(out->v3sigma3 != NULL) out->v3sigma3[ip*p->dim.v3sigma3 + 0] += d3F_dgaa3;
  if(out->v3sigma3 != NULL) out->v3sigma3[ip*p->dim.v3sigma3 + 9] += d3F_dgbb3;
  if(out->v3sigma2tau != NULL) out->v3sigma2tau[ip*p->dim.v3sigma2tau + 0] += d3F_dgaa2_dta;
  if(out->v3sigma2tau != NULL) out->v3sigma2tau[ip*p->dim.v3sigma2tau + 11] += d3F_dgbb2_dtb;
  if(out->v3sigmatau2 != NULL) out->v3sigmatau2[ip*p->dim.v3sigmatau2 + 0] += d3F_dgaa_dta2;
  if(out->v3sigmatau2 != NULL) out->v3sigmatau2[ip*p->dim.v3sigmatau2 + 8] += d3F_dgbb_dtb2;
  if(out->v3tau3 != NULL) out->v3tau3[ip*p->dim.v3tau3 + 0] += d3F_dta3;
  if(out->v3tau3 != NULL) out->v3tau3[ip*p->dim.v3tau3 + 3] += d3F_dtb3;
#endif
#if _KMAX >= 4
  const double d4F_dna4 = _hc0[69];
  const double d4F_dnb4 = _hc1[69];
  const double d4F_dna3_dgaa = _hc0[68];
  const double d4F_dnb3_dgbb = _hc1[68];
  const double d4F_dna3_dta = _hc0[66];
  const double d4F_dnb3_dtb = _hc1[66];
  const double d4F_dna2_dgaa2 = _hc0[65];
  const double d4F_dnb2_dgbb2 = _hc1[65];
  const double d4F_dna2_dgaa_dta = _hc0[63];
  const double d4F_dnb2_dgbb_dtb = _hc1[63];
  const double d4F_dna2_dta2 = _hc0[60];
  const double d4F_dnb2_dtb2 = _hc1[60];
  const double d4F_dna_dgaa3 = _hc0[59];
  const double d4F_dnb_dgbb3 = _hc1[59];
  const double d4F_dna_dgaa2_dta = _hc0[57];
  const double d4F_dnb_dgbb2_dtb = _hc1[57];
  const double d4F_dna_dgaa_dta2 = _hc0[54];
  const double d4F_dnb_dgbb_dtb2 = _hc1[54];
  const double d4F_dna_dta3 = _hc0[50];
  const double d4F_dnb_dtb3 = _hc1[50];
  const double d4F_dgaa4 = _hc0[49];
  const double d4F_dgbb4 = _hc1[49];
  const double d4F_dgaa3_dta = _hc0[47];
  const double d4F_dgbb3_dtb = _hc1[47];
  const double d4F_dgaa2_dta2 = _hc0[44];
  const double d4F_dgbb2_dtb2 = _hc1[44];
  const double d4F_dgaa_dta3 = _hc0[40];
  const double d4F_dgbb_dtb3 = _hc1[40];
  const double d4F_dta4 = _hc0[35];
  const double d4F_dtb4 = _hc1[35];
  if(out->v4rho4 != NULL) out->v4rho4[ip*p->dim.v4rho4 + 0] += d4F_dna4;
  if(out->v4rho4 != NULL) out->v4rho4[ip*p->dim.v4rho4 + 4] += d4F_dnb4;
  if(out->v4rho3sigma != NULL) out->v4rho3sigma[ip*p->dim.v4rho3sigma + 0] += d4F_dna3_dgaa;
  if(out->v4rho3sigma != NULL) out->v4rho3sigma[ip*p->dim.v4rho3sigma + 11] += d4F_dnb3_dgbb;
  if(out->v4rho3tau != NULL) out->v4rho3tau[ip*p->dim.v4rho3tau + 0] += d4F_dna3_dta;
  if(out->v4rho3tau != NULL) out->v4rho3tau[ip*p->dim.v4rho3tau + 7] += d4F_dnb3_dtb;
  if(out->v4rho2sigma2 != NULL) out->v4rho2sigma2[ip*p->dim.v4rho2sigma2 + 0] += d4F_dna2_dgaa2;
  if(out->v4rho2sigma2 != NULL) out->v4rho2sigma2[ip*p->dim.v4rho2sigma2 + 17] += d4F_dnb2_dgbb2;
  if(out->v4rho2sigmatau != NULL) out->v4rho2sigmatau[ip*p->dim.v4rho2sigmatau + 0] += d4F_dna2_dgaa_dta;
  if(out->v4rho2sigmatau != NULL) out->v4rho2sigmatau[ip*p->dim.v4rho2sigmatau + 17] += d4F_dnb2_dgbb_dtb;
  if(out->v4rho2tau2 != NULL) out->v4rho2tau2[ip*p->dim.v4rho2tau2 + 0] += d4F_dna2_dta2;
  if(out->v4rho2tau2 != NULL) out->v4rho2tau2[ip*p->dim.v4rho2tau2 + 8] += d4F_dnb2_dtb2;
  if(out->v4rhosigma3 != NULL) out->v4rhosigma3[ip*p->dim.v4rhosigma3 + 0] += d4F_dna_dgaa3;
  if(out->v4rhosigma3 != NULL) out->v4rhosigma3[ip*p->dim.v4rhosigma3 + 19] += d4F_dnb_dgbb3;
  if(out->v4rhosigma2tau != NULL) out->v4rhosigma2tau[ip*p->dim.v4rhosigma2tau + 0] += d4F_dna_dgaa2_dta;
  if(out->v4rhosigma2tau != NULL) out->v4rhosigma2tau[ip*p->dim.v4rhosigma2tau + 23] += d4F_dnb_dgbb2_dtb;
  if(out->v4rhosigmatau2 != NULL) out->v4rhosigmatau2[ip*p->dim.v4rhosigmatau2 + 0] += d4F_dna_dgaa_dta2;
  if(out->v4rhosigmatau2 != NULL) out->v4rhosigmatau2[ip*p->dim.v4rhosigmatau2 + 17] += d4F_dnb_dgbb_dtb2;
  if(out->v4rhotau3 != NULL) out->v4rhotau3[ip*p->dim.v4rhotau3 + 0] += d4F_dna_dta3;
  if(out->v4rhotau3 != NULL) out->v4rhotau3[ip*p->dim.v4rhotau3 + 7] += d4F_dnb_dtb3;
  if(out->v4sigma4 != NULL) out->v4sigma4[ip*p->dim.v4sigma4 + 0] += d4F_dgaa4;
  if(out->v4sigma4 != NULL) out->v4sigma4[ip*p->dim.v4sigma4 + 14] += d4F_dgbb4;
  if(out->v4sigma3tau != NULL) out->v4sigma3tau[ip*p->dim.v4sigma3tau + 0] += d4F_dgaa3_dta;
  if(out->v4sigma3tau != NULL) out->v4sigma3tau[ip*p->dim.v4sigma3tau + 19] += d4F_dgbb3_dtb;
  if(out->v4sigma2tau2 != NULL) out->v4sigma2tau2[ip*p->dim.v4sigma2tau2 + 0] += d4F_dgaa2_dta2;
  if(out->v4sigma2tau2 != NULL) out->v4sigma2tau2[ip*p->dim.v4sigma2tau2 + 17] += d4F_dgbb2_dtb2;
  if(out->v4sigmatau3 != NULL) out->v4sigmatau3[ip*p->dim.v4sigmatau3 + 0] += d4F_dgaa_dta3;
  if(out->v4sigmatau3 != NULL) out->v4sigmatau3[ip*p->dim.v4sigmatau3 + 11] += d4F_dgbb_dtb3;
  if(out->v4tau4 != NULL) out->v4tau4[ip*p->dim.v4tau4 + 0] += d4F_dta4;
  if(out->v4tau4 != NULL) out->v4tau4[ip*p->dim.v4tau4 + 4] += d4F_dtb4;
#endif
#endif
}
#endif