void AD_Init__47_nfs2_47_snarayan_47_sandbox_47_hg_47_RoseFE_RegressionADIC_47_civl_47_fcn_47_adicexampleforward_47_head_46_c_();
/************************** DISCLAIMER ********************************/
/*                                                                    */
/*   This file was generated on 10/13/14 03:58:29 by                  */
/*   ADIC version /*                                                                    */
/*   ADIC was prepared as an account of work sponsored by an          */
/*   agency of the United States Government and the University of     */
/*   Chicago.  NEITHER THE AUTHOR(S), THE UNITED STATES GOVERNMENT    */
/*   NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, INCLUDING */
/*   ANY OF THEIR EMPLOYEES OR OFFICERS, MAKES ANY WARRANTY, EXPRESS  */
/*   OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR */
/*   THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION OR  */
/*   PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE */
/*   PRIVATELY OWNED RIGHTS.                                          */
/*                                                                    */
/**********************************************************************/
#ifdef ADIC_DENSE
#include "ad_types.h"
#include "ad_grad_saxpy-n_dense.h"
#endif
#ifdef ADIC_DENSE_REVERSE
#include "ad_types.hpp"
#include "ad_grad_saxpy-n_dense.h"
#endif
#ifdef ADIC_DENSE_SEED
#include "ad_types.h"
#include "ad_grad_saxpy-n_dense.h"
#endif
#ifdef ADIC_GRAD_LENGTH
#include "ad_grad_length_types.h"
#include "ad_grad_saxpy-n_dense.h"
#endif
#ifdef ADIC_SPARSE_NO_GRAD
#include "noderiv_sparslinc.h"
#include "ad_grad_saxpy-n_sparse.h"
#endif
#ifdef ADIC_SPARSE
#include "sparslinc.h"
#include "ad_grad_saxpy-n_sparse.h"
#endif
#ifdef _CIVL
#include <civlc.cvh>
#endif
#define epsilon 1.00000e-14
/*****************************************************************************/
/* This set of functions reference triangular elements to an equilateral     */
/* triangle.  The input are the coordinates in the following order:          */
/*      [x1 x2 x3 y1 y2 y3]                                                  */
/* A zero return value indicates success, while a nonzero value indicates    */
/* failure.                                                                  */
/*****************************************************************************/
/* Not all compilers substitute out constants (especially the square root).  */
/* Therefore, they are substituted out manually.  The values below were      */
/* calculated on a solaris machine using long doubles. I believe they are    */
/* accurate.                                                                 */
/*****************************************************************************/
/* #define sqrt3    .577350269189625797959429519858         1.0/sqrt(3.0) */
#define sqrt3    .577350F   /*  1.0/sqrt(3.0) */
/*#define tsqrt3  1.15470053837925159591885903972          2.0/sqrt(3.0) */
#define a        .500000000000000000000000000000        /*  1.0/2.0       */
#define b      -1.00000000000000000000000000000        /* -1.0/1.0       */
#define bm1    -2.00000000000000000000000000000        /* -2.0/1.0       */
/* Rose2XAIF_NODE_NOT_UNPARSED */
DERIV_TYPE ad_tsqrt3;
/* const */
/*x)*/

int ad_o_fcn(DERIV_TYPE *obj,DERIV_TYPE x[6UL])
{
  DERIV_TYPE ad_prp_26;
  ADIC_Initialize(&ad_prp_26);
  DERIV_TYPE ad_prp_25;
  ADIC_Initialize(&ad_prp_25);
  double ad_acc_2;
  double ad_lin_13;
  double ad_lin_12;
  double ad_aux_2;
  DERIV_TYPE ad_prp_24;
  ADIC_Initialize(&ad_prp_24);
  DERIV_TYPE ad_prp_23;
  ADIC_Initialize(&ad_prp_23);
  DERIV_TYPE ad_prp_22;
  ADIC_Initialize(&ad_prp_22);
  DERIV_TYPE ad_prp_21;
  ADIC_Initialize(&ad_prp_21);
  DERIV_TYPE ad_prp_20;
  ADIC_Initialize(&ad_prp_20);
  DERIV_TYPE ad_prp_19;
  ADIC_Initialize(&ad_prp_19);
  DERIV_TYPE ad_prp_18;
  ADIC_Initialize(&ad_prp_18);
  DERIV_TYPE ad_prp_17;
  ADIC_Initialize(&ad_prp_17);
  double ad_lin_11;
  double ad_lin_10;
  double ad_lin_9;
  double ad_lin_8;
  double ad_lin_7;
  double ad_lin_6;
  double ad_lin_5;
  double ad_lin_4;
  DERIV_TYPE ad_prp_15;
  ADIC_Initialize(&ad_prp_15);
  DERIV_TYPE ad_prp_14;
  ADIC_Initialize(&ad_prp_14);
  DERIV_TYPE ad_prp_13;
  ADIC_Initialize(&ad_prp_13);
  DERIV_TYPE ad_prp_12;
  ADIC_Initialize(&ad_prp_12);
  double ad_acc_1;
  double ad_acc_0;
  double ad_lin_3;
  double ad_lin_2;
  double ad_lin_1;
  double ad_lin_0;
  DERIV_TYPE ad_prp_11;
  ADIC_Initialize(&ad_prp_11);
  DERIV_TYPE ad_prp_10;
  ADIC_Initialize(&ad_prp_10);
  DERIV_TYPE ad_prp_9;
  ADIC_Initialize(&ad_prp_9);
  DERIV_TYPE ad_prp_8;
  ADIC_Initialize(&ad_prp_8);
  double ad_aux_1;
  DERIV_TYPE ad_prp_7;
  ADIC_Initialize(&ad_prp_7);
  DERIV_TYPE ad_prp_6;
  ADIC_Initialize(&ad_prp_6);
  DERIV_TYPE ad_prp_5;
  ADIC_Initialize(&ad_prp_5);
  DERIV_TYPE ad_prp_4;
  ADIC_Initialize(&ad_prp_4);
  DERIV_TYPE ad_prp_3;
  ADIC_Initialize(&ad_prp_3);
  DERIV_TYPE ad_prp_2;
  ADIC_Initialize(&ad_prp_2);
  double ad_aux_0;
  DERIV_TYPE ad_prp_1;
  ADIC_Initialize(&ad_prp_1);
  DERIV_TYPE ad_prp_0;
  ADIC_Initialize(&ad_prp_0);
/* static */
/* Rose2XAIF_NODE_NOT_UNPARSED Rose2XAIF_NODE_NOT_UNPARSED Rose2XAIF_NODE_NOT_UNPARSED Rose2XAIF_NODE_NOT_UNPARSED */
  DERIV_TYPE ad_matr[4UL];
  DERIV_TYPE ad_f;
/* static */
  DERIV_TYPE ad_g;
  DERIV_val(ad_matr[0]) = DERIV_val(x[1]) - DERIV_val(x[0]);
  ADIC_SetDeriv(x[1],ad_prp_0);
  ADIC_SetDeriv(x[0],ad_prp_1);
  ADIC_Sax_2(1,ad_prp_0,-1,ad_prp_1,ad_matr[0]);
  ad_aux_0 = 2.00000 * DERIV_val(x[2]) - DERIV_val(x[1]) - DERIV_val(x[0]);
  DERIV_val(ad_matr[1]) = ad_aux_0 * 0.577350F;
  ADIC_SetDeriv(x[2],ad_prp_2);
  ADIC_SetDeriv(x[1],ad_prp_3);
  ADIC_SetDeriv(x[0],ad_prp_4);
  ADIC_Sax_3(-1,ad_prp_4,-1,ad_prp_3,2.00000,ad_prp_2,ad_prp_5);
  ADIC_Sax_1(0.577350,ad_prp_5,ad_matr[1]);
  DERIV_val(ad_matr[2]) = DERIV_val(x[4]) - DERIV_val(x[3]);
  ADIC_SetDeriv(x[4],ad_prp_6);
  ADIC_SetDeriv(x[3],ad_prp_7);
  ADIC_Sax_2(1,ad_prp_6,-1,ad_prp_7,ad_matr[2]);
  ad_aux_1 = 2.00000 * DERIV_val(x[5]) - DERIV_val(x[4]) - DERIV_val(x[3]);
  DERIV_val(ad_matr[3]) = ad_aux_1 * 0.577350F;
  ADIC_SetDeriv(x[5],ad_prp_8);
  ADIC_SetDeriv(x[4],ad_prp_9);
  ADIC_SetDeriv(x[3],ad_prp_10);
  ADIC_Sax_3(-1,ad_prp_10,-1,ad_prp_9,2.00000,ad_prp_8,ad_prp_11);
  ADIC_Sax_1(0.577350,ad_prp_11,ad_matr[3]);
  ad_lin_0 = DERIV_val(ad_matr[3]);
  ad_lin_1 = DERIV_val(ad_matr[0]);
  ad_lin_2 = DERIV_val(ad_matr[2]);
  ad_lin_3 = DERIV_val(ad_matr[1]);
  DERIV_val(ad_g) = DERIV_val(ad_matr[0]) * DERIV_val(ad_matr[3]) - DERIV_val(ad_matr[1]) * DERIV_val(ad_matr[2]);
  ad_acc_0 = ad_lin_2 * -1;
  ad_acc_1 = ad_lin_3 * -1;
  ADIC_SetDeriv(ad_matr[0],ad_prp_12);
  ADIC_SetDeriv(ad_matr[3],ad_prp_13);
  ADIC_SetDeriv(ad_matr[1],ad_prp_14);
  ADIC_SetDeriv(ad_matr[2],ad_prp_15);
  ADIC_Sax_4(ad_lin_0,ad_prp_12,ad_lin_1,ad_prp_13,ad_acc_0,ad_prp_14,ad_acc_1,ad_prp_15,ad_g);
/*if(Rose2XAIF_NODE_NOT_UNPARSED)*/
  if (DERIV_val(ad_g) <= 1.00000e-14) {
    DERIV_TYPE ad_prp_16;
    ADIC_Initialize(&ad_prp_16);
    DERIV_val( *obj) = DERIV_val(ad_g);
    ADIC_SetDeriv(ad_g,ad_prp_16);
    ADIC_Sax_1(1,ad_prp_16, *obj);
    return 1;
  }
{
  }
  ad_lin_4 = DERIV_val(ad_matr[0]);
  ad_lin_5 = DERIV_val(ad_matr[0]);
  ad_lin_6 = DERIV_val(ad_matr[1]);
  ad_lin_7 = DERIV_val(ad_matr[1]);
  ad_lin_8 = DERIV_val(ad_matr[2]);
  ad_lin_9 = DERIV_val(ad_matr[2]);
  ad_lin_10 = DERIV_val(ad_matr[3]);
  ad_lin_11 = DERIV_val(ad_matr[3]);
  DERIV_val(ad_f) = DERIV_val(ad_matr[0]) * DERIV_val(ad_matr[0]) + DERIV_val(ad_matr[1]) * DERIV_val(ad_matr[1]) + DERIV_val(ad_matr[2]) * DERIV_val(ad_matr[2]) + DERIV_val(ad_matr[3]) * DERIV_val(ad_matr[3]);
  ADIC_SetDeriv(ad_matr[0],ad_prp_17);
  ADIC_SetDeriv(ad_matr[0],ad_prp_18);
  ADIC_SetDeriv(ad_matr[1],ad_prp_19);
  ADIC_SetDeriv(ad_matr[1],ad_prp_20);
  ADIC_SetDeriv(ad_matr[2],ad_prp_21);
  ADIC_SetDeriv(ad_matr[2],ad_prp_22);
  ADIC_SetDeriv(ad_matr[3],ad_prp_23);
  ADIC_SetDeriv(ad_matr[3],ad_prp_24);
  ADIC_Sax_8(ad_lin_4,ad_prp_17,ad_lin_5,ad_prp_18,ad_lin_6,ad_prp_19,ad_lin_7,ad_prp_20,ad_lin_8,ad_prp_21,ad_lin_9,ad_prp_22,ad_lin_10,ad_prp_23,ad_lin_11,ad_prp_24,ad_f);
  ad_aux_2 = 0.500000 * DERIV_val(ad_f);
  #ifdef _CIVL
  $assume(DERIV_val(ad_g) != 0);
  #endif 
  ad_lin_12 = 1.00000 / DERIV_val(ad_g);
  ad_lin_13 = -(ad_aux_2 / (DERIV_val(ad_g) * DERIV_val(ad_g)));
  DERIV_val( *obj) = ad_aux_2 / DERIV_val(ad_g);
  ad_acc_2 = 0.500000 * ad_lin_12;
  ADIC_SetDeriv(ad_f,ad_prp_25);
  ADIC_SetDeriv(ad_g,ad_prp_26);
  ADIC_Sax_2(ad_lin_13,ad_prp_26,ad_acc_2,ad_prp_25, *obj);
  return 0;
}

void AD_Init__47_nfs2_47_snarayan_47_sandbox_47_hg_47_RoseFE_RegressionADIC_47_civl_47_fcn_47_adicexampleforward_47_head_46_c_()
{
  DERIV_val(ad_tsqrt3) = 2.00000 / 0.577350F;
  ADIC_ZeroDeriv(ad_tsqrt3);
}
