/* 
  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_c_wigner.mpl
  Type of functional: work_lda
*/

static void
func0(const xc_func_type *p, xc_lda_work_t *r)
{
  double t1, t4, t11;

  lda_c_wigner_params *params;

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

  t1 = params->b + r->rs;
  r->f = 0.1e1 * params->a / t1;

  if(r->order < 1) return;

  t4 = t1 * t1;
  r->dfdrs = -0.1e1 * params->a / t4;

  if(r->order < 2) return;

  r->d2fdrs2 = 0.2e1 * params->a / t4 / t1;

  if(r->order < 3) return;

  t11 = t4 * t4;
  r->d3fdrs3 = -0.6e1 * params->a / t11;

  if(r->order < 4) return;


}

static void
func1(const xc_func_type *p, xc_lda_work_t *r)
{
  double t1, t3, t4, t5, t6, t7, t9, t13;
  double t18;

  lda_c_wigner_params *params;

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

  t1 = r->z * r->z;
  t3 = (-t1 + 0.1e1) * params->a;
  t4 = params->b + r->rs;
  t5 = 0.1e1 / t4;
  r->f = t3 * t5;

  if(r->order < 1) return;

  t6 = t4 * t4;
  t7 = 0.1e1 / t6;
  r->dfdrs = -t3 * t7;
  t9 = r->z * params->a;
  r->dfdz = -0.2e1 * t9 * t5;

  if(r->order < 2) return;

  t13 = 0.1e1 / t6 / t4;
  r->d2fdrs2 = 0.2e1 * t3 * t13;
  r->d2fdrsz = 0.2e1 * t9 * t7;
  r->d2fdz2 = -0.2e1 * params->a * t5;

  if(r->order < 3) return;

  t18 = t6 * t6;
  r->d3fdrs3 = -0.6e1 * t3 / t18;
  r->d3fdrs2z = -0.4e1 * t9 * t13;
  r->d3fdrsz2 = 0.2e1 * params->a * t7;
  r->d3fdz3 = 0.0e0;

  if(r->order < 4) return;


}

void 
xc_lda_c_wigner_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_c_wigner_func
