/* 
  This file was generated automatically with ../scripts/maple2c.pl.
  Do not edit this file directly as it can be overwritten!!

  This Source Code Form is subject to the terms of the Mozilla Public
  License, v. 2.0. If a copy of the MPL was not distributed with this
  file, You can obtain one at http://mozilla.org/MPL/2.0/.

  Maple version     : Maple 2016 (X86 64 LINUX)
  Maple source      : ../maple/lda_xc_1d_ehwlrg.mpl
  Type of functional: work_lda
*/

static void
func0(const xc_func_type *p, xc_lda_work_t *r)
{
  double t1, t4, t5, t10, t13, t17, t18, t21;
  double t22, t26, t29, t30, t32;

  lda_xc_1d_ehwlrg_params *params;
 
  assert(p->params != NULL);
  params = (lda_xc_1d_ehwlrg_params * )(p->params);

  t1 = 0.1e1 / r->rs;
  t4 = r->rs * r->rs;
  t5 = 0.1e1 / t4;
  t10 = pow(t1 / 0.2e1, params->alpha);
  r->f = (params->a1 + params->a2 * t1 / 0.2e1 + params->a3 * t5 / 0.4e1) * t10;

  if(r->order < 1) return;

  t13 = 0.1e1 / t4 / r->rs;
  t17 = (-params->a3 * t13 / 0.2e1 - params->a2 * t5 / 0.2e1) * t10;
  t18 = params->alpha * t1;
  r->dfdrs = -r->f * t18 + t17;

  if(r->order < 2) return;

  t21 = t4 * t4;
  t22 = 0.1e1 / t21;
  t26 = (params->a2 * t13 + 0.3e1 / 0.2e1 * params->a3 * t22) * t10;
  t29 = params->alpha * params->alpha;
  t30 = t29 * t5;
  t32 = params->alpha * t5;
  r->d2fdrs2 = r->f * t30 + r->f * t32 - 0.2e1 * t17 * t18 + t26;

  if(r->order < 3) return;

  r->d3fdrs3 = (-0.3e1 * params->a2 * t22 - 0.6e1 * params->a3 / t21 / r->rs) * t10 - 0.3e1 * t26 * t18 + 0.3e1 * t17 * t30 + 0.3e1 * t17 * t32 - r->f * t29 * params->alpha * t13 - 0.3e1 * r->f * t29 * t13 - 0.2e1 * r->f * params->alpha * t13;

  if(r->order < 4) return;


}

static void
func1(const xc_func_type *p, xc_lda_work_t *r)
{
  double t1, t4, t5, t10, t13, t17, t18, t21;
  double t22, t26, t29, t30, t32;

  lda_xc_1d_ehwlrg_params *params;
 
  assert(p->params != NULL);
  params = (lda_xc_1d_ehwlrg_params * )(p->params);

  t1 = 0.1e1 / r->rs;
  t4 = r->rs * r->rs;
  t5 = 0.1e1 / t4;
  t10 = pow(t1 / 0.2e1, params->alpha);
  r->f = (params->a1 + params->a2 * t1 / 0.2e1 + params->a3 * t5 / 0.4e1) * t10;

  if(r->order < 1) return;

  t13 = 0.1e1 / t4 / r->rs;
  t17 = (-params->a3 * t13 / 0.2e1 - params->a2 * t5 / 0.2e1) * t10;
  t18 = params->alpha * t1;
  r->dfdrs = -r->f * t18 + t17;
  r->dfdz = 0.0e0;

  if(r->order < 2) return;

  t21 = t4 * t4;
  t22 = 0.1e1 / t21;
  t26 = (params->a2 * t13 + 0.3e1 / 0.2e1 * params->a3 * t22) * t10;
  t29 = params->alpha * params->alpha;
  t30 = t29 * t5;
  t32 = params->alpha * t5;
  r->d2fdrs2 = r->f * t30 + r->f * t32 - 0.2e1 * t17 * t18 + t26;
  r->d2fdrsz = 0.0e0;
  r->d2fdz2 = 0.0e0;

  if(r->order < 3) return;

  r->d3fdrs3 = (-0.3e1 * params->a2 * t22 - 0.6e1 * params->a3 / t21 / r->rs) * t10 - 0.3e1 * t26 * t18 + 0.3e1 * t17 * t30 + 0.3e1 * t17 * t32 - r->f * t29 * params->alpha * t13 - 0.3e1 * r->f * t29 * t13 - 0.2e1 * r->f * params->alpha * t13;
  r->d3fdrs2z = 0.0e0;
  r->d3fdrsz2 = 0.0e0;
  r->d3fdz3 = 0.0e0;

  if(r->order < 4) return;


}

void 
xc_lda_xc_1d_ehwlrg_func(const xc_func_type *p, xc_lda_work_t *r)
{
  if(p->nspin == XC_UNPOLARIZED)
    func0(p, r);
  else
    func1(p, r);
}

#define maple2c_order 3
#define maple2c_func  xc_lda_xc_1d_ehwlrg_func
