~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to src/kernel/elements/ffc_25.h

  • Committer: Johannes Ring
  • Date: 2008-03-05 22:43:06 UTC
  • Revision ID: johannr@simula.no-20080305224306-2npsdyhfdpl2esji
The BIG commit!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// This code conforms with the UFC specification version 1.0
2
 
// and was automatically generated by FFC version 0.4.3.
3
 
 
4
 
#ifndef __FFC_25_H
5
 
#define __FFC_25_H
6
 
 
7
 
#include <cmath>
8
 
#include <stdexcept>
9
 
#include <ufc.h>
10
 
 
11
 
/// This class defines the interface for a finite element.
12
 
 
13
 
class ffc_25_finite_element_0_0: public ufc::finite_element
14
 
{
15
 
public:
16
 
 
17
 
  /// Constructor
18
 
  ffc_25_finite_element_0_0() : ufc::finite_element()
19
 
  {
20
 
    // Do nothing
21
 
  }
22
 
 
23
 
  /// Destructor
24
 
  virtual ~ffc_25_finite_element_0_0()
25
 
  {
26
 
    // Do nothing
27
 
  }
28
 
 
29
 
  /// Return a string identifying the finite element
30
 
  virtual const char* signature() const
31
 
  {
32
 
    return "Discontinuous Lagrange finite element of degree 3 on a tetrahedron";
33
 
  }
34
 
 
35
 
  /// Return the cell shape
36
 
  virtual ufc::shape cell_shape() const
37
 
  {
38
 
    return ufc::tetrahedron;
39
 
  }
40
 
 
41
 
  /// Return the dimension of the finite element function space
42
 
  virtual unsigned int space_dimension() const
43
 
  {
44
 
    return 20;
45
 
  }
46
 
 
47
 
  /// Return the rank of the value space
48
 
  virtual unsigned int value_rank() const
49
 
  {
50
 
    return 0;
51
 
  }
52
 
 
53
 
  /// Return the dimension of the value space for axis i
54
 
  virtual unsigned int value_dimension(unsigned int i) const
55
 
  {
56
 
    return 1;
57
 
  }
58
 
 
59
 
  /// Evaluate basis function i at given point in cell
60
 
  virtual void evaluate_basis(unsigned int i,
61
 
                              double* values,
62
 
                              const double* coordinates,
63
 
                              const ufc::cell& c) const
64
 
  {
65
 
    // Extract vertex coordinates
66
 
    const double * const * element_coordinates = c.coordinates;
67
 
    
68
 
    // Compute Jacobian of affine map from reference cell
69
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
70
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
71
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
72
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
73
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
74
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
75
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
76
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
77
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
78
 
      
79
 
    // Compute sub determinants
80
 
    const double d00 = J_11*J_22 - J_12*J_21;
81
 
    const double d01 = J_12*J_20 - J_10*J_22;
82
 
    const double d02 = J_10*J_21 - J_11*J_20;
83
 
    
84
 
    const double d10 = J_02*J_21 - J_01*J_22;
85
 
    const double d11 = J_00*J_22 - J_02*J_20;
86
 
    const double d12 = J_01*J_20 - J_00*J_21;
87
 
    
88
 
    const double d20 = J_01*J_12 - J_02*J_11;
89
 
    const double d21 = J_02*J_10 - J_00*J_12;
90
 
    const double d22 = J_00*J_11 - J_01*J_10;
91
 
      
92
 
    // Compute determinant of Jacobian
93
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
94
 
    
95
 
    // Compute inverse of Jacobian
96
 
    
97
 
    // Compute constants
98
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
99
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
100
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
101
 
    
102
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
103
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
104
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
105
 
    
106
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
107
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
108
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
109
 
    
110
 
    // Get coordinates and map to the UFC reference element
111
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
112
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
113
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
114
 
    
115
 
    // Map coordinates to the reference cube
116
 
    if (std::abs(y + z - 1.0) < 1e-14)
117
 
      x = 1.0;
118
 
    else
119
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
120
 
    if (std::abs(z - 1.0) < 1e-14)
121
 
      y = -1.0;
122
 
    else
123
 
      y = 2.0 * y/(1.0 - z) - 1.0;
124
 
    z = 2.0 * z - 1.0;
125
 
    
126
 
    // Reset values
127
 
    *values = 0;
128
 
    
129
 
    // Map degree of freedom to element degree of freedom
130
 
    const unsigned int dof = i;
131
 
    
132
 
    // Generate scalings
133
 
    const double scalings_y_0 = 1;
134
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
135
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
136
 
    const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
137
 
    const double scalings_z_0 = 1;
138
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
139
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
140
 
    const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
141
 
    
142
 
    // Compute psitilde_a
143
 
    const double psitilde_a_0 = 1;
144
 
    const double psitilde_a_1 = x;
145
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
146
 
    const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
147
 
    
148
 
    // Compute psitilde_bs
149
 
    const double psitilde_bs_0_0 = 1;
150
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
151
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
152
 
    const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
153
 
    const double psitilde_bs_1_0 = 1;
154
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
155
 
    const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
156
 
    const double psitilde_bs_2_0 = 1;
157
 
    const double psitilde_bs_2_1 = 3.5*y + 2.5;
158
 
    const double psitilde_bs_3_0 = 1;
159
 
    
160
 
    // Compute psitilde_cs
161
 
    const double psitilde_cs_00_0 = 1;
162
 
    const double psitilde_cs_00_1 = 2*z + 1;
163
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
164
 
    const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
165
 
    const double psitilde_cs_01_0 = 1;
166
 
    const double psitilde_cs_01_1 = 3*z + 2;
167
 
    const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
168
 
    const double psitilde_cs_02_0 = 1;
169
 
    const double psitilde_cs_02_1 = 4*z + 3;
170
 
    const double psitilde_cs_03_0 = 1;
171
 
    const double psitilde_cs_10_0 = 1;
172
 
    const double psitilde_cs_10_1 = 3*z + 2;
173
 
    const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
174
 
    const double psitilde_cs_11_0 = 1;
175
 
    const double psitilde_cs_11_1 = 4*z + 3;
176
 
    const double psitilde_cs_12_0 = 1;
177
 
    const double psitilde_cs_20_0 = 1;
178
 
    const double psitilde_cs_20_1 = 4*z + 3;
179
 
    const double psitilde_cs_21_0 = 1;
180
 
    const double psitilde_cs_30_0 = 1;
181
 
    
182
 
    // Compute basisvalues
183
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
184
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
185
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
186
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
187
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
188
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
189
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
190
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
191
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
192
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
193
 
    const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
194
 
    const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
195
 
    const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
196
 
    const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
197
 
    const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
198
 
    const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
199
 
    const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
200
 
    const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
201
 
    const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
202
 
    const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
203
 
    
204
 
    // Table(s) of coefficients
205
 
    const static double coefficients0[20][20] = \
206
 
    {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
207
 
    {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
208
 
    {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
209
 
    {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
210
 
    {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
211
 
    {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
212
 
    {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
213
 
    {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
214
 
    {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
215
 
    {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
216
 
    {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
217
 
    {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
218
 
    {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
219
 
    {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
220
 
    {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
221
 
    {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
222
 
    {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
223
 
    {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
224
 
    {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
225
 
    {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
226
 
    
227
 
    // Extract relevant coefficients
228
 
    const double coeff0_0 = coefficients0[dof][0];
229
 
    const double coeff0_1 = coefficients0[dof][1];
230
 
    const double coeff0_2 = coefficients0[dof][2];
231
 
    const double coeff0_3 = coefficients0[dof][3];
232
 
    const double coeff0_4 = coefficients0[dof][4];
233
 
    const double coeff0_5 = coefficients0[dof][5];
234
 
    const double coeff0_6 = coefficients0[dof][6];
235
 
    const double coeff0_7 = coefficients0[dof][7];
236
 
    const double coeff0_8 = coefficients0[dof][8];
237
 
    const double coeff0_9 = coefficients0[dof][9];
238
 
    const double coeff0_10 = coefficients0[dof][10];
239
 
    const double coeff0_11 = coefficients0[dof][11];
240
 
    const double coeff0_12 = coefficients0[dof][12];
241
 
    const double coeff0_13 = coefficients0[dof][13];
242
 
    const double coeff0_14 = coefficients0[dof][14];
243
 
    const double coeff0_15 = coefficients0[dof][15];
244
 
    const double coeff0_16 = coefficients0[dof][16];
245
 
    const double coeff0_17 = coefficients0[dof][17];
246
 
    const double coeff0_18 = coefficients0[dof][18];
247
 
    const double coeff0_19 = coefficients0[dof][19];
248
 
    
249
 
    // Compute value(s)
250
 
    *values = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9 + coeff0_10*basisvalue10 + coeff0_11*basisvalue11 + coeff0_12*basisvalue12 + coeff0_13*basisvalue13 + coeff0_14*basisvalue14 + coeff0_15*basisvalue15 + coeff0_16*basisvalue16 + coeff0_17*basisvalue17 + coeff0_18*basisvalue18 + coeff0_19*basisvalue19;
251
 
  }
252
 
 
253
 
  /// Evaluate all basis functions at given point in cell
254
 
  virtual void evaluate_basis_all(double* values,
255
 
                                  const double* coordinates,
256
 
                                  const ufc::cell& c) const
257
 
  {
258
 
    throw std::runtime_error("The vectorised version of evaluate_basis() is not yet implemented.");
259
 
  }
260
 
 
261
 
  /// Evaluate order n derivatives of basis function i at given point in cell
262
 
  virtual void evaluate_basis_derivatives(unsigned int i,
263
 
                                          unsigned int n,
264
 
                                          double* values,
265
 
                                          const double* coordinates,
266
 
                                          const ufc::cell& c) const
267
 
  {
268
 
    // Extract vertex coordinates
269
 
    const double * const * element_coordinates = c.coordinates;
270
 
    
271
 
    // Compute Jacobian of affine map from reference cell
272
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
273
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
274
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
275
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
276
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
277
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
278
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
279
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
280
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
281
 
      
282
 
    // Compute sub determinants
283
 
    const double d00 = J_11*J_22 - J_12*J_21;
284
 
    const double d01 = J_12*J_20 - J_10*J_22;
285
 
    const double d02 = J_10*J_21 - J_11*J_20;
286
 
    
287
 
    const double d10 = J_02*J_21 - J_01*J_22;
288
 
    const double d11 = J_00*J_22 - J_02*J_20;
289
 
    const double d12 = J_01*J_20 - J_00*J_21;
290
 
    
291
 
    const double d20 = J_01*J_12 - J_02*J_11;
292
 
    const double d21 = J_02*J_10 - J_00*J_12;
293
 
    const double d22 = J_00*J_11 - J_01*J_10;
294
 
      
295
 
    // Compute determinant of Jacobian
296
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
297
 
    
298
 
    // Compute inverse of Jacobian
299
 
    
300
 
    // Compute constants
301
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
302
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
303
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
304
 
    
305
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
306
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
307
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
308
 
    
309
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
310
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
311
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
312
 
    
313
 
    // Get coordinates and map to the UFC reference element
314
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
315
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
316
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
317
 
    
318
 
    // Map coordinates to the reference cube
319
 
    if (std::abs(y + z - 1.0) < 1e-14)
320
 
      x = 1.0;
321
 
    else
322
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
323
 
    if (std::abs(z - 1.0) < 1e-14)
324
 
      y = -1.0;
325
 
    else
326
 
      y = 2.0 * y/(1.0 - z) - 1.0;
327
 
    z = 2.0 * z - 1.0;
328
 
    
329
 
    // Compute number of derivatives
330
 
    unsigned int num_derivatives = 1;
331
 
    
332
 
    for (unsigned int j = 0; j < n; j++)
333
 
      num_derivatives *= 3;
334
 
    
335
 
    
336
 
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
337
 
    unsigned int **combinations = new unsigned int *[num_derivatives];
338
 
        
339
 
    for (unsigned int j = 0; j < num_derivatives; j++)
340
 
    {
341
 
      combinations[j] = new unsigned int [n];
342
 
      for (unsigned int k = 0; k < n; k++)
343
 
        combinations[j][k] = 0;
344
 
    }
345
 
        
346
 
    // Generate combinations of derivatives
347
 
    for (unsigned int row = 1; row < num_derivatives; row++)
348
 
    {
349
 
      for (unsigned int num = 0; num < row; num++)
350
 
      {
351
 
        for (unsigned int col = n-1; col+1 > 0; col--)
352
 
        {
353
 
          if (combinations[row][col] + 1 > 2)
354
 
            combinations[row][col] = 0;
355
 
          else
356
 
          {
357
 
            combinations[row][col] += 1;
358
 
            break;
359
 
          }
360
 
        }
361
 
      }
362
 
    }
363
 
    
364
 
    // Compute inverse of Jacobian
365
 
    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};
366
 
    
367
 
    // Declare transformation matrix
368
 
    // Declare pointer to two dimensional array and initialise
369
 
    double **transform = new double *[num_derivatives];
370
 
        
371
 
    for (unsigned int j = 0; j < num_derivatives; j++)
372
 
    {
373
 
      transform[j] = new double [num_derivatives];
374
 
      for (unsigned int k = 0; k < num_derivatives; k++)
375
 
        transform[j][k] = 1;
376
 
    }
377
 
    
378
 
    // Construct transformation matrix
379
 
    for (unsigned int row = 0; row < num_derivatives; row++)
380
 
    {
381
 
      for (unsigned int col = 0; col < num_derivatives; col++)
382
 
      {
383
 
        for (unsigned int k = 0; k < n; k++)
384
 
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
385
 
      }
386
 
    }
387
 
    
388
 
    // Reset values
389
 
    for (unsigned int j = 0; j < 1*num_derivatives; j++)
390
 
      values[j] = 0;
391
 
    
392
 
    // Map degree of freedom to element degree of freedom
393
 
    const unsigned int dof = i;
394
 
    
395
 
    // Generate scalings
396
 
    const double scalings_y_0 = 1;
397
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
398
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
399
 
    const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
400
 
    const double scalings_z_0 = 1;
401
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
402
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
403
 
    const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
404
 
    
405
 
    // Compute psitilde_a
406
 
    const double psitilde_a_0 = 1;
407
 
    const double psitilde_a_1 = x;
408
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
409
 
    const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
410
 
    
411
 
    // Compute psitilde_bs
412
 
    const double psitilde_bs_0_0 = 1;
413
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
414
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
415
 
    const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
416
 
    const double psitilde_bs_1_0 = 1;
417
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
418
 
    const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
419
 
    const double psitilde_bs_2_0 = 1;
420
 
    const double psitilde_bs_2_1 = 3.5*y + 2.5;
421
 
    const double psitilde_bs_3_0 = 1;
422
 
    
423
 
    // Compute psitilde_cs
424
 
    const double psitilde_cs_00_0 = 1;
425
 
    const double psitilde_cs_00_1 = 2*z + 1;
426
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
427
 
    const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
428
 
    const double psitilde_cs_01_0 = 1;
429
 
    const double psitilde_cs_01_1 = 3*z + 2;
430
 
    const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
431
 
    const double psitilde_cs_02_0 = 1;
432
 
    const double psitilde_cs_02_1 = 4*z + 3;
433
 
    const double psitilde_cs_03_0 = 1;
434
 
    const double psitilde_cs_10_0 = 1;
435
 
    const double psitilde_cs_10_1 = 3*z + 2;
436
 
    const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
437
 
    const double psitilde_cs_11_0 = 1;
438
 
    const double psitilde_cs_11_1 = 4*z + 3;
439
 
    const double psitilde_cs_12_0 = 1;
440
 
    const double psitilde_cs_20_0 = 1;
441
 
    const double psitilde_cs_20_1 = 4*z + 3;
442
 
    const double psitilde_cs_21_0 = 1;
443
 
    const double psitilde_cs_30_0 = 1;
444
 
    
445
 
    // Compute basisvalues
446
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
447
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
448
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
449
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
450
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
451
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
452
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
453
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
454
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
455
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
456
 
    const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
457
 
    const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
458
 
    const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
459
 
    const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
460
 
    const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
461
 
    const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
462
 
    const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
463
 
    const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
464
 
    const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
465
 
    const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
466
 
    
467
 
    // Table(s) of coefficients
468
 
    const static double coefficients0[20][20] = \
469
 
    {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
470
 
    {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
471
 
    {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
472
 
    {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
473
 
    {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
474
 
    {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
475
 
    {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
476
 
    {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
477
 
    {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
478
 
    {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
479
 
    {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
480
 
    {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
481
 
    {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
482
 
    {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
483
 
    {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
484
 
    {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
485
 
    {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
486
 
    {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
487
 
    {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
488
 
    {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
489
 
    
490
 
    // Interesting (new) part
491
 
    // Tables of derivatives of the polynomial base (transpose)
492
 
    const static double dmats0[20][20] = \
493
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
494
 
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
495
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
496
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
497
 
    {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
498
 
    {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
499
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
500
 
    {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
501
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
502
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
503
 
    {5.49909083394701, 0, -3.3466401061363, -2.36643191323985, 15.4919333848297, 0, 0.692820323027551, 0, 0.565685424949239, 0.400000000000001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
504
 
    {0, 4.89897948556636, 0, 0, 0, 14.1985914794391, 0, -0.82807867121083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
505
 
    {3.6, 0, 8.76356092008266, -1.54919333848297, 0, 0, 9.52470471983253, 0, -1.48131215963608, 0.261861468283192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
506
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
507
 
    {0, 4.24264068711928, 0, 0, 0, 0, 0, 14.3427433120127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
508
 
    {3.11769145362398, 0, 3.16227766016838, 4.91934955049954, 0, 0, 0, 0, 10.690449676497, -2.41897262725906, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
509
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
510
 
    {2.54558441227157, 0, 0, 7.66811580507233, 0, 0, 0, 0, 0, 10.3691851174526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
511
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
512
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
513
 
    
514
 
    const static double dmats1[20][20] = \
515
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
516
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
517
 
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
518
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
519
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
520
 
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309959, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
521
 
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
522
 
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
523
 
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
524
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
525
 
    {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.28284271247462, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
526
 
    {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 9.16515138991168, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
527
 
    {1.8, -5.69209978830308, 4.38178046004133, -0.774596669241487, 0, 10.998181667894, 4.76235235991626, 0.962140470884726, -0.740656079818041, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
528
 
    {5.19615242270664, 0, -3.16227766016838, -2.23606797749979, 0, 0, 13.7477270848675, 0, 0.534522483824849, 0.37796447300923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
529
 
    {2.01246117974981, 2.12132034355964, -0.408248290463864, 3.17542648054294, 0, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
530
 
    {1.55884572681199, 2.73861278752583, 1.58113883008419, 2.45967477524977, 0, 0, 0, 9.25820099772551, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
531
 
    {-1.8, 0, 3.65148371670111, -2.84018778721878, 0, 0, 0, 0, 12.3442679969674, 1.39659449751035, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
532
 
    {1.27279220613579, 0, 0, 3.83405790253616, 0, 0, 0, 0, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
533
 
    {2.20454076850486, 0, 0, 6.6407830863536, 0, 0, 0, 0, 0, 8.97997772825746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
534
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
535
 
    
536
 
    const static double dmats2[20][20] = \
537
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
538
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
539
 
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
540
 
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
541
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
542
 
    {2.29128784747792, 1.44913767461895, 4.18330013267038, -0.59160797830996, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
543
 
    {1.32287565553229, 0, 3.86436713231718, -0.341565025531987, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
544
 
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
545
 
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
546
 
    {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
547
 
    {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.282842712474619, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
548
 
    {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 1.30930734141595, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
549
 
    {1.8, 0.632455532033675, 4.38178046004133, -0.774596669241484, 0, 3.14233761939829, 4.76235235991626, -0.10690449676497, -0.740656079818042, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
550
 
    {1.03923048454133, 0, 3.16227766016838, -0.447213595499959, 0, 0, 5.8918830363718, 0, -0.53452248382485, 0.0755928946018459, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
551
 
    {2.01246117974981, 2.12132034355964, -0.408248290463863, 3.17542648054294, 9.07114735222145, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
552
 
    {1.55884572681199, 0.547722557505165, 1.58113883008419, 2.45967477524977, 0, 9.07114735222145, 0, 1.8516401995451, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
553
 
    {0.900000000000001, 0, 1.46059348668045, 1.42009389360939, 0, 0, 9.07114735222145, 0, 4.93770719878694, -0.698297248755175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
554
 
    {1.27279220613578, -6.26099033699941, 0, 3.83405790253616, 0, 0, 0, 10.5830052442584, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
555
 
    {0.734846922834954, 0, -6.26099033699941, 2.21359436211787, 0, 0, 0, 0, 10.5830052442584, 2.99332590941915, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
556
 
    {5.7157676649773, 0, 0, -4.69574275274955, 0, 0, 0, 0, 0, 12.69960629311, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
557
 
    
558
 
    // Compute reference derivatives
559
 
    // Declare pointer to array of derivatives on FIAT element
560
 
    double *derivatives = new double [num_derivatives];
561
 
    
562
 
    // Declare coefficients
563
 
    double coeff0_0 = 0;
564
 
    double coeff0_1 = 0;
565
 
    double coeff0_2 = 0;
566
 
    double coeff0_3 = 0;
567
 
    double coeff0_4 = 0;
568
 
    double coeff0_5 = 0;
569
 
    double coeff0_6 = 0;
570
 
    double coeff0_7 = 0;
571
 
    double coeff0_8 = 0;
572
 
    double coeff0_9 = 0;
573
 
    double coeff0_10 = 0;
574
 
    double coeff0_11 = 0;
575
 
    double coeff0_12 = 0;
576
 
    double coeff0_13 = 0;
577
 
    double coeff0_14 = 0;
578
 
    double coeff0_15 = 0;
579
 
    double coeff0_16 = 0;
580
 
    double coeff0_17 = 0;
581
 
    double coeff0_18 = 0;
582
 
    double coeff0_19 = 0;
583
 
    
584
 
    // Declare new coefficients
585
 
    double new_coeff0_0 = 0;
586
 
    double new_coeff0_1 = 0;
587
 
    double new_coeff0_2 = 0;
588
 
    double new_coeff0_3 = 0;
589
 
    double new_coeff0_4 = 0;
590
 
    double new_coeff0_5 = 0;
591
 
    double new_coeff0_6 = 0;
592
 
    double new_coeff0_7 = 0;
593
 
    double new_coeff0_8 = 0;
594
 
    double new_coeff0_9 = 0;
595
 
    double new_coeff0_10 = 0;
596
 
    double new_coeff0_11 = 0;
597
 
    double new_coeff0_12 = 0;
598
 
    double new_coeff0_13 = 0;
599
 
    double new_coeff0_14 = 0;
600
 
    double new_coeff0_15 = 0;
601
 
    double new_coeff0_16 = 0;
602
 
    double new_coeff0_17 = 0;
603
 
    double new_coeff0_18 = 0;
604
 
    double new_coeff0_19 = 0;
605
 
    
606
 
    // Loop possible derivatives
607
 
    for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
608
 
    {
609
 
      // Get values from coefficients array
610
 
      new_coeff0_0 = coefficients0[dof][0];
611
 
      new_coeff0_1 = coefficients0[dof][1];
612
 
      new_coeff0_2 = coefficients0[dof][2];
613
 
      new_coeff0_3 = coefficients0[dof][3];
614
 
      new_coeff0_4 = coefficients0[dof][4];
615
 
      new_coeff0_5 = coefficients0[dof][5];
616
 
      new_coeff0_6 = coefficients0[dof][6];
617
 
      new_coeff0_7 = coefficients0[dof][7];
618
 
      new_coeff0_8 = coefficients0[dof][8];
619
 
      new_coeff0_9 = coefficients0[dof][9];
620
 
      new_coeff0_10 = coefficients0[dof][10];
621
 
      new_coeff0_11 = coefficients0[dof][11];
622
 
      new_coeff0_12 = coefficients0[dof][12];
623
 
      new_coeff0_13 = coefficients0[dof][13];
624
 
      new_coeff0_14 = coefficients0[dof][14];
625
 
      new_coeff0_15 = coefficients0[dof][15];
626
 
      new_coeff0_16 = coefficients0[dof][16];
627
 
      new_coeff0_17 = coefficients0[dof][17];
628
 
      new_coeff0_18 = coefficients0[dof][18];
629
 
      new_coeff0_19 = coefficients0[dof][19];
630
 
    
631
 
      // Loop derivative order
632
 
      for (unsigned int j = 0; j < n; j++)
633
 
      {
634
 
        // Update old coefficients
635
 
        coeff0_0 = new_coeff0_0;
636
 
        coeff0_1 = new_coeff0_1;
637
 
        coeff0_2 = new_coeff0_2;
638
 
        coeff0_3 = new_coeff0_3;
639
 
        coeff0_4 = new_coeff0_4;
640
 
        coeff0_5 = new_coeff0_5;
641
 
        coeff0_6 = new_coeff0_6;
642
 
        coeff0_7 = new_coeff0_7;
643
 
        coeff0_8 = new_coeff0_8;
644
 
        coeff0_9 = new_coeff0_9;
645
 
        coeff0_10 = new_coeff0_10;
646
 
        coeff0_11 = new_coeff0_11;
647
 
        coeff0_12 = new_coeff0_12;
648
 
        coeff0_13 = new_coeff0_13;
649
 
        coeff0_14 = new_coeff0_14;
650
 
        coeff0_15 = new_coeff0_15;
651
 
        coeff0_16 = new_coeff0_16;
652
 
        coeff0_17 = new_coeff0_17;
653
 
        coeff0_18 = new_coeff0_18;
654
 
        coeff0_19 = new_coeff0_19;
655
 
    
656
 
        if(combinations[deriv_num][j] == 0)
657
 
        {
658
 
          new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0] + coeff0_10*dmats0[10][0] + coeff0_11*dmats0[11][0] + coeff0_12*dmats0[12][0] + coeff0_13*dmats0[13][0] + coeff0_14*dmats0[14][0] + coeff0_15*dmats0[15][0] + coeff0_16*dmats0[16][0] + coeff0_17*dmats0[17][0] + coeff0_18*dmats0[18][0] + coeff0_19*dmats0[19][0];
659
 
          new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1] + coeff0_10*dmats0[10][1] + coeff0_11*dmats0[11][1] + coeff0_12*dmats0[12][1] + coeff0_13*dmats0[13][1] + coeff0_14*dmats0[14][1] + coeff0_15*dmats0[15][1] + coeff0_16*dmats0[16][1] + coeff0_17*dmats0[17][1] + coeff0_18*dmats0[18][1] + coeff0_19*dmats0[19][1];
660
 
          new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2] + coeff0_10*dmats0[10][2] + coeff0_11*dmats0[11][2] + coeff0_12*dmats0[12][2] + coeff0_13*dmats0[13][2] + coeff0_14*dmats0[14][2] + coeff0_15*dmats0[15][2] + coeff0_16*dmats0[16][2] + coeff0_17*dmats0[17][2] + coeff0_18*dmats0[18][2] + coeff0_19*dmats0[19][2];
661
 
          new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3] + coeff0_10*dmats0[10][3] + coeff0_11*dmats0[11][3] + coeff0_12*dmats0[12][3] + coeff0_13*dmats0[13][3] + coeff0_14*dmats0[14][3] + coeff0_15*dmats0[15][3] + coeff0_16*dmats0[16][3] + coeff0_17*dmats0[17][3] + coeff0_18*dmats0[18][3] + coeff0_19*dmats0[19][3];
662
 
          new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4] + coeff0_10*dmats0[10][4] + coeff0_11*dmats0[11][4] + coeff0_12*dmats0[12][4] + coeff0_13*dmats0[13][4] + coeff0_14*dmats0[14][4] + coeff0_15*dmats0[15][4] + coeff0_16*dmats0[16][4] + coeff0_17*dmats0[17][4] + coeff0_18*dmats0[18][4] + coeff0_19*dmats0[19][4];
663
 
          new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5] + coeff0_10*dmats0[10][5] + coeff0_11*dmats0[11][5] + coeff0_12*dmats0[12][5] + coeff0_13*dmats0[13][5] + coeff0_14*dmats0[14][5] + coeff0_15*dmats0[15][5] + coeff0_16*dmats0[16][5] + coeff0_17*dmats0[17][5] + coeff0_18*dmats0[18][5] + coeff0_19*dmats0[19][5];
664
 
          new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6] + coeff0_10*dmats0[10][6] + coeff0_11*dmats0[11][6] + coeff0_12*dmats0[12][6] + coeff0_13*dmats0[13][6] + coeff0_14*dmats0[14][6] + coeff0_15*dmats0[15][6] + coeff0_16*dmats0[16][6] + coeff0_17*dmats0[17][6] + coeff0_18*dmats0[18][6] + coeff0_19*dmats0[19][6];
665
 
          new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7] + coeff0_10*dmats0[10][7] + coeff0_11*dmats0[11][7] + coeff0_12*dmats0[12][7] + coeff0_13*dmats0[13][7] + coeff0_14*dmats0[14][7] + coeff0_15*dmats0[15][7] + coeff0_16*dmats0[16][7] + coeff0_17*dmats0[17][7] + coeff0_18*dmats0[18][7] + coeff0_19*dmats0[19][7];
666
 
          new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8] + coeff0_10*dmats0[10][8] + coeff0_11*dmats0[11][8] + coeff0_12*dmats0[12][8] + coeff0_13*dmats0[13][8] + coeff0_14*dmats0[14][8] + coeff0_15*dmats0[15][8] + coeff0_16*dmats0[16][8] + coeff0_17*dmats0[17][8] + coeff0_18*dmats0[18][8] + coeff0_19*dmats0[19][8];
667
 
          new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9] + coeff0_10*dmats0[10][9] + coeff0_11*dmats0[11][9] + coeff0_12*dmats0[12][9] + coeff0_13*dmats0[13][9] + coeff0_14*dmats0[14][9] + coeff0_15*dmats0[15][9] + coeff0_16*dmats0[16][9] + coeff0_17*dmats0[17][9] + coeff0_18*dmats0[18][9] + coeff0_19*dmats0[19][9];
668
 
          new_coeff0_10 = coeff0_0*dmats0[0][10] + coeff0_1*dmats0[1][10] + coeff0_2*dmats0[2][10] + coeff0_3*dmats0[3][10] + coeff0_4*dmats0[4][10] + coeff0_5*dmats0[5][10] + coeff0_6*dmats0[6][10] + coeff0_7*dmats0[7][10] + coeff0_8*dmats0[8][10] + coeff0_9*dmats0[9][10] + coeff0_10*dmats0[10][10] + coeff0_11*dmats0[11][10] + coeff0_12*dmats0[12][10] + coeff0_13*dmats0[13][10] + coeff0_14*dmats0[14][10] + coeff0_15*dmats0[15][10] + coeff0_16*dmats0[16][10] + coeff0_17*dmats0[17][10] + coeff0_18*dmats0[18][10] + coeff0_19*dmats0[19][10];
669
 
          new_coeff0_11 = coeff0_0*dmats0[0][11] + coeff0_1*dmats0[1][11] + coeff0_2*dmats0[2][11] + coeff0_3*dmats0[3][11] + coeff0_4*dmats0[4][11] + coeff0_5*dmats0[5][11] + coeff0_6*dmats0[6][11] + coeff0_7*dmats0[7][11] + coeff0_8*dmats0[8][11] + coeff0_9*dmats0[9][11] + coeff0_10*dmats0[10][11] + coeff0_11*dmats0[11][11] + coeff0_12*dmats0[12][11] + coeff0_13*dmats0[13][11] + coeff0_14*dmats0[14][11] + coeff0_15*dmats0[15][11] + coeff0_16*dmats0[16][11] + coeff0_17*dmats0[17][11] + coeff0_18*dmats0[18][11] + coeff0_19*dmats0[19][11];
670
 
          new_coeff0_12 = coeff0_0*dmats0[0][12] + coeff0_1*dmats0[1][12] + coeff0_2*dmats0[2][12] + coeff0_3*dmats0[3][12] + coeff0_4*dmats0[4][12] + coeff0_5*dmats0[5][12] + coeff0_6*dmats0[6][12] + coeff0_7*dmats0[7][12] + coeff0_8*dmats0[8][12] + coeff0_9*dmats0[9][12] + coeff0_10*dmats0[10][12] + coeff0_11*dmats0[11][12] + coeff0_12*dmats0[12][12] + coeff0_13*dmats0[13][12] + coeff0_14*dmats0[14][12] + coeff0_15*dmats0[15][12] + coeff0_16*dmats0[16][12] + coeff0_17*dmats0[17][12] + coeff0_18*dmats0[18][12] + coeff0_19*dmats0[19][12];
671
 
          new_coeff0_13 = coeff0_0*dmats0[0][13] + coeff0_1*dmats0[1][13] + coeff0_2*dmats0[2][13] + coeff0_3*dmats0[3][13] + coeff0_4*dmats0[4][13] + coeff0_5*dmats0[5][13] + coeff0_6*dmats0[6][13] + coeff0_7*dmats0[7][13] + coeff0_8*dmats0[8][13] + coeff0_9*dmats0[9][13] + coeff0_10*dmats0[10][13] + coeff0_11*dmats0[11][13] + coeff0_12*dmats0[12][13] + coeff0_13*dmats0[13][13] + coeff0_14*dmats0[14][13] + coeff0_15*dmats0[15][13] + coeff0_16*dmats0[16][13] + coeff0_17*dmats0[17][13] + coeff0_18*dmats0[18][13] + coeff0_19*dmats0[19][13];
672
 
          new_coeff0_14 = coeff0_0*dmats0[0][14] + coeff0_1*dmats0[1][14] + coeff0_2*dmats0[2][14] + coeff0_3*dmats0[3][14] + coeff0_4*dmats0[4][14] + coeff0_5*dmats0[5][14] + coeff0_6*dmats0[6][14] + coeff0_7*dmats0[7][14] + coeff0_8*dmats0[8][14] + coeff0_9*dmats0[9][14] + coeff0_10*dmats0[10][14] + coeff0_11*dmats0[11][14] + coeff0_12*dmats0[12][14] + coeff0_13*dmats0[13][14] + coeff0_14*dmats0[14][14] + coeff0_15*dmats0[15][14] + coeff0_16*dmats0[16][14] + coeff0_17*dmats0[17][14] + coeff0_18*dmats0[18][14] + coeff0_19*dmats0[19][14];
673
 
          new_coeff0_15 = coeff0_0*dmats0[0][15] + coeff0_1*dmats0[1][15] + coeff0_2*dmats0[2][15] + coeff0_3*dmats0[3][15] + coeff0_4*dmats0[4][15] + coeff0_5*dmats0[5][15] + coeff0_6*dmats0[6][15] + coeff0_7*dmats0[7][15] + coeff0_8*dmats0[8][15] + coeff0_9*dmats0[9][15] + coeff0_10*dmats0[10][15] + coeff0_11*dmats0[11][15] + coeff0_12*dmats0[12][15] + coeff0_13*dmats0[13][15] + coeff0_14*dmats0[14][15] + coeff0_15*dmats0[15][15] + coeff0_16*dmats0[16][15] + coeff0_17*dmats0[17][15] + coeff0_18*dmats0[18][15] + coeff0_19*dmats0[19][15];
674
 
          new_coeff0_16 = coeff0_0*dmats0[0][16] + coeff0_1*dmats0[1][16] + coeff0_2*dmats0[2][16] + coeff0_3*dmats0[3][16] + coeff0_4*dmats0[4][16] + coeff0_5*dmats0[5][16] + coeff0_6*dmats0[6][16] + coeff0_7*dmats0[7][16] + coeff0_8*dmats0[8][16] + coeff0_9*dmats0[9][16] + coeff0_10*dmats0[10][16] + coeff0_11*dmats0[11][16] + coeff0_12*dmats0[12][16] + coeff0_13*dmats0[13][16] + coeff0_14*dmats0[14][16] + coeff0_15*dmats0[15][16] + coeff0_16*dmats0[16][16] + coeff0_17*dmats0[17][16] + coeff0_18*dmats0[18][16] + coeff0_19*dmats0[19][16];
675
 
          new_coeff0_17 = coeff0_0*dmats0[0][17] + coeff0_1*dmats0[1][17] + coeff0_2*dmats0[2][17] + coeff0_3*dmats0[3][17] + coeff0_4*dmats0[4][17] + coeff0_5*dmats0[5][17] + coeff0_6*dmats0[6][17] + coeff0_7*dmats0[7][17] + coeff0_8*dmats0[8][17] + coeff0_9*dmats0[9][17] + coeff0_10*dmats0[10][17] + coeff0_11*dmats0[11][17] + coeff0_12*dmats0[12][17] + coeff0_13*dmats0[13][17] + coeff0_14*dmats0[14][17] + coeff0_15*dmats0[15][17] + coeff0_16*dmats0[16][17] + coeff0_17*dmats0[17][17] + coeff0_18*dmats0[18][17] + coeff0_19*dmats0[19][17];
676
 
          new_coeff0_18 = coeff0_0*dmats0[0][18] + coeff0_1*dmats0[1][18] + coeff0_2*dmats0[2][18] + coeff0_3*dmats0[3][18] + coeff0_4*dmats0[4][18] + coeff0_5*dmats0[5][18] + coeff0_6*dmats0[6][18] + coeff0_7*dmats0[7][18] + coeff0_8*dmats0[8][18] + coeff0_9*dmats0[9][18] + coeff0_10*dmats0[10][18] + coeff0_11*dmats0[11][18] + coeff0_12*dmats0[12][18] + coeff0_13*dmats0[13][18] + coeff0_14*dmats0[14][18] + coeff0_15*dmats0[15][18] + coeff0_16*dmats0[16][18] + coeff0_17*dmats0[17][18] + coeff0_18*dmats0[18][18] + coeff0_19*dmats0[19][18];
677
 
          new_coeff0_19 = coeff0_0*dmats0[0][19] + coeff0_1*dmats0[1][19] + coeff0_2*dmats0[2][19] + coeff0_3*dmats0[3][19] + coeff0_4*dmats0[4][19] + coeff0_5*dmats0[5][19] + coeff0_6*dmats0[6][19] + coeff0_7*dmats0[7][19] + coeff0_8*dmats0[8][19] + coeff0_9*dmats0[9][19] + coeff0_10*dmats0[10][19] + coeff0_11*dmats0[11][19] + coeff0_12*dmats0[12][19] + coeff0_13*dmats0[13][19] + coeff0_14*dmats0[14][19] + coeff0_15*dmats0[15][19] + coeff0_16*dmats0[16][19] + coeff0_17*dmats0[17][19] + coeff0_18*dmats0[18][19] + coeff0_19*dmats0[19][19];
678
 
        }
679
 
        if(combinations[deriv_num][j] == 1)
680
 
        {
681
 
          new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0] + coeff0_10*dmats1[10][0] + coeff0_11*dmats1[11][0] + coeff0_12*dmats1[12][0] + coeff0_13*dmats1[13][0] + coeff0_14*dmats1[14][0] + coeff0_15*dmats1[15][0] + coeff0_16*dmats1[16][0] + coeff0_17*dmats1[17][0] + coeff0_18*dmats1[18][0] + coeff0_19*dmats1[19][0];
682
 
          new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1] + coeff0_10*dmats1[10][1] + coeff0_11*dmats1[11][1] + coeff0_12*dmats1[12][1] + coeff0_13*dmats1[13][1] + coeff0_14*dmats1[14][1] + coeff0_15*dmats1[15][1] + coeff0_16*dmats1[16][1] + coeff0_17*dmats1[17][1] + coeff0_18*dmats1[18][1] + coeff0_19*dmats1[19][1];
683
 
          new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2] + coeff0_10*dmats1[10][2] + coeff0_11*dmats1[11][2] + coeff0_12*dmats1[12][2] + coeff0_13*dmats1[13][2] + coeff0_14*dmats1[14][2] + coeff0_15*dmats1[15][2] + coeff0_16*dmats1[16][2] + coeff0_17*dmats1[17][2] + coeff0_18*dmats1[18][2] + coeff0_19*dmats1[19][2];
684
 
          new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3] + coeff0_10*dmats1[10][3] + coeff0_11*dmats1[11][3] + coeff0_12*dmats1[12][3] + coeff0_13*dmats1[13][3] + coeff0_14*dmats1[14][3] + coeff0_15*dmats1[15][3] + coeff0_16*dmats1[16][3] + coeff0_17*dmats1[17][3] + coeff0_18*dmats1[18][3] + coeff0_19*dmats1[19][3];
685
 
          new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4] + coeff0_10*dmats1[10][4] + coeff0_11*dmats1[11][4] + coeff0_12*dmats1[12][4] + coeff0_13*dmats1[13][4] + coeff0_14*dmats1[14][4] + coeff0_15*dmats1[15][4] + coeff0_16*dmats1[16][4] + coeff0_17*dmats1[17][4] + coeff0_18*dmats1[18][4] + coeff0_19*dmats1[19][4];
686
 
          new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5] + coeff0_10*dmats1[10][5] + coeff0_11*dmats1[11][5] + coeff0_12*dmats1[12][5] + coeff0_13*dmats1[13][5] + coeff0_14*dmats1[14][5] + coeff0_15*dmats1[15][5] + coeff0_16*dmats1[16][5] + coeff0_17*dmats1[17][5] + coeff0_18*dmats1[18][5] + coeff0_19*dmats1[19][5];
687
 
          new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6] + coeff0_10*dmats1[10][6] + coeff0_11*dmats1[11][6] + coeff0_12*dmats1[12][6] + coeff0_13*dmats1[13][6] + coeff0_14*dmats1[14][6] + coeff0_15*dmats1[15][6] + coeff0_16*dmats1[16][6] + coeff0_17*dmats1[17][6] + coeff0_18*dmats1[18][6] + coeff0_19*dmats1[19][6];
688
 
          new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7] + coeff0_10*dmats1[10][7] + coeff0_11*dmats1[11][7] + coeff0_12*dmats1[12][7] + coeff0_13*dmats1[13][7] + coeff0_14*dmats1[14][7] + coeff0_15*dmats1[15][7] + coeff0_16*dmats1[16][7] + coeff0_17*dmats1[17][7] + coeff0_18*dmats1[18][7] + coeff0_19*dmats1[19][7];
689
 
          new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8] + coeff0_10*dmats1[10][8] + coeff0_11*dmats1[11][8] + coeff0_12*dmats1[12][8] + coeff0_13*dmats1[13][8] + coeff0_14*dmats1[14][8] + coeff0_15*dmats1[15][8] + coeff0_16*dmats1[16][8] + coeff0_17*dmats1[17][8] + coeff0_18*dmats1[18][8] + coeff0_19*dmats1[19][8];
690
 
          new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9] + coeff0_10*dmats1[10][9] + coeff0_11*dmats1[11][9] + coeff0_12*dmats1[12][9] + coeff0_13*dmats1[13][9] + coeff0_14*dmats1[14][9] + coeff0_15*dmats1[15][9] + coeff0_16*dmats1[16][9] + coeff0_17*dmats1[17][9] + coeff0_18*dmats1[18][9] + coeff0_19*dmats1[19][9];
691
 
          new_coeff0_10 = coeff0_0*dmats1[0][10] + coeff0_1*dmats1[1][10] + coeff0_2*dmats1[2][10] + coeff0_3*dmats1[3][10] + coeff0_4*dmats1[4][10] + coeff0_5*dmats1[5][10] + coeff0_6*dmats1[6][10] + coeff0_7*dmats1[7][10] + coeff0_8*dmats1[8][10] + coeff0_9*dmats1[9][10] + coeff0_10*dmats1[10][10] + coeff0_11*dmats1[11][10] + coeff0_12*dmats1[12][10] + coeff0_13*dmats1[13][10] + coeff0_14*dmats1[14][10] + coeff0_15*dmats1[15][10] + coeff0_16*dmats1[16][10] + coeff0_17*dmats1[17][10] + coeff0_18*dmats1[18][10] + coeff0_19*dmats1[19][10];
692
 
          new_coeff0_11 = coeff0_0*dmats1[0][11] + coeff0_1*dmats1[1][11] + coeff0_2*dmats1[2][11] + coeff0_3*dmats1[3][11] + coeff0_4*dmats1[4][11] + coeff0_5*dmats1[5][11] + coeff0_6*dmats1[6][11] + coeff0_7*dmats1[7][11] + coeff0_8*dmats1[8][11] + coeff0_9*dmats1[9][11] + coeff0_10*dmats1[10][11] + coeff0_11*dmats1[11][11] + coeff0_12*dmats1[12][11] + coeff0_13*dmats1[13][11] + coeff0_14*dmats1[14][11] + coeff0_15*dmats1[15][11] + coeff0_16*dmats1[16][11] + coeff0_17*dmats1[17][11] + coeff0_18*dmats1[18][11] + coeff0_19*dmats1[19][11];
693
 
          new_coeff0_12 = coeff0_0*dmats1[0][12] + coeff0_1*dmats1[1][12] + coeff0_2*dmats1[2][12] + coeff0_3*dmats1[3][12] + coeff0_4*dmats1[4][12] + coeff0_5*dmats1[5][12] + coeff0_6*dmats1[6][12] + coeff0_7*dmats1[7][12] + coeff0_8*dmats1[8][12] + coeff0_9*dmats1[9][12] + coeff0_10*dmats1[10][12] + coeff0_11*dmats1[11][12] + coeff0_12*dmats1[12][12] + coeff0_13*dmats1[13][12] + coeff0_14*dmats1[14][12] + coeff0_15*dmats1[15][12] + coeff0_16*dmats1[16][12] + coeff0_17*dmats1[17][12] + coeff0_18*dmats1[18][12] + coeff0_19*dmats1[19][12];
694
 
          new_coeff0_13 = coeff0_0*dmats1[0][13] + coeff0_1*dmats1[1][13] + coeff0_2*dmats1[2][13] + coeff0_3*dmats1[3][13] + coeff0_4*dmats1[4][13] + coeff0_5*dmats1[5][13] + coeff0_6*dmats1[6][13] + coeff0_7*dmats1[7][13] + coeff0_8*dmats1[8][13] + coeff0_9*dmats1[9][13] + coeff0_10*dmats1[10][13] + coeff0_11*dmats1[11][13] + coeff0_12*dmats1[12][13] + coeff0_13*dmats1[13][13] + coeff0_14*dmats1[14][13] + coeff0_15*dmats1[15][13] + coeff0_16*dmats1[16][13] + coeff0_17*dmats1[17][13] + coeff0_18*dmats1[18][13] + coeff0_19*dmats1[19][13];
695
 
          new_coeff0_14 = coeff0_0*dmats1[0][14] + coeff0_1*dmats1[1][14] + coeff0_2*dmats1[2][14] + coeff0_3*dmats1[3][14] + coeff0_4*dmats1[4][14] + coeff0_5*dmats1[5][14] + coeff0_6*dmats1[6][14] + coeff0_7*dmats1[7][14] + coeff0_8*dmats1[8][14] + coeff0_9*dmats1[9][14] + coeff0_10*dmats1[10][14] + coeff0_11*dmats1[11][14] + coeff0_12*dmats1[12][14] + coeff0_13*dmats1[13][14] + coeff0_14*dmats1[14][14] + coeff0_15*dmats1[15][14] + coeff0_16*dmats1[16][14] + coeff0_17*dmats1[17][14] + coeff0_18*dmats1[18][14] + coeff0_19*dmats1[19][14];
696
 
          new_coeff0_15 = coeff0_0*dmats1[0][15] + coeff0_1*dmats1[1][15] + coeff0_2*dmats1[2][15] + coeff0_3*dmats1[3][15] + coeff0_4*dmats1[4][15] + coeff0_5*dmats1[5][15] + coeff0_6*dmats1[6][15] + coeff0_7*dmats1[7][15] + coeff0_8*dmats1[8][15] + coeff0_9*dmats1[9][15] + coeff0_10*dmats1[10][15] + coeff0_11*dmats1[11][15] + coeff0_12*dmats1[12][15] + coeff0_13*dmats1[13][15] + coeff0_14*dmats1[14][15] + coeff0_15*dmats1[15][15] + coeff0_16*dmats1[16][15] + coeff0_17*dmats1[17][15] + coeff0_18*dmats1[18][15] + coeff0_19*dmats1[19][15];
697
 
          new_coeff0_16 = coeff0_0*dmats1[0][16] + coeff0_1*dmats1[1][16] + coeff0_2*dmats1[2][16] + coeff0_3*dmats1[3][16] + coeff0_4*dmats1[4][16] + coeff0_5*dmats1[5][16] + coeff0_6*dmats1[6][16] + coeff0_7*dmats1[7][16] + coeff0_8*dmats1[8][16] + coeff0_9*dmats1[9][16] + coeff0_10*dmats1[10][16] + coeff0_11*dmats1[11][16] + coeff0_12*dmats1[12][16] + coeff0_13*dmats1[13][16] + coeff0_14*dmats1[14][16] + coeff0_15*dmats1[15][16] + coeff0_16*dmats1[16][16] + coeff0_17*dmats1[17][16] + coeff0_18*dmats1[18][16] + coeff0_19*dmats1[19][16];
698
 
          new_coeff0_17 = coeff0_0*dmats1[0][17] + coeff0_1*dmats1[1][17] + coeff0_2*dmats1[2][17] + coeff0_3*dmats1[3][17] + coeff0_4*dmats1[4][17] + coeff0_5*dmats1[5][17] + coeff0_6*dmats1[6][17] + coeff0_7*dmats1[7][17] + coeff0_8*dmats1[8][17] + coeff0_9*dmats1[9][17] + coeff0_10*dmats1[10][17] + coeff0_11*dmats1[11][17] + coeff0_12*dmats1[12][17] + coeff0_13*dmats1[13][17] + coeff0_14*dmats1[14][17] + coeff0_15*dmats1[15][17] + coeff0_16*dmats1[16][17] + coeff0_17*dmats1[17][17] + coeff0_18*dmats1[18][17] + coeff0_19*dmats1[19][17];
699
 
          new_coeff0_18 = coeff0_0*dmats1[0][18] + coeff0_1*dmats1[1][18] + coeff0_2*dmats1[2][18] + coeff0_3*dmats1[3][18] + coeff0_4*dmats1[4][18] + coeff0_5*dmats1[5][18] + coeff0_6*dmats1[6][18] + coeff0_7*dmats1[7][18] + coeff0_8*dmats1[8][18] + coeff0_9*dmats1[9][18] + coeff0_10*dmats1[10][18] + coeff0_11*dmats1[11][18] + coeff0_12*dmats1[12][18] + coeff0_13*dmats1[13][18] + coeff0_14*dmats1[14][18] + coeff0_15*dmats1[15][18] + coeff0_16*dmats1[16][18] + coeff0_17*dmats1[17][18] + coeff0_18*dmats1[18][18] + coeff0_19*dmats1[19][18];
700
 
          new_coeff0_19 = coeff0_0*dmats1[0][19] + coeff0_1*dmats1[1][19] + coeff0_2*dmats1[2][19] + coeff0_3*dmats1[3][19] + coeff0_4*dmats1[4][19] + coeff0_5*dmats1[5][19] + coeff0_6*dmats1[6][19] + coeff0_7*dmats1[7][19] + coeff0_8*dmats1[8][19] + coeff0_9*dmats1[9][19] + coeff0_10*dmats1[10][19] + coeff0_11*dmats1[11][19] + coeff0_12*dmats1[12][19] + coeff0_13*dmats1[13][19] + coeff0_14*dmats1[14][19] + coeff0_15*dmats1[15][19] + coeff0_16*dmats1[16][19] + coeff0_17*dmats1[17][19] + coeff0_18*dmats1[18][19] + coeff0_19*dmats1[19][19];
701
 
        }
702
 
        if(combinations[deriv_num][j] == 2)
703
 
        {
704
 
          new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0] + coeff0_10*dmats2[10][0] + coeff0_11*dmats2[11][0] + coeff0_12*dmats2[12][0] + coeff0_13*dmats2[13][0] + coeff0_14*dmats2[14][0] + coeff0_15*dmats2[15][0] + coeff0_16*dmats2[16][0] + coeff0_17*dmats2[17][0] + coeff0_18*dmats2[18][0] + coeff0_19*dmats2[19][0];
705
 
          new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1] + coeff0_10*dmats2[10][1] + coeff0_11*dmats2[11][1] + coeff0_12*dmats2[12][1] + coeff0_13*dmats2[13][1] + coeff0_14*dmats2[14][1] + coeff0_15*dmats2[15][1] + coeff0_16*dmats2[16][1] + coeff0_17*dmats2[17][1] + coeff0_18*dmats2[18][1] + coeff0_19*dmats2[19][1];
706
 
          new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2] + coeff0_10*dmats2[10][2] + coeff0_11*dmats2[11][2] + coeff0_12*dmats2[12][2] + coeff0_13*dmats2[13][2] + coeff0_14*dmats2[14][2] + coeff0_15*dmats2[15][2] + coeff0_16*dmats2[16][2] + coeff0_17*dmats2[17][2] + coeff0_18*dmats2[18][2] + coeff0_19*dmats2[19][2];
707
 
          new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3] + coeff0_10*dmats2[10][3] + coeff0_11*dmats2[11][3] + coeff0_12*dmats2[12][3] + coeff0_13*dmats2[13][3] + coeff0_14*dmats2[14][3] + coeff0_15*dmats2[15][3] + coeff0_16*dmats2[16][3] + coeff0_17*dmats2[17][3] + coeff0_18*dmats2[18][3] + coeff0_19*dmats2[19][3];
708
 
          new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4] + coeff0_10*dmats2[10][4] + coeff0_11*dmats2[11][4] + coeff0_12*dmats2[12][4] + coeff0_13*dmats2[13][4] + coeff0_14*dmats2[14][4] + coeff0_15*dmats2[15][4] + coeff0_16*dmats2[16][4] + coeff0_17*dmats2[17][4] + coeff0_18*dmats2[18][4] + coeff0_19*dmats2[19][4];
709
 
          new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5] + coeff0_10*dmats2[10][5] + coeff0_11*dmats2[11][5] + coeff0_12*dmats2[12][5] + coeff0_13*dmats2[13][5] + coeff0_14*dmats2[14][5] + coeff0_15*dmats2[15][5] + coeff0_16*dmats2[16][5] + coeff0_17*dmats2[17][5] + coeff0_18*dmats2[18][5] + coeff0_19*dmats2[19][5];
710
 
          new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6] + coeff0_10*dmats2[10][6] + coeff0_11*dmats2[11][6] + coeff0_12*dmats2[12][6] + coeff0_13*dmats2[13][6] + coeff0_14*dmats2[14][6] + coeff0_15*dmats2[15][6] + coeff0_16*dmats2[16][6] + coeff0_17*dmats2[17][6] + coeff0_18*dmats2[18][6] + coeff0_19*dmats2[19][6];
711
 
          new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7] + coeff0_10*dmats2[10][7] + coeff0_11*dmats2[11][7] + coeff0_12*dmats2[12][7] + coeff0_13*dmats2[13][7] + coeff0_14*dmats2[14][7] + coeff0_15*dmats2[15][7] + coeff0_16*dmats2[16][7] + coeff0_17*dmats2[17][7] + coeff0_18*dmats2[18][7] + coeff0_19*dmats2[19][7];
712
 
          new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8] + coeff0_10*dmats2[10][8] + coeff0_11*dmats2[11][8] + coeff0_12*dmats2[12][8] + coeff0_13*dmats2[13][8] + coeff0_14*dmats2[14][8] + coeff0_15*dmats2[15][8] + coeff0_16*dmats2[16][8] + coeff0_17*dmats2[17][8] + coeff0_18*dmats2[18][8] + coeff0_19*dmats2[19][8];
713
 
          new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9] + coeff0_10*dmats2[10][9] + coeff0_11*dmats2[11][9] + coeff0_12*dmats2[12][9] + coeff0_13*dmats2[13][9] + coeff0_14*dmats2[14][9] + coeff0_15*dmats2[15][9] + coeff0_16*dmats2[16][9] + coeff0_17*dmats2[17][9] + coeff0_18*dmats2[18][9] + coeff0_19*dmats2[19][9];
714
 
          new_coeff0_10 = coeff0_0*dmats2[0][10] + coeff0_1*dmats2[1][10] + coeff0_2*dmats2[2][10] + coeff0_3*dmats2[3][10] + coeff0_4*dmats2[4][10] + coeff0_5*dmats2[5][10] + coeff0_6*dmats2[6][10] + coeff0_7*dmats2[7][10] + coeff0_8*dmats2[8][10] + coeff0_9*dmats2[9][10] + coeff0_10*dmats2[10][10] + coeff0_11*dmats2[11][10] + coeff0_12*dmats2[12][10] + coeff0_13*dmats2[13][10] + coeff0_14*dmats2[14][10] + coeff0_15*dmats2[15][10] + coeff0_16*dmats2[16][10] + coeff0_17*dmats2[17][10] + coeff0_18*dmats2[18][10] + coeff0_19*dmats2[19][10];
715
 
          new_coeff0_11 = coeff0_0*dmats2[0][11] + coeff0_1*dmats2[1][11] + coeff0_2*dmats2[2][11] + coeff0_3*dmats2[3][11] + coeff0_4*dmats2[4][11] + coeff0_5*dmats2[5][11] + coeff0_6*dmats2[6][11] + coeff0_7*dmats2[7][11] + coeff0_8*dmats2[8][11] + coeff0_9*dmats2[9][11] + coeff0_10*dmats2[10][11] + coeff0_11*dmats2[11][11] + coeff0_12*dmats2[12][11] + coeff0_13*dmats2[13][11] + coeff0_14*dmats2[14][11] + coeff0_15*dmats2[15][11] + coeff0_16*dmats2[16][11] + coeff0_17*dmats2[17][11] + coeff0_18*dmats2[18][11] + coeff0_19*dmats2[19][11];
716
 
          new_coeff0_12 = coeff0_0*dmats2[0][12] + coeff0_1*dmats2[1][12] + coeff0_2*dmats2[2][12] + coeff0_3*dmats2[3][12] + coeff0_4*dmats2[4][12] + coeff0_5*dmats2[5][12] + coeff0_6*dmats2[6][12] + coeff0_7*dmats2[7][12] + coeff0_8*dmats2[8][12] + coeff0_9*dmats2[9][12] + coeff0_10*dmats2[10][12] + coeff0_11*dmats2[11][12] + coeff0_12*dmats2[12][12] + coeff0_13*dmats2[13][12] + coeff0_14*dmats2[14][12] + coeff0_15*dmats2[15][12] + coeff0_16*dmats2[16][12] + coeff0_17*dmats2[17][12] + coeff0_18*dmats2[18][12] + coeff0_19*dmats2[19][12];
717
 
          new_coeff0_13 = coeff0_0*dmats2[0][13] + coeff0_1*dmats2[1][13] + coeff0_2*dmats2[2][13] + coeff0_3*dmats2[3][13] + coeff0_4*dmats2[4][13] + coeff0_5*dmats2[5][13] + coeff0_6*dmats2[6][13] + coeff0_7*dmats2[7][13] + coeff0_8*dmats2[8][13] + coeff0_9*dmats2[9][13] + coeff0_10*dmats2[10][13] + coeff0_11*dmats2[11][13] + coeff0_12*dmats2[12][13] + coeff0_13*dmats2[13][13] + coeff0_14*dmats2[14][13] + coeff0_15*dmats2[15][13] + coeff0_16*dmats2[16][13] + coeff0_17*dmats2[17][13] + coeff0_18*dmats2[18][13] + coeff0_19*dmats2[19][13];
718
 
          new_coeff0_14 = coeff0_0*dmats2[0][14] + coeff0_1*dmats2[1][14] + coeff0_2*dmats2[2][14] + coeff0_3*dmats2[3][14] + coeff0_4*dmats2[4][14] + coeff0_5*dmats2[5][14] + coeff0_6*dmats2[6][14] + coeff0_7*dmats2[7][14] + coeff0_8*dmats2[8][14] + coeff0_9*dmats2[9][14] + coeff0_10*dmats2[10][14] + coeff0_11*dmats2[11][14] + coeff0_12*dmats2[12][14] + coeff0_13*dmats2[13][14] + coeff0_14*dmats2[14][14] + coeff0_15*dmats2[15][14] + coeff0_16*dmats2[16][14] + coeff0_17*dmats2[17][14] + coeff0_18*dmats2[18][14] + coeff0_19*dmats2[19][14];
719
 
          new_coeff0_15 = coeff0_0*dmats2[0][15] + coeff0_1*dmats2[1][15] + coeff0_2*dmats2[2][15] + coeff0_3*dmats2[3][15] + coeff0_4*dmats2[4][15] + coeff0_5*dmats2[5][15] + coeff0_6*dmats2[6][15] + coeff0_7*dmats2[7][15] + coeff0_8*dmats2[8][15] + coeff0_9*dmats2[9][15] + coeff0_10*dmats2[10][15] + coeff0_11*dmats2[11][15] + coeff0_12*dmats2[12][15] + coeff0_13*dmats2[13][15] + coeff0_14*dmats2[14][15] + coeff0_15*dmats2[15][15] + coeff0_16*dmats2[16][15] + coeff0_17*dmats2[17][15] + coeff0_18*dmats2[18][15] + coeff0_19*dmats2[19][15];
720
 
          new_coeff0_16 = coeff0_0*dmats2[0][16] + coeff0_1*dmats2[1][16] + coeff0_2*dmats2[2][16] + coeff0_3*dmats2[3][16] + coeff0_4*dmats2[4][16] + coeff0_5*dmats2[5][16] + coeff0_6*dmats2[6][16] + coeff0_7*dmats2[7][16] + coeff0_8*dmats2[8][16] + coeff0_9*dmats2[9][16] + coeff0_10*dmats2[10][16] + coeff0_11*dmats2[11][16] + coeff0_12*dmats2[12][16] + coeff0_13*dmats2[13][16] + coeff0_14*dmats2[14][16] + coeff0_15*dmats2[15][16] + coeff0_16*dmats2[16][16] + coeff0_17*dmats2[17][16] + coeff0_18*dmats2[18][16] + coeff0_19*dmats2[19][16];
721
 
          new_coeff0_17 = coeff0_0*dmats2[0][17] + coeff0_1*dmats2[1][17] + coeff0_2*dmats2[2][17] + coeff0_3*dmats2[3][17] + coeff0_4*dmats2[4][17] + coeff0_5*dmats2[5][17] + coeff0_6*dmats2[6][17] + coeff0_7*dmats2[7][17] + coeff0_8*dmats2[8][17] + coeff0_9*dmats2[9][17] + coeff0_10*dmats2[10][17] + coeff0_11*dmats2[11][17] + coeff0_12*dmats2[12][17] + coeff0_13*dmats2[13][17] + coeff0_14*dmats2[14][17] + coeff0_15*dmats2[15][17] + coeff0_16*dmats2[16][17] + coeff0_17*dmats2[17][17] + coeff0_18*dmats2[18][17] + coeff0_19*dmats2[19][17];
722
 
          new_coeff0_18 = coeff0_0*dmats2[0][18] + coeff0_1*dmats2[1][18] + coeff0_2*dmats2[2][18] + coeff0_3*dmats2[3][18] + coeff0_4*dmats2[4][18] + coeff0_5*dmats2[5][18] + coeff0_6*dmats2[6][18] + coeff0_7*dmats2[7][18] + coeff0_8*dmats2[8][18] + coeff0_9*dmats2[9][18] + coeff0_10*dmats2[10][18] + coeff0_11*dmats2[11][18] + coeff0_12*dmats2[12][18] + coeff0_13*dmats2[13][18] + coeff0_14*dmats2[14][18] + coeff0_15*dmats2[15][18] + coeff0_16*dmats2[16][18] + coeff0_17*dmats2[17][18] + coeff0_18*dmats2[18][18] + coeff0_19*dmats2[19][18];
723
 
          new_coeff0_19 = coeff0_0*dmats2[0][19] + coeff0_1*dmats2[1][19] + coeff0_2*dmats2[2][19] + coeff0_3*dmats2[3][19] + coeff0_4*dmats2[4][19] + coeff0_5*dmats2[5][19] + coeff0_6*dmats2[6][19] + coeff0_7*dmats2[7][19] + coeff0_8*dmats2[8][19] + coeff0_9*dmats2[9][19] + coeff0_10*dmats2[10][19] + coeff0_11*dmats2[11][19] + coeff0_12*dmats2[12][19] + coeff0_13*dmats2[13][19] + coeff0_14*dmats2[14][19] + coeff0_15*dmats2[15][19] + coeff0_16*dmats2[16][19] + coeff0_17*dmats2[17][19] + coeff0_18*dmats2[18][19] + coeff0_19*dmats2[19][19];
724
 
        }
725
 
    
726
 
      }
727
 
      // Compute derivatives on reference element as dot product of coefficients and basisvalues
728
 
      derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9 + new_coeff0_10*basisvalue10 + new_coeff0_11*basisvalue11 + new_coeff0_12*basisvalue12 + new_coeff0_13*basisvalue13 + new_coeff0_14*basisvalue14 + new_coeff0_15*basisvalue15 + new_coeff0_16*basisvalue16 + new_coeff0_17*basisvalue17 + new_coeff0_18*basisvalue18 + new_coeff0_19*basisvalue19;
729
 
    }
730
 
    
731
 
    // Transform derivatives back to physical element
732
 
    for (unsigned int row = 0; row < num_derivatives; row++)
733
 
    {
734
 
      for (unsigned int col = 0; col < num_derivatives; col++)
735
 
      {
736
 
        values[row] += transform[row][col]*derivatives[col];
737
 
      }
738
 
    }
739
 
    // Delete pointer to array of derivatives on FIAT element
740
 
    delete [] derivatives;
741
 
    
742
 
    // Delete pointer to array of combinations of derivatives and transform
743
 
    for (unsigned int row = 0; row < num_derivatives; row++)
744
 
    {
745
 
      delete [] combinations[row];
746
 
      delete [] transform[row];
747
 
    }
748
 
    
749
 
    delete [] combinations;
750
 
    delete [] transform;
751
 
  }
752
 
 
753
 
  /// Evaluate order n derivatives of all basis functions at given point in cell
754
 
  virtual void evaluate_basis_derivatives_all(unsigned int n,
755
 
                                              double* values,
756
 
                                              const double* coordinates,
757
 
                                              const ufc::cell& c) const
758
 
  {
759
 
    throw std::runtime_error("The vectorised version of evaluate_basis_derivatives() is not yet implemented.");
760
 
  }
761
 
 
762
 
  /// Evaluate linear functional for dof i on the function f
763
 
  virtual double evaluate_dof(unsigned int i,
764
 
                              const ufc::function& f,
765
 
                              const ufc::cell& c) const
766
 
  {
767
 
    // The reference points, direction and weights:
768
 
    const static double X[20][1][3] = {{{0, 0, 0}}, {{0.333333333333333, 0, 0}}, {{0.666666666666667, 0, 0}}, {{1, 0, 0}}, {{0, 0.333333333333333, 0}}, {{0.333333333333333, 0.333333333333333, 0}}, {{0.666666666666667, 0.333333333333333, 0}}, {{0, 0.666666666666667, 0}}, {{0.333333333333333, 0.666666666666667, 0}}, {{0, 1, 0}}, {{0, 0, 0.333333333333333}}, {{0.333333333333333, 0, 0.333333333333333}}, {{0.666666666666667, 0, 0.333333333333333}}, {{0, 0.333333333333333, 0.333333333333333}}, {{0.333333333333333, 0.333333333333333, 0.333333333333333}}, {{0, 0.666666666666667, 0.333333333333333}}, {{0, 0, 0.666666666666667}}, {{0.333333333333333, 0, 0.666666666666667}}, {{0, 0.333333333333333, 0.666666666666667}}, {{0, 0, 1}}};
769
 
    const static double W[20][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
770
 
    const static double D[20][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
771
 
    
772
 
    const double * const * x = c.coordinates;
773
 
    double result = 0.0;
774
 
    // Iterate over the points:
775
 
    // Evaluate basis functions for affine mapping
776
 
    const double w0 = 1.0 - X[i][0][0] - X[i][0][1] - X[i][0][2];
777
 
    const double w1 = X[i][0][0];
778
 
    const double w2 = X[i][0][1];
779
 
    const double w3 = X[i][0][2];
780
 
    
781
 
    // Compute affine mapping y = F(X)
782
 
    double y[3];
783
 
    y[0] = w0*x[0][0] + w1*x[1][0] + w2*x[2][0] + w3*x[3][0];
784
 
    y[1] = w0*x[0][1] + w1*x[1][1] + w2*x[2][1] + w3*x[3][1];
785
 
    y[2] = w0*x[0][2] + w1*x[1][2] + w2*x[2][2] + w3*x[3][2];
786
 
    
787
 
    // Evaluate function at physical points
788
 
    double values[1];
789
 
    f.evaluate(values, y, c);
790
 
    
791
 
    // Map function values using appropriate mapping
792
 
    // Affine map: Do nothing
793
 
    
794
 
    // Note that we do not map the weights (yet).
795
 
    
796
 
    // Take directional components
797
 
    for(int k = 0; k < 1; k++)
798
 
      result += values[k]*D[i][0][k];
799
 
    // Multiply by weights 
800
 
    result *= W[i][0];
801
 
    
802
 
    return result;
803
 
  }
804
 
 
805
 
  /// Evaluate linear functionals for all dofs on the function f
806
 
  virtual void evaluate_dofs(double* values,
807
 
                             const ufc::function& f,
808
 
                             const ufc::cell& c) const
809
 
  {
810
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
811
 
  }
812
 
 
813
 
  /// Interpolate vertex values from dof values
814
 
  virtual void interpolate_vertex_values(double* vertex_values,
815
 
                                         const double* dof_values,
816
 
                                         const ufc::cell& c) const
817
 
  {
818
 
    // Evaluate at vertices and use affine mapping
819
 
    vertex_values[0] = dof_values[0];
820
 
    vertex_values[1] = dof_values[3];
821
 
    vertex_values[2] = dof_values[9];
822
 
    vertex_values[3] = dof_values[19];
823
 
  }
824
 
 
825
 
  /// Return the number of sub elements (for a mixed element)
826
 
  virtual unsigned int num_sub_elements() const
827
 
  {
828
 
    return 1;
829
 
  }
830
 
 
831
 
  /// Create a new finite element for sub element i (for a mixed element)
832
 
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
833
 
  {
834
 
    return new ffc_25_finite_element_0_0();
835
 
  }
836
 
 
837
 
};
838
 
 
839
 
/// This class defines the interface for a finite element.
840
 
 
841
 
class ffc_25_finite_element_0_1: public ufc::finite_element
842
 
{
843
 
public:
844
 
 
845
 
  /// Constructor
846
 
  ffc_25_finite_element_0_1() : ufc::finite_element()
847
 
  {
848
 
    // Do nothing
849
 
  }
850
 
 
851
 
  /// Destructor
852
 
  virtual ~ffc_25_finite_element_0_1()
853
 
  {
854
 
    // Do nothing
855
 
  }
856
 
 
857
 
  /// Return a string identifying the finite element
858
 
  virtual const char* signature() const
859
 
  {
860
 
    return "Discontinuous Lagrange finite element of degree 3 on a tetrahedron";
861
 
  }
862
 
 
863
 
  /// Return the cell shape
864
 
  virtual ufc::shape cell_shape() const
865
 
  {
866
 
    return ufc::tetrahedron;
867
 
  }
868
 
 
869
 
  /// Return the dimension of the finite element function space
870
 
  virtual unsigned int space_dimension() const
871
 
  {
872
 
    return 20;
873
 
  }
874
 
 
875
 
  /// Return the rank of the value space
876
 
  virtual unsigned int value_rank() const
877
 
  {
878
 
    return 0;
879
 
  }
880
 
 
881
 
  /// Return the dimension of the value space for axis i
882
 
  virtual unsigned int value_dimension(unsigned int i) const
883
 
  {
884
 
    return 1;
885
 
  }
886
 
 
887
 
  /// Evaluate basis function i at given point in cell
888
 
  virtual void evaluate_basis(unsigned int i,
889
 
                              double* values,
890
 
                              const double* coordinates,
891
 
                              const ufc::cell& c) const
892
 
  {
893
 
    // Extract vertex coordinates
894
 
    const double * const * element_coordinates = c.coordinates;
895
 
    
896
 
    // Compute Jacobian of affine map from reference cell
897
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
898
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
899
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
900
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
901
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
902
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
903
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
904
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
905
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
906
 
      
907
 
    // Compute sub determinants
908
 
    const double d00 = J_11*J_22 - J_12*J_21;
909
 
    const double d01 = J_12*J_20 - J_10*J_22;
910
 
    const double d02 = J_10*J_21 - J_11*J_20;
911
 
    
912
 
    const double d10 = J_02*J_21 - J_01*J_22;
913
 
    const double d11 = J_00*J_22 - J_02*J_20;
914
 
    const double d12 = J_01*J_20 - J_00*J_21;
915
 
    
916
 
    const double d20 = J_01*J_12 - J_02*J_11;
917
 
    const double d21 = J_02*J_10 - J_00*J_12;
918
 
    const double d22 = J_00*J_11 - J_01*J_10;
919
 
      
920
 
    // Compute determinant of Jacobian
921
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
922
 
    
923
 
    // Compute inverse of Jacobian
924
 
    
925
 
    // Compute constants
926
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
927
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
928
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
929
 
    
930
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
931
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
932
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
933
 
    
934
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
935
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
936
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
937
 
    
938
 
    // Get coordinates and map to the UFC reference element
939
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
940
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
941
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
942
 
    
943
 
    // Map coordinates to the reference cube
944
 
    if (std::abs(y + z - 1.0) < 1e-14)
945
 
      x = 1.0;
946
 
    else
947
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
948
 
    if (std::abs(z - 1.0) < 1e-14)
949
 
      y = -1.0;
950
 
    else
951
 
      y = 2.0 * y/(1.0 - z) - 1.0;
952
 
    z = 2.0 * z - 1.0;
953
 
    
954
 
    // Reset values
955
 
    *values = 0;
956
 
    
957
 
    // Map degree of freedom to element degree of freedom
958
 
    const unsigned int dof = i;
959
 
    
960
 
    // Generate scalings
961
 
    const double scalings_y_0 = 1;
962
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
963
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
964
 
    const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
965
 
    const double scalings_z_0 = 1;
966
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
967
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
968
 
    const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
969
 
    
970
 
    // Compute psitilde_a
971
 
    const double psitilde_a_0 = 1;
972
 
    const double psitilde_a_1 = x;
973
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
974
 
    const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
975
 
    
976
 
    // Compute psitilde_bs
977
 
    const double psitilde_bs_0_0 = 1;
978
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
979
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
980
 
    const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
981
 
    const double psitilde_bs_1_0 = 1;
982
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
983
 
    const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
984
 
    const double psitilde_bs_2_0 = 1;
985
 
    const double psitilde_bs_2_1 = 3.5*y + 2.5;
986
 
    const double psitilde_bs_3_0 = 1;
987
 
    
988
 
    // Compute psitilde_cs
989
 
    const double psitilde_cs_00_0 = 1;
990
 
    const double psitilde_cs_00_1 = 2*z + 1;
991
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
992
 
    const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
993
 
    const double psitilde_cs_01_0 = 1;
994
 
    const double psitilde_cs_01_1 = 3*z + 2;
995
 
    const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
996
 
    const double psitilde_cs_02_0 = 1;
997
 
    const double psitilde_cs_02_1 = 4*z + 3;
998
 
    const double psitilde_cs_03_0 = 1;
999
 
    const double psitilde_cs_10_0 = 1;
1000
 
    const double psitilde_cs_10_1 = 3*z + 2;
1001
 
    const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
1002
 
    const double psitilde_cs_11_0 = 1;
1003
 
    const double psitilde_cs_11_1 = 4*z + 3;
1004
 
    const double psitilde_cs_12_0 = 1;
1005
 
    const double psitilde_cs_20_0 = 1;
1006
 
    const double psitilde_cs_20_1 = 4*z + 3;
1007
 
    const double psitilde_cs_21_0 = 1;
1008
 
    const double psitilde_cs_30_0 = 1;
1009
 
    
1010
 
    // Compute basisvalues
1011
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
1012
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
1013
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
1014
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
1015
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
1016
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
1017
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
1018
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
1019
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
1020
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
1021
 
    const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
1022
 
    const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
1023
 
    const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
1024
 
    const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
1025
 
    const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
1026
 
    const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
1027
 
    const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
1028
 
    const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
1029
 
    const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
1030
 
    const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
1031
 
    
1032
 
    // Table(s) of coefficients
1033
 
    const static double coefficients0[20][20] = \
1034
 
    {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
1035
 
    {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
1036
 
    {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
1037
 
    {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
1038
 
    {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
1039
 
    {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
1040
 
    {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
1041
 
    {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
1042
 
    {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
1043
 
    {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
1044
 
    {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
1045
 
    {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
1046
 
    {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
1047
 
    {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
1048
 
    {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
1049
 
    {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
1050
 
    {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
1051
 
    {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
1052
 
    {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
1053
 
    {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
1054
 
    
1055
 
    // Extract relevant coefficients
1056
 
    const double coeff0_0 = coefficients0[dof][0];
1057
 
    const double coeff0_1 = coefficients0[dof][1];
1058
 
    const double coeff0_2 = coefficients0[dof][2];
1059
 
    const double coeff0_3 = coefficients0[dof][3];
1060
 
    const double coeff0_4 = coefficients0[dof][4];
1061
 
    const double coeff0_5 = coefficients0[dof][5];
1062
 
    const double coeff0_6 = coefficients0[dof][6];
1063
 
    const double coeff0_7 = coefficients0[dof][7];
1064
 
    const double coeff0_8 = coefficients0[dof][8];
1065
 
    const double coeff0_9 = coefficients0[dof][9];
1066
 
    const double coeff0_10 = coefficients0[dof][10];
1067
 
    const double coeff0_11 = coefficients0[dof][11];
1068
 
    const double coeff0_12 = coefficients0[dof][12];
1069
 
    const double coeff0_13 = coefficients0[dof][13];
1070
 
    const double coeff0_14 = coefficients0[dof][14];
1071
 
    const double coeff0_15 = coefficients0[dof][15];
1072
 
    const double coeff0_16 = coefficients0[dof][16];
1073
 
    const double coeff0_17 = coefficients0[dof][17];
1074
 
    const double coeff0_18 = coefficients0[dof][18];
1075
 
    const double coeff0_19 = coefficients0[dof][19];
1076
 
    
1077
 
    // Compute value(s)
1078
 
    *values = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9 + coeff0_10*basisvalue10 + coeff0_11*basisvalue11 + coeff0_12*basisvalue12 + coeff0_13*basisvalue13 + coeff0_14*basisvalue14 + coeff0_15*basisvalue15 + coeff0_16*basisvalue16 + coeff0_17*basisvalue17 + coeff0_18*basisvalue18 + coeff0_19*basisvalue19;
1079
 
  }
1080
 
 
1081
 
  /// Evaluate all basis functions at given point in cell
1082
 
  virtual void evaluate_basis_all(double* values,
1083
 
                                  const double* coordinates,
1084
 
                                  const ufc::cell& c) const
1085
 
  {
1086
 
    throw std::runtime_error("The vectorised version of evaluate_basis() is not yet implemented.");
1087
 
  }
1088
 
 
1089
 
  /// Evaluate order n derivatives of basis function i at given point in cell
1090
 
  virtual void evaluate_basis_derivatives(unsigned int i,
1091
 
                                          unsigned int n,
1092
 
                                          double* values,
1093
 
                                          const double* coordinates,
1094
 
                                          const ufc::cell& c) const
1095
 
  {
1096
 
    // Extract vertex coordinates
1097
 
    const double * const * element_coordinates = c.coordinates;
1098
 
    
1099
 
    // Compute Jacobian of affine map from reference cell
1100
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
1101
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
1102
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
1103
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
1104
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
1105
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
1106
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
1107
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
1108
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
1109
 
      
1110
 
    // Compute sub determinants
1111
 
    const double d00 = J_11*J_22 - J_12*J_21;
1112
 
    const double d01 = J_12*J_20 - J_10*J_22;
1113
 
    const double d02 = J_10*J_21 - J_11*J_20;
1114
 
    
1115
 
    const double d10 = J_02*J_21 - J_01*J_22;
1116
 
    const double d11 = J_00*J_22 - J_02*J_20;
1117
 
    const double d12 = J_01*J_20 - J_00*J_21;
1118
 
    
1119
 
    const double d20 = J_01*J_12 - J_02*J_11;
1120
 
    const double d21 = J_02*J_10 - J_00*J_12;
1121
 
    const double d22 = J_00*J_11 - J_01*J_10;
1122
 
      
1123
 
    // Compute determinant of Jacobian
1124
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
1125
 
    
1126
 
    // Compute inverse of Jacobian
1127
 
    
1128
 
    // Compute constants
1129
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
1130
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
1131
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
1132
 
    
1133
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
1134
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
1135
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
1136
 
    
1137
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
1138
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
1139
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
1140
 
    
1141
 
    // Get coordinates and map to the UFC reference element
1142
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
1143
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
1144
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
1145
 
    
1146
 
    // Map coordinates to the reference cube
1147
 
    if (std::abs(y + z - 1.0) < 1e-14)
1148
 
      x = 1.0;
1149
 
    else
1150
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
1151
 
    if (std::abs(z - 1.0) < 1e-14)
1152
 
      y = -1.0;
1153
 
    else
1154
 
      y = 2.0 * y/(1.0 - z) - 1.0;
1155
 
    z = 2.0 * z - 1.0;
1156
 
    
1157
 
    // Compute number of derivatives
1158
 
    unsigned int num_derivatives = 1;
1159
 
    
1160
 
    for (unsigned int j = 0; j < n; j++)
1161
 
      num_derivatives *= 3;
1162
 
    
1163
 
    
1164
 
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
1165
 
    unsigned int **combinations = new unsigned int *[num_derivatives];
1166
 
        
1167
 
    for (unsigned int j = 0; j < num_derivatives; j++)
1168
 
    {
1169
 
      combinations[j] = new unsigned int [n];
1170
 
      for (unsigned int k = 0; k < n; k++)
1171
 
        combinations[j][k] = 0;
1172
 
    }
1173
 
        
1174
 
    // Generate combinations of derivatives
1175
 
    for (unsigned int row = 1; row < num_derivatives; row++)
1176
 
    {
1177
 
      for (unsigned int num = 0; num < row; num++)
1178
 
      {
1179
 
        for (unsigned int col = n-1; col+1 > 0; col--)
1180
 
        {
1181
 
          if (combinations[row][col] + 1 > 2)
1182
 
            combinations[row][col] = 0;
1183
 
          else
1184
 
          {
1185
 
            combinations[row][col] += 1;
1186
 
            break;
1187
 
          }
1188
 
        }
1189
 
      }
1190
 
    }
1191
 
    
1192
 
    // Compute inverse of Jacobian
1193
 
    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};
1194
 
    
1195
 
    // Declare transformation matrix
1196
 
    // Declare pointer to two dimensional array and initialise
1197
 
    double **transform = new double *[num_derivatives];
1198
 
        
1199
 
    for (unsigned int j = 0; j < num_derivatives; j++)
1200
 
    {
1201
 
      transform[j] = new double [num_derivatives];
1202
 
      for (unsigned int k = 0; k < num_derivatives; k++)
1203
 
        transform[j][k] = 1;
1204
 
    }
1205
 
    
1206
 
    // Construct transformation matrix
1207
 
    for (unsigned int row = 0; row < num_derivatives; row++)
1208
 
    {
1209
 
      for (unsigned int col = 0; col < num_derivatives; col++)
1210
 
      {
1211
 
        for (unsigned int k = 0; k < n; k++)
1212
 
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
1213
 
      }
1214
 
    }
1215
 
    
1216
 
    // Reset values
1217
 
    for (unsigned int j = 0; j < 1*num_derivatives; j++)
1218
 
      values[j] = 0;
1219
 
    
1220
 
    // Map degree of freedom to element degree of freedom
1221
 
    const unsigned int dof = i;
1222
 
    
1223
 
    // Generate scalings
1224
 
    const double scalings_y_0 = 1;
1225
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
1226
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
1227
 
    const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
1228
 
    const double scalings_z_0 = 1;
1229
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
1230
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
1231
 
    const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
1232
 
    
1233
 
    // Compute psitilde_a
1234
 
    const double psitilde_a_0 = 1;
1235
 
    const double psitilde_a_1 = x;
1236
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
1237
 
    const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
1238
 
    
1239
 
    // Compute psitilde_bs
1240
 
    const double psitilde_bs_0_0 = 1;
1241
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
1242
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
1243
 
    const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
1244
 
    const double psitilde_bs_1_0 = 1;
1245
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
1246
 
    const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
1247
 
    const double psitilde_bs_2_0 = 1;
1248
 
    const double psitilde_bs_2_1 = 3.5*y + 2.5;
1249
 
    const double psitilde_bs_3_0 = 1;
1250
 
    
1251
 
    // Compute psitilde_cs
1252
 
    const double psitilde_cs_00_0 = 1;
1253
 
    const double psitilde_cs_00_1 = 2*z + 1;
1254
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
1255
 
    const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
1256
 
    const double psitilde_cs_01_0 = 1;
1257
 
    const double psitilde_cs_01_1 = 3*z + 2;
1258
 
    const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
1259
 
    const double psitilde_cs_02_0 = 1;
1260
 
    const double psitilde_cs_02_1 = 4*z + 3;
1261
 
    const double psitilde_cs_03_0 = 1;
1262
 
    const double psitilde_cs_10_0 = 1;
1263
 
    const double psitilde_cs_10_1 = 3*z + 2;
1264
 
    const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
1265
 
    const double psitilde_cs_11_0 = 1;
1266
 
    const double psitilde_cs_11_1 = 4*z + 3;
1267
 
    const double psitilde_cs_12_0 = 1;
1268
 
    const double psitilde_cs_20_0 = 1;
1269
 
    const double psitilde_cs_20_1 = 4*z + 3;
1270
 
    const double psitilde_cs_21_0 = 1;
1271
 
    const double psitilde_cs_30_0 = 1;
1272
 
    
1273
 
    // Compute basisvalues
1274
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
1275
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
1276
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
1277
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
1278
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
1279
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
1280
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
1281
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
1282
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
1283
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
1284
 
    const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
1285
 
    const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
1286
 
    const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
1287
 
    const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
1288
 
    const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
1289
 
    const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
1290
 
    const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
1291
 
    const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
1292
 
    const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
1293
 
    const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
1294
 
    
1295
 
    // Table(s) of coefficients
1296
 
    const static double coefficients0[20][20] = \
1297
 
    {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
1298
 
    {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
1299
 
    {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
1300
 
    {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
1301
 
    {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
1302
 
    {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
1303
 
    {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
1304
 
    {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
1305
 
    {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
1306
 
    {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
1307
 
    {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
1308
 
    {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
1309
 
    {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
1310
 
    {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
1311
 
    {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
1312
 
    {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
1313
 
    {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
1314
 
    {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
1315
 
    {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
1316
 
    {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
1317
 
    
1318
 
    // Interesting (new) part
1319
 
    // Tables of derivatives of the polynomial base (transpose)
1320
 
    const static double dmats0[20][20] = \
1321
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1322
 
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1323
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1324
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1325
 
    {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1326
 
    {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1327
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1328
 
    {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1329
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1330
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1331
 
    {5.49909083394701, 0, -3.3466401061363, -2.36643191323985, 15.4919333848297, 0, 0.692820323027551, 0, 0.565685424949239, 0.400000000000001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1332
 
    {0, 4.89897948556636, 0, 0, 0, 14.1985914794391, 0, -0.82807867121083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1333
 
    {3.6, 0, 8.76356092008266, -1.54919333848297, 0, 0, 9.52470471983253, 0, -1.48131215963608, 0.261861468283192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1334
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1335
 
    {0, 4.24264068711928, 0, 0, 0, 0, 0, 14.3427433120127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1336
 
    {3.11769145362398, 0, 3.16227766016838, 4.91934955049954, 0, 0, 0, 0, 10.690449676497, -2.41897262725906, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1337
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1338
 
    {2.54558441227157, 0, 0, 7.66811580507233, 0, 0, 0, 0, 0, 10.3691851174526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1339
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1340
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
1341
 
    
1342
 
    const static double dmats1[20][20] = \
1343
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1344
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1345
 
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1346
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1347
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1348
 
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309959, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1349
 
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1350
 
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1351
 
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1352
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1353
 
    {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.28284271247462, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1354
 
    {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 9.16515138991168, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1355
 
    {1.8, -5.69209978830308, 4.38178046004133, -0.774596669241487, 0, 10.998181667894, 4.76235235991626, 0.962140470884726, -0.740656079818041, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1356
 
    {5.19615242270664, 0, -3.16227766016838, -2.23606797749979, 0, 0, 13.7477270848675, 0, 0.534522483824849, 0.37796447300923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1357
 
    {2.01246117974981, 2.12132034355964, -0.408248290463864, 3.17542648054294, 0, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1358
 
    {1.55884572681199, 2.73861278752583, 1.58113883008419, 2.45967477524977, 0, 0, 0, 9.25820099772551, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1359
 
    {-1.8, 0, 3.65148371670111, -2.84018778721878, 0, 0, 0, 0, 12.3442679969674, 1.39659449751035, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1360
 
    {1.27279220613579, 0, 0, 3.83405790253616, 0, 0, 0, 0, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1361
 
    {2.20454076850486, 0, 0, 6.6407830863536, 0, 0, 0, 0, 0, 8.97997772825746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1362
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
1363
 
    
1364
 
    const static double dmats2[20][20] = \
1365
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1366
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1367
 
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1368
 
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1369
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1370
 
    {2.29128784747792, 1.44913767461895, 4.18330013267038, -0.59160797830996, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1371
 
    {1.32287565553229, 0, 3.86436713231718, -0.341565025531987, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1372
 
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1373
 
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1374
 
    {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1375
 
    {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.282842712474619, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1376
 
    {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 1.30930734141595, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1377
 
    {1.8, 0.632455532033675, 4.38178046004133, -0.774596669241484, 0, 3.14233761939829, 4.76235235991626, -0.10690449676497, -0.740656079818042, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1378
 
    {1.03923048454133, 0, 3.16227766016838, -0.447213595499959, 0, 0, 5.8918830363718, 0, -0.53452248382485, 0.0755928946018459, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1379
 
    {2.01246117974981, 2.12132034355964, -0.408248290463863, 3.17542648054294, 9.07114735222145, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1380
 
    {1.55884572681199, 0.547722557505165, 1.58113883008419, 2.45967477524977, 0, 9.07114735222145, 0, 1.8516401995451, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1381
 
    {0.900000000000001, 0, 1.46059348668045, 1.42009389360939, 0, 0, 9.07114735222145, 0, 4.93770719878694, -0.698297248755175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1382
 
    {1.27279220613578, -6.26099033699941, 0, 3.83405790253616, 0, 0, 0, 10.5830052442584, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1383
 
    {0.734846922834954, 0, -6.26099033699941, 2.21359436211787, 0, 0, 0, 0, 10.5830052442584, 2.99332590941915, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1384
 
    {5.7157676649773, 0, 0, -4.69574275274955, 0, 0, 0, 0, 0, 12.69960629311, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
1385
 
    
1386
 
    // Compute reference derivatives
1387
 
    // Declare pointer to array of derivatives on FIAT element
1388
 
    double *derivatives = new double [num_derivatives];
1389
 
    
1390
 
    // Declare coefficients
1391
 
    double coeff0_0 = 0;
1392
 
    double coeff0_1 = 0;
1393
 
    double coeff0_2 = 0;
1394
 
    double coeff0_3 = 0;
1395
 
    double coeff0_4 = 0;
1396
 
    double coeff0_5 = 0;
1397
 
    double coeff0_6 = 0;
1398
 
    double coeff0_7 = 0;
1399
 
    double coeff0_8 = 0;
1400
 
    double coeff0_9 = 0;
1401
 
    double coeff0_10 = 0;
1402
 
    double coeff0_11 = 0;
1403
 
    double coeff0_12 = 0;
1404
 
    double coeff0_13 = 0;
1405
 
    double coeff0_14 = 0;
1406
 
    double coeff0_15 = 0;
1407
 
    double coeff0_16 = 0;
1408
 
    double coeff0_17 = 0;
1409
 
    double coeff0_18 = 0;
1410
 
    double coeff0_19 = 0;
1411
 
    
1412
 
    // Declare new coefficients
1413
 
    double new_coeff0_0 = 0;
1414
 
    double new_coeff0_1 = 0;
1415
 
    double new_coeff0_2 = 0;
1416
 
    double new_coeff0_3 = 0;
1417
 
    double new_coeff0_4 = 0;
1418
 
    double new_coeff0_5 = 0;
1419
 
    double new_coeff0_6 = 0;
1420
 
    double new_coeff0_7 = 0;
1421
 
    double new_coeff0_8 = 0;
1422
 
    double new_coeff0_9 = 0;
1423
 
    double new_coeff0_10 = 0;
1424
 
    double new_coeff0_11 = 0;
1425
 
    double new_coeff0_12 = 0;
1426
 
    double new_coeff0_13 = 0;
1427
 
    double new_coeff0_14 = 0;
1428
 
    double new_coeff0_15 = 0;
1429
 
    double new_coeff0_16 = 0;
1430
 
    double new_coeff0_17 = 0;
1431
 
    double new_coeff0_18 = 0;
1432
 
    double new_coeff0_19 = 0;
1433
 
    
1434
 
    // Loop possible derivatives
1435
 
    for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
1436
 
    {
1437
 
      // Get values from coefficients array
1438
 
      new_coeff0_0 = coefficients0[dof][0];
1439
 
      new_coeff0_1 = coefficients0[dof][1];
1440
 
      new_coeff0_2 = coefficients0[dof][2];
1441
 
      new_coeff0_3 = coefficients0[dof][3];
1442
 
      new_coeff0_4 = coefficients0[dof][4];
1443
 
      new_coeff0_5 = coefficients0[dof][5];
1444
 
      new_coeff0_6 = coefficients0[dof][6];
1445
 
      new_coeff0_7 = coefficients0[dof][7];
1446
 
      new_coeff0_8 = coefficients0[dof][8];
1447
 
      new_coeff0_9 = coefficients0[dof][9];
1448
 
      new_coeff0_10 = coefficients0[dof][10];
1449
 
      new_coeff0_11 = coefficients0[dof][11];
1450
 
      new_coeff0_12 = coefficients0[dof][12];
1451
 
      new_coeff0_13 = coefficients0[dof][13];
1452
 
      new_coeff0_14 = coefficients0[dof][14];
1453
 
      new_coeff0_15 = coefficients0[dof][15];
1454
 
      new_coeff0_16 = coefficients0[dof][16];
1455
 
      new_coeff0_17 = coefficients0[dof][17];
1456
 
      new_coeff0_18 = coefficients0[dof][18];
1457
 
      new_coeff0_19 = coefficients0[dof][19];
1458
 
    
1459
 
      // Loop derivative order
1460
 
      for (unsigned int j = 0; j < n; j++)
1461
 
      {
1462
 
        // Update old coefficients
1463
 
        coeff0_0 = new_coeff0_0;
1464
 
        coeff0_1 = new_coeff0_1;
1465
 
        coeff0_2 = new_coeff0_2;
1466
 
        coeff0_3 = new_coeff0_3;
1467
 
        coeff0_4 = new_coeff0_4;
1468
 
        coeff0_5 = new_coeff0_5;
1469
 
        coeff0_6 = new_coeff0_6;
1470
 
        coeff0_7 = new_coeff0_7;
1471
 
        coeff0_8 = new_coeff0_8;
1472
 
        coeff0_9 = new_coeff0_9;
1473
 
        coeff0_10 = new_coeff0_10;
1474
 
        coeff0_11 = new_coeff0_11;
1475
 
        coeff0_12 = new_coeff0_12;
1476
 
        coeff0_13 = new_coeff0_13;
1477
 
        coeff0_14 = new_coeff0_14;
1478
 
        coeff0_15 = new_coeff0_15;
1479
 
        coeff0_16 = new_coeff0_16;
1480
 
        coeff0_17 = new_coeff0_17;
1481
 
        coeff0_18 = new_coeff0_18;
1482
 
        coeff0_19 = new_coeff0_19;
1483
 
    
1484
 
        if(combinations[deriv_num][j] == 0)
1485
 
        {
1486
 
          new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0] + coeff0_10*dmats0[10][0] + coeff0_11*dmats0[11][0] + coeff0_12*dmats0[12][0] + coeff0_13*dmats0[13][0] + coeff0_14*dmats0[14][0] + coeff0_15*dmats0[15][0] + coeff0_16*dmats0[16][0] + coeff0_17*dmats0[17][0] + coeff0_18*dmats0[18][0] + coeff0_19*dmats0[19][0];
1487
 
          new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1] + coeff0_10*dmats0[10][1] + coeff0_11*dmats0[11][1] + coeff0_12*dmats0[12][1] + coeff0_13*dmats0[13][1] + coeff0_14*dmats0[14][1] + coeff0_15*dmats0[15][1] + coeff0_16*dmats0[16][1] + coeff0_17*dmats0[17][1] + coeff0_18*dmats0[18][1] + coeff0_19*dmats0[19][1];
1488
 
          new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2] + coeff0_10*dmats0[10][2] + coeff0_11*dmats0[11][2] + coeff0_12*dmats0[12][2] + coeff0_13*dmats0[13][2] + coeff0_14*dmats0[14][2] + coeff0_15*dmats0[15][2] + coeff0_16*dmats0[16][2] + coeff0_17*dmats0[17][2] + coeff0_18*dmats0[18][2] + coeff0_19*dmats0[19][2];
1489
 
          new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3] + coeff0_10*dmats0[10][3] + coeff0_11*dmats0[11][3] + coeff0_12*dmats0[12][3] + coeff0_13*dmats0[13][3] + coeff0_14*dmats0[14][3] + coeff0_15*dmats0[15][3] + coeff0_16*dmats0[16][3] + coeff0_17*dmats0[17][3] + coeff0_18*dmats0[18][3] + coeff0_19*dmats0[19][3];
1490
 
          new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4] + coeff0_10*dmats0[10][4] + coeff0_11*dmats0[11][4] + coeff0_12*dmats0[12][4] + coeff0_13*dmats0[13][4] + coeff0_14*dmats0[14][4] + coeff0_15*dmats0[15][4] + coeff0_16*dmats0[16][4] + coeff0_17*dmats0[17][4] + coeff0_18*dmats0[18][4] + coeff0_19*dmats0[19][4];
1491
 
          new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5] + coeff0_10*dmats0[10][5] + coeff0_11*dmats0[11][5] + coeff0_12*dmats0[12][5] + coeff0_13*dmats0[13][5] + coeff0_14*dmats0[14][5] + coeff0_15*dmats0[15][5] + coeff0_16*dmats0[16][5] + coeff0_17*dmats0[17][5] + coeff0_18*dmats0[18][5] + coeff0_19*dmats0[19][5];
1492
 
          new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6] + coeff0_10*dmats0[10][6] + coeff0_11*dmats0[11][6] + coeff0_12*dmats0[12][6] + coeff0_13*dmats0[13][6] + coeff0_14*dmats0[14][6] + coeff0_15*dmats0[15][6] + coeff0_16*dmats0[16][6] + coeff0_17*dmats0[17][6] + coeff0_18*dmats0[18][6] + coeff0_19*dmats0[19][6];
1493
 
          new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7] + coeff0_10*dmats0[10][7] + coeff0_11*dmats0[11][7] + coeff0_12*dmats0[12][7] + coeff0_13*dmats0[13][7] + coeff0_14*dmats0[14][7] + coeff0_15*dmats0[15][7] + coeff0_16*dmats0[16][7] + coeff0_17*dmats0[17][7] + coeff0_18*dmats0[18][7] + coeff0_19*dmats0[19][7];
1494
 
          new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8] + coeff0_10*dmats0[10][8] + coeff0_11*dmats0[11][8] + coeff0_12*dmats0[12][8] + coeff0_13*dmats0[13][8] + coeff0_14*dmats0[14][8] + coeff0_15*dmats0[15][8] + coeff0_16*dmats0[16][8] + coeff0_17*dmats0[17][8] + coeff0_18*dmats0[18][8] + coeff0_19*dmats0[19][8];
1495
 
          new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9] + coeff0_10*dmats0[10][9] + coeff0_11*dmats0[11][9] + coeff0_12*dmats0[12][9] + coeff0_13*dmats0[13][9] + coeff0_14*dmats0[14][9] + coeff0_15*dmats0[15][9] + coeff0_16*dmats0[16][9] + coeff0_17*dmats0[17][9] + coeff0_18*dmats0[18][9] + coeff0_19*dmats0[19][9];
1496
 
          new_coeff0_10 = coeff0_0*dmats0[0][10] + coeff0_1*dmats0[1][10] + coeff0_2*dmats0[2][10] + coeff0_3*dmats0[3][10] + coeff0_4*dmats0[4][10] + coeff0_5*dmats0[5][10] + coeff0_6*dmats0[6][10] + coeff0_7*dmats0[7][10] + coeff0_8*dmats0[8][10] + coeff0_9*dmats0[9][10] + coeff0_10*dmats0[10][10] + coeff0_11*dmats0[11][10] + coeff0_12*dmats0[12][10] + coeff0_13*dmats0[13][10] + coeff0_14*dmats0[14][10] + coeff0_15*dmats0[15][10] + coeff0_16*dmats0[16][10] + coeff0_17*dmats0[17][10] + coeff0_18*dmats0[18][10] + coeff0_19*dmats0[19][10];
1497
 
          new_coeff0_11 = coeff0_0*dmats0[0][11] + coeff0_1*dmats0[1][11] + coeff0_2*dmats0[2][11] + coeff0_3*dmats0[3][11] + coeff0_4*dmats0[4][11] + coeff0_5*dmats0[5][11] + coeff0_6*dmats0[6][11] + coeff0_7*dmats0[7][11] + coeff0_8*dmats0[8][11] + coeff0_9*dmats0[9][11] + coeff0_10*dmats0[10][11] + coeff0_11*dmats0[11][11] + coeff0_12*dmats0[12][11] + coeff0_13*dmats0[13][11] + coeff0_14*dmats0[14][11] + coeff0_15*dmats0[15][11] + coeff0_16*dmats0[16][11] + coeff0_17*dmats0[17][11] + coeff0_18*dmats0[18][11] + coeff0_19*dmats0[19][11];
1498
 
          new_coeff0_12 = coeff0_0*dmats0[0][12] + coeff0_1*dmats0[1][12] + coeff0_2*dmats0[2][12] + coeff0_3*dmats0[3][12] + coeff0_4*dmats0[4][12] + coeff0_5*dmats0[5][12] + coeff0_6*dmats0[6][12] + coeff0_7*dmats0[7][12] + coeff0_8*dmats0[8][12] + coeff0_9*dmats0[9][12] + coeff0_10*dmats0[10][12] + coeff0_11*dmats0[11][12] + coeff0_12*dmats0[12][12] + coeff0_13*dmats0[13][12] + coeff0_14*dmats0[14][12] + coeff0_15*dmats0[15][12] + coeff0_16*dmats0[16][12] + coeff0_17*dmats0[17][12] + coeff0_18*dmats0[18][12] + coeff0_19*dmats0[19][12];
1499
 
          new_coeff0_13 = coeff0_0*dmats0[0][13] + coeff0_1*dmats0[1][13] + coeff0_2*dmats0[2][13] + coeff0_3*dmats0[3][13] + coeff0_4*dmats0[4][13] + coeff0_5*dmats0[5][13] + coeff0_6*dmats0[6][13] + coeff0_7*dmats0[7][13] + coeff0_8*dmats0[8][13] + coeff0_9*dmats0[9][13] + coeff0_10*dmats0[10][13] + coeff0_11*dmats0[11][13] + coeff0_12*dmats0[12][13] + coeff0_13*dmats0[13][13] + coeff0_14*dmats0[14][13] + coeff0_15*dmats0[15][13] + coeff0_16*dmats0[16][13] + coeff0_17*dmats0[17][13] + coeff0_18*dmats0[18][13] + coeff0_19*dmats0[19][13];
1500
 
          new_coeff0_14 = coeff0_0*dmats0[0][14] + coeff0_1*dmats0[1][14] + coeff0_2*dmats0[2][14] + coeff0_3*dmats0[3][14] + coeff0_4*dmats0[4][14] + coeff0_5*dmats0[5][14] + coeff0_6*dmats0[6][14] + coeff0_7*dmats0[7][14] + coeff0_8*dmats0[8][14] + coeff0_9*dmats0[9][14] + coeff0_10*dmats0[10][14] + coeff0_11*dmats0[11][14] + coeff0_12*dmats0[12][14] + coeff0_13*dmats0[13][14] + coeff0_14*dmats0[14][14] + coeff0_15*dmats0[15][14] + coeff0_16*dmats0[16][14] + coeff0_17*dmats0[17][14] + coeff0_18*dmats0[18][14] + coeff0_19*dmats0[19][14];
1501
 
          new_coeff0_15 = coeff0_0*dmats0[0][15] + coeff0_1*dmats0[1][15] + coeff0_2*dmats0[2][15] + coeff0_3*dmats0[3][15] + coeff0_4*dmats0[4][15] + coeff0_5*dmats0[5][15] + coeff0_6*dmats0[6][15] + coeff0_7*dmats0[7][15] + coeff0_8*dmats0[8][15] + coeff0_9*dmats0[9][15] + coeff0_10*dmats0[10][15] + coeff0_11*dmats0[11][15] + coeff0_12*dmats0[12][15] + coeff0_13*dmats0[13][15] + coeff0_14*dmats0[14][15] + coeff0_15*dmats0[15][15] + coeff0_16*dmats0[16][15] + coeff0_17*dmats0[17][15] + coeff0_18*dmats0[18][15] + coeff0_19*dmats0[19][15];
1502
 
          new_coeff0_16 = coeff0_0*dmats0[0][16] + coeff0_1*dmats0[1][16] + coeff0_2*dmats0[2][16] + coeff0_3*dmats0[3][16] + coeff0_4*dmats0[4][16] + coeff0_5*dmats0[5][16] + coeff0_6*dmats0[6][16] + coeff0_7*dmats0[7][16] + coeff0_8*dmats0[8][16] + coeff0_9*dmats0[9][16] + coeff0_10*dmats0[10][16] + coeff0_11*dmats0[11][16] + coeff0_12*dmats0[12][16] + coeff0_13*dmats0[13][16] + coeff0_14*dmats0[14][16] + coeff0_15*dmats0[15][16] + coeff0_16*dmats0[16][16] + coeff0_17*dmats0[17][16] + coeff0_18*dmats0[18][16] + coeff0_19*dmats0[19][16];
1503
 
          new_coeff0_17 = coeff0_0*dmats0[0][17] + coeff0_1*dmats0[1][17] + coeff0_2*dmats0[2][17] + coeff0_3*dmats0[3][17] + coeff0_4*dmats0[4][17] + coeff0_5*dmats0[5][17] + coeff0_6*dmats0[6][17] + coeff0_7*dmats0[7][17] + coeff0_8*dmats0[8][17] + coeff0_9*dmats0[9][17] + coeff0_10*dmats0[10][17] + coeff0_11*dmats0[11][17] + coeff0_12*dmats0[12][17] + coeff0_13*dmats0[13][17] + coeff0_14*dmats0[14][17] + coeff0_15*dmats0[15][17] + coeff0_16*dmats0[16][17] + coeff0_17*dmats0[17][17] + coeff0_18*dmats0[18][17] + coeff0_19*dmats0[19][17];
1504
 
          new_coeff0_18 = coeff0_0*dmats0[0][18] + coeff0_1*dmats0[1][18] + coeff0_2*dmats0[2][18] + coeff0_3*dmats0[3][18] + coeff0_4*dmats0[4][18] + coeff0_5*dmats0[5][18] + coeff0_6*dmats0[6][18] + coeff0_7*dmats0[7][18] + coeff0_8*dmats0[8][18] + coeff0_9*dmats0[9][18] + coeff0_10*dmats0[10][18] + coeff0_11*dmats0[11][18] + coeff0_12*dmats0[12][18] + coeff0_13*dmats0[13][18] + coeff0_14*dmats0[14][18] + coeff0_15*dmats0[15][18] + coeff0_16*dmats0[16][18] + coeff0_17*dmats0[17][18] + coeff0_18*dmats0[18][18] + coeff0_19*dmats0[19][18];
1505
 
          new_coeff0_19 = coeff0_0*dmats0[0][19] + coeff0_1*dmats0[1][19] + coeff0_2*dmats0[2][19] + coeff0_3*dmats0[3][19] + coeff0_4*dmats0[4][19] + coeff0_5*dmats0[5][19] + coeff0_6*dmats0[6][19] + coeff0_7*dmats0[7][19] + coeff0_8*dmats0[8][19] + coeff0_9*dmats0[9][19] + coeff0_10*dmats0[10][19] + coeff0_11*dmats0[11][19] + coeff0_12*dmats0[12][19] + coeff0_13*dmats0[13][19] + coeff0_14*dmats0[14][19] + coeff0_15*dmats0[15][19] + coeff0_16*dmats0[16][19] + coeff0_17*dmats0[17][19] + coeff0_18*dmats0[18][19] + coeff0_19*dmats0[19][19];
1506
 
        }
1507
 
        if(combinations[deriv_num][j] == 1)
1508
 
        {
1509
 
          new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0] + coeff0_10*dmats1[10][0] + coeff0_11*dmats1[11][0] + coeff0_12*dmats1[12][0] + coeff0_13*dmats1[13][0] + coeff0_14*dmats1[14][0] + coeff0_15*dmats1[15][0] + coeff0_16*dmats1[16][0] + coeff0_17*dmats1[17][0] + coeff0_18*dmats1[18][0] + coeff0_19*dmats1[19][0];
1510
 
          new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1] + coeff0_10*dmats1[10][1] + coeff0_11*dmats1[11][1] + coeff0_12*dmats1[12][1] + coeff0_13*dmats1[13][1] + coeff0_14*dmats1[14][1] + coeff0_15*dmats1[15][1] + coeff0_16*dmats1[16][1] + coeff0_17*dmats1[17][1] + coeff0_18*dmats1[18][1] + coeff0_19*dmats1[19][1];
1511
 
          new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2] + coeff0_10*dmats1[10][2] + coeff0_11*dmats1[11][2] + coeff0_12*dmats1[12][2] + coeff0_13*dmats1[13][2] + coeff0_14*dmats1[14][2] + coeff0_15*dmats1[15][2] + coeff0_16*dmats1[16][2] + coeff0_17*dmats1[17][2] + coeff0_18*dmats1[18][2] + coeff0_19*dmats1[19][2];
1512
 
          new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3] + coeff0_10*dmats1[10][3] + coeff0_11*dmats1[11][3] + coeff0_12*dmats1[12][3] + coeff0_13*dmats1[13][3] + coeff0_14*dmats1[14][3] + coeff0_15*dmats1[15][3] + coeff0_16*dmats1[16][3] + coeff0_17*dmats1[17][3] + coeff0_18*dmats1[18][3] + coeff0_19*dmats1[19][3];
1513
 
          new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4] + coeff0_10*dmats1[10][4] + coeff0_11*dmats1[11][4] + coeff0_12*dmats1[12][4] + coeff0_13*dmats1[13][4] + coeff0_14*dmats1[14][4] + coeff0_15*dmats1[15][4] + coeff0_16*dmats1[16][4] + coeff0_17*dmats1[17][4] + coeff0_18*dmats1[18][4] + coeff0_19*dmats1[19][4];
1514
 
          new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5] + coeff0_10*dmats1[10][5] + coeff0_11*dmats1[11][5] + coeff0_12*dmats1[12][5] + coeff0_13*dmats1[13][5] + coeff0_14*dmats1[14][5] + coeff0_15*dmats1[15][5] + coeff0_16*dmats1[16][5] + coeff0_17*dmats1[17][5] + coeff0_18*dmats1[18][5] + coeff0_19*dmats1[19][5];
1515
 
          new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6] + coeff0_10*dmats1[10][6] + coeff0_11*dmats1[11][6] + coeff0_12*dmats1[12][6] + coeff0_13*dmats1[13][6] + coeff0_14*dmats1[14][6] + coeff0_15*dmats1[15][6] + coeff0_16*dmats1[16][6] + coeff0_17*dmats1[17][6] + coeff0_18*dmats1[18][6] + coeff0_19*dmats1[19][6];
1516
 
          new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7] + coeff0_10*dmats1[10][7] + coeff0_11*dmats1[11][7] + coeff0_12*dmats1[12][7] + coeff0_13*dmats1[13][7] + coeff0_14*dmats1[14][7] + coeff0_15*dmats1[15][7] + coeff0_16*dmats1[16][7] + coeff0_17*dmats1[17][7] + coeff0_18*dmats1[18][7] + coeff0_19*dmats1[19][7];
1517
 
          new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8] + coeff0_10*dmats1[10][8] + coeff0_11*dmats1[11][8] + coeff0_12*dmats1[12][8] + coeff0_13*dmats1[13][8] + coeff0_14*dmats1[14][8] + coeff0_15*dmats1[15][8] + coeff0_16*dmats1[16][8] + coeff0_17*dmats1[17][8] + coeff0_18*dmats1[18][8] + coeff0_19*dmats1[19][8];
1518
 
          new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9] + coeff0_10*dmats1[10][9] + coeff0_11*dmats1[11][9] + coeff0_12*dmats1[12][9] + coeff0_13*dmats1[13][9] + coeff0_14*dmats1[14][9] + coeff0_15*dmats1[15][9] + coeff0_16*dmats1[16][9] + coeff0_17*dmats1[17][9] + coeff0_18*dmats1[18][9] + coeff0_19*dmats1[19][9];
1519
 
          new_coeff0_10 = coeff0_0*dmats1[0][10] + coeff0_1*dmats1[1][10] + coeff0_2*dmats1[2][10] + coeff0_3*dmats1[3][10] + coeff0_4*dmats1[4][10] + coeff0_5*dmats1[5][10] + coeff0_6*dmats1[6][10] + coeff0_7*dmats1[7][10] + coeff0_8*dmats1[8][10] + coeff0_9*dmats1[9][10] + coeff0_10*dmats1[10][10] + coeff0_11*dmats1[11][10] + coeff0_12*dmats1[12][10] + coeff0_13*dmats1[13][10] + coeff0_14*dmats1[14][10] + coeff0_15*dmats1[15][10] + coeff0_16*dmats1[16][10] + coeff0_17*dmats1[17][10] + coeff0_18*dmats1[18][10] + coeff0_19*dmats1[19][10];
1520
 
          new_coeff0_11 = coeff0_0*dmats1[0][11] + coeff0_1*dmats1[1][11] + coeff0_2*dmats1[2][11] + coeff0_3*dmats1[3][11] + coeff0_4*dmats1[4][11] + coeff0_5*dmats1[5][11] + coeff0_6*dmats1[6][11] + coeff0_7*dmats1[7][11] + coeff0_8*dmats1[8][11] + coeff0_9*dmats1[9][11] + coeff0_10*dmats1[10][11] + coeff0_11*dmats1[11][11] + coeff0_12*dmats1[12][11] + coeff0_13*dmats1[13][11] + coeff0_14*dmats1[14][11] + coeff0_15*dmats1[15][11] + coeff0_16*dmats1[16][11] + coeff0_17*dmats1[17][11] + coeff0_18*dmats1[18][11] + coeff0_19*dmats1[19][11];
1521
 
          new_coeff0_12 = coeff0_0*dmats1[0][12] + coeff0_1*dmats1[1][12] + coeff0_2*dmats1[2][12] + coeff0_3*dmats1[3][12] + coeff0_4*dmats1[4][12] + coeff0_5*dmats1[5][12] + coeff0_6*dmats1[6][12] + coeff0_7*dmats1[7][12] + coeff0_8*dmats1[8][12] + coeff0_9*dmats1[9][12] + coeff0_10*dmats1[10][12] + coeff0_11*dmats1[11][12] + coeff0_12*dmats1[12][12] + coeff0_13*dmats1[13][12] + coeff0_14*dmats1[14][12] + coeff0_15*dmats1[15][12] + coeff0_16*dmats1[16][12] + coeff0_17*dmats1[17][12] + coeff0_18*dmats1[18][12] + coeff0_19*dmats1[19][12];
1522
 
          new_coeff0_13 = coeff0_0*dmats1[0][13] + coeff0_1*dmats1[1][13] + coeff0_2*dmats1[2][13] + coeff0_3*dmats1[3][13] + coeff0_4*dmats1[4][13] + coeff0_5*dmats1[5][13] + coeff0_6*dmats1[6][13] + coeff0_7*dmats1[7][13] + coeff0_8*dmats1[8][13] + coeff0_9*dmats1[9][13] + coeff0_10*dmats1[10][13] + coeff0_11*dmats1[11][13] + coeff0_12*dmats1[12][13] + coeff0_13*dmats1[13][13] + coeff0_14*dmats1[14][13] + coeff0_15*dmats1[15][13] + coeff0_16*dmats1[16][13] + coeff0_17*dmats1[17][13] + coeff0_18*dmats1[18][13] + coeff0_19*dmats1[19][13];
1523
 
          new_coeff0_14 = coeff0_0*dmats1[0][14] + coeff0_1*dmats1[1][14] + coeff0_2*dmats1[2][14] + coeff0_3*dmats1[3][14] + coeff0_4*dmats1[4][14] + coeff0_5*dmats1[5][14] + coeff0_6*dmats1[6][14] + coeff0_7*dmats1[7][14] + coeff0_8*dmats1[8][14] + coeff0_9*dmats1[9][14] + coeff0_10*dmats1[10][14] + coeff0_11*dmats1[11][14] + coeff0_12*dmats1[12][14] + coeff0_13*dmats1[13][14] + coeff0_14*dmats1[14][14] + coeff0_15*dmats1[15][14] + coeff0_16*dmats1[16][14] + coeff0_17*dmats1[17][14] + coeff0_18*dmats1[18][14] + coeff0_19*dmats1[19][14];
1524
 
          new_coeff0_15 = coeff0_0*dmats1[0][15] + coeff0_1*dmats1[1][15] + coeff0_2*dmats1[2][15] + coeff0_3*dmats1[3][15] + coeff0_4*dmats1[4][15] + coeff0_5*dmats1[5][15] + coeff0_6*dmats1[6][15] + coeff0_7*dmats1[7][15] + coeff0_8*dmats1[8][15] + coeff0_9*dmats1[9][15] + coeff0_10*dmats1[10][15] + coeff0_11*dmats1[11][15] + coeff0_12*dmats1[12][15] + coeff0_13*dmats1[13][15] + coeff0_14*dmats1[14][15] + coeff0_15*dmats1[15][15] + coeff0_16*dmats1[16][15] + coeff0_17*dmats1[17][15] + coeff0_18*dmats1[18][15] + coeff0_19*dmats1[19][15];
1525
 
          new_coeff0_16 = coeff0_0*dmats1[0][16] + coeff0_1*dmats1[1][16] + coeff0_2*dmats1[2][16] + coeff0_3*dmats1[3][16] + coeff0_4*dmats1[4][16] + coeff0_5*dmats1[5][16] + coeff0_6*dmats1[6][16] + coeff0_7*dmats1[7][16] + coeff0_8*dmats1[8][16] + coeff0_9*dmats1[9][16] + coeff0_10*dmats1[10][16] + coeff0_11*dmats1[11][16] + coeff0_12*dmats1[12][16] + coeff0_13*dmats1[13][16] + coeff0_14*dmats1[14][16] + coeff0_15*dmats1[15][16] + coeff0_16*dmats1[16][16] + coeff0_17*dmats1[17][16] + coeff0_18*dmats1[18][16] + coeff0_19*dmats1[19][16];
1526
 
          new_coeff0_17 = coeff0_0*dmats1[0][17] + coeff0_1*dmats1[1][17] + coeff0_2*dmats1[2][17] + coeff0_3*dmats1[3][17] + coeff0_4*dmats1[4][17] + coeff0_5*dmats1[5][17] + coeff0_6*dmats1[6][17] + coeff0_7*dmats1[7][17] + coeff0_8*dmats1[8][17] + coeff0_9*dmats1[9][17] + coeff0_10*dmats1[10][17] + coeff0_11*dmats1[11][17] + coeff0_12*dmats1[12][17] + coeff0_13*dmats1[13][17] + coeff0_14*dmats1[14][17] + coeff0_15*dmats1[15][17] + coeff0_16*dmats1[16][17] + coeff0_17*dmats1[17][17] + coeff0_18*dmats1[18][17] + coeff0_19*dmats1[19][17];
1527
 
          new_coeff0_18 = coeff0_0*dmats1[0][18] + coeff0_1*dmats1[1][18] + coeff0_2*dmats1[2][18] + coeff0_3*dmats1[3][18] + coeff0_4*dmats1[4][18] + coeff0_5*dmats1[5][18] + coeff0_6*dmats1[6][18] + coeff0_7*dmats1[7][18] + coeff0_8*dmats1[8][18] + coeff0_9*dmats1[9][18] + coeff0_10*dmats1[10][18] + coeff0_11*dmats1[11][18] + coeff0_12*dmats1[12][18] + coeff0_13*dmats1[13][18] + coeff0_14*dmats1[14][18] + coeff0_15*dmats1[15][18] + coeff0_16*dmats1[16][18] + coeff0_17*dmats1[17][18] + coeff0_18*dmats1[18][18] + coeff0_19*dmats1[19][18];
1528
 
          new_coeff0_19 = coeff0_0*dmats1[0][19] + coeff0_1*dmats1[1][19] + coeff0_2*dmats1[2][19] + coeff0_3*dmats1[3][19] + coeff0_4*dmats1[4][19] + coeff0_5*dmats1[5][19] + coeff0_6*dmats1[6][19] + coeff0_7*dmats1[7][19] + coeff0_8*dmats1[8][19] + coeff0_9*dmats1[9][19] + coeff0_10*dmats1[10][19] + coeff0_11*dmats1[11][19] + coeff0_12*dmats1[12][19] + coeff0_13*dmats1[13][19] + coeff0_14*dmats1[14][19] + coeff0_15*dmats1[15][19] + coeff0_16*dmats1[16][19] + coeff0_17*dmats1[17][19] + coeff0_18*dmats1[18][19] + coeff0_19*dmats1[19][19];
1529
 
        }
1530
 
        if(combinations[deriv_num][j] == 2)
1531
 
        {
1532
 
          new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0] + coeff0_10*dmats2[10][0] + coeff0_11*dmats2[11][0] + coeff0_12*dmats2[12][0] + coeff0_13*dmats2[13][0] + coeff0_14*dmats2[14][0] + coeff0_15*dmats2[15][0] + coeff0_16*dmats2[16][0] + coeff0_17*dmats2[17][0] + coeff0_18*dmats2[18][0] + coeff0_19*dmats2[19][0];
1533
 
          new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1] + coeff0_10*dmats2[10][1] + coeff0_11*dmats2[11][1] + coeff0_12*dmats2[12][1] + coeff0_13*dmats2[13][1] + coeff0_14*dmats2[14][1] + coeff0_15*dmats2[15][1] + coeff0_16*dmats2[16][1] + coeff0_17*dmats2[17][1] + coeff0_18*dmats2[18][1] + coeff0_19*dmats2[19][1];
1534
 
          new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2] + coeff0_10*dmats2[10][2] + coeff0_11*dmats2[11][2] + coeff0_12*dmats2[12][2] + coeff0_13*dmats2[13][2] + coeff0_14*dmats2[14][2] + coeff0_15*dmats2[15][2] + coeff0_16*dmats2[16][2] + coeff0_17*dmats2[17][2] + coeff0_18*dmats2[18][2] + coeff0_19*dmats2[19][2];
1535
 
          new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3] + coeff0_10*dmats2[10][3] + coeff0_11*dmats2[11][3] + coeff0_12*dmats2[12][3] + coeff0_13*dmats2[13][3] + coeff0_14*dmats2[14][3] + coeff0_15*dmats2[15][3] + coeff0_16*dmats2[16][3] + coeff0_17*dmats2[17][3] + coeff0_18*dmats2[18][3] + coeff0_19*dmats2[19][3];
1536
 
          new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4] + coeff0_10*dmats2[10][4] + coeff0_11*dmats2[11][4] + coeff0_12*dmats2[12][4] + coeff0_13*dmats2[13][4] + coeff0_14*dmats2[14][4] + coeff0_15*dmats2[15][4] + coeff0_16*dmats2[16][4] + coeff0_17*dmats2[17][4] + coeff0_18*dmats2[18][4] + coeff0_19*dmats2[19][4];
1537
 
          new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5] + coeff0_10*dmats2[10][5] + coeff0_11*dmats2[11][5] + coeff0_12*dmats2[12][5] + coeff0_13*dmats2[13][5] + coeff0_14*dmats2[14][5] + coeff0_15*dmats2[15][5] + coeff0_16*dmats2[16][5] + coeff0_17*dmats2[17][5] + coeff0_18*dmats2[18][5] + coeff0_19*dmats2[19][5];
1538
 
          new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6] + coeff0_10*dmats2[10][6] + coeff0_11*dmats2[11][6] + coeff0_12*dmats2[12][6] + coeff0_13*dmats2[13][6] + coeff0_14*dmats2[14][6] + coeff0_15*dmats2[15][6] + coeff0_16*dmats2[16][6] + coeff0_17*dmats2[17][6] + coeff0_18*dmats2[18][6] + coeff0_19*dmats2[19][6];
1539
 
          new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7] + coeff0_10*dmats2[10][7] + coeff0_11*dmats2[11][7] + coeff0_12*dmats2[12][7] + coeff0_13*dmats2[13][7] + coeff0_14*dmats2[14][7] + coeff0_15*dmats2[15][7] + coeff0_16*dmats2[16][7] + coeff0_17*dmats2[17][7] + coeff0_18*dmats2[18][7] + coeff0_19*dmats2[19][7];
1540
 
          new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8] + coeff0_10*dmats2[10][8] + coeff0_11*dmats2[11][8] + coeff0_12*dmats2[12][8] + coeff0_13*dmats2[13][8] + coeff0_14*dmats2[14][8] + coeff0_15*dmats2[15][8] + coeff0_16*dmats2[16][8] + coeff0_17*dmats2[17][8] + coeff0_18*dmats2[18][8] + coeff0_19*dmats2[19][8];
1541
 
          new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9] + coeff0_10*dmats2[10][9] + coeff0_11*dmats2[11][9] + coeff0_12*dmats2[12][9] + coeff0_13*dmats2[13][9] + coeff0_14*dmats2[14][9] + coeff0_15*dmats2[15][9] + coeff0_16*dmats2[16][9] + coeff0_17*dmats2[17][9] + coeff0_18*dmats2[18][9] + coeff0_19*dmats2[19][9];
1542
 
          new_coeff0_10 = coeff0_0*dmats2[0][10] + coeff0_1*dmats2[1][10] + coeff0_2*dmats2[2][10] + coeff0_3*dmats2[3][10] + coeff0_4*dmats2[4][10] + coeff0_5*dmats2[5][10] + coeff0_6*dmats2[6][10] + coeff0_7*dmats2[7][10] + coeff0_8*dmats2[8][10] + coeff0_9*dmats2[9][10] + coeff0_10*dmats2[10][10] + coeff0_11*dmats2[11][10] + coeff0_12*dmats2[12][10] + coeff0_13*dmats2[13][10] + coeff0_14*dmats2[14][10] + coeff0_15*dmats2[15][10] + coeff0_16*dmats2[16][10] + coeff0_17*dmats2[17][10] + coeff0_18*dmats2[18][10] + coeff0_19*dmats2[19][10];
1543
 
          new_coeff0_11 = coeff0_0*dmats2[0][11] + coeff0_1*dmats2[1][11] + coeff0_2*dmats2[2][11] + coeff0_3*dmats2[3][11] + coeff0_4*dmats2[4][11] + coeff0_5*dmats2[5][11] + coeff0_6*dmats2[6][11] + coeff0_7*dmats2[7][11] + coeff0_8*dmats2[8][11] + coeff0_9*dmats2[9][11] + coeff0_10*dmats2[10][11] + coeff0_11*dmats2[11][11] + coeff0_12*dmats2[12][11] + coeff0_13*dmats2[13][11] + coeff0_14*dmats2[14][11] + coeff0_15*dmats2[15][11] + coeff0_16*dmats2[16][11] + coeff0_17*dmats2[17][11] + coeff0_18*dmats2[18][11] + coeff0_19*dmats2[19][11];
1544
 
          new_coeff0_12 = coeff0_0*dmats2[0][12] + coeff0_1*dmats2[1][12] + coeff0_2*dmats2[2][12] + coeff0_3*dmats2[3][12] + coeff0_4*dmats2[4][12] + coeff0_5*dmats2[5][12] + coeff0_6*dmats2[6][12] + coeff0_7*dmats2[7][12] + coeff0_8*dmats2[8][12] + coeff0_9*dmats2[9][12] + coeff0_10*dmats2[10][12] + coeff0_11*dmats2[11][12] + coeff0_12*dmats2[12][12] + coeff0_13*dmats2[13][12] + coeff0_14*dmats2[14][12] + coeff0_15*dmats2[15][12] + coeff0_16*dmats2[16][12] + coeff0_17*dmats2[17][12] + coeff0_18*dmats2[18][12] + coeff0_19*dmats2[19][12];
1545
 
          new_coeff0_13 = coeff0_0*dmats2[0][13] + coeff0_1*dmats2[1][13] + coeff0_2*dmats2[2][13] + coeff0_3*dmats2[3][13] + coeff0_4*dmats2[4][13] + coeff0_5*dmats2[5][13] + coeff0_6*dmats2[6][13] + coeff0_7*dmats2[7][13] + coeff0_8*dmats2[8][13] + coeff0_9*dmats2[9][13] + coeff0_10*dmats2[10][13] + coeff0_11*dmats2[11][13] + coeff0_12*dmats2[12][13] + coeff0_13*dmats2[13][13] + coeff0_14*dmats2[14][13] + coeff0_15*dmats2[15][13] + coeff0_16*dmats2[16][13] + coeff0_17*dmats2[17][13] + coeff0_18*dmats2[18][13] + coeff0_19*dmats2[19][13];
1546
 
          new_coeff0_14 = coeff0_0*dmats2[0][14] + coeff0_1*dmats2[1][14] + coeff0_2*dmats2[2][14] + coeff0_3*dmats2[3][14] + coeff0_4*dmats2[4][14] + coeff0_5*dmats2[5][14] + coeff0_6*dmats2[6][14] + coeff0_7*dmats2[7][14] + coeff0_8*dmats2[8][14] + coeff0_9*dmats2[9][14] + coeff0_10*dmats2[10][14] + coeff0_11*dmats2[11][14] + coeff0_12*dmats2[12][14] + coeff0_13*dmats2[13][14] + coeff0_14*dmats2[14][14] + coeff0_15*dmats2[15][14] + coeff0_16*dmats2[16][14] + coeff0_17*dmats2[17][14] + coeff0_18*dmats2[18][14] + coeff0_19*dmats2[19][14];
1547
 
          new_coeff0_15 = coeff0_0*dmats2[0][15] + coeff0_1*dmats2[1][15] + coeff0_2*dmats2[2][15] + coeff0_3*dmats2[3][15] + coeff0_4*dmats2[4][15] + coeff0_5*dmats2[5][15] + coeff0_6*dmats2[6][15] + coeff0_7*dmats2[7][15] + coeff0_8*dmats2[8][15] + coeff0_9*dmats2[9][15] + coeff0_10*dmats2[10][15] + coeff0_11*dmats2[11][15] + coeff0_12*dmats2[12][15] + coeff0_13*dmats2[13][15] + coeff0_14*dmats2[14][15] + coeff0_15*dmats2[15][15] + coeff0_16*dmats2[16][15] + coeff0_17*dmats2[17][15] + coeff0_18*dmats2[18][15] + coeff0_19*dmats2[19][15];
1548
 
          new_coeff0_16 = coeff0_0*dmats2[0][16] + coeff0_1*dmats2[1][16] + coeff0_2*dmats2[2][16] + coeff0_3*dmats2[3][16] + coeff0_4*dmats2[4][16] + coeff0_5*dmats2[5][16] + coeff0_6*dmats2[6][16] + coeff0_7*dmats2[7][16] + coeff0_8*dmats2[8][16] + coeff0_9*dmats2[9][16] + coeff0_10*dmats2[10][16] + coeff0_11*dmats2[11][16] + coeff0_12*dmats2[12][16] + coeff0_13*dmats2[13][16] + coeff0_14*dmats2[14][16] + coeff0_15*dmats2[15][16] + coeff0_16*dmats2[16][16] + coeff0_17*dmats2[17][16] + coeff0_18*dmats2[18][16] + coeff0_19*dmats2[19][16];
1549
 
          new_coeff0_17 = coeff0_0*dmats2[0][17] + coeff0_1*dmats2[1][17] + coeff0_2*dmats2[2][17] + coeff0_3*dmats2[3][17] + coeff0_4*dmats2[4][17] + coeff0_5*dmats2[5][17] + coeff0_6*dmats2[6][17] + coeff0_7*dmats2[7][17] + coeff0_8*dmats2[8][17] + coeff0_9*dmats2[9][17] + coeff0_10*dmats2[10][17] + coeff0_11*dmats2[11][17] + coeff0_12*dmats2[12][17] + coeff0_13*dmats2[13][17] + coeff0_14*dmats2[14][17] + coeff0_15*dmats2[15][17] + coeff0_16*dmats2[16][17] + coeff0_17*dmats2[17][17] + coeff0_18*dmats2[18][17] + coeff0_19*dmats2[19][17];
1550
 
          new_coeff0_18 = coeff0_0*dmats2[0][18] + coeff0_1*dmats2[1][18] + coeff0_2*dmats2[2][18] + coeff0_3*dmats2[3][18] + coeff0_4*dmats2[4][18] + coeff0_5*dmats2[5][18] + coeff0_6*dmats2[6][18] + coeff0_7*dmats2[7][18] + coeff0_8*dmats2[8][18] + coeff0_9*dmats2[9][18] + coeff0_10*dmats2[10][18] + coeff0_11*dmats2[11][18] + coeff0_12*dmats2[12][18] + coeff0_13*dmats2[13][18] + coeff0_14*dmats2[14][18] + coeff0_15*dmats2[15][18] + coeff0_16*dmats2[16][18] + coeff0_17*dmats2[17][18] + coeff0_18*dmats2[18][18] + coeff0_19*dmats2[19][18];
1551
 
          new_coeff0_19 = coeff0_0*dmats2[0][19] + coeff0_1*dmats2[1][19] + coeff0_2*dmats2[2][19] + coeff0_3*dmats2[3][19] + coeff0_4*dmats2[4][19] + coeff0_5*dmats2[5][19] + coeff0_6*dmats2[6][19] + coeff0_7*dmats2[7][19] + coeff0_8*dmats2[8][19] + coeff0_9*dmats2[9][19] + coeff0_10*dmats2[10][19] + coeff0_11*dmats2[11][19] + coeff0_12*dmats2[12][19] + coeff0_13*dmats2[13][19] + coeff0_14*dmats2[14][19] + coeff0_15*dmats2[15][19] + coeff0_16*dmats2[16][19] + coeff0_17*dmats2[17][19] + coeff0_18*dmats2[18][19] + coeff0_19*dmats2[19][19];
1552
 
        }
1553
 
    
1554
 
      }
1555
 
      // Compute derivatives on reference element as dot product of coefficients and basisvalues
1556
 
      derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9 + new_coeff0_10*basisvalue10 + new_coeff0_11*basisvalue11 + new_coeff0_12*basisvalue12 + new_coeff0_13*basisvalue13 + new_coeff0_14*basisvalue14 + new_coeff0_15*basisvalue15 + new_coeff0_16*basisvalue16 + new_coeff0_17*basisvalue17 + new_coeff0_18*basisvalue18 + new_coeff0_19*basisvalue19;
1557
 
    }
1558
 
    
1559
 
    // Transform derivatives back to physical element
1560
 
    for (unsigned int row = 0; row < num_derivatives; row++)
1561
 
    {
1562
 
      for (unsigned int col = 0; col < num_derivatives; col++)
1563
 
      {
1564
 
        values[row] += transform[row][col]*derivatives[col];
1565
 
      }
1566
 
    }
1567
 
    // Delete pointer to array of derivatives on FIAT element
1568
 
    delete [] derivatives;
1569
 
    
1570
 
    // Delete pointer to array of combinations of derivatives and transform
1571
 
    for (unsigned int row = 0; row < num_derivatives; row++)
1572
 
    {
1573
 
      delete [] combinations[row];
1574
 
      delete [] transform[row];
1575
 
    }
1576
 
    
1577
 
    delete [] combinations;
1578
 
    delete [] transform;
1579
 
  }
1580
 
 
1581
 
  /// Evaluate order n derivatives of all basis functions at given point in cell
1582
 
  virtual void evaluate_basis_derivatives_all(unsigned int n,
1583
 
                                              double* values,
1584
 
                                              const double* coordinates,
1585
 
                                              const ufc::cell& c) const
1586
 
  {
1587
 
    throw std::runtime_error("The vectorised version of evaluate_basis_derivatives() is not yet implemented.");
1588
 
  }
1589
 
 
1590
 
  /// Evaluate linear functional for dof i on the function f
1591
 
  virtual double evaluate_dof(unsigned int i,
1592
 
                              const ufc::function& f,
1593
 
                              const ufc::cell& c) const
1594
 
  {
1595
 
    // The reference points, direction and weights:
1596
 
    const static double X[20][1][3] = {{{0, 0, 0}}, {{0.333333333333333, 0, 0}}, {{0.666666666666667, 0, 0}}, {{1, 0, 0}}, {{0, 0.333333333333333, 0}}, {{0.333333333333333, 0.333333333333333, 0}}, {{0.666666666666667, 0.333333333333333, 0}}, {{0, 0.666666666666667, 0}}, {{0.333333333333333, 0.666666666666667, 0}}, {{0, 1, 0}}, {{0, 0, 0.333333333333333}}, {{0.333333333333333, 0, 0.333333333333333}}, {{0.666666666666667, 0, 0.333333333333333}}, {{0, 0.333333333333333, 0.333333333333333}}, {{0.333333333333333, 0.333333333333333, 0.333333333333333}}, {{0, 0.666666666666667, 0.333333333333333}}, {{0, 0, 0.666666666666667}}, {{0.333333333333333, 0, 0.666666666666667}}, {{0, 0.333333333333333, 0.666666666666667}}, {{0, 0, 1}}};
1597
 
    const static double W[20][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
1598
 
    const static double D[20][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
1599
 
    
1600
 
    const double * const * x = c.coordinates;
1601
 
    double result = 0.0;
1602
 
    // Iterate over the points:
1603
 
    // Evaluate basis functions for affine mapping
1604
 
    const double w0 = 1.0 - X[i][0][0] - X[i][0][1] - X[i][0][2];
1605
 
    const double w1 = X[i][0][0];
1606
 
    const double w2 = X[i][0][1];
1607
 
    const double w3 = X[i][0][2];
1608
 
    
1609
 
    // Compute affine mapping y = F(X)
1610
 
    double y[3];
1611
 
    y[0] = w0*x[0][0] + w1*x[1][0] + w2*x[2][0] + w3*x[3][0];
1612
 
    y[1] = w0*x[0][1] + w1*x[1][1] + w2*x[2][1] + w3*x[3][1];
1613
 
    y[2] = w0*x[0][2] + w1*x[1][2] + w2*x[2][2] + w3*x[3][2];
1614
 
    
1615
 
    // Evaluate function at physical points
1616
 
    double values[1];
1617
 
    f.evaluate(values, y, c);
1618
 
    
1619
 
    // Map function values using appropriate mapping
1620
 
    // Affine map: Do nothing
1621
 
    
1622
 
    // Note that we do not map the weights (yet).
1623
 
    
1624
 
    // Take directional components
1625
 
    for(int k = 0; k < 1; k++)
1626
 
      result += values[k]*D[i][0][k];
1627
 
    // Multiply by weights 
1628
 
    result *= W[i][0];
1629
 
    
1630
 
    return result;
1631
 
  }
1632
 
 
1633
 
  /// Evaluate linear functionals for all dofs on the function f
1634
 
  virtual void evaluate_dofs(double* values,
1635
 
                             const ufc::function& f,
1636
 
                             const ufc::cell& c) const
1637
 
  {
1638
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
1639
 
  }
1640
 
 
1641
 
  /// Interpolate vertex values from dof values
1642
 
  virtual void interpolate_vertex_values(double* vertex_values,
1643
 
                                         const double* dof_values,
1644
 
                                         const ufc::cell& c) const
1645
 
  {
1646
 
    // Evaluate at vertices and use affine mapping
1647
 
    vertex_values[0] = dof_values[0];
1648
 
    vertex_values[1] = dof_values[3];
1649
 
    vertex_values[2] = dof_values[9];
1650
 
    vertex_values[3] = dof_values[19];
1651
 
  }
1652
 
 
1653
 
  /// Return the number of sub elements (for a mixed element)
1654
 
  virtual unsigned int num_sub_elements() const
1655
 
  {
1656
 
    return 1;
1657
 
  }
1658
 
 
1659
 
  /// Create a new finite element for sub element i (for a mixed element)
1660
 
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
1661
 
  {
1662
 
    return new ffc_25_finite_element_0_1();
1663
 
  }
1664
 
 
1665
 
};
1666
 
 
1667
 
/// This class defines the interface for a finite element.
1668
 
 
1669
 
class ffc_25_finite_element_0_2: public ufc::finite_element
1670
 
{
1671
 
public:
1672
 
 
1673
 
  /// Constructor
1674
 
  ffc_25_finite_element_0_2() : ufc::finite_element()
1675
 
  {
1676
 
    // Do nothing
1677
 
  }
1678
 
 
1679
 
  /// Destructor
1680
 
  virtual ~ffc_25_finite_element_0_2()
1681
 
  {
1682
 
    // Do nothing
1683
 
  }
1684
 
 
1685
 
  /// Return a string identifying the finite element
1686
 
  virtual const char* signature() const
1687
 
  {
1688
 
    return "Discontinuous Lagrange finite element of degree 3 on a tetrahedron";
1689
 
  }
1690
 
 
1691
 
  /// Return the cell shape
1692
 
  virtual ufc::shape cell_shape() const
1693
 
  {
1694
 
    return ufc::tetrahedron;
1695
 
  }
1696
 
 
1697
 
  /// Return the dimension of the finite element function space
1698
 
  virtual unsigned int space_dimension() const
1699
 
  {
1700
 
    return 20;
1701
 
  }
1702
 
 
1703
 
  /// Return the rank of the value space
1704
 
  virtual unsigned int value_rank() const
1705
 
  {
1706
 
    return 0;
1707
 
  }
1708
 
 
1709
 
  /// Return the dimension of the value space for axis i
1710
 
  virtual unsigned int value_dimension(unsigned int i) const
1711
 
  {
1712
 
    return 1;
1713
 
  }
1714
 
 
1715
 
  /// Evaluate basis function i at given point in cell
1716
 
  virtual void evaluate_basis(unsigned int i,
1717
 
                              double* values,
1718
 
                              const double* coordinates,
1719
 
                              const ufc::cell& c) const
1720
 
  {
1721
 
    // Extract vertex coordinates
1722
 
    const double * const * element_coordinates = c.coordinates;
1723
 
    
1724
 
    // Compute Jacobian of affine map from reference cell
1725
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
1726
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
1727
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
1728
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
1729
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
1730
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
1731
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
1732
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
1733
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
1734
 
      
1735
 
    // Compute sub determinants
1736
 
    const double d00 = J_11*J_22 - J_12*J_21;
1737
 
    const double d01 = J_12*J_20 - J_10*J_22;
1738
 
    const double d02 = J_10*J_21 - J_11*J_20;
1739
 
    
1740
 
    const double d10 = J_02*J_21 - J_01*J_22;
1741
 
    const double d11 = J_00*J_22 - J_02*J_20;
1742
 
    const double d12 = J_01*J_20 - J_00*J_21;
1743
 
    
1744
 
    const double d20 = J_01*J_12 - J_02*J_11;
1745
 
    const double d21 = J_02*J_10 - J_00*J_12;
1746
 
    const double d22 = J_00*J_11 - J_01*J_10;
1747
 
      
1748
 
    // Compute determinant of Jacobian
1749
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
1750
 
    
1751
 
    // Compute inverse of Jacobian
1752
 
    
1753
 
    // Compute constants
1754
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
1755
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
1756
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
1757
 
    
1758
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
1759
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
1760
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
1761
 
    
1762
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
1763
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
1764
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
1765
 
    
1766
 
    // Get coordinates and map to the UFC reference element
1767
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
1768
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
1769
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
1770
 
    
1771
 
    // Map coordinates to the reference cube
1772
 
    if (std::abs(y + z - 1.0) < 1e-14)
1773
 
      x = 1.0;
1774
 
    else
1775
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
1776
 
    if (std::abs(z - 1.0) < 1e-14)
1777
 
      y = -1.0;
1778
 
    else
1779
 
      y = 2.0 * y/(1.0 - z) - 1.0;
1780
 
    z = 2.0 * z - 1.0;
1781
 
    
1782
 
    // Reset values
1783
 
    *values = 0;
1784
 
    
1785
 
    // Map degree of freedom to element degree of freedom
1786
 
    const unsigned int dof = i;
1787
 
    
1788
 
    // Generate scalings
1789
 
    const double scalings_y_0 = 1;
1790
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
1791
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
1792
 
    const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
1793
 
    const double scalings_z_0 = 1;
1794
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
1795
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
1796
 
    const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
1797
 
    
1798
 
    // Compute psitilde_a
1799
 
    const double psitilde_a_0 = 1;
1800
 
    const double psitilde_a_1 = x;
1801
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
1802
 
    const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
1803
 
    
1804
 
    // Compute psitilde_bs
1805
 
    const double psitilde_bs_0_0 = 1;
1806
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
1807
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
1808
 
    const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
1809
 
    const double psitilde_bs_1_0 = 1;
1810
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
1811
 
    const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
1812
 
    const double psitilde_bs_2_0 = 1;
1813
 
    const double psitilde_bs_2_1 = 3.5*y + 2.5;
1814
 
    const double psitilde_bs_3_0 = 1;
1815
 
    
1816
 
    // Compute psitilde_cs
1817
 
    const double psitilde_cs_00_0 = 1;
1818
 
    const double psitilde_cs_00_1 = 2*z + 1;
1819
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
1820
 
    const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
1821
 
    const double psitilde_cs_01_0 = 1;
1822
 
    const double psitilde_cs_01_1 = 3*z + 2;
1823
 
    const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
1824
 
    const double psitilde_cs_02_0 = 1;
1825
 
    const double psitilde_cs_02_1 = 4*z + 3;
1826
 
    const double psitilde_cs_03_0 = 1;
1827
 
    const double psitilde_cs_10_0 = 1;
1828
 
    const double psitilde_cs_10_1 = 3*z + 2;
1829
 
    const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
1830
 
    const double psitilde_cs_11_0 = 1;
1831
 
    const double psitilde_cs_11_1 = 4*z + 3;
1832
 
    const double psitilde_cs_12_0 = 1;
1833
 
    const double psitilde_cs_20_0 = 1;
1834
 
    const double psitilde_cs_20_1 = 4*z + 3;
1835
 
    const double psitilde_cs_21_0 = 1;
1836
 
    const double psitilde_cs_30_0 = 1;
1837
 
    
1838
 
    // Compute basisvalues
1839
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
1840
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
1841
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
1842
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
1843
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
1844
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
1845
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
1846
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
1847
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
1848
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
1849
 
    const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
1850
 
    const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
1851
 
    const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
1852
 
    const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
1853
 
    const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
1854
 
    const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
1855
 
    const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
1856
 
    const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
1857
 
    const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
1858
 
    const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
1859
 
    
1860
 
    // Table(s) of coefficients
1861
 
    const static double coefficients0[20][20] = \
1862
 
    {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
1863
 
    {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
1864
 
    {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
1865
 
    {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
1866
 
    {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
1867
 
    {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
1868
 
    {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
1869
 
    {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
1870
 
    {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
1871
 
    {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
1872
 
    {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
1873
 
    {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
1874
 
    {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
1875
 
    {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
1876
 
    {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
1877
 
    {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
1878
 
    {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
1879
 
    {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
1880
 
    {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
1881
 
    {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
1882
 
    
1883
 
    // Extract relevant coefficients
1884
 
    const double coeff0_0 = coefficients0[dof][0];
1885
 
    const double coeff0_1 = coefficients0[dof][1];
1886
 
    const double coeff0_2 = coefficients0[dof][2];
1887
 
    const double coeff0_3 = coefficients0[dof][3];
1888
 
    const double coeff0_4 = coefficients0[dof][4];
1889
 
    const double coeff0_5 = coefficients0[dof][5];
1890
 
    const double coeff0_6 = coefficients0[dof][6];
1891
 
    const double coeff0_7 = coefficients0[dof][7];
1892
 
    const double coeff0_8 = coefficients0[dof][8];
1893
 
    const double coeff0_9 = coefficients0[dof][9];
1894
 
    const double coeff0_10 = coefficients0[dof][10];
1895
 
    const double coeff0_11 = coefficients0[dof][11];
1896
 
    const double coeff0_12 = coefficients0[dof][12];
1897
 
    const double coeff0_13 = coefficients0[dof][13];
1898
 
    const double coeff0_14 = coefficients0[dof][14];
1899
 
    const double coeff0_15 = coefficients0[dof][15];
1900
 
    const double coeff0_16 = coefficients0[dof][16];
1901
 
    const double coeff0_17 = coefficients0[dof][17];
1902
 
    const double coeff0_18 = coefficients0[dof][18];
1903
 
    const double coeff0_19 = coefficients0[dof][19];
1904
 
    
1905
 
    // Compute value(s)
1906
 
    *values = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9 + coeff0_10*basisvalue10 + coeff0_11*basisvalue11 + coeff0_12*basisvalue12 + coeff0_13*basisvalue13 + coeff0_14*basisvalue14 + coeff0_15*basisvalue15 + coeff0_16*basisvalue16 + coeff0_17*basisvalue17 + coeff0_18*basisvalue18 + coeff0_19*basisvalue19;
1907
 
  }
1908
 
 
1909
 
  /// Evaluate all basis functions at given point in cell
1910
 
  virtual void evaluate_basis_all(double* values,
1911
 
                                  const double* coordinates,
1912
 
                                  const ufc::cell& c) const
1913
 
  {
1914
 
    throw std::runtime_error("The vectorised version of evaluate_basis() is not yet implemented.");
1915
 
  }
1916
 
 
1917
 
  /// Evaluate order n derivatives of basis function i at given point in cell
1918
 
  virtual void evaluate_basis_derivatives(unsigned int i,
1919
 
                                          unsigned int n,
1920
 
                                          double* values,
1921
 
                                          const double* coordinates,
1922
 
                                          const ufc::cell& c) const
1923
 
  {
1924
 
    // Extract vertex coordinates
1925
 
    const double * const * element_coordinates = c.coordinates;
1926
 
    
1927
 
    // Compute Jacobian of affine map from reference cell
1928
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
1929
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
1930
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
1931
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
1932
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
1933
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
1934
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
1935
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
1936
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
1937
 
      
1938
 
    // Compute sub determinants
1939
 
    const double d00 = J_11*J_22 - J_12*J_21;
1940
 
    const double d01 = J_12*J_20 - J_10*J_22;
1941
 
    const double d02 = J_10*J_21 - J_11*J_20;
1942
 
    
1943
 
    const double d10 = J_02*J_21 - J_01*J_22;
1944
 
    const double d11 = J_00*J_22 - J_02*J_20;
1945
 
    const double d12 = J_01*J_20 - J_00*J_21;
1946
 
    
1947
 
    const double d20 = J_01*J_12 - J_02*J_11;
1948
 
    const double d21 = J_02*J_10 - J_00*J_12;
1949
 
    const double d22 = J_00*J_11 - J_01*J_10;
1950
 
      
1951
 
    // Compute determinant of Jacobian
1952
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
1953
 
    
1954
 
    // Compute inverse of Jacobian
1955
 
    
1956
 
    // Compute constants
1957
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
1958
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
1959
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
1960
 
    
1961
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
1962
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
1963
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
1964
 
    
1965
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
1966
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
1967
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
1968
 
    
1969
 
    // Get coordinates and map to the UFC reference element
1970
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
1971
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
1972
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
1973
 
    
1974
 
    // Map coordinates to the reference cube
1975
 
    if (std::abs(y + z - 1.0) < 1e-14)
1976
 
      x = 1.0;
1977
 
    else
1978
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
1979
 
    if (std::abs(z - 1.0) < 1e-14)
1980
 
      y = -1.0;
1981
 
    else
1982
 
      y = 2.0 * y/(1.0 - z) - 1.0;
1983
 
    z = 2.0 * z - 1.0;
1984
 
    
1985
 
    // Compute number of derivatives
1986
 
    unsigned int num_derivatives = 1;
1987
 
    
1988
 
    for (unsigned int j = 0; j < n; j++)
1989
 
      num_derivatives *= 3;
1990
 
    
1991
 
    
1992
 
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
1993
 
    unsigned int **combinations = new unsigned int *[num_derivatives];
1994
 
        
1995
 
    for (unsigned int j = 0; j < num_derivatives; j++)
1996
 
    {
1997
 
      combinations[j] = new unsigned int [n];
1998
 
      for (unsigned int k = 0; k < n; k++)
1999
 
        combinations[j][k] = 0;
2000
 
    }
2001
 
        
2002
 
    // Generate combinations of derivatives
2003
 
    for (unsigned int row = 1; row < num_derivatives; row++)
2004
 
    {
2005
 
      for (unsigned int num = 0; num < row; num++)
2006
 
      {
2007
 
        for (unsigned int col = n-1; col+1 > 0; col--)
2008
 
        {
2009
 
          if (combinations[row][col] + 1 > 2)
2010
 
            combinations[row][col] = 0;
2011
 
          else
2012
 
          {
2013
 
            combinations[row][col] += 1;
2014
 
            break;
2015
 
          }
2016
 
        }
2017
 
      }
2018
 
    }
2019
 
    
2020
 
    // Compute inverse of Jacobian
2021
 
    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};
2022
 
    
2023
 
    // Declare transformation matrix
2024
 
    // Declare pointer to two dimensional array and initialise
2025
 
    double **transform = new double *[num_derivatives];
2026
 
        
2027
 
    for (unsigned int j = 0; j < num_derivatives; j++)
2028
 
    {
2029
 
      transform[j] = new double [num_derivatives];
2030
 
      for (unsigned int k = 0; k < num_derivatives; k++)
2031
 
        transform[j][k] = 1;
2032
 
    }
2033
 
    
2034
 
    // Construct transformation matrix
2035
 
    for (unsigned int row = 0; row < num_derivatives; row++)
2036
 
    {
2037
 
      for (unsigned int col = 0; col < num_derivatives; col++)
2038
 
      {
2039
 
        for (unsigned int k = 0; k < n; k++)
2040
 
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
2041
 
      }
2042
 
    }
2043
 
    
2044
 
    // Reset values
2045
 
    for (unsigned int j = 0; j < 1*num_derivatives; j++)
2046
 
      values[j] = 0;
2047
 
    
2048
 
    // Map degree of freedom to element degree of freedom
2049
 
    const unsigned int dof = i;
2050
 
    
2051
 
    // Generate scalings
2052
 
    const double scalings_y_0 = 1;
2053
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
2054
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
2055
 
    const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
2056
 
    const double scalings_z_0 = 1;
2057
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
2058
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
2059
 
    const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
2060
 
    
2061
 
    // Compute psitilde_a
2062
 
    const double psitilde_a_0 = 1;
2063
 
    const double psitilde_a_1 = x;
2064
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
2065
 
    const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
2066
 
    
2067
 
    // Compute psitilde_bs
2068
 
    const double psitilde_bs_0_0 = 1;
2069
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
2070
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
2071
 
    const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
2072
 
    const double psitilde_bs_1_0 = 1;
2073
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
2074
 
    const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
2075
 
    const double psitilde_bs_2_0 = 1;
2076
 
    const double psitilde_bs_2_1 = 3.5*y + 2.5;
2077
 
    const double psitilde_bs_3_0 = 1;
2078
 
    
2079
 
    // Compute psitilde_cs
2080
 
    const double psitilde_cs_00_0 = 1;
2081
 
    const double psitilde_cs_00_1 = 2*z + 1;
2082
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
2083
 
    const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
2084
 
    const double psitilde_cs_01_0 = 1;
2085
 
    const double psitilde_cs_01_1 = 3*z + 2;
2086
 
    const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
2087
 
    const double psitilde_cs_02_0 = 1;
2088
 
    const double psitilde_cs_02_1 = 4*z + 3;
2089
 
    const double psitilde_cs_03_0 = 1;
2090
 
    const double psitilde_cs_10_0 = 1;
2091
 
    const double psitilde_cs_10_1 = 3*z + 2;
2092
 
    const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
2093
 
    const double psitilde_cs_11_0 = 1;
2094
 
    const double psitilde_cs_11_1 = 4*z + 3;
2095
 
    const double psitilde_cs_12_0 = 1;
2096
 
    const double psitilde_cs_20_0 = 1;
2097
 
    const double psitilde_cs_20_1 = 4*z + 3;
2098
 
    const double psitilde_cs_21_0 = 1;
2099
 
    const double psitilde_cs_30_0 = 1;
2100
 
    
2101
 
    // Compute basisvalues
2102
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
2103
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
2104
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
2105
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
2106
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
2107
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
2108
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
2109
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
2110
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
2111
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
2112
 
    const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
2113
 
    const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
2114
 
    const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
2115
 
    const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
2116
 
    const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
2117
 
    const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
2118
 
    const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
2119
 
    const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
2120
 
    const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
2121
 
    const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
2122
 
    
2123
 
    // Table(s) of coefficients
2124
 
    const static double coefficients0[20][20] = \
2125
 
    {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
2126
 
    {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
2127
 
    {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
2128
 
    {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
2129
 
    {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
2130
 
    {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
2131
 
    {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
2132
 
    {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
2133
 
    {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
2134
 
    {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
2135
 
    {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
2136
 
    {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
2137
 
    {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
2138
 
    {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
2139
 
    {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
2140
 
    {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
2141
 
    {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
2142
 
    {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
2143
 
    {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
2144
 
    {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
2145
 
    
2146
 
    // Interesting (new) part
2147
 
    // Tables of derivatives of the polynomial base (transpose)
2148
 
    const static double dmats0[20][20] = \
2149
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2150
 
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2151
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2152
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2153
 
    {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2154
 
    {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2155
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2156
 
    {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2157
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2158
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2159
 
    {5.49909083394701, 0, -3.3466401061363, -2.36643191323985, 15.4919333848297, 0, 0.692820323027551, 0, 0.565685424949239, 0.400000000000001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2160
 
    {0, 4.89897948556636, 0, 0, 0, 14.1985914794391, 0, -0.82807867121083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2161
 
    {3.6, 0, 8.76356092008266, -1.54919333848297, 0, 0, 9.52470471983253, 0, -1.48131215963608, 0.261861468283192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2162
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2163
 
    {0, 4.24264068711928, 0, 0, 0, 0, 0, 14.3427433120127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2164
 
    {3.11769145362398, 0, 3.16227766016838, 4.91934955049954, 0, 0, 0, 0, 10.690449676497, -2.41897262725906, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2165
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2166
 
    {2.54558441227157, 0, 0, 7.66811580507233, 0, 0, 0, 0, 0, 10.3691851174526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2167
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2168
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
2169
 
    
2170
 
    const static double dmats1[20][20] = \
2171
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2172
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2173
 
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2174
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2175
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2176
 
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309959, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2177
 
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2178
 
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2179
 
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2180
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2181
 
    {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.28284271247462, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2182
 
    {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 9.16515138991168, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2183
 
    {1.8, -5.69209978830308, 4.38178046004133, -0.774596669241487, 0, 10.998181667894, 4.76235235991626, 0.962140470884726, -0.740656079818041, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2184
 
    {5.19615242270664, 0, -3.16227766016838, -2.23606797749979, 0, 0, 13.7477270848675, 0, 0.534522483824849, 0.37796447300923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2185
 
    {2.01246117974981, 2.12132034355964, -0.408248290463864, 3.17542648054294, 0, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2186
 
    {1.55884572681199, 2.73861278752583, 1.58113883008419, 2.45967477524977, 0, 0, 0, 9.25820099772551, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2187
 
    {-1.8, 0, 3.65148371670111, -2.84018778721878, 0, 0, 0, 0, 12.3442679969674, 1.39659449751035, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2188
 
    {1.27279220613579, 0, 0, 3.83405790253616, 0, 0, 0, 0, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2189
 
    {2.20454076850486, 0, 0, 6.6407830863536, 0, 0, 0, 0, 0, 8.97997772825746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2190
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
2191
 
    
2192
 
    const static double dmats2[20][20] = \
2193
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2194
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2195
 
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2196
 
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2197
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2198
 
    {2.29128784747792, 1.44913767461895, 4.18330013267038, -0.59160797830996, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2199
 
    {1.32287565553229, 0, 3.86436713231718, -0.341565025531987, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2200
 
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2201
 
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2202
 
    {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2203
 
    {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.282842712474619, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2204
 
    {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 1.30930734141595, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2205
 
    {1.8, 0.632455532033675, 4.38178046004133, -0.774596669241484, 0, 3.14233761939829, 4.76235235991626, -0.10690449676497, -0.740656079818042, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2206
 
    {1.03923048454133, 0, 3.16227766016838, -0.447213595499959, 0, 0, 5.8918830363718, 0, -0.53452248382485, 0.0755928946018459, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2207
 
    {2.01246117974981, 2.12132034355964, -0.408248290463863, 3.17542648054294, 9.07114735222145, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2208
 
    {1.55884572681199, 0.547722557505165, 1.58113883008419, 2.45967477524977, 0, 9.07114735222145, 0, 1.8516401995451, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2209
 
    {0.900000000000001, 0, 1.46059348668045, 1.42009389360939, 0, 0, 9.07114735222145, 0, 4.93770719878694, -0.698297248755175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2210
 
    {1.27279220613578, -6.26099033699941, 0, 3.83405790253616, 0, 0, 0, 10.5830052442584, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2211
 
    {0.734846922834954, 0, -6.26099033699941, 2.21359436211787, 0, 0, 0, 0, 10.5830052442584, 2.99332590941915, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2212
 
    {5.7157676649773, 0, 0, -4.69574275274955, 0, 0, 0, 0, 0, 12.69960629311, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
2213
 
    
2214
 
    // Compute reference derivatives
2215
 
    // Declare pointer to array of derivatives on FIAT element
2216
 
    double *derivatives = new double [num_derivatives];
2217
 
    
2218
 
    // Declare coefficients
2219
 
    double coeff0_0 = 0;
2220
 
    double coeff0_1 = 0;
2221
 
    double coeff0_2 = 0;
2222
 
    double coeff0_3 = 0;
2223
 
    double coeff0_4 = 0;
2224
 
    double coeff0_5 = 0;
2225
 
    double coeff0_6 = 0;
2226
 
    double coeff0_7 = 0;
2227
 
    double coeff0_8 = 0;
2228
 
    double coeff0_9 = 0;
2229
 
    double coeff0_10 = 0;
2230
 
    double coeff0_11 = 0;
2231
 
    double coeff0_12 = 0;
2232
 
    double coeff0_13 = 0;
2233
 
    double coeff0_14 = 0;
2234
 
    double coeff0_15 = 0;
2235
 
    double coeff0_16 = 0;
2236
 
    double coeff0_17 = 0;
2237
 
    double coeff0_18 = 0;
2238
 
    double coeff0_19 = 0;
2239
 
    
2240
 
    // Declare new coefficients
2241
 
    double new_coeff0_0 = 0;
2242
 
    double new_coeff0_1 = 0;
2243
 
    double new_coeff0_2 = 0;
2244
 
    double new_coeff0_3 = 0;
2245
 
    double new_coeff0_4 = 0;
2246
 
    double new_coeff0_5 = 0;
2247
 
    double new_coeff0_6 = 0;
2248
 
    double new_coeff0_7 = 0;
2249
 
    double new_coeff0_8 = 0;
2250
 
    double new_coeff0_9 = 0;
2251
 
    double new_coeff0_10 = 0;
2252
 
    double new_coeff0_11 = 0;
2253
 
    double new_coeff0_12 = 0;
2254
 
    double new_coeff0_13 = 0;
2255
 
    double new_coeff0_14 = 0;
2256
 
    double new_coeff0_15 = 0;
2257
 
    double new_coeff0_16 = 0;
2258
 
    double new_coeff0_17 = 0;
2259
 
    double new_coeff0_18 = 0;
2260
 
    double new_coeff0_19 = 0;
2261
 
    
2262
 
    // Loop possible derivatives
2263
 
    for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
2264
 
    {
2265
 
      // Get values from coefficients array
2266
 
      new_coeff0_0 = coefficients0[dof][0];
2267
 
      new_coeff0_1 = coefficients0[dof][1];
2268
 
      new_coeff0_2 = coefficients0[dof][2];
2269
 
      new_coeff0_3 = coefficients0[dof][3];
2270
 
      new_coeff0_4 = coefficients0[dof][4];
2271
 
      new_coeff0_5 = coefficients0[dof][5];
2272
 
      new_coeff0_6 = coefficients0[dof][6];
2273
 
      new_coeff0_7 = coefficients0[dof][7];
2274
 
      new_coeff0_8 = coefficients0[dof][8];
2275
 
      new_coeff0_9 = coefficients0[dof][9];
2276
 
      new_coeff0_10 = coefficients0[dof][10];
2277
 
      new_coeff0_11 = coefficients0[dof][11];
2278
 
      new_coeff0_12 = coefficients0[dof][12];
2279
 
      new_coeff0_13 = coefficients0[dof][13];
2280
 
      new_coeff0_14 = coefficients0[dof][14];
2281
 
      new_coeff0_15 = coefficients0[dof][15];
2282
 
      new_coeff0_16 = coefficients0[dof][16];
2283
 
      new_coeff0_17 = coefficients0[dof][17];
2284
 
      new_coeff0_18 = coefficients0[dof][18];
2285
 
      new_coeff0_19 = coefficients0[dof][19];
2286
 
    
2287
 
      // Loop derivative order
2288
 
      for (unsigned int j = 0; j < n; j++)
2289
 
      {
2290
 
        // Update old coefficients
2291
 
        coeff0_0 = new_coeff0_0;
2292
 
        coeff0_1 = new_coeff0_1;
2293
 
        coeff0_2 = new_coeff0_2;
2294
 
        coeff0_3 = new_coeff0_3;
2295
 
        coeff0_4 = new_coeff0_4;
2296
 
        coeff0_5 = new_coeff0_5;
2297
 
        coeff0_6 = new_coeff0_6;
2298
 
        coeff0_7 = new_coeff0_7;
2299
 
        coeff0_8 = new_coeff0_8;
2300
 
        coeff0_9 = new_coeff0_9;
2301
 
        coeff0_10 = new_coeff0_10;
2302
 
        coeff0_11 = new_coeff0_11;
2303
 
        coeff0_12 = new_coeff0_12;
2304
 
        coeff0_13 = new_coeff0_13;
2305
 
        coeff0_14 = new_coeff0_14;
2306
 
        coeff0_15 = new_coeff0_15;
2307
 
        coeff0_16 = new_coeff0_16;
2308
 
        coeff0_17 = new_coeff0_17;
2309
 
        coeff0_18 = new_coeff0_18;
2310
 
        coeff0_19 = new_coeff0_19;
2311
 
    
2312
 
        if(combinations[deriv_num][j] == 0)
2313
 
        {
2314
 
          new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0] + coeff0_10*dmats0[10][0] + coeff0_11*dmats0[11][0] + coeff0_12*dmats0[12][0] + coeff0_13*dmats0[13][0] + coeff0_14*dmats0[14][0] + coeff0_15*dmats0[15][0] + coeff0_16*dmats0[16][0] + coeff0_17*dmats0[17][0] + coeff0_18*dmats0[18][0] + coeff0_19*dmats0[19][0];
2315
 
          new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1] + coeff0_10*dmats0[10][1] + coeff0_11*dmats0[11][1] + coeff0_12*dmats0[12][1] + coeff0_13*dmats0[13][1] + coeff0_14*dmats0[14][1] + coeff0_15*dmats0[15][1] + coeff0_16*dmats0[16][1] + coeff0_17*dmats0[17][1] + coeff0_18*dmats0[18][1] + coeff0_19*dmats0[19][1];
2316
 
          new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2] + coeff0_10*dmats0[10][2] + coeff0_11*dmats0[11][2] + coeff0_12*dmats0[12][2] + coeff0_13*dmats0[13][2] + coeff0_14*dmats0[14][2] + coeff0_15*dmats0[15][2] + coeff0_16*dmats0[16][2] + coeff0_17*dmats0[17][2] + coeff0_18*dmats0[18][2] + coeff0_19*dmats0[19][2];
2317
 
          new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3] + coeff0_10*dmats0[10][3] + coeff0_11*dmats0[11][3] + coeff0_12*dmats0[12][3] + coeff0_13*dmats0[13][3] + coeff0_14*dmats0[14][3] + coeff0_15*dmats0[15][3] + coeff0_16*dmats0[16][3] + coeff0_17*dmats0[17][3] + coeff0_18*dmats0[18][3] + coeff0_19*dmats0[19][3];
2318
 
          new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4] + coeff0_10*dmats0[10][4] + coeff0_11*dmats0[11][4] + coeff0_12*dmats0[12][4] + coeff0_13*dmats0[13][4] + coeff0_14*dmats0[14][4] + coeff0_15*dmats0[15][4] + coeff0_16*dmats0[16][4] + coeff0_17*dmats0[17][4] + coeff0_18*dmats0[18][4] + coeff0_19*dmats0[19][4];
2319
 
          new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5] + coeff0_10*dmats0[10][5] + coeff0_11*dmats0[11][5] + coeff0_12*dmats0[12][5] + coeff0_13*dmats0[13][5] + coeff0_14*dmats0[14][5] + coeff0_15*dmats0[15][5] + coeff0_16*dmats0[16][5] + coeff0_17*dmats0[17][5] + coeff0_18*dmats0[18][5] + coeff0_19*dmats0[19][5];
2320
 
          new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6] + coeff0_10*dmats0[10][6] + coeff0_11*dmats0[11][6] + coeff0_12*dmats0[12][6] + coeff0_13*dmats0[13][6] + coeff0_14*dmats0[14][6] + coeff0_15*dmats0[15][6] + coeff0_16*dmats0[16][6] + coeff0_17*dmats0[17][6] + coeff0_18*dmats0[18][6] + coeff0_19*dmats0[19][6];
2321
 
          new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7] + coeff0_10*dmats0[10][7] + coeff0_11*dmats0[11][7] + coeff0_12*dmats0[12][7] + coeff0_13*dmats0[13][7] + coeff0_14*dmats0[14][7] + coeff0_15*dmats0[15][7] + coeff0_16*dmats0[16][7] + coeff0_17*dmats0[17][7] + coeff0_18*dmats0[18][7] + coeff0_19*dmats0[19][7];
2322
 
          new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8] + coeff0_10*dmats0[10][8] + coeff0_11*dmats0[11][8] + coeff0_12*dmats0[12][8] + coeff0_13*dmats0[13][8] + coeff0_14*dmats0[14][8] + coeff0_15*dmats0[15][8] + coeff0_16*dmats0[16][8] + coeff0_17*dmats0[17][8] + coeff0_18*dmats0[18][8] + coeff0_19*dmats0[19][8];
2323
 
          new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9] + coeff0_10*dmats0[10][9] + coeff0_11*dmats0[11][9] + coeff0_12*dmats0[12][9] + coeff0_13*dmats0[13][9] + coeff0_14*dmats0[14][9] + coeff0_15*dmats0[15][9] + coeff0_16*dmats0[16][9] + coeff0_17*dmats0[17][9] + coeff0_18*dmats0[18][9] + coeff0_19*dmats0[19][9];
2324
 
          new_coeff0_10 = coeff0_0*dmats0[0][10] + coeff0_1*dmats0[1][10] + coeff0_2*dmats0[2][10] + coeff0_3*dmats0[3][10] + coeff0_4*dmats0[4][10] + coeff0_5*dmats0[5][10] + coeff0_6*dmats0[6][10] + coeff0_7*dmats0[7][10] + coeff0_8*dmats0[8][10] + coeff0_9*dmats0[9][10] + coeff0_10*dmats0[10][10] + coeff0_11*dmats0[11][10] + coeff0_12*dmats0[12][10] + coeff0_13*dmats0[13][10] + coeff0_14*dmats0[14][10] + coeff0_15*dmats0[15][10] + coeff0_16*dmats0[16][10] + coeff0_17*dmats0[17][10] + coeff0_18*dmats0[18][10] + coeff0_19*dmats0[19][10];
2325
 
          new_coeff0_11 = coeff0_0*dmats0[0][11] + coeff0_1*dmats0[1][11] + coeff0_2*dmats0[2][11] + coeff0_3*dmats0[3][11] + coeff0_4*dmats0[4][11] + coeff0_5*dmats0[5][11] + coeff0_6*dmats0[6][11] + coeff0_7*dmats0[7][11] + coeff0_8*dmats0[8][11] + coeff0_9*dmats0[9][11] + coeff0_10*dmats0[10][11] + coeff0_11*dmats0[11][11] + coeff0_12*dmats0[12][11] + coeff0_13*dmats0[13][11] + coeff0_14*dmats0[14][11] + coeff0_15*dmats0[15][11] + coeff0_16*dmats0[16][11] + coeff0_17*dmats0[17][11] + coeff0_18*dmats0[18][11] + coeff0_19*dmats0[19][11];
2326
 
          new_coeff0_12 = coeff0_0*dmats0[0][12] + coeff0_1*dmats0[1][12] + coeff0_2*dmats0[2][12] + coeff0_3*dmats0[3][12] + coeff0_4*dmats0[4][12] + coeff0_5*dmats0[5][12] + coeff0_6*dmats0[6][12] + coeff0_7*dmats0[7][12] + coeff0_8*dmats0[8][12] + coeff0_9*dmats0[9][12] + coeff0_10*dmats0[10][12] + coeff0_11*dmats0[11][12] + coeff0_12*dmats0[12][12] + coeff0_13*dmats0[13][12] + coeff0_14*dmats0[14][12] + coeff0_15*dmats0[15][12] + coeff0_16*dmats0[16][12] + coeff0_17*dmats0[17][12] + coeff0_18*dmats0[18][12] + coeff0_19*dmats0[19][12];
2327
 
          new_coeff0_13 = coeff0_0*dmats0[0][13] + coeff0_1*dmats0[1][13] + coeff0_2*dmats0[2][13] + coeff0_3*dmats0[3][13] + coeff0_4*dmats0[4][13] + coeff0_5*dmats0[5][13] + coeff0_6*dmats0[6][13] + coeff0_7*dmats0[7][13] + coeff0_8*dmats0[8][13] + coeff0_9*dmats0[9][13] + coeff0_10*dmats0[10][13] + coeff0_11*dmats0[11][13] + coeff0_12*dmats0[12][13] + coeff0_13*dmats0[13][13] + coeff0_14*dmats0[14][13] + coeff0_15*dmats0[15][13] + coeff0_16*dmats0[16][13] + coeff0_17*dmats0[17][13] + coeff0_18*dmats0[18][13] + coeff0_19*dmats0[19][13];
2328
 
          new_coeff0_14 = coeff0_0*dmats0[0][14] + coeff0_1*dmats0[1][14] + coeff0_2*dmats0[2][14] + coeff0_3*dmats0[3][14] + coeff0_4*dmats0[4][14] + coeff0_5*dmats0[5][14] + coeff0_6*dmats0[6][14] + coeff0_7*dmats0[7][14] + coeff0_8*dmats0[8][14] + coeff0_9*dmats0[9][14] + coeff0_10*dmats0[10][14] + coeff0_11*dmats0[11][14] + coeff0_12*dmats0[12][14] + coeff0_13*dmats0[13][14] + coeff0_14*dmats0[14][14] + coeff0_15*dmats0[15][14] + coeff0_16*dmats0[16][14] + coeff0_17*dmats0[17][14] + coeff0_18*dmats0[18][14] + coeff0_19*dmats0[19][14];
2329
 
          new_coeff0_15 = coeff0_0*dmats0[0][15] + coeff0_1*dmats0[1][15] + coeff0_2*dmats0[2][15] + coeff0_3*dmats0[3][15] + coeff0_4*dmats0[4][15] + coeff0_5*dmats0[5][15] + coeff0_6*dmats0[6][15] + coeff0_7*dmats0[7][15] + coeff0_8*dmats0[8][15] + coeff0_9*dmats0[9][15] + coeff0_10*dmats0[10][15] + coeff0_11*dmats0[11][15] + coeff0_12*dmats0[12][15] + coeff0_13*dmats0[13][15] + coeff0_14*dmats0[14][15] + coeff0_15*dmats0[15][15] + coeff0_16*dmats0[16][15] + coeff0_17*dmats0[17][15] + coeff0_18*dmats0[18][15] + coeff0_19*dmats0[19][15];
2330
 
          new_coeff0_16 = coeff0_0*dmats0[0][16] + coeff0_1*dmats0[1][16] + coeff0_2*dmats0[2][16] + coeff0_3*dmats0[3][16] + coeff0_4*dmats0[4][16] + coeff0_5*dmats0[5][16] + coeff0_6*dmats0[6][16] + coeff0_7*dmats0[7][16] + coeff0_8*dmats0[8][16] + coeff0_9*dmats0[9][16] + coeff0_10*dmats0[10][16] + coeff0_11*dmats0[11][16] + coeff0_12*dmats0[12][16] + coeff0_13*dmats0[13][16] + coeff0_14*dmats0[14][16] + coeff0_15*dmats0[15][16] + coeff0_16*dmats0[16][16] + coeff0_17*dmats0[17][16] + coeff0_18*dmats0[18][16] + coeff0_19*dmats0[19][16];
2331
 
          new_coeff0_17 = coeff0_0*dmats0[0][17] + coeff0_1*dmats0[1][17] + coeff0_2*dmats0[2][17] + coeff0_3*dmats0[3][17] + coeff0_4*dmats0[4][17] + coeff0_5*dmats0[5][17] + coeff0_6*dmats0[6][17] + coeff0_7*dmats0[7][17] + coeff0_8*dmats0[8][17] + coeff0_9*dmats0[9][17] + coeff0_10*dmats0[10][17] + coeff0_11*dmats0[11][17] + coeff0_12*dmats0[12][17] + coeff0_13*dmats0[13][17] + coeff0_14*dmats0[14][17] + coeff0_15*dmats0[15][17] + coeff0_16*dmats0[16][17] + coeff0_17*dmats0[17][17] + coeff0_18*dmats0[18][17] + coeff0_19*dmats0[19][17];
2332
 
          new_coeff0_18 = coeff0_0*dmats0[0][18] + coeff0_1*dmats0[1][18] + coeff0_2*dmats0[2][18] + coeff0_3*dmats0[3][18] + coeff0_4*dmats0[4][18] + coeff0_5*dmats0[5][18] + coeff0_6*dmats0[6][18] + coeff0_7*dmats0[7][18] + coeff0_8*dmats0[8][18] + coeff0_9*dmats0[9][18] + coeff0_10*dmats0[10][18] + coeff0_11*dmats0[11][18] + coeff0_12*dmats0[12][18] + coeff0_13*dmats0[13][18] + coeff0_14*dmats0[14][18] + coeff0_15*dmats0[15][18] + coeff0_16*dmats0[16][18] + coeff0_17*dmats0[17][18] + coeff0_18*dmats0[18][18] + coeff0_19*dmats0[19][18];
2333
 
          new_coeff0_19 = coeff0_0*dmats0[0][19] + coeff0_1*dmats0[1][19] + coeff0_2*dmats0[2][19] + coeff0_3*dmats0[3][19] + coeff0_4*dmats0[4][19] + coeff0_5*dmats0[5][19] + coeff0_6*dmats0[6][19] + coeff0_7*dmats0[7][19] + coeff0_8*dmats0[8][19] + coeff0_9*dmats0[9][19] + coeff0_10*dmats0[10][19] + coeff0_11*dmats0[11][19] + coeff0_12*dmats0[12][19] + coeff0_13*dmats0[13][19] + coeff0_14*dmats0[14][19] + coeff0_15*dmats0[15][19] + coeff0_16*dmats0[16][19] + coeff0_17*dmats0[17][19] + coeff0_18*dmats0[18][19] + coeff0_19*dmats0[19][19];
2334
 
        }
2335
 
        if(combinations[deriv_num][j] == 1)
2336
 
        {
2337
 
          new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0] + coeff0_10*dmats1[10][0] + coeff0_11*dmats1[11][0] + coeff0_12*dmats1[12][0] + coeff0_13*dmats1[13][0] + coeff0_14*dmats1[14][0] + coeff0_15*dmats1[15][0] + coeff0_16*dmats1[16][0] + coeff0_17*dmats1[17][0] + coeff0_18*dmats1[18][0] + coeff0_19*dmats1[19][0];
2338
 
          new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1] + coeff0_10*dmats1[10][1] + coeff0_11*dmats1[11][1] + coeff0_12*dmats1[12][1] + coeff0_13*dmats1[13][1] + coeff0_14*dmats1[14][1] + coeff0_15*dmats1[15][1] + coeff0_16*dmats1[16][1] + coeff0_17*dmats1[17][1] + coeff0_18*dmats1[18][1] + coeff0_19*dmats1[19][1];
2339
 
          new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2] + coeff0_10*dmats1[10][2] + coeff0_11*dmats1[11][2] + coeff0_12*dmats1[12][2] + coeff0_13*dmats1[13][2] + coeff0_14*dmats1[14][2] + coeff0_15*dmats1[15][2] + coeff0_16*dmats1[16][2] + coeff0_17*dmats1[17][2] + coeff0_18*dmats1[18][2] + coeff0_19*dmats1[19][2];
2340
 
          new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3] + coeff0_10*dmats1[10][3] + coeff0_11*dmats1[11][3] + coeff0_12*dmats1[12][3] + coeff0_13*dmats1[13][3] + coeff0_14*dmats1[14][3] + coeff0_15*dmats1[15][3] + coeff0_16*dmats1[16][3] + coeff0_17*dmats1[17][3] + coeff0_18*dmats1[18][3] + coeff0_19*dmats1[19][3];
2341
 
          new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4] + coeff0_10*dmats1[10][4] + coeff0_11*dmats1[11][4] + coeff0_12*dmats1[12][4] + coeff0_13*dmats1[13][4] + coeff0_14*dmats1[14][4] + coeff0_15*dmats1[15][4] + coeff0_16*dmats1[16][4] + coeff0_17*dmats1[17][4] + coeff0_18*dmats1[18][4] + coeff0_19*dmats1[19][4];
2342
 
          new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5] + coeff0_10*dmats1[10][5] + coeff0_11*dmats1[11][5] + coeff0_12*dmats1[12][5] + coeff0_13*dmats1[13][5] + coeff0_14*dmats1[14][5] + coeff0_15*dmats1[15][5] + coeff0_16*dmats1[16][5] + coeff0_17*dmats1[17][5] + coeff0_18*dmats1[18][5] + coeff0_19*dmats1[19][5];
2343
 
          new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6] + coeff0_10*dmats1[10][6] + coeff0_11*dmats1[11][6] + coeff0_12*dmats1[12][6] + coeff0_13*dmats1[13][6] + coeff0_14*dmats1[14][6] + coeff0_15*dmats1[15][6] + coeff0_16*dmats1[16][6] + coeff0_17*dmats1[17][6] + coeff0_18*dmats1[18][6] + coeff0_19*dmats1[19][6];
2344
 
          new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7] + coeff0_10*dmats1[10][7] + coeff0_11*dmats1[11][7] + coeff0_12*dmats1[12][7] + coeff0_13*dmats1[13][7] + coeff0_14*dmats1[14][7] + coeff0_15*dmats1[15][7] + coeff0_16*dmats1[16][7] + coeff0_17*dmats1[17][7] + coeff0_18*dmats1[18][7] + coeff0_19*dmats1[19][7];
2345
 
          new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8] + coeff0_10*dmats1[10][8] + coeff0_11*dmats1[11][8] + coeff0_12*dmats1[12][8] + coeff0_13*dmats1[13][8] + coeff0_14*dmats1[14][8] + coeff0_15*dmats1[15][8] + coeff0_16*dmats1[16][8] + coeff0_17*dmats1[17][8] + coeff0_18*dmats1[18][8] + coeff0_19*dmats1[19][8];
2346
 
          new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9] + coeff0_10*dmats1[10][9] + coeff0_11*dmats1[11][9] + coeff0_12*dmats1[12][9] + coeff0_13*dmats1[13][9] + coeff0_14*dmats1[14][9] + coeff0_15*dmats1[15][9] + coeff0_16*dmats1[16][9] + coeff0_17*dmats1[17][9] + coeff0_18*dmats1[18][9] + coeff0_19*dmats1[19][9];
2347
 
          new_coeff0_10 = coeff0_0*dmats1[0][10] + coeff0_1*dmats1[1][10] + coeff0_2*dmats1[2][10] + coeff0_3*dmats1[3][10] + coeff0_4*dmats1[4][10] + coeff0_5*dmats1[5][10] + coeff0_6*dmats1[6][10] + coeff0_7*dmats1[7][10] + coeff0_8*dmats1[8][10] + coeff0_9*dmats1[9][10] + coeff0_10*dmats1[10][10] + coeff0_11*dmats1[11][10] + coeff0_12*dmats1[12][10] + coeff0_13*dmats1[13][10] + coeff0_14*dmats1[14][10] + coeff0_15*dmats1[15][10] + coeff0_16*dmats1[16][10] + coeff0_17*dmats1[17][10] + coeff0_18*dmats1[18][10] + coeff0_19*dmats1[19][10];
2348
 
          new_coeff0_11 = coeff0_0*dmats1[0][11] + coeff0_1*dmats1[1][11] + coeff0_2*dmats1[2][11] + coeff0_3*dmats1[3][11] + coeff0_4*dmats1[4][11] + coeff0_5*dmats1[5][11] + coeff0_6*dmats1[6][11] + coeff0_7*dmats1[7][11] + coeff0_8*dmats1[8][11] + coeff0_9*dmats1[9][11] + coeff0_10*dmats1[10][11] + coeff0_11*dmats1[11][11] + coeff0_12*dmats1[12][11] + coeff0_13*dmats1[13][11] + coeff0_14*dmats1[14][11] + coeff0_15*dmats1[15][11] + coeff0_16*dmats1[16][11] + coeff0_17*dmats1[17][11] + coeff0_18*dmats1[18][11] + coeff0_19*dmats1[19][11];
2349
 
          new_coeff0_12 = coeff0_0*dmats1[0][12] + coeff0_1*dmats1[1][12] + coeff0_2*dmats1[2][12] + coeff0_3*dmats1[3][12] + coeff0_4*dmats1[4][12] + coeff0_5*dmats1[5][12] + coeff0_6*dmats1[6][12] + coeff0_7*dmats1[7][12] + coeff0_8*dmats1[8][12] + coeff0_9*dmats1[9][12] + coeff0_10*dmats1[10][12] + coeff0_11*dmats1[11][12] + coeff0_12*dmats1[12][12] + coeff0_13*dmats1[13][12] + coeff0_14*dmats1[14][12] + coeff0_15*dmats1[15][12] + coeff0_16*dmats1[16][12] + coeff0_17*dmats1[17][12] + coeff0_18*dmats1[18][12] + coeff0_19*dmats1[19][12];
2350
 
          new_coeff0_13 = coeff0_0*dmats1[0][13] + coeff0_1*dmats1[1][13] + coeff0_2*dmats1[2][13] + coeff0_3*dmats1[3][13] + coeff0_4*dmats1[4][13] + coeff0_5*dmats1[5][13] + coeff0_6*dmats1[6][13] + coeff0_7*dmats1[7][13] + coeff0_8*dmats1[8][13] + coeff0_9*dmats1[9][13] + coeff0_10*dmats1[10][13] + coeff0_11*dmats1[11][13] + coeff0_12*dmats1[12][13] + coeff0_13*dmats1[13][13] + coeff0_14*dmats1[14][13] + coeff0_15*dmats1[15][13] + coeff0_16*dmats1[16][13] + coeff0_17*dmats1[17][13] + coeff0_18*dmats1[18][13] + coeff0_19*dmats1[19][13];
2351
 
          new_coeff0_14 = coeff0_0*dmats1[0][14] + coeff0_1*dmats1[1][14] + coeff0_2*dmats1[2][14] + coeff0_3*dmats1[3][14] + coeff0_4*dmats1[4][14] + coeff0_5*dmats1[5][14] + coeff0_6*dmats1[6][14] + coeff0_7*dmats1[7][14] + coeff0_8*dmats1[8][14] + coeff0_9*dmats1[9][14] + coeff0_10*dmats1[10][14] + coeff0_11*dmats1[11][14] + coeff0_12*dmats1[12][14] + coeff0_13*dmats1[13][14] + coeff0_14*dmats1[14][14] + coeff0_15*dmats1[15][14] + coeff0_16*dmats1[16][14] + coeff0_17*dmats1[17][14] + coeff0_18*dmats1[18][14] + coeff0_19*dmats1[19][14];
2352
 
          new_coeff0_15 = coeff0_0*dmats1[0][15] + coeff0_1*dmats1[1][15] + coeff0_2*dmats1[2][15] + coeff0_3*dmats1[3][15] + coeff0_4*dmats1[4][15] + coeff0_5*dmats1[5][15] + coeff0_6*dmats1[6][15] + coeff0_7*dmats1[7][15] + coeff0_8*dmats1[8][15] + coeff0_9*dmats1[9][15] + coeff0_10*dmats1[10][15] + coeff0_11*dmats1[11][15] + coeff0_12*dmats1[12][15] + coeff0_13*dmats1[13][15] + coeff0_14*dmats1[14][15] + coeff0_15*dmats1[15][15] + coeff0_16*dmats1[16][15] + coeff0_17*dmats1[17][15] + coeff0_18*dmats1[18][15] + coeff0_19*dmats1[19][15];
2353
 
          new_coeff0_16 = coeff0_0*dmats1[0][16] + coeff0_1*dmats1[1][16] + coeff0_2*dmats1[2][16] + coeff0_3*dmats1[3][16] + coeff0_4*dmats1[4][16] + coeff0_5*dmats1[5][16] + coeff0_6*dmats1[6][16] + coeff0_7*dmats1[7][16] + coeff0_8*dmats1[8][16] + coeff0_9*dmats1[9][16] + coeff0_10*dmats1[10][16] + coeff0_11*dmats1[11][16] + coeff0_12*dmats1[12][16] + coeff0_13*dmats1[13][16] + coeff0_14*dmats1[14][16] + coeff0_15*dmats1[15][16] + coeff0_16*dmats1[16][16] + coeff0_17*dmats1[17][16] + coeff0_18*dmats1[18][16] + coeff0_19*dmats1[19][16];
2354
 
          new_coeff0_17 = coeff0_0*dmats1[0][17] + coeff0_1*dmats1[1][17] + coeff0_2*dmats1[2][17] + coeff0_3*dmats1[3][17] + coeff0_4*dmats1[4][17] + coeff0_5*dmats1[5][17] + coeff0_6*dmats1[6][17] + coeff0_7*dmats1[7][17] + coeff0_8*dmats1[8][17] + coeff0_9*dmats1[9][17] + coeff0_10*dmats1[10][17] + coeff0_11*dmats1[11][17] + coeff0_12*dmats1[12][17] + coeff0_13*dmats1[13][17] + coeff0_14*dmats1[14][17] + coeff0_15*dmats1[15][17] + coeff0_16*dmats1[16][17] + coeff0_17*dmats1[17][17] + coeff0_18*dmats1[18][17] + coeff0_19*dmats1[19][17];
2355
 
          new_coeff0_18 = coeff0_0*dmats1[0][18] + coeff0_1*dmats1[1][18] + coeff0_2*dmats1[2][18] + coeff0_3*dmats1[3][18] + coeff0_4*dmats1[4][18] + coeff0_5*dmats1[5][18] + coeff0_6*dmats1[6][18] + coeff0_7*dmats1[7][18] + coeff0_8*dmats1[8][18] + coeff0_9*dmats1[9][18] + coeff0_10*dmats1[10][18] + coeff0_11*dmats1[11][18] + coeff0_12*dmats1[12][18] + coeff0_13*dmats1[13][18] + coeff0_14*dmats1[14][18] + coeff0_15*dmats1[15][18] + coeff0_16*dmats1[16][18] + coeff0_17*dmats1[17][18] + coeff0_18*dmats1[18][18] + coeff0_19*dmats1[19][18];
2356
 
          new_coeff0_19 = coeff0_0*dmats1[0][19] + coeff0_1*dmats1[1][19] + coeff0_2*dmats1[2][19] + coeff0_3*dmats1[3][19] + coeff0_4*dmats1[4][19] + coeff0_5*dmats1[5][19] + coeff0_6*dmats1[6][19] + coeff0_7*dmats1[7][19] + coeff0_8*dmats1[8][19] + coeff0_9*dmats1[9][19] + coeff0_10*dmats1[10][19] + coeff0_11*dmats1[11][19] + coeff0_12*dmats1[12][19] + coeff0_13*dmats1[13][19] + coeff0_14*dmats1[14][19] + coeff0_15*dmats1[15][19] + coeff0_16*dmats1[16][19] + coeff0_17*dmats1[17][19] + coeff0_18*dmats1[18][19] + coeff0_19*dmats1[19][19];
2357
 
        }
2358
 
        if(combinations[deriv_num][j] == 2)
2359
 
        {
2360
 
          new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0] + coeff0_10*dmats2[10][0] + coeff0_11*dmats2[11][0] + coeff0_12*dmats2[12][0] + coeff0_13*dmats2[13][0] + coeff0_14*dmats2[14][0] + coeff0_15*dmats2[15][0] + coeff0_16*dmats2[16][0] + coeff0_17*dmats2[17][0] + coeff0_18*dmats2[18][0] + coeff0_19*dmats2[19][0];
2361
 
          new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1] + coeff0_10*dmats2[10][1] + coeff0_11*dmats2[11][1] + coeff0_12*dmats2[12][1] + coeff0_13*dmats2[13][1] + coeff0_14*dmats2[14][1] + coeff0_15*dmats2[15][1] + coeff0_16*dmats2[16][1] + coeff0_17*dmats2[17][1] + coeff0_18*dmats2[18][1] + coeff0_19*dmats2[19][1];
2362
 
          new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2] + coeff0_10*dmats2[10][2] + coeff0_11*dmats2[11][2] + coeff0_12*dmats2[12][2] + coeff0_13*dmats2[13][2] + coeff0_14*dmats2[14][2] + coeff0_15*dmats2[15][2] + coeff0_16*dmats2[16][2] + coeff0_17*dmats2[17][2] + coeff0_18*dmats2[18][2] + coeff0_19*dmats2[19][2];
2363
 
          new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3] + coeff0_10*dmats2[10][3] + coeff0_11*dmats2[11][3] + coeff0_12*dmats2[12][3] + coeff0_13*dmats2[13][3] + coeff0_14*dmats2[14][3] + coeff0_15*dmats2[15][3] + coeff0_16*dmats2[16][3] + coeff0_17*dmats2[17][3] + coeff0_18*dmats2[18][3] + coeff0_19*dmats2[19][3];
2364
 
          new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4] + coeff0_10*dmats2[10][4] + coeff0_11*dmats2[11][4] + coeff0_12*dmats2[12][4] + coeff0_13*dmats2[13][4] + coeff0_14*dmats2[14][4] + coeff0_15*dmats2[15][4] + coeff0_16*dmats2[16][4] + coeff0_17*dmats2[17][4] + coeff0_18*dmats2[18][4] + coeff0_19*dmats2[19][4];
2365
 
          new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5] + coeff0_10*dmats2[10][5] + coeff0_11*dmats2[11][5] + coeff0_12*dmats2[12][5] + coeff0_13*dmats2[13][5] + coeff0_14*dmats2[14][5] + coeff0_15*dmats2[15][5] + coeff0_16*dmats2[16][5] + coeff0_17*dmats2[17][5] + coeff0_18*dmats2[18][5] + coeff0_19*dmats2[19][5];
2366
 
          new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6] + coeff0_10*dmats2[10][6] + coeff0_11*dmats2[11][6] + coeff0_12*dmats2[12][6] + coeff0_13*dmats2[13][6] + coeff0_14*dmats2[14][6] + coeff0_15*dmats2[15][6] + coeff0_16*dmats2[16][6] + coeff0_17*dmats2[17][6] + coeff0_18*dmats2[18][6] + coeff0_19*dmats2[19][6];
2367
 
          new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7] + coeff0_10*dmats2[10][7] + coeff0_11*dmats2[11][7] + coeff0_12*dmats2[12][7] + coeff0_13*dmats2[13][7] + coeff0_14*dmats2[14][7] + coeff0_15*dmats2[15][7] + coeff0_16*dmats2[16][7] + coeff0_17*dmats2[17][7] + coeff0_18*dmats2[18][7] + coeff0_19*dmats2[19][7];
2368
 
          new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8] + coeff0_10*dmats2[10][8] + coeff0_11*dmats2[11][8] + coeff0_12*dmats2[12][8] + coeff0_13*dmats2[13][8] + coeff0_14*dmats2[14][8] + coeff0_15*dmats2[15][8] + coeff0_16*dmats2[16][8] + coeff0_17*dmats2[17][8] + coeff0_18*dmats2[18][8] + coeff0_19*dmats2[19][8];
2369
 
          new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9] + coeff0_10*dmats2[10][9] + coeff0_11*dmats2[11][9] + coeff0_12*dmats2[12][9] + coeff0_13*dmats2[13][9] + coeff0_14*dmats2[14][9] + coeff0_15*dmats2[15][9] + coeff0_16*dmats2[16][9] + coeff0_17*dmats2[17][9] + coeff0_18*dmats2[18][9] + coeff0_19*dmats2[19][9];
2370
 
          new_coeff0_10 = coeff0_0*dmats2[0][10] + coeff0_1*dmats2[1][10] + coeff0_2*dmats2[2][10] + coeff0_3*dmats2[3][10] + coeff0_4*dmats2[4][10] + coeff0_5*dmats2[5][10] + coeff0_6*dmats2[6][10] + coeff0_7*dmats2[7][10] + coeff0_8*dmats2[8][10] + coeff0_9*dmats2[9][10] + coeff0_10*dmats2[10][10] + coeff0_11*dmats2[11][10] + coeff0_12*dmats2[12][10] + coeff0_13*dmats2[13][10] + coeff0_14*dmats2[14][10] + coeff0_15*dmats2[15][10] + coeff0_16*dmats2[16][10] + coeff0_17*dmats2[17][10] + coeff0_18*dmats2[18][10] + coeff0_19*dmats2[19][10];
2371
 
          new_coeff0_11 = coeff0_0*dmats2[0][11] + coeff0_1*dmats2[1][11] + coeff0_2*dmats2[2][11] + coeff0_3*dmats2[3][11] + coeff0_4*dmats2[4][11] + coeff0_5*dmats2[5][11] + coeff0_6*dmats2[6][11] + coeff0_7*dmats2[7][11] + coeff0_8*dmats2[8][11] + coeff0_9*dmats2[9][11] + coeff0_10*dmats2[10][11] + coeff0_11*dmats2[11][11] + coeff0_12*dmats2[12][11] + coeff0_13*dmats2[13][11] + coeff0_14*dmats2[14][11] + coeff0_15*dmats2[15][11] + coeff0_16*dmats2[16][11] + coeff0_17*dmats2[17][11] + coeff0_18*dmats2[18][11] + coeff0_19*dmats2[19][11];
2372
 
          new_coeff0_12 = coeff0_0*dmats2[0][12] + coeff0_1*dmats2[1][12] + coeff0_2*dmats2[2][12] + coeff0_3*dmats2[3][12] + coeff0_4*dmats2[4][12] + coeff0_5*dmats2[5][12] + coeff0_6*dmats2[6][12] + coeff0_7*dmats2[7][12] + coeff0_8*dmats2[8][12] + coeff0_9*dmats2[9][12] + coeff0_10*dmats2[10][12] + coeff0_11*dmats2[11][12] + coeff0_12*dmats2[12][12] + coeff0_13*dmats2[13][12] + coeff0_14*dmats2[14][12] + coeff0_15*dmats2[15][12] + coeff0_16*dmats2[16][12] + coeff0_17*dmats2[17][12] + coeff0_18*dmats2[18][12] + coeff0_19*dmats2[19][12];
2373
 
          new_coeff0_13 = coeff0_0*dmats2[0][13] + coeff0_1*dmats2[1][13] + coeff0_2*dmats2[2][13] + coeff0_3*dmats2[3][13] + coeff0_4*dmats2[4][13] + coeff0_5*dmats2[5][13] + coeff0_6*dmats2[6][13] + coeff0_7*dmats2[7][13] + coeff0_8*dmats2[8][13] + coeff0_9*dmats2[9][13] + coeff0_10*dmats2[10][13] + coeff0_11*dmats2[11][13] + coeff0_12*dmats2[12][13] + coeff0_13*dmats2[13][13] + coeff0_14*dmats2[14][13] + coeff0_15*dmats2[15][13] + coeff0_16*dmats2[16][13] + coeff0_17*dmats2[17][13] + coeff0_18*dmats2[18][13] + coeff0_19*dmats2[19][13];
2374
 
          new_coeff0_14 = coeff0_0*dmats2[0][14] + coeff0_1*dmats2[1][14] + coeff0_2*dmats2[2][14] + coeff0_3*dmats2[3][14] + coeff0_4*dmats2[4][14] + coeff0_5*dmats2[5][14] + coeff0_6*dmats2[6][14] + coeff0_7*dmats2[7][14] + coeff0_8*dmats2[8][14] + coeff0_9*dmats2[9][14] + coeff0_10*dmats2[10][14] + coeff0_11*dmats2[11][14] + coeff0_12*dmats2[12][14] + coeff0_13*dmats2[13][14] + coeff0_14*dmats2[14][14] + coeff0_15*dmats2[15][14] + coeff0_16*dmats2[16][14] + coeff0_17*dmats2[17][14] + coeff0_18*dmats2[18][14] + coeff0_19*dmats2[19][14];
2375
 
          new_coeff0_15 = coeff0_0*dmats2[0][15] + coeff0_1*dmats2[1][15] + coeff0_2*dmats2[2][15] + coeff0_3*dmats2[3][15] + coeff0_4*dmats2[4][15] + coeff0_5*dmats2[5][15] + coeff0_6*dmats2[6][15] + coeff0_7*dmats2[7][15] + coeff0_8*dmats2[8][15] + coeff0_9*dmats2[9][15] + coeff0_10*dmats2[10][15] + coeff0_11*dmats2[11][15] + coeff0_12*dmats2[12][15] + coeff0_13*dmats2[13][15] + coeff0_14*dmats2[14][15] + coeff0_15*dmats2[15][15] + coeff0_16*dmats2[16][15] + coeff0_17*dmats2[17][15] + coeff0_18*dmats2[18][15] + coeff0_19*dmats2[19][15];
2376
 
          new_coeff0_16 = coeff0_0*dmats2[0][16] + coeff0_1*dmats2[1][16] + coeff0_2*dmats2[2][16] + coeff0_3*dmats2[3][16] + coeff0_4*dmats2[4][16] + coeff0_5*dmats2[5][16] + coeff0_6*dmats2[6][16] + coeff0_7*dmats2[7][16] + coeff0_8*dmats2[8][16] + coeff0_9*dmats2[9][16] + coeff0_10*dmats2[10][16] + coeff0_11*dmats2[11][16] + coeff0_12*dmats2[12][16] + coeff0_13*dmats2[13][16] + coeff0_14*dmats2[14][16] + coeff0_15*dmats2[15][16] + coeff0_16*dmats2[16][16] + coeff0_17*dmats2[17][16] + coeff0_18*dmats2[18][16] + coeff0_19*dmats2[19][16];
2377
 
          new_coeff0_17 = coeff0_0*dmats2[0][17] + coeff0_1*dmats2[1][17] + coeff0_2*dmats2[2][17] + coeff0_3*dmats2[3][17] + coeff0_4*dmats2[4][17] + coeff0_5*dmats2[5][17] + coeff0_6*dmats2[6][17] + coeff0_7*dmats2[7][17] + coeff0_8*dmats2[8][17] + coeff0_9*dmats2[9][17] + coeff0_10*dmats2[10][17] + coeff0_11*dmats2[11][17] + coeff0_12*dmats2[12][17] + coeff0_13*dmats2[13][17] + coeff0_14*dmats2[14][17] + coeff0_15*dmats2[15][17] + coeff0_16*dmats2[16][17] + coeff0_17*dmats2[17][17] + coeff0_18*dmats2[18][17] + coeff0_19*dmats2[19][17];
2378
 
          new_coeff0_18 = coeff0_0*dmats2[0][18] + coeff0_1*dmats2[1][18] + coeff0_2*dmats2[2][18] + coeff0_3*dmats2[3][18] + coeff0_4*dmats2[4][18] + coeff0_5*dmats2[5][18] + coeff0_6*dmats2[6][18] + coeff0_7*dmats2[7][18] + coeff0_8*dmats2[8][18] + coeff0_9*dmats2[9][18] + coeff0_10*dmats2[10][18] + coeff0_11*dmats2[11][18] + coeff0_12*dmats2[12][18] + coeff0_13*dmats2[13][18] + coeff0_14*dmats2[14][18] + coeff0_15*dmats2[15][18] + coeff0_16*dmats2[16][18] + coeff0_17*dmats2[17][18] + coeff0_18*dmats2[18][18] + coeff0_19*dmats2[19][18];
2379
 
          new_coeff0_19 = coeff0_0*dmats2[0][19] + coeff0_1*dmats2[1][19] + coeff0_2*dmats2[2][19] + coeff0_3*dmats2[3][19] + coeff0_4*dmats2[4][19] + coeff0_5*dmats2[5][19] + coeff0_6*dmats2[6][19] + coeff0_7*dmats2[7][19] + coeff0_8*dmats2[8][19] + coeff0_9*dmats2[9][19] + coeff0_10*dmats2[10][19] + coeff0_11*dmats2[11][19] + coeff0_12*dmats2[12][19] + coeff0_13*dmats2[13][19] + coeff0_14*dmats2[14][19] + coeff0_15*dmats2[15][19] + coeff0_16*dmats2[16][19] + coeff0_17*dmats2[17][19] + coeff0_18*dmats2[18][19] + coeff0_19*dmats2[19][19];
2380
 
        }
2381
 
    
2382
 
      }
2383
 
      // Compute derivatives on reference element as dot product of coefficients and basisvalues
2384
 
      derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9 + new_coeff0_10*basisvalue10 + new_coeff0_11*basisvalue11 + new_coeff0_12*basisvalue12 + new_coeff0_13*basisvalue13 + new_coeff0_14*basisvalue14 + new_coeff0_15*basisvalue15 + new_coeff0_16*basisvalue16 + new_coeff0_17*basisvalue17 + new_coeff0_18*basisvalue18 + new_coeff0_19*basisvalue19;
2385
 
    }
2386
 
    
2387
 
    // Transform derivatives back to physical element
2388
 
    for (unsigned int row = 0; row < num_derivatives; row++)
2389
 
    {
2390
 
      for (unsigned int col = 0; col < num_derivatives; col++)
2391
 
      {
2392
 
        values[row] += transform[row][col]*derivatives[col];
2393
 
      }
2394
 
    }
2395
 
    // Delete pointer to array of derivatives on FIAT element
2396
 
    delete [] derivatives;
2397
 
    
2398
 
    // Delete pointer to array of combinations of derivatives and transform
2399
 
    for (unsigned int row = 0; row < num_derivatives; row++)
2400
 
    {
2401
 
      delete [] combinations[row];
2402
 
      delete [] transform[row];
2403
 
    }
2404
 
    
2405
 
    delete [] combinations;
2406
 
    delete [] transform;
2407
 
  }
2408
 
 
2409
 
  /// Evaluate order n derivatives of all basis functions at given point in cell
2410
 
  virtual void evaluate_basis_derivatives_all(unsigned int n,
2411
 
                                              double* values,
2412
 
                                              const double* coordinates,
2413
 
                                              const ufc::cell& c) const
2414
 
  {
2415
 
    throw std::runtime_error("The vectorised version of evaluate_basis_derivatives() is not yet implemented.");
2416
 
  }
2417
 
 
2418
 
  /// Evaluate linear functional for dof i on the function f
2419
 
  virtual double evaluate_dof(unsigned int i,
2420
 
                              const ufc::function& f,
2421
 
                              const ufc::cell& c) const
2422
 
  {
2423
 
    // The reference points, direction and weights:
2424
 
    const static double X[20][1][3] = {{{0, 0, 0}}, {{0.333333333333333, 0, 0}}, {{0.666666666666667, 0, 0}}, {{1, 0, 0}}, {{0, 0.333333333333333, 0}}, {{0.333333333333333, 0.333333333333333, 0}}, {{0.666666666666667, 0.333333333333333, 0}}, {{0, 0.666666666666667, 0}}, {{0.333333333333333, 0.666666666666667, 0}}, {{0, 1, 0}}, {{0, 0, 0.333333333333333}}, {{0.333333333333333, 0, 0.333333333333333}}, {{0.666666666666667, 0, 0.333333333333333}}, {{0, 0.333333333333333, 0.333333333333333}}, {{0.333333333333333, 0.333333333333333, 0.333333333333333}}, {{0, 0.666666666666667, 0.333333333333333}}, {{0, 0, 0.666666666666667}}, {{0.333333333333333, 0, 0.666666666666667}}, {{0, 0.333333333333333, 0.666666666666667}}, {{0, 0, 1}}};
2425
 
    const static double W[20][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
2426
 
    const static double D[20][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
2427
 
    
2428
 
    const double * const * x = c.coordinates;
2429
 
    double result = 0.0;
2430
 
    // Iterate over the points:
2431
 
    // Evaluate basis functions for affine mapping
2432
 
    const double w0 = 1.0 - X[i][0][0] - X[i][0][1] - X[i][0][2];
2433
 
    const double w1 = X[i][0][0];
2434
 
    const double w2 = X[i][0][1];
2435
 
    const double w3 = X[i][0][2];
2436
 
    
2437
 
    // Compute affine mapping y = F(X)
2438
 
    double y[3];
2439
 
    y[0] = w0*x[0][0] + w1*x[1][0] + w2*x[2][0] + w3*x[3][0];
2440
 
    y[1] = w0*x[0][1] + w1*x[1][1] + w2*x[2][1] + w3*x[3][1];
2441
 
    y[2] = w0*x[0][2] + w1*x[1][2] + w2*x[2][2] + w3*x[3][2];
2442
 
    
2443
 
    // Evaluate function at physical points
2444
 
    double values[1];
2445
 
    f.evaluate(values, y, c);
2446
 
    
2447
 
    // Map function values using appropriate mapping
2448
 
    // Affine map: Do nothing
2449
 
    
2450
 
    // Note that we do not map the weights (yet).
2451
 
    
2452
 
    // Take directional components
2453
 
    for(int k = 0; k < 1; k++)
2454
 
      result += values[k]*D[i][0][k];
2455
 
    // Multiply by weights 
2456
 
    result *= W[i][0];
2457
 
    
2458
 
    return result;
2459
 
  }
2460
 
 
2461
 
  /// Evaluate linear functionals for all dofs on the function f
2462
 
  virtual void evaluate_dofs(double* values,
2463
 
                             const ufc::function& f,
2464
 
                             const ufc::cell& c) const
2465
 
  {
2466
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
2467
 
  }
2468
 
 
2469
 
  /// Interpolate vertex values from dof values
2470
 
  virtual void interpolate_vertex_values(double* vertex_values,
2471
 
                                         const double* dof_values,
2472
 
                                         const ufc::cell& c) const
2473
 
  {
2474
 
    // Evaluate at vertices and use affine mapping
2475
 
    vertex_values[0] = dof_values[0];
2476
 
    vertex_values[1] = dof_values[3];
2477
 
    vertex_values[2] = dof_values[9];
2478
 
    vertex_values[3] = dof_values[19];
2479
 
  }
2480
 
 
2481
 
  /// Return the number of sub elements (for a mixed element)
2482
 
  virtual unsigned int num_sub_elements() const
2483
 
  {
2484
 
    return 1;
2485
 
  }
2486
 
 
2487
 
  /// Create a new finite element for sub element i (for a mixed element)
2488
 
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
2489
 
  {
2490
 
    return new ffc_25_finite_element_0_2();
2491
 
  }
2492
 
 
2493
 
};
2494
 
 
2495
 
/// This class defines the interface for a finite element.
2496
 
 
2497
 
class ffc_25_finite_element_0: public ufc::finite_element
2498
 
{
2499
 
public:
2500
 
 
2501
 
  /// Constructor
2502
 
  ffc_25_finite_element_0() : ufc::finite_element()
2503
 
  {
2504
 
    // Do nothing
2505
 
  }
2506
 
 
2507
 
  /// Destructor
2508
 
  virtual ~ffc_25_finite_element_0()
2509
 
  {
2510
 
    // Do nothing
2511
 
  }
2512
 
 
2513
 
  /// Return a string identifying the finite element
2514
 
  virtual const char* signature() const
2515
 
  {
2516
 
    return "Mixed finite element: [Discontinuous Lagrange finite element of degree 3 on a tetrahedron, Discontinuous Lagrange finite element of degree 3 on a tetrahedron, Discontinuous Lagrange finite element of degree 3 on a tetrahedron]";
2517
 
  }
2518
 
 
2519
 
  /// Return the cell shape
2520
 
  virtual ufc::shape cell_shape() const
2521
 
  {
2522
 
    return ufc::tetrahedron;
2523
 
  }
2524
 
 
2525
 
  /// Return the dimension of the finite element function space
2526
 
  virtual unsigned int space_dimension() const
2527
 
  {
2528
 
    return 60;
2529
 
  }
2530
 
 
2531
 
  /// Return the rank of the value space
2532
 
  virtual unsigned int value_rank() const
2533
 
  {
2534
 
    return 1;
2535
 
  }
2536
 
 
2537
 
  /// Return the dimension of the value space for axis i
2538
 
  virtual unsigned int value_dimension(unsigned int i) const
2539
 
  {
2540
 
    return 3;
2541
 
  }
2542
 
 
2543
 
  /// Evaluate basis function i at given point in cell
2544
 
  virtual void evaluate_basis(unsigned int i,
2545
 
                              double* values,
2546
 
                              const double* coordinates,
2547
 
                              const ufc::cell& c) const
2548
 
  {
2549
 
    // Extract vertex coordinates
2550
 
    const double * const * element_coordinates = c.coordinates;
2551
 
    
2552
 
    // Compute Jacobian of affine map from reference cell
2553
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
2554
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
2555
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
2556
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
2557
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
2558
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
2559
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
2560
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
2561
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
2562
 
      
2563
 
    // Compute sub determinants
2564
 
    const double d00 = J_11*J_22 - J_12*J_21;
2565
 
    const double d01 = J_12*J_20 - J_10*J_22;
2566
 
    const double d02 = J_10*J_21 - J_11*J_20;
2567
 
    
2568
 
    const double d10 = J_02*J_21 - J_01*J_22;
2569
 
    const double d11 = J_00*J_22 - J_02*J_20;
2570
 
    const double d12 = J_01*J_20 - J_00*J_21;
2571
 
    
2572
 
    const double d20 = J_01*J_12 - J_02*J_11;
2573
 
    const double d21 = J_02*J_10 - J_00*J_12;
2574
 
    const double d22 = J_00*J_11 - J_01*J_10;
2575
 
      
2576
 
    // Compute determinant of Jacobian
2577
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
2578
 
    
2579
 
    // Compute inverse of Jacobian
2580
 
    
2581
 
    // Compute constants
2582
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
2583
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
2584
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
2585
 
    
2586
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
2587
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
2588
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
2589
 
    
2590
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
2591
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
2592
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
2593
 
    
2594
 
    // Get coordinates and map to the UFC reference element
2595
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
2596
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
2597
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
2598
 
    
2599
 
    // Map coordinates to the reference cube
2600
 
    if (std::abs(y + z - 1.0) < 1e-14)
2601
 
      x = 1.0;
2602
 
    else
2603
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
2604
 
    if (std::abs(z - 1.0) < 1e-14)
2605
 
      y = -1.0;
2606
 
    else
2607
 
      y = 2.0 * y/(1.0 - z) - 1.0;
2608
 
    z = 2.0 * z - 1.0;
2609
 
    
2610
 
    // Reset values
2611
 
    values[0] = 0;
2612
 
    values[1] = 0;
2613
 
    values[2] = 0;
2614
 
    
2615
 
    if (0 <= i && i <= 19)
2616
 
    {
2617
 
      // Map degree of freedom to element degree of freedom
2618
 
      const unsigned int dof = i;
2619
 
    
2620
 
      // Generate scalings
2621
 
      const double scalings_y_0 = 1;
2622
 
      const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
2623
 
      const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
2624
 
      const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
2625
 
      const double scalings_z_0 = 1;
2626
 
      const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
2627
 
      const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
2628
 
      const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
2629
 
    
2630
 
      // Compute psitilde_a
2631
 
      const double psitilde_a_0 = 1;
2632
 
      const double psitilde_a_1 = x;
2633
 
      const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
2634
 
      const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
2635
 
    
2636
 
      // Compute psitilde_bs
2637
 
      const double psitilde_bs_0_0 = 1;
2638
 
      const double psitilde_bs_0_1 = 1.5*y + 0.5;
2639
 
      const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
2640
 
      const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
2641
 
      const double psitilde_bs_1_0 = 1;
2642
 
      const double psitilde_bs_1_1 = 2.5*y + 1.5;
2643
 
      const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
2644
 
      const double psitilde_bs_2_0 = 1;
2645
 
      const double psitilde_bs_2_1 = 3.5*y + 2.5;
2646
 
      const double psitilde_bs_3_0 = 1;
2647
 
    
2648
 
      // Compute psitilde_cs
2649
 
      const double psitilde_cs_00_0 = 1;
2650
 
      const double psitilde_cs_00_1 = 2*z + 1;
2651
 
      const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
2652
 
      const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
2653
 
      const double psitilde_cs_01_0 = 1;
2654
 
      const double psitilde_cs_01_1 = 3*z + 2;
2655
 
      const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
2656
 
      const double psitilde_cs_02_0 = 1;
2657
 
      const double psitilde_cs_02_1 = 4*z + 3;
2658
 
      const double psitilde_cs_03_0 = 1;
2659
 
      const double psitilde_cs_10_0 = 1;
2660
 
      const double psitilde_cs_10_1 = 3*z + 2;
2661
 
      const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
2662
 
      const double psitilde_cs_11_0 = 1;
2663
 
      const double psitilde_cs_11_1 = 4*z + 3;
2664
 
      const double psitilde_cs_12_0 = 1;
2665
 
      const double psitilde_cs_20_0 = 1;
2666
 
      const double psitilde_cs_20_1 = 4*z + 3;
2667
 
      const double psitilde_cs_21_0 = 1;
2668
 
      const double psitilde_cs_30_0 = 1;
2669
 
    
2670
 
      // Compute basisvalues
2671
 
      const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
2672
 
      const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
2673
 
      const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
2674
 
      const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
2675
 
      const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
2676
 
      const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
2677
 
      const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
2678
 
      const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
2679
 
      const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
2680
 
      const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
2681
 
      const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
2682
 
      const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
2683
 
      const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
2684
 
      const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
2685
 
      const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
2686
 
      const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
2687
 
      const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
2688
 
      const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
2689
 
      const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
2690
 
      const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
2691
 
    
2692
 
      // Table(s) of coefficients
2693
 
      const static double coefficients0[20][20] =   \
2694
 
      {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
2695
 
      {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
2696
 
      {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
2697
 
      {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
2698
 
      {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
2699
 
      {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
2700
 
      {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
2701
 
      {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
2702
 
      {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
2703
 
      {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
2704
 
      {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
2705
 
      {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
2706
 
      {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
2707
 
      {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
2708
 
      {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
2709
 
      {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
2710
 
      {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
2711
 
      {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
2712
 
      {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
2713
 
      {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
2714
 
    
2715
 
      // Extract relevant coefficients
2716
 
      const double coeff0_0 =   coefficients0[dof][0];
2717
 
      const double coeff0_1 =   coefficients0[dof][1];
2718
 
      const double coeff0_2 =   coefficients0[dof][2];
2719
 
      const double coeff0_3 =   coefficients0[dof][3];
2720
 
      const double coeff0_4 =   coefficients0[dof][4];
2721
 
      const double coeff0_5 =   coefficients0[dof][5];
2722
 
      const double coeff0_6 =   coefficients0[dof][6];
2723
 
      const double coeff0_7 =   coefficients0[dof][7];
2724
 
      const double coeff0_8 =   coefficients0[dof][8];
2725
 
      const double coeff0_9 =   coefficients0[dof][9];
2726
 
      const double coeff0_10 =   coefficients0[dof][10];
2727
 
      const double coeff0_11 =   coefficients0[dof][11];
2728
 
      const double coeff0_12 =   coefficients0[dof][12];
2729
 
      const double coeff0_13 =   coefficients0[dof][13];
2730
 
      const double coeff0_14 =   coefficients0[dof][14];
2731
 
      const double coeff0_15 =   coefficients0[dof][15];
2732
 
      const double coeff0_16 =   coefficients0[dof][16];
2733
 
      const double coeff0_17 =   coefficients0[dof][17];
2734
 
      const double coeff0_18 =   coefficients0[dof][18];
2735
 
      const double coeff0_19 =   coefficients0[dof][19];
2736
 
    
2737
 
      // Compute value(s)
2738
 
      values[0] = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9 + coeff0_10*basisvalue10 + coeff0_11*basisvalue11 + coeff0_12*basisvalue12 + coeff0_13*basisvalue13 + coeff0_14*basisvalue14 + coeff0_15*basisvalue15 + coeff0_16*basisvalue16 + coeff0_17*basisvalue17 + coeff0_18*basisvalue18 + coeff0_19*basisvalue19;
2739
 
    }
2740
 
    
2741
 
    if (20 <= i && i <= 39)
2742
 
    {
2743
 
      // Map degree of freedom to element degree of freedom
2744
 
      const unsigned int dof = i - 20;
2745
 
    
2746
 
      // Generate scalings
2747
 
      const double scalings_y_0 = 1;
2748
 
      const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
2749
 
      const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
2750
 
      const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
2751
 
      const double scalings_z_0 = 1;
2752
 
      const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
2753
 
      const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
2754
 
      const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
2755
 
    
2756
 
      // Compute psitilde_a
2757
 
      const double psitilde_a_0 = 1;
2758
 
      const double psitilde_a_1 = x;
2759
 
      const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
2760
 
      const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
2761
 
    
2762
 
      // Compute psitilde_bs
2763
 
      const double psitilde_bs_0_0 = 1;
2764
 
      const double psitilde_bs_0_1 = 1.5*y + 0.5;
2765
 
      const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
2766
 
      const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
2767
 
      const double psitilde_bs_1_0 = 1;
2768
 
      const double psitilde_bs_1_1 = 2.5*y + 1.5;
2769
 
      const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
2770
 
      const double psitilde_bs_2_0 = 1;
2771
 
      const double psitilde_bs_2_1 = 3.5*y + 2.5;
2772
 
      const double psitilde_bs_3_0 = 1;
2773
 
    
2774
 
      // Compute psitilde_cs
2775
 
      const double psitilde_cs_00_0 = 1;
2776
 
      const double psitilde_cs_00_1 = 2*z + 1;
2777
 
      const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
2778
 
      const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
2779
 
      const double psitilde_cs_01_0 = 1;
2780
 
      const double psitilde_cs_01_1 = 3*z + 2;
2781
 
      const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
2782
 
      const double psitilde_cs_02_0 = 1;
2783
 
      const double psitilde_cs_02_1 = 4*z + 3;
2784
 
      const double psitilde_cs_03_0 = 1;
2785
 
      const double psitilde_cs_10_0 = 1;
2786
 
      const double psitilde_cs_10_1 = 3*z + 2;
2787
 
      const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
2788
 
      const double psitilde_cs_11_0 = 1;
2789
 
      const double psitilde_cs_11_1 = 4*z + 3;
2790
 
      const double psitilde_cs_12_0 = 1;
2791
 
      const double psitilde_cs_20_0 = 1;
2792
 
      const double psitilde_cs_20_1 = 4*z + 3;
2793
 
      const double psitilde_cs_21_0 = 1;
2794
 
      const double psitilde_cs_30_0 = 1;
2795
 
    
2796
 
      // Compute basisvalues
2797
 
      const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
2798
 
      const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
2799
 
      const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
2800
 
      const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
2801
 
      const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
2802
 
      const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
2803
 
      const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
2804
 
      const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
2805
 
      const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
2806
 
      const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
2807
 
      const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
2808
 
      const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
2809
 
      const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
2810
 
      const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
2811
 
      const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
2812
 
      const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
2813
 
      const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
2814
 
      const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
2815
 
      const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
2816
 
      const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
2817
 
    
2818
 
      // Table(s) of coefficients
2819
 
      const static double coefficients0[20][20] =   \
2820
 
      {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
2821
 
      {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
2822
 
      {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
2823
 
      {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
2824
 
      {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
2825
 
      {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
2826
 
      {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
2827
 
      {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
2828
 
      {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
2829
 
      {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
2830
 
      {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
2831
 
      {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
2832
 
      {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
2833
 
      {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
2834
 
      {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
2835
 
      {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
2836
 
      {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
2837
 
      {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
2838
 
      {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
2839
 
      {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
2840
 
    
2841
 
      // Extract relevant coefficients
2842
 
      const double coeff0_0 =   coefficients0[dof][0];
2843
 
      const double coeff0_1 =   coefficients0[dof][1];
2844
 
      const double coeff0_2 =   coefficients0[dof][2];
2845
 
      const double coeff0_3 =   coefficients0[dof][3];
2846
 
      const double coeff0_4 =   coefficients0[dof][4];
2847
 
      const double coeff0_5 =   coefficients0[dof][5];
2848
 
      const double coeff0_6 =   coefficients0[dof][6];
2849
 
      const double coeff0_7 =   coefficients0[dof][7];
2850
 
      const double coeff0_8 =   coefficients0[dof][8];
2851
 
      const double coeff0_9 =   coefficients0[dof][9];
2852
 
      const double coeff0_10 =   coefficients0[dof][10];
2853
 
      const double coeff0_11 =   coefficients0[dof][11];
2854
 
      const double coeff0_12 =   coefficients0[dof][12];
2855
 
      const double coeff0_13 =   coefficients0[dof][13];
2856
 
      const double coeff0_14 =   coefficients0[dof][14];
2857
 
      const double coeff0_15 =   coefficients0[dof][15];
2858
 
      const double coeff0_16 =   coefficients0[dof][16];
2859
 
      const double coeff0_17 =   coefficients0[dof][17];
2860
 
      const double coeff0_18 =   coefficients0[dof][18];
2861
 
      const double coeff0_19 =   coefficients0[dof][19];
2862
 
    
2863
 
      // Compute value(s)
2864
 
      values[1] = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9 + coeff0_10*basisvalue10 + coeff0_11*basisvalue11 + coeff0_12*basisvalue12 + coeff0_13*basisvalue13 + coeff0_14*basisvalue14 + coeff0_15*basisvalue15 + coeff0_16*basisvalue16 + coeff0_17*basisvalue17 + coeff0_18*basisvalue18 + coeff0_19*basisvalue19;
2865
 
    }
2866
 
    
2867
 
    if (40 <= i && i <= 59)
2868
 
    {
2869
 
      // Map degree of freedom to element degree of freedom
2870
 
      const unsigned int dof = i - 40;
2871
 
    
2872
 
      // Generate scalings
2873
 
      const double scalings_y_0 = 1;
2874
 
      const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
2875
 
      const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
2876
 
      const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
2877
 
      const double scalings_z_0 = 1;
2878
 
      const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
2879
 
      const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
2880
 
      const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
2881
 
    
2882
 
      // Compute psitilde_a
2883
 
      const double psitilde_a_0 = 1;
2884
 
      const double psitilde_a_1 = x;
2885
 
      const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
2886
 
      const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
2887
 
    
2888
 
      // Compute psitilde_bs
2889
 
      const double psitilde_bs_0_0 = 1;
2890
 
      const double psitilde_bs_0_1 = 1.5*y + 0.5;
2891
 
      const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
2892
 
      const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
2893
 
      const double psitilde_bs_1_0 = 1;
2894
 
      const double psitilde_bs_1_1 = 2.5*y + 1.5;
2895
 
      const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
2896
 
      const double psitilde_bs_2_0 = 1;
2897
 
      const double psitilde_bs_2_1 = 3.5*y + 2.5;
2898
 
      const double psitilde_bs_3_0 = 1;
2899
 
    
2900
 
      // Compute psitilde_cs
2901
 
      const double psitilde_cs_00_0 = 1;
2902
 
      const double psitilde_cs_00_1 = 2*z + 1;
2903
 
      const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
2904
 
      const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
2905
 
      const double psitilde_cs_01_0 = 1;
2906
 
      const double psitilde_cs_01_1 = 3*z + 2;
2907
 
      const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
2908
 
      const double psitilde_cs_02_0 = 1;
2909
 
      const double psitilde_cs_02_1 = 4*z + 3;
2910
 
      const double psitilde_cs_03_0 = 1;
2911
 
      const double psitilde_cs_10_0 = 1;
2912
 
      const double psitilde_cs_10_1 = 3*z + 2;
2913
 
      const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
2914
 
      const double psitilde_cs_11_0 = 1;
2915
 
      const double psitilde_cs_11_1 = 4*z + 3;
2916
 
      const double psitilde_cs_12_0 = 1;
2917
 
      const double psitilde_cs_20_0 = 1;
2918
 
      const double psitilde_cs_20_1 = 4*z + 3;
2919
 
      const double psitilde_cs_21_0 = 1;
2920
 
      const double psitilde_cs_30_0 = 1;
2921
 
    
2922
 
      // Compute basisvalues
2923
 
      const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
2924
 
      const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
2925
 
      const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
2926
 
      const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
2927
 
      const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
2928
 
      const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
2929
 
      const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
2930
 
      const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
2931
 
      const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
2932
 
      const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
2933
 
      const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
2934
 
      const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
2935
 
      const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
2936
 
      const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
2937
 
      const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
2938
 
      const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
2939
 
      const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
2940
 
      const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
2941
 
      const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
2942
 
      const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
2943
 
    
2944
 
      // Table(s) of coefficients
2945
 
      const static double coefficients0[20][20] =   \
2946
 
      {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
2947
 
      {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
2948
 
      {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
2949
 
      {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
2950
 
      {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
2951
 
      {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
2952
 
      {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
2953
 
      {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
2954
 
      {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
2955
 
      {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
2956
 
      {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
2957
 
      {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
2958
 
      {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
2959
 
      {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
2960
 
      {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
2961
 
      {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
2962
 
      {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
2963
 
      {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
2964
 
      {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
2965
 
      {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
2966
 
    
2967
 
      // Extract relevant coefficients
2968
 
      const double coeff0_0 =   coefficients0[dof][0];
2969
 
      const double coeff0_1 =   coefficients0[dof][1];
2970
 
      const double coeff0_2 =   coefficients0[dof][2];
2971
 
      const double coeff0_3 =   coefficients0[dof][3];
2972
 
      const double coeff0_4 =   coefficients0[dof][4];
2973
 
      const double coeff0_5 =   coefficients0[dof][5];
2974
 
      const double coeff0_6 =   coefficients0[dof][6];
2975
 
      const double coeff0_7 =   coefficients0[dof][7];
2976
 
      const double coeff0_8 =   coefficients0[dof][8];
2977
 
      const double coeff0_9 =   coefficients0[dof][9];
2978
 
      const double coeff0_10 =   coefficients0[dof][10];
2979
 
      const double coeff0_11 =   coefficients0[dof][11];
2980
 
      const double coeff0_12 =   coefficients0[dof][12];
2981
 
      const double coeff0_13 =   coefficients0[dof][13];
2982
 
      const double coeff0_14 =   coefficients0[dof][14];
2983
 
      const double coeff0_15 =   coefficients0[dof][15];
2984
 
      const double coeff0_16 =   coefficients0[dof][16];
2985
 
      const double coeff0_17 =   coefficients0[dof][17];
2986
 
      const double coeff0_18 =   coefficients0[dof][18];
2987
 
      const double coeff0_19 =   coefficients0[dof][19];
2988
 
    
2989
 
      // Compute value(s)
2990
 
      values[2] = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9 + coeff0_10*basisvalue10 + coeff0_11*basisvalue11 + coeff0_12*basisvalue12 + coeff0_13*basisvalue13 + coeff0_14*basisvalue14 + coeff0_15*basisvalue15 + coeff0_16*basisvalue16 + coeff0_17*basisvalue17 + coeff0_18*basisvalue18 + coeff0_19*basisvalue19;
2991
 
    }
2992
 
    
2993
 
  }
2994
 
 
2995
 
  /// Evaluate all basis functions at given point in cell
2996
 
  virtual void evaluate_basis_all(double* values,
2997
 
                                  const double* coordinates,
2998
 
                                  const ufc::cell& c) const
2999
 
  {
3000
 
    throw std::runtime_error("The vectorised version of evaluate_basis() is not yet implemented.");
3001
 
  }
3002
 
 
3003
 
  /// Evaluate order n derivatives of basis function i at given point in cell
3004
 
  virtual void evaluate_basis_derivatives(unsigned int i,
3005
 
                                          unsigned int n,
3006
 
                                          double* values,
3007
 
                                          const double* coordinates,
3008
 
                                          const ufc::cell& c) const
3009
 
  {
3010
 
    // Extract vertex coordinates
3011
 
    const double * const * element_coordinates = c.coordinates;
3012
 
    
3013
 
    // Compute Jacobian of affine map from reference cell
3014
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
3015
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
3016
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
3017
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
3018
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
3019
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
3020
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
3021
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
3022
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
3023
 
      
3024
 
    // Compute sub determinants
3025
 
    const double d00 = J_11*J_22 - J_12*J_21;
3026
 
    const double d01 = J_12*J_20 - J_10*J_22;
3027
 
    const double d02 = J_10*J_21 - J_11*J_20;
3028
 
    
3029
 
    const double d10 = J_02*J_21 - J_01*J_22;
3030
 
    const double d11 = J_00*J_22 - J_02*J_20;
3031
 
    const double d12 = J_01*J_20 - J_00*J_21;
3032
 
    
3033
 
    const double d20 = J_01*J_12 - J_02*J_11;
3034
 
    const double d21 = J_02*J_10 - J_00*J_12;
3035
 
    const double d22 = J_00*J_11 - J_01*J_10;
3036
 
      
3037
 
    // Compute determinant of Jacobian
3038
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
3039
 
    
3040
 
    // Compute inverse of Jacobian
3041
 
    
3042
 
    // Compute constants
3043
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
3044
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
3045
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
3046
 
    
3047
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
3048
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
3049
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
3050
 
    
3051
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
3052
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
3053
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
3054
 
    
3055
 
    // Get coordinates and map to the UFC reference element
3056
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
3057
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
3058
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
3059
 
    
3060
 
    // Map coordinates to the reference cube
3061
 
    if (std::abs(y + z - 1.0) < 1e-14)
3062
 
      x = 1.0;
3063
 
    else
3064
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
3065
 
    if (std::abs(z - 1.0) < 1e-14)
3066
 
      y = -1.0;
3067
 
    else
3068
 
      y = 2.0 * y/(1.0 - z) - 1.0;
3069
 
    z = 2.0 * z - 1.0;
3070
 
    
3071
 
    // Compute number of derivatives
3072
 
    unsigned int num_derivatives = 1;
3073
 
    
3074
 
    for (unsigned int j = 0; j < n; j++)
3075
 
      num_derivatives *= 3;
3076
 
    
3077
 
    
3078
 
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
3079
 
    unsigned int **combinations = new unsigned int *[num_derivatives];
3080
 
        
3081
 
    for (unsigned int j = 0; j < num_derivatives; j++)
3082
 
    {
3083
 
      combinations[j] = new unsigned int [n];
3084
 
      for (unsigned int k = 0; k < n; k++)
3085
 
        combinations[j][k] = 0;
3086
 
    }
3087
 
        
3088
 
    // Generate combinations of derivatives
3089
 
    for (unsigned int row = 1; row < num_derivatives; row++)
3090
 
    {
3091
 
      for (unsigned int num = 0; num < row; num++)
3092
 
      {
3093
 
        for (unsigned int col = n-1; col+1 > 0; col--)
3094
 
        {
3095
 
          if (combinations[row][col] + 1 > 2)
3096
 
            combinations[row][col] = 0;
3097
 
          else
3098
 
          {
3099
 
            combinations[row][col] += 1;
3100
 
            break;
3101
 
          }
3102
 
        }
3103
 
      }
3104
 
    }
3105
 
    
3106
 
    // Compute inverse of Jacobian
3107
 
    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};
3108
 
    
3109
 
    // Declare transformation matrix
3110
 
    // Declare pointer to two dimensional array and initialise
3111
 
    double **transform = new double *[num_derivatives];
3112
 
        
3113
 
    for (unsigned int j = 0; j < num_derivatives; j++)
3114
 
    {
3115
 
      transform[j] = new double [num_derivatives];
3116
 
      for (unsigned int k = 0; k < num_derivatives; k++)
3117
 
        transform[j][k] = 1;
3118
 
    }
3119
 
    
3120
 
    // Construct transformation matrix
3121
 
    for (unsigned int row = 0; row < num_derivatives; row++)
3122
 
    {
3123
 
      for (unsigned int col = 0; col < num_derivatives; col++)
3124
 
      {
3125
 
        for (unsigned int k = 0; k < n; k++)
3126
 
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
3127
 
      }
3128
 
    }
3129
 
    
3130
 
    // Reset values
3131
 
    for (unsigned int j = 0; j < 3*num_derivatives; j++)
3132
 
      values[j] = 0;
3133
 
    
3134
 
    if (0 <= i && i <= 19)
3135
 
    {
3136
 
      // Map degree of freedom to element degree of freedom
3137
 
      const unsigned int dof = i;
3138
 
    
3139
 
      // Generate scalings
3140
 
      const double scalings_y_0 = 1;
3141
 
      const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
3142
 
      const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
3143
 
      const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
3144
 
      const double scalings_z_0 = 1;
3145
 
      const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
3146
 
      const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
3147
 
      const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
3148
 
    
3149
 
      // Compute psitilde_a
3150
 
      const double psitilde_a_0 = 1;
3151
 
      const double psitilde_a_1 = x;
3152
 
      const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
3153
 
      const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
3154
 
    
3155
 
      // Compute psitilde_bs
3156
 
      const double psitilde_bs_0_0 = 1;
3157
 
      const double psitilde_bs_0_1 = 1.5*y + 0.5;
3158
 
      const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
3159
 
      const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
3160
 
      const double psitilde_bs_1_0 = 1;
3161
 
      const double psitilde_bs_1_1 = 2.5*y + 1.5;
3162
 
      const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
3163
 
      const double psitilde_bs_2_0 = 1;
3164
 
      const double psitilde_bs_2_1 = 3.5*y + 2.5;
3165
 
      const double psitilde_bs_3_0 = 1;
3166
 
    
3167
 
      // Compute psitilde_cs
3168
 
      const double psitilde_cs_00_0 = 1;
3169
 
      const double psitilde_cs_00_1 = 2*z + 1;
3170
 
      const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
3171
 
      const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
3172
 
      const double psitilde_cs_01_0 = 1;
3173
 
      const double psitilde_cs_01_1 = 3*z + 2;
3174
 
      const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
3175
 
      const double psitilde_cs_02_0 = 1;
3176
 
      const double psitilde_cs_02_1 = 4*z + 3;
3177
 
      const double psitilde_cs_03_0 = 1;
3178
 
      const double psitilde_cs_10_0 = 1;
3179
 
      const double psitilde_cs_10_1 = 3*z + 2;
3180
 
      const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
3181
 
      const double psitilde_cs_11_0 = 1;
3182
 
      const double psitilde_cs_11_1 = 4*z + 3;
3183
 
      const double psitilde_cs_12_0 = 1;
3184
 
      const double psitilde_cs_20_0 = 1;
3185
 
      const double psitilde_cs_20_1 = 4*z + 3;
3186
 
      const double psitilde_cs_21_0 = 1;
3187
 
      const double psitilde_cs_30_0 = 1;
3188
 
    
3189
 
      // Compute basisvalues
3190
 
      const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
3191
 
      const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
3192
 
      const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
3193
 
      const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
3194
 
      const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
3195
 
      const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
3196
 
      const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
3197
 
      const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
3198
 
      const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
3199
 
      const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
3200
 
      const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
3201
 
      const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
3202
 
      const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
3203
 
      const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
3204
 
      const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
3205
 
      const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
3206
 
      const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
3207
 
      const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
3208
 
      const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
3209
 
      const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
3210
 
    
3211
 
      // Table(s) of coefficients
3212
 
      const static double coefficients0[20][20] =   \
3213
 
      {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
3214
 
      {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
3215
 
      {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
3216
 
      {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
3217
 
      {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
3218
 
      {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
3219
 
      {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
3220
 
      {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
3221
 
      {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
3222
 
      {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
3223
 
      {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
3224
 
      {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
3225
 
      {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
3226
 
      {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
3227
 
      {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
3228
 
      {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
3229
 
      {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
3230
 
      {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
3231
 
      {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
3232
 
      {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
3233
 
    
3234
 
      // Interesting (new) part
3235
 
      // Tables of derivatives of the polynomial base (transpose)
3236
 
      const static double dmats0[20][20] =   \
3237
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3238
 
      {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3239
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3240
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3241
 
      {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3242
 
      {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3243
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3244
 
      {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3245
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3246
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3247
 
      {5.49909083394701, 0, -3.3466401061363, -2.36643191323985, 15.4919333848297, 0, 0.692820323027551, 0, 0.565685424949239, 0.400000000000001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3248
 
      {0, 4.89897948556636, 0, 0, 0, 14.1985914794391, 0, -0.82807867121083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3249
 
      {3.6, 0, 8.76356092008266, -1.54919333848297, 0, 0, 9.52470471983253, 0, -1.48131215963608, 0.261861468283192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3250
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3251
 
      {0, 4.24264068711928, 0, 0, 0, 0, 0, 14.3427433120127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3252
 
      {3.11769145362398, 0, 3.16227766016838, 4.91934955049954, 0, 0, 0, 0, 10.690449676497, -2.41897262725906, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3253
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3254
 
      {2.54558441227157, 0, 0, 7.66811580507233, 0, 0, 0, 0, 0, 10.3691851174526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3255
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3256
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3257
 
    
3258
 
      const static double dmats1[20][20] =   \
3259
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3260
 
      {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3261
 
      {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3262
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3263
 
      {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3264
 
      {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309959, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3265
 
      {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3266
 
      {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3267
 
      {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3268
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3269
 
      {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.28284271247462, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3270
 
      {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 9.16515138991168, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3271
 
      {1.8, -5.69209978830308, 4.38178046004133, -0.774596669241487, 0, 10.998181667894, 4.76235235991626, 0.962140470884726, -0.740656079818041, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3272
 
      {5.19615242270664, 0, -3.16227766016838, -2.23606797749979, 0, 0, 13.7477270848675, 0, 0.534522483824849, 0.37796447300923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3273
 
      {2.01246117974981, 2.12132034355964, -0.408248290463864, 3.17542648054294, 0, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3274
 
      {1.55884572681199, 2.73861278752583, 1.58113883008419, 2.45967477524977, 0, 0, 0, 9.25820099772551, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3275
 
      {-1.8, 0, 3.65148371670111, -2.84018778721878, 0, 0, 0, 0, 12.3442679969674, 1.39659449751035, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3276
 
      {1.27279220613579, 0, 0, 3.83405790253616, 0, 0, 0, 0, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3277
 
      {2.20454076850486, 0, 0, 6.6407830863536, 0, 0, 0, 0, 0, 8.97997772825746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3278
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3279
 
    
3280
 
      const static double dmats2[20][20] =   \
3281
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3282
 
      {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3283
 
      {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3284
 
      {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3285
 
      {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3286
 
      {2.29128784747792, 1.44913767461895, 4.18330013267038, -0.59160797830996, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3287
 
      {1.32287565553229, 0, 3.86436713231718, -0.341565025531987, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3288
 
      {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3289
 
      {1.08012344973464, 0, 7.09929573971954, 2.50998007960222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3290
 
      {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3291
 
      {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.282842712474619, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3292
 
      {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 1.30930734141595, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3293
 
      {1.8, 0.632455532033675, 4.38178046004133, -0.774596669241484, 0, 3.14233761939829, 4.76235235991626, -0.10690449676497, -0.740656079818042, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3294
 
      {1.03923048454133, 0, 3.16227766016838, -0.447213595499959, 0, 0, 5.8918830363718, 0, -0.53452248382485, 0.0755928946018459, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3295
 
      {2.01246117974981, 2.12132034355964, -0.408248290463863, 3.17542648054294, 9.07114735222145, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3296
 
      {1.55884572681199, 0.547722557505165, 1.58113883008419, 2.45967477524977, 0, 9.07114735222145, 0, 1.8516401995451, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3297
 
      {0.900000000000001, 0, 1.46059348668045, 1.42009389360939, 0, 0, 9.07114735222145, 0, 4.93770719878694, -0.698297248755175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3298
 
      {1.27279220613578, -6.26099033699941, 0, 3.83405790253616, 0, 0, 0, 10.5830052442584, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3299
 
      {0.734846922834954, 0, -6.26099033699941, 2.21359436211787, 0, 0, 0, 0, 10.5830052442584, 2.99332590941915, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3300
 
      {5.7157676649773, 0, 0, -4.69574275274955, 0, 0, 0, 0, 0, 12.69960629311, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3301
 
    
3302
 
      // Compute reference derivatives
3303
 
      // Declare pointer to array of derivatives on FIAT element
3304
 
      double *derivatives = new double [num_derivatives];
3305
 
    
3306
 
      // Declare coefficients
3307
 
      double coeff0_0 = 0;
3308
 
      double coeff0_1 = 0;
3309
 
      double coeff0_2 = 0;
3310
 
      double coeff0_3 = 0;
3311
 
      double coeff0_4 = 0;
3312
 
      double coeff0_5 = 0;
3313
 
      double coeff0_6 = 0;
3314
 
      double coeff0_7 = 0;
3315
 
      double coeff0_8 = 0;
3316
 
      double coeff0_9 = 0;
3317
 
      double coeff0_10 = 0;
3318
 
      double coeff0_11 = 0;
3319
 
      double coeff0_12 = 0;
3320
 
      double coeff0_13 = 0;
3321
 
      double coeff0_14 = 0;
3322
 
      double coeff0_15 = 0;
3323
 
      double coeff0_16 = 0;
3324
 
      double coeff0_17 = 0;
3325
 
      double coeff0_18 = 0;
3326
 
      double coeff0_19 = 0;
3327
 
    
3328
 
      // Declare new coefficients
3329
 
      double new_coeff0_0 = 0;
3330
 
      double new_coeff0_1 = 0;
3331
 
      double new_coeff0_2 = 0;
3332
 
      double new_coeff0_3 = 0;
3333
 
      double new_coeff0_4 = 0;
3334
 
      double new_coeff0_5 = 0;
3335
 
      double new_coeff0_6 = 0;
3336
 
      double new_coeff0_7 = 0;
3337
 
      double new_coeff0_8 = 0;
3338
 
      double new_coeff0_9 = 0;
3339
 
      double new_coeff0_10 = 0;
3340
 
      double new_coeff0_11 = 0;
3341
 
      double new_coeff0_12 = 0;
3342
 
      double new_coeff0_13 = 0;
3343
 
      double new_coeff0_14 = 0;
3344
 
      double new_coeff0_15 = 0;
3345
 
      double new_coeff0_16 = 0;
3346
 
      double new_coeff0_17 = 0;
3347
 
      double new_coeff0_18 = 0;
3348
 
      double new_coeff0_19 = 0;
3349
 
    
3350
 
      // Loop possible derivatives
3351
 
      for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
3352
 
      {
3353
 
        // Get values from coefficients array
3354
 
        new_coeff0_0 = coefficients0[dof][0];
3355
 
        new_coeff0_1 = coefficients0[dof][1];
3356
 
        new_coeff0_2 = coefficients0[dof][2];
3357
 
        new_coeff0_3 = coefficients0[dof][3];
3358
 
        new_coeff0_4 = coefficients0[dof][4];
3359
 
        new_coeff0_5 = coefficients0[dof][5];
3360
 
        new_coeff0_6 = coefficients0[dof][6];
3361
 
        new_coeff0_7 = coefficients0[dof][7];
3362
 
        new_coeff0_8 = coefficients0[dof][8];
3363
 
        new_coeff0_9 = coefficients0[dof][9];
3364
 
        new_coeff0_10 = coefficients0[dof][10];
3365
 
        new_coeff0_11 = coefficients0[dof][11];
3366
 
        new_coeff0_12 = coefficients0[dof][12];
3367
 
        new_coeff0_13 = coefficients0[dof][13];
3368
 
        new_coeff0_14 = coefficients0[dof][14];
3369
 
        new_coeff0_15 = coefficients0[dof][15];
3370
 
        new_coeff0_16 = coefficients0[dof][16];
3371
 
        new_coeff0_17 = coefficients0[dof][17];
3372
 
        new_coeff0_18 = coefficients0[dof][18];
3373
 
        new_coeff0_19 = coefficients0[dof][19];
3374
 
    
3375
 
        // Loop derivative order
3376
 
        for (unsigned int j = 0; j < n; j++)
3377
 
        {
3378
 
          // Update old coefficients
3379
 
          coeff0_0 = new_coeff0_0;
3380
 
          coeff0_1 = new_coeff0_1;
3381
 
          coeff0_2 = new_coeff0_2;
3382
 
          coeff0_3 = new_coeff0_3;
3383
 
          coeff0_4 = new_coeff0_4;
3384
 
          coeff0_5 = new_coeff0_5;
3385
 
          coeff0_6 = new_coeff0_6;
3386
 
          coeff0_7 = new_coeff0_7;
3387
 
          coeff0_8 = new_coeff0_8;
3388
 
          coeff0_9 = new_coeff0_9;
3389
 
          coeff0_10 = new_coeff0_10;
3390
 
          coeff0_11 = new_coeff0_11;
3391
 
          coeff0_12 = new_coeff0_12;
3392
 
          coeff0_13 = new_coeff0_13;
3393
 
          coeff0_14 = new_coeff0_14;
3394
 
          coeff0_15 = new_coeff0_15;
3395
 
          coeff0_16 = new_coeff0_16;
3396
 
          coeff0_17 = new_coeff0_17;
3397
 
          coeff0_18 = new_coeff0_18;
3398
 
          coeff0_19 = new_coeff0_19;
3399
 
    
3400
 
          if(combinations[deriv_num][j] == 0)
3401
 
          {
3402
 
            new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0] + coeff0_10*dmats0[10][0] + coeff0_11*dmats0[11][0] + coeff0_12*dmats0[12][0] + coeff0_13*dmats0[13][0] + coeff0_14*dmats0[14][0] + coeff0_15*dmats0[15][0] + coeff0_16*dmats0[16][0] + coeff0_17*dmats0[17][0] + coeff0_18*dmats0[18][0] + coeff0_19*dmats0[19][0];
3403
 
            new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1] + coeff0_10*dmats0[10][1] + coeff0_11*dmats0[11][1] + coeff0_12*dmats0[12][1] + coeff0_13*dmats0[13][1] + coeff0_14*dmats0[14][1] + coeff0_15*dmats0[15][1] + coeff0_16*dmats0[16][1] + coeff0_17*dmats0[17][1] + coeff0_18*dmats0[18][1] + coeff0_19*dmats0[19][1];
3404
 
            new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2] + coeff0_10*dmats0[10][2] + coeff0_11*dmats0[11][2] + coeff0_12*dmats0[12][2] + coeff0_13*dmats0[13][2] + coeff0_14*dmats0[14][2] + coeff0_15*dmats0[15][2] + coeff0_16*dmats0[16][2] + coeff0_17*dmats0[17][2] + coeff0_18*dmats0[18][2] + coeff0_19*dmats0[19][2];
3405
 
            new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3] + coeff0_10*dmats0[10][3] + coeff0_11*dmats0[11][3] + coeff0_12*dmats0[12][3] + coeff0_13*dmats0[13][3] + coeff0_14*dmats0[14][3] + coeff0_15*dmats0[15][3] + coeff0_16*dmats0[16][3] + coeff0_17*dmats0[17][3] + coeff0_18*dmats0[18][3] + coeff0_19*dmats0[19][3];
3406
 
            new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4] + coeff0_10*dmats0[10][4] + coeff0_11*dmats0[11][4] + coeff0_12*dmats0[12][4] + coeff0_13*dmats0[13][4] + coeff0_14*dmats0[14][4] + coeff0_15*dmats0[15][4] + coeff0_16*dmats0[16][4] + coeff0_17*dmats0[17][4] + coeff0_18*dmats0[18][4] + coeff0_19*dmats0[19][4];
3407
 
            new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5] + coeff0_10*dmats0[10][5] + coeff0_11*dmats0[11][5] + coeff0_12*dmats0[12][5] + coeff0_13*dmats0[13][5] + coeff0_14*dmats0[14][5] + coeff0_15*dmats0[15][5] + coeff0_16*dmats0[16][5] + coeff0_17*dmats0[17][5] + coeff0_18*dmats0[18][5] + coeff0_19*dmats0[19][5];
3408
 
            new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6] + coeff0_10*dmats0[10][6] + coeff0_11*dmats0[11][6] + coeff0_12*dmats0[12][6] + coeff0_13*dmats0[13][6] + coeff0_14*dmats0[14][6] + coeff0_15*dmats0[15][6] + coeff0_16*dmats0[16][6] + coeff0_17*dmats0[17][6] + coeff0_18*dmats0[18][6] + coeff0_19*dmats0[19][6];
3409
 
            new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7] + coeff0_10*dmats0[10][7] + coeff0_11*dmats0[11][7] + coeff0_12*dmats0[12][7] + coeff0_13*dmats0[13][7] + coeff0_14*dmats0[14][7] + coeff0_15*dmats0[15][7] + coeff0_16*dmats0[16][7] + coeff0_17*dmats0[17][7] + coeff0_18*dmats0[18][7] + coeff0_19*dmats0[19][7];
3410
 
            new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8] + coeff0_10*dmats0[10][8] + coeff0_11*dmats0[11][8] + coeff0_12*dmats0[12][8] + coeff0_13*dmats0[13][8] + coeff0_14*dmats0[14][8] + coeff0_15*dmats0[15][8] + coeff0_16*dmats0[16][8] + coeff0_17*dmats0[17][8] + coeff0_18*dmats0[18][8] + coeff0_19*dmats0[19][8];
3411
 
            new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9] + coeff0_10*dmats0[10][9] + coeff0_11*dmats0[11][9] + coeff0_12*dmats0[12][9] + coeff0_13*dmats0[13][9] + coeff0_14*dmats0[14][9] + coeff0_15*dmats0[15][9] + coeff0_16*dmats0[16][9] + coeff0_17*dmats0[17][9] + coeff0_18*dmats0[18][9] + coeff0_19*dmats0[19][9];
3412
 
            new_coeff0_10 = coeff0_0*dmats0[0][10] + coeff0_1*dmats0[1][10] + coeff0_2*dmats0[2][10] + coeff0_3*dmats0[3][10] + coeff0_4*dmats0[4][10] + coeff0_5*dmats0[5][10] + coeff0_6*dmats0[6][10] + coeff0_7*dmats0[7][10] + coeff0_8*dmats0[8][10] + coeff0_9*dmats0[9][10] + coeff0_10*dmats0[10][10] + coeff0_11*dmats0[11][10] + coeff0_12*dmats0[12][10] + coeff0_13*dmats0[13][10] + coeff0_14*dmats0[14][10] + coeff0_15*dmats0[15][10] + coeff0_16*dmats0[16][10] + coeff0_17*dmats0[17][10] + coeff0_18*dmats0[18][10] + coeff0_19*dmats0[19][10];
3413
 
            new_coeff0_11 = coeff0_0*dmats0[0][11] + coeff0_1*dmats0[1][11] + coeff0_2*dmats0[2][11] + coeff0_3*dmats0[3][11] + coeff0_4*dmats0[4][11] + coeff0_5*dmats0[5][11] + coeff0_6*dmats0[6][11] + coeff0_7*dmats0[7][11] + coeff0_8*dmats0[8][11] + coeff0_9*dmats0[9][11] + coeff0_10*dmats0[10][11] + coeff0_11*dmats0[11][11] + coeff0_12*dmats0[12][11] + coeff0_13*dmats0[13][11] + coeff0_14*dmats0[14][11] + coeff0_15*dmats0[15][11] + coeff0_16*dmats0[16][11] + coeff0_17*dmats0[17][11] + coeff0_18*dmats0[18][11] + coeff0_19*dmats0[19][11];
3414
 
            new_coeff0_12 = coeff0_0*dmats0[0][12] + coeff0_1*dmats0[1][12] + coeff0_2*dmats0[2][12] + coeff0_3*dmats0[3][12] + coeff0_4*dmats0[4][12] + coeff0_5*dmats0[5][12] + coeff0_6*dmats0[6][12] + coeff0_7*dmats0[7][12] + coeff0_8*dmats0[8][12] + coeff0_9*dmats0[9][12] + coeff0_10*dmats0[10][12] + coeff0_11*dmats0[11][12] + coeff0_12*dmats0[12][12] + coeff0_13*dmats0[13][12] + coeff0_14*dmats0[14][12] + coeff0_15*dmats0[15][12] + coeff0_16*dmats0[16][12] + coeff0_17*dmats0[17][12] + coeff0_18*dmats0[18][12] + coeff0_19*dmats0[19][12];
3415
 
            new_coeff0_13 = coeff0_0*dmats0[0][13] + coeff0_1*dmats0[1][13] + coeff0_2*dmats0[2][13] + coeff0_3*dmats0[3][13] + coeff0_4*dmats0[4][13] + coeff0_5*dmats0[5][13] + coeff0_6*dmats0[6][13] + coeff0_7*dmats0[7][13] + coeff0_8*dmats0[8][13] + coeff0_9*dmats0[9][13] + coeff0_10*dmats0[10][13] + coeff0_11*dmats0[11][13] + coeff0_12*dmats0[12][13] + coeff0_13*dmats0[13][13] + coeff0_14*dmats0[14][13] + coeff0_15*dmats0[15][13] + coeff0_16*dmats0[16][13] + coeff0_17*dmats0[17][13] + coeff0_18*dmats0[18][13] + coeff0_19*dmats0[19][13];
3416
 
            new_coeff0_14 = coeff0_0*dmats0[0][14] + coeff0_1*dmats0[1][14] + coeff0_2*dmats0[2][14] + coeff0_3*dmats0[3][14] + coeff0_4*dmats0[4][14] + coeff0_5*dmats0[5][14] + coeff0_6*dmats0[6][14] + coeff0_7*dmats0[7][14] + coeff0_8*dmats0[8][14] + coeff0_9*dmats0[9][14] + coeff0_10*dmats0[10][14] + coeff0_11*dmats0[11][14] + coeff0_12*dmats0[12][14] + coeff0_13*dmats0[13][14] + coeff0_14*dmats0[14][14] + coeff0_15*dmats0[15][14] + coeff0_16*dmats0[16][14] + coeff0_17*dmats0[17][14] + coeff0_18*dmats0[18][14] + coeff0_19*dmats0[19][14];
3417
 
            new_coeff0_15 = coeff0_0*dmats0[0][15] + coeff0_1*dmats0[1][15] + coeff0_2*dmats0[2][15] + coeff0_3*dmats0[3][15] + coeff0_4*dmats0[4][15] + coeff0_5*dmats0[5][15] + coeff0_6*dmats0[6][15] + coeff0_7*dmats0[7][15] + coeff0_8*dmats0[8][15] + coeff0_9*dmats0[9][15] + coeff0_10*dmats0[10][15] + coeff0_11*dmats0[11][15] + coeff0_12*dmats0[12][15] + coeff0_13*dmats0[13][15] + coeff0_14*dmats0[14][15] + coeff0_15*dmats0[15][15] + coeff0_16*dmats0[16][15] + coeff0_17*dmats0[17][15] + coeff0_18*dmats0[18][15] + coeff0_19*dmats0[19][15];
3418
 
            new_coeff0_16 = coeff0_0*dmats0[0][16] + coeff0_1*dmats0[1][16] + coeff0_2*dmats0[2][16] + coeff0_3*dmats0[3][16] + coeff0_4*dmats0[4][16] + coeff0_5*dmats0[5][16] + coeff0_6*dmats0[6][16] + coeff0_7*dmats0[7][16] + coeff0_8*dmats0[8][16] + coeff0_9*dmats0[9][16] + coeff0_10*dmats0[10][16] + coeff0_11*dmats0[11][16] + coeff0_12*dmats0[12][16] + coeff0_13*dmats0[13][16] + coeff0_14*dmats0[14][16] + coeff0_15*dmats0[15][16] + coeff0_16*dmats0[16][16] + coeff0_17*dmats0[17][16] + coeff0_18*dmats0[18][16] + coeff0_19*dmats0[19][16];
3419
 
            new_coeff0_17 = coeff0_0*dmats0[0][17] + coeff0_1*dmats0[1][17] + coeff0_2*dmats0[2][17] + coeff0_3*dmats0[3][17] + coeff0_4*dmats0[4][17] + coeff0_5*dmats0[5][17] + coeff0_6*dmats0[6][17] + coeff0_7*dmats0[7][17] + coeff0_8*dmats0[8][17] + coeff0_9*dmats0[9][17] + coeff0_10*dmats0[10][17] + coeff0_11*dmats0[11][17] + coeff0_12*dmats0[12][17] + coeff0_13*dmats0[13][17] + coeff0_14*dmats0[14][17] + coeff0_15*dmats0[15][17] + coeff0_16*dmats0[16][17] + coeff0_17*dmats0[17][17] + coeff0_18*dmats0[18][17] + coeff0_19*dmats0[19][17];
3420
 
            new_coeff0_18 = coeff0_0*dmats0[0][18] + coeff0_1*dmats0[1][18] + coeff0_2*dmats0[2][18] + coeff0_3*dmats0[3][18] + coeff0_4*dmats0[4][18] + coeff0_5*dmats0[5][18] + coeff0_6*dmats0[6][18] + coeff0_7*dmats0[7][18] + coeff0_8*dmats0[8][18] + coeff0_9*dmats0[9][18] + coeff0_10*dmats0[10][18] + coeff0_11*dmats0[11][18] + coeff0_12*dmats0[12][18] + coeff0_13*dmats0[13][18] + coeff0_14*dmats0[14][18] + coeff0_15*dmats0[15][18] + coeff0_16*dmats0[16][18] + coeff0_17*dmats0[17][18] + coeff0_18*dmats0[18][18] + coeff0_19*dmats0[19][18];
3421
 
            new_coeff0_19 = coeff0_0*dmats0[0][19] + coeff0_1*dmats0[1][19] + coeff0_2*dmats0[2][19] + coeff0_3*dmats0[3][19] + coeff0_4*dmats0[4][19] + coeff0_5*dmats0[5][19] + coeff0_6*dmats0[6][19] + coeff0_7*dmats0[7][19] + coeff0_8*dmats0[8][19] + coeff0_9*dmats0[9][19] + coeff0_10*dmats0[10][19] + coeff0_11*dmats0[11][19] + coeff0_12*dmats0[12][19] + coeff0_13*dmats0[13][19] + coeff0_14*dmats0[14][19] + coeff0_15*dmats0[15][19] + coeff0_16*dmats0[16][19] + coeff0_17*dmats0[17][19] + coeff0_18*dmats0[18][19] + coeff0_19*dmats0[19][19];
3422
 
          }
3423
 
          if(combinations[deriv_num][j] == 1)
3424
 
          {
3425
 
            new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0] + coeff0_10*dmats1[10][0] + coeff0_11*dmats1[11][0] + coeff0_12*dmats1[12][0] + coeff0_13*dmats1[13][0] + coeff0_14*dmats1[14][0] + coeff0_15*dmats1[15][0] + coeff0_16*dmats1[16][0] + coeff0_17*dmats1[17][0] + coeff0_18*dmats1[18][0] + coeff0_19*dmats1[19][0];
3426
 
            new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1] + coeff0_10*dmats1[10][1] + coeff0_11*dmats1[11][1] + coeff0_12*dmats1[12][1] + coeff0_13*dmats1[13][1] + coeff0_14*dmats1[14][1] + coeff0_15*dmats1[15][1] + coeff0_16*dmats1[16][1] + coeff0_17*dmats1[17][1] + coeff0_18*dmats1[18][1] + coeff0_19*dmats1[19][1];
3427
 
            new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2] + coeff0_10*dmats1[10][2] + coeff0_11*dmats1[11][2] + coeff0_12*dmats1[12][2] + coeff0_13*dmats1[13][2] + coeff0_14*dmats1[14][2] + coeff0_15*dmats1[15][2] + coeff0_16*dmats1[16][2] + coeff0_17*dmats1[17][2] + coeff0_18*dmats1[18][2] + coeff0_19*dmats1[19][2];
3428
 
            new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3] + coeff0_10*dmats1[10][3] + coeff0_11*dmats1[11][3] + coeff0_12*dmats1[12][3] + coeff0_13*dmats1[13][3] + coeff0_14*dmats1[14][3] + coeff0_15*dmats1[15][3] + coeff0_16*dmats1[16][3] + coeff0_17*dmats1[17][3] + coeff0_18*dmats1[18][3] + coeff0_19*dmats1[19][3];
3429
 
            new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4] + coeff0_10*dmats1[10][4] + coeff0_11*dmats1[11][4] + coeff0_12*dmats1[12][4] + coeff0_13*dmats1[13][4] + coeff0_14*dmats1[14][4] + coeff0_15*dmats1[15][4] + coeff0_16*dmats1[16][4] + coeff0_17*dmats1[17][4] + coeff0_18*dmats1[18][4] + coeff0_19*dmats1[19][4];
3430
 
            new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5] + coeff0_10*dmats1[10][5] + coeff0_11*dmats1[11][5] + coeff0_12*dmats1[12][5] + coeff0_13*dmats1[13][5] + coeff0_14*dmats1[14][5] + coeff0_15*dmats1[15][5] + coeff0_16*dmats1[16][5] + coeff0_17*dmats1[17][5] + coeff0_18*dmats1[18][5] + coeff0_19*dmats1[19][5];
3431
 
            new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6] + coeff0_10*dmats1[10][6] + coeff0_11*dmats1[11][6] + coeff0_12*dmats1[12][6] + coeff0_13*dmats1[13][6] + coeff0_14*dmats1[14][6] + coeff0_15*dmats1[15][6] + coeff0_16*dmats1[16][6] + coeff0_17*dmats1[17][6] + coeff0_18*dmats1[18][6] + coeff0_19*dmats1[19][6];
3432
 
            new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7] + coeff0_10*dmats1[10][7] + coeff0_11*dmats1[11][7] + coeff0_12*dmats1[12][7] + coeff0_13*dmats1[13][7] + coeff0_14*dmats1[14][7] + coeff0_15*dmats1[15][7] + coeff0_16*dmats1[16][7] + coeff0_17*dmats1[17][7] + coeff0_18*dmats1[18][7] + coeff0_19*dmats1[19][7];
3433
 
            new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8] + coeff0_10*dmats1[10][8] + coeff0_11*dmats1[11][8] + coeff0_12*dmats1[12][8] + coeff0_13*dmats1[13][8] + coeff0_14*dmats1[14][8] + coeff0_15*dmats1[15][8] + coeff0_16*dmats1[16][8] + coeff0_17*dmats1[17][8] + coeff0_18*dmats1[18][8] + coeff0_19*dmats1[19][8];
3434
 
            new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9] + coeff0_10*dmats1[10][9] + coeff0_11*dmats1[11][9] + coeff0_12*dmats1[12][9] + coeff0_13*dmats1[13][9] + coeff0_14*dmats1[14][9] + coeff0_15*dmats1[15][9] + coeff0_16*dmats1[16][9] + coeff0_17*dmats1[17][9] + coeff0_18*dmats1[18][9] + coeff0_19*dmats1[19][9];
3435
 
            new_coeff0_10 = coeff0_0*dmats1[0][10] + coeff0_1*dmats1[1][10] + coeff0_2*dmats1[2][10] + coeff0_3*dmats1[3][10] + coeff0_4*dmats1[4][10] + coeff0_5*dmats1[5][10] + coeff0_6*dmats1[6][10] + coeff0_7*dmats1[7][10] + coeff0_8*dmats1[8][10] + coeff0_9*dmats1[9][10] + coeff0_10*dmats1[10][10] + coeff0_11*dmats1[11][10] + coeff0_12*dmats1[12][10] + coeff0_13*dmats1[13][10] + coeff0_14*dmats1[14][10] + coeff0_15*dmats1[15][10] + coeff0_16*dmats1[16][10] + coeff0_17*dmats1[17][10] + coeff0_18*dmats1[18][10] + coeff0_19*dmats1[19][10];
3436
 
            new_coeff0_11 = coeff0_0*dmats1[0][11] + coeff0_1*dmats1[1][11] + coeff0_2*dmats1[2][11] + coeff0_3*dmats1[3][11] + coeff0_4*dmats1[4][11] + coeff0_5*dmats1[5][11] + coeff0_6*dmats1[6][11] + coeff0_7*dmats1[7][11] + coeff0_8*dmats1[8][11] + coeff0_9*dmats1[9][11] + coeff0_10*dmats1[10][11] + coeff0_11*dmats1[11][11] + coeff0_12*dmats1[12][11] + coeff0_13*dmats1[13][11] + coeff0_14*dmats1[14][11] + coeff0_15*dmats1[15][11] + coeff0_16*dmats1[16][11] + coeff0_17*dmats1[17][11] + coeff0_18*dmats1[18][11] + coeff0_19*dmats1[19][11];
3437
 
            new_coeff0_12 = coeff0_0*dmats1[0][12] + coeff0_1*dmats1[1][12] + coeff0_2*dmats1[2][12] + coeff0_3*dmats1[3][12] + coeff0_4*dmats1[4][12] + coeff0_5*dmats1[5][12] + coeff0_6*dmats1[6][12] + coeff0_7*dmats1[7][12] + coeff0_8*dmats1[8][12] + coeff0_9*dmats1[9][12] + coeff0_10*dmats1[10][12] + coeff0_11*dmats1[11][12] + coeff0_12*dmats1[12][12] + coeff0_13*dmats1[13][12] + coeff0_14*dmats1[14][12] + coeff0_15*dmats1[15][12] + coeff0_16*dmats1[16][12] + coeff0_17*dmats1[17][12] + coeff0_18*dmats1[18][12] + coeff0_19*dmats1[19][12];
3438
 
            new_coeff0_13 = coeff0_0*dmats1[0][13] + coeff0_1*dmats1[1][13] + coeff0_2*dmats1[2][13] + coeff0_3*dmats1[3][13] + coeff0_4*dmats1[4][13] + coeff0_5*dmats1[5][13] + coeff0_6*dmats1[6][13] + coeff0_7*dmats1[7][13] + coeff0_8*dmats1[8][13] + coeff0_9*dmats1[9][13] + coeff0_10*dmats1[10][13] + coeff0_11*dmats1[11][13] + coeff0_12*dmats1[12][13] + coeff0_13*dmats1[13][13] + coeff0_14*dmats1[14][13] + coeff0_15*dmats1[15][13] + coeff0_16*dmats1[16][13] + coeff0_17*dmats1[17][13] + coeff0_18*dmats1[18][13] + coeff0_19*dmats1[19][13];
3439
 
            new_coeff0_14 = coeff0_0*dmats1[0][14] + coeff0_1*dmats1[1][14] + coeff0_2*dmats1[2][14] + coeff0_3*dmats1[3][14] + coeff0_4*dmats1[4][14] + coeff0_5*dmats1[5][14] + coeff0_6*dmats1[6][14] + coeff0_7*dmats1[7][14] + coeff0_8*dmats1[8][14] + coeff0_9*dmats1[9][14] + coeff0_10*dmats1[10][14] + coeff0_11*dmats1[11][14] + coeff0_12*dmats1[12][14] + coeff0_13*dmats1[13][14] + coeff0_14*dmats1[14][14] + coeff0_15*dmats1[15][14] + coeff0_16*dmats1[16][14] + coeff0_17*dmats1[17][14] + coeff0_18*dmats1[18][14] + coeff0_19*dmats1[19][14];
3440
 
            new_coeff0_15 = coeff0_0*dmats1[0][15] + coeff0_1*dmats1[1][15] + coeff0_2*dmats1[2][15] + coeff0_3*dmats1[3][15] + coeff0_4*dmats1[4][15] + coeff0_5*dmats1[5][15] + coeff0_6*dmats1[6][15] + coeff0_7*dmats1[7][15] + coeff0_8*dmats1[8][15] + coeff0_9*dmats1[9][15] + coeff0_10*dmats1[10][15] + coeff0_11*dmats1[11][15] + coeff0_12*dmats1[12][15] + coeff0_13*dmats1[13][15] + coeff0_14*dmats1[14][15] + coeff0_15*dmats1[15][15] + coeff0_16*dmats1[16][15] + coeff0_17*dmats1[17][15] + coeff0_18*dmats1[18][15] + coeff0_19*dmats1[19][15];
3441
 
            new_coeff0_16 = coeff0_0*dmats1[0][16] + coeff0_1*dmats1[1][16] + coeff0_2*dmats1[2][16] + coeff0_3*dmats1[3][16] + coeff0_4*dmats1[4][16] + coeff0_5*dmats1[5][16] + coeff0_6*dmats1[6][16] + coeff0_7*dmats1[7][16] + coeff0_8*dmats1[8][16] + coeff0_9*dmats1[9][16] + coeff0_10*dmats1[10][16] + coeff0_11*dmats1[11][16] + coeff0_12*dmats1[12][16] + coeff0_13*dmats1[13][16] + coeff0_14*dmats1[14][16] + coeff0_15*dmats1[15][16] + coeff0_16*dmats1[16][16] + coeff0_17*dmats1[17][16] + coeff0_18*dmats1[18][16] + coeff0_19*dmats1[19][16];
3442
 
            new_coeff0_17 = coeff0_0*dmats1[0][17] + coeff0_1*dmats1[1][17] + coeff0_2*dmats1[2][17] + coeff0_3*dmats1[3][17] + coeff0_4*dmats1[4][17] + coeff0_5*dmats1[5][17] + coeff0_6*dmats1[6][17] + coeff0_7*dmats1[7][17] + coeff0_8*dmats1[8][17] + coeff0_9*dmats1[9][17] + coeff0_10*dmats1[10][17] + coeff0_11*dmats1[11][17] + coeff0_12*dmats1[12][17] + coeff0_13*dmats1[13][17] + coeff0_14*dmats1[14][17] + coeff0_15*dmats1[15][17] + coeff0_16*dmats1[16][17] + coeff0_17*dmats1[17][17] + coeff0_18*dmats1[18][17] + coeff0_19*dmats1[19][17];
3443
 
            new_coeff0_18 = coeff0_0*dmats1[0][18] + coeff0_1*dmats1[1][18] + coeff0_2*dmats1[2][18] + coeff0_3*dmats1[3][18] + coeff0_4*dmats1[4][18] + coeff0_5*dmats1[5][18] + coeff0_6*dmats1[6][18] + coeff0_7*dmats1[7][18] + coeff0_8*dmats1[8][18] + coeff0_9*dmats1[9][18] + coeff0_10*dmats1[10][18] + coeff0_11*dmats1[11][18] + coeff0_12*dmats1[12][18] + coeff0_13*dmats1[13][18] + coeff0_14*dmats1[14][18] + coeff0_15*dmats1[15][18] + coeff0_16*dmats1[16][18] + coeff0_17*dmats1[17][18] + coeff0_18*dmats1[18][18] + coeff0_19*dmats1[19][18];
3444
 
            new_coeff0_19 = coeff0_0*dmats1[0][19] + coeff0_1*dmats1[1][19] + coeff0_2*dmats1[2][19] + coeff0_3*dmats1[3][19] + coeff0_4*dmats1[4][19] + coeff0_5*dmats1[5][19] + coeff0_6*dmats1[6][19] + coeff0_7*dmats1[7][19] + coeff0_8*dmats1[8][19] + coeff0_9*dmats1[9][19] + coeff0_10*dmats1[10][19] + coeff0_11*dmats1[11][19] + coeff0_12*dmats1[12][19] + coeff0_13*dmats1[13][19] + coeff0_14*dmats1[14][19] + coeff0_15*dmats1[15][19] + coeff0_16*dmats1[16][19] + coeff0_17*dmats1[17][19] + coeff0_18*dmats1[18][19] + coeff0_19*dmats1[19][19];
3445
 
          }
3446
 
          if(combinations[deriv_num][j] == 2)
3447
 
          {
3448
 
            new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0] + coeff0_10*dmats2[10][0] + coeff0_11*dmats2[11][0] + coeff0_12*dmats2[12][0] + coeff0_13*dmats2[13][0] + coeff0_14*dmats2[14][0] + coeff0_15*dmats2[15][0] + coeff0_16*dmats2[16][0] + coeff0_17*dmats2[17][0] + coeff0_18*dmats2[18][0] + coeff0_19*dmats2[19][0];
3449
 
            new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1] + coeff0_10*dmats2[10][1] + coeff0_11*dmats2[11][1] + coeff0_12*dmats2[12][1] + coeff0_13*dmats2[13][1] + coeff0_14*dmats2[14][1] + coeff0_15*dmats2[15][1] + coeff0_16*dmats2[16][1] + coeff0_17*dmats2[17][1] + coeff0_18*dmats2[18][1] + coeff0_19*dmats2[19][1];
3450
 
            new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2] + coeff0_10*dmats2[10][2] + coeff0_11*dmats2[11][2] + coeff0_12*dmats2[12][2] + coeff0_13*dmats2[13][2] + coeff0_14*dmats2[14][2] + coeff0_15*dmats2[15][2] + coeff0_16*dmats2[16][2] + coeff0_17*dmats2[17][2] + coeff0_18*dmats2[18][2] + coeff0_19*dmats2[19][2];
3451
 
            new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3] + coeff0_10*dmats2[10][3] + coeff0_11*dmats2[11][3] + coeff0_12*dmats2[12][3] + coeff0_13*dmats2[13][3] + coeff0_14*dmats2[14][3] + coeff0_15*dmats2[15][3] + coeff0_16*dmats2[16][3] + coeff0_17*dmats2[17][3] + coeff0_18*dmats2[18][3] + coeff0_19*dmats2[19][3];
3452
 
            new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4] + coeff0_10*dmats2[10][4] + coeff0_11*dmats2[11][4] + coeff0_12*dmats2[12][4] + coeff0_13*dmats2[13][4] + coeff0_14*dmats2[14][4] + coeff0_15*dmats2[15][4] + coeff0_16*dmats2[16][4] + coeff0_17*dmats2[17][4] + coeff0_18*dmats2[18][4] + coeff0_19*dmats2[19][4];
3453
 
            new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5] + coeff0_10*dmats2[10][5] + coeff0_11*dmats2[11][5] + coeff0_12*dmats2[12][5] + coeff0_13*dmats2[13][5] + coeff0_14*dmats2[14][5] + coeff0_15*dmats2[15][5] + coeff0_16*dmats2[16][5] + coeff0_17*dmats2[17][5] + coeff0_18*dmats2[18][5] + coeff0_19*dmats2[19][5];
3454
 
            new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6] + coeff0_10*dmats2[10][6] + coeff0_11*dmats2[11][6] + coeff0_12*dmats2[12][6] + coeff0_13*dmats2[13][6] + coeff0_14*dmats2[14][6] + coeff0_15*dmats2[15][6] + coeff0_16*dmats2[16][6] + coeff0_17*dmats2[17][6] + coeff0_18*dmats2[18][6] + coeff0_19*dmats2[19][6];
3455
 
            new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7] + coeff0_10*dmats2[10][7] + coeff0_11*dmats2[11][7] + coeff0_12*dmats2[12][7] + coeff0_13*dmats2[13][7] + coeff0_14*dmats2[14][7] + coeff0_15*dmats2[15][7] + coeff0_16*dmats2[16][7] + coeff0_17*dmats2[17][7] + coeff0_18*dmats2[18][7] + coeff0_19*dmats2[19][7];
3456
 
            new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8] + coeff0_10*dmats2[10][8] + coeff0_11*dmats2[11][8] + coeff0_12*dmats2[12][8] + coeff0_13*dmats2[13][8] + coeff0_14*dmats2[14][8] + coeff0_15*dmats2[15][8] + coeff0_16*dmats2[16][8] + coeff0_17*dmats2[17][8] + coeff0_18*dmats2[18][8] + coeff0_19*dmats2[19][8];
3457
 
            new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9] + coeff0_10*dmats2[10][9] + coeff0_11*dmats2[11][9] + coeff0_12*dmats2[12][9] + coeff0_13*dmats2[13][9] + coeff0_14*dmats2[14][9] + coeff0_15*dmats2[15][9] + coeff0_16*dmats2[16][9] + coeff0_17*dmats2[17][9] + coeff0_18*dmats2[18][9] + coeff0_19*dmats2[19][9];
3458
 
            new_coeff0_10 = coeff0_0*dmats2[0][10] + coeff0_1*dmats2[1][10] + coeff0_2*dmats2[2][10] + coeff0_3*dmats2[3][10] + coeff0_4*dmats2[4][10] + coeff0_5*dmats2[5][10] + coeff0_6*dmats2[6][10] + coeff0_7*dmats2[7][10] + coeff0_8*dmats2[8][10] + coeff0_9*dmats2[9][10] + coeff0_10*dmats2[10][10] + coeff0_11*dmats2[11][10] + coeff0_12*dmats2[12][10] + coeff0_13*dmats2[13][10] + coeff0_14*dmats2[14][10] + coeff0_15*dmats2[15][10] + coeff0_16*dmats2[16][10] + coeff0_17*dmats2[17][10] + coeff0_18*dmats2[18][10] + coeff0_19*dmats2[19][10];
3459
 
            new_coeff0_11 = coeff0_0*dmats2[0][11] + coeff0_1*dmats2[1][11] + coeff0_2*dmats2[2][11] + coeff0_3*dmats2[3][11] + coeff0_4*dmats2[4][11] + coeff0_5*dmats2[5][11] + coeff0_6*dmats2[6][11] + coeff0_7*dmats2[7][11] + coeff0_8*dmats2[8][11] + coeff0_9*dmats2[9][11] + coeff0_10*dmats2[10][11] + coeff0_11*dmats2[11][11] + coeff0_12*dmats2[12][11] + coeff0_13*dmats2[13][11] + coeff0_14*dmats2[14][11] + coeff0_15*dmats2[15][11] + coeff0_16*dmats2[16][11] + coeff0_17*dmats2[17][11] + coeff0_18*dmats2[18][11] + coeff0_19*dmats2[19][11];
3460
 
            new_coeff0_12 = coeff0_0*dmats2[0][12] + coeff0_1*dmats2[1][12] + coeff0_2*dmats2[2][12] + coeff0_3*dmats2[3][12] + coeff0_4*dmats2[4][12] + coeff0_5*dmats2[5][12] + coeff0_6*dmats2[6][12] + coeff0_7*dmats2[7][12] + coeff0_8*dmats2[8][12] + coeff0_9*dmats2[9][12] + coeff0_10*dmats2[10][12] + coeff0_11*dmats2[11][12] + coeff0_12*dmats2[12][12] + coeff0_13*dmats2[13][12] + coeff0_14*dmats2[14][12] + coeff0_15*dmats2[15][12] + coeff0_16*dmats2[16][12] + coeff0_17*dmats2[17][12] + coeff0_18*dmats2[18][12] + coeff0_19*dmats2[19][12];
3461
 
            new_coeff0_13 = coeff0_0*dmats2[0][13] + coeff0_1*dmats2[1][13] + coeff0_2*dmats2[2][13] + coeff0_3*dmats2[3][13] + coeff0_4*dmats2[4][13] + coeff0_5*dmats2[5][13] + coeff0_6*dmats2[6][13] + coeff0_7*dmats2[7][13] + coeff0_8*dmats2[8][13] + coeff0_9*dmats2[9][13] + coeff0_10*dmats2[10][13] + coeff0_11*dmats2[11][13] + coeff0_12*dmats2[12][13] + coeff0_13*dmats2[13][13] + coeff0_14*dmats2[14][13] + coeff0_15*dmats2[15][13] + coeff0_16*dmats2[16][13] + coeff0_17*dmats2[17][13] + coeff0_18*dmats2[18][13] + coeff0_19*dmats2[19][13];
3462
 
            new_coeff0_14 = coeff0_0*dmats2[0][14] + coeff0_1*dmats2[1][14] + coeff0_2*dmats2[2][14] + coeff0_3*dmats2[3][14] + coeff0_4*dmats2[4][14] + coeff0_5*dmats2[5][14] + coeff0_6*dmats2[6][14] + coeff0_7*dmats2[7][14] + coeff0_8*dmats2[8][14] + coeff0_9*dmats2[9][14] + coeff0_10*dmats2[10][14] + coeff0_11*dmats2[11][14] + coeff0_12*dmats2[12][14] + coeff0_13*dmats2[13][14] + coeff0_14*dmats2[14][14] + coeff0_15*dmats2[15][14] + coeff0_16*dmats2[16][14] + coeff0_17*dmats2[17][14] + coeff0_18*dmats2[18][14] + coeff0_19*dmats2[19][14];
3463
 
            new_coeff0_15 = coeff0_0*dmats2[0][15] + coeff0_1*dmats2[1][15] + coeff0_2*dmats2[2][15] + coeff0_3*dmats2[3][15] + coeff0_4*dmats2[4][15] + coeff0_5*dmats2[5][15] + coeff0_6*dmats2[6][15] + coeff0_7*dmats2[7][15] + coeff0_8*dmats2[8][15] + coeff0_9*dmats2[9][15] + coeff0_10*dmats2[10][15] + coeff0_11*dmats2[11][15] + coeff0_12*dmats2[12][15] + coeff0_13*dmats2[13][15] + coeff0_14*dmats2[14][15] + coeff0_15*dmats2[15][15] + coeff0_16*dmats2[16][15] + coeff0_17*dmats2[17][15] + coeff0_18*dmats2[18][15] + coeff0_19*dmats2[19][15];
3464
 
            new_coeff0_16 = coeff0_0*dmats2[0][16] + coeff0_1*dmats2[1][16] + coeff0_2*dmats2[2][16] + coeff0_3*dmats2[3][16] + coeff0_4*dmats2[4][16] + coeff0_5*dmats2[5][16] + coeff0_6*dmats2[6][16] + coeff0_7*dmats2[7][16] + coeff0_8*dmats2[8][16] + coeff0_9*dmats2[9][16] + coeff0_10*dmats2[10][16] + coeff0_11*dmats2[11][16] + coeff0_12*dmats2[12][16] + coeff0_13*dmats2[13][16] + coeff0_14*dmats2[14][16] + coeff0_15*dmats2[15][16] + coeff0_16*dmats2[16][16] + coeff0_17*dmats2[17][16] + coeff0_18*dmats2[18][16] + coeff0_19*dmats2[19][16];
3465
 
            new_coeff0_17 = coeff0_0*dmats2[0][17] + coeff0_1*dmats2[1][17] + coeff0_2*dmats2[2][17] + coeff0_3*dmats2[3][17] + coeff0_4*dmats2[4][17] + coeff0_5*dmats2[5][17] + coeff0_6*dmats2[6][17] + coeff0_7*dmats2[7][17] + coeff0_8*dmats2[8][17] + coeff0_9*dmats2[9][17] + coeff0_10*dmats2[10][17] + coeff0_11*dmats2[11][17] + coeff0_12*dmats2[12][17] + coeff0_13*dmats2[13][17] + coeff0_14*dmats2[14][17] + coeff0_15*dmats2[15][17] + coeff0_16*dmats2[16][17] + coeff0_17*dmats2[17][17] + coeff0_18*dmats2[18][17] + coeff0_19*dmats2[19][17];
3466
 
            new_coeff0_18 = coeff0_0*dmats2[0][18] + coeff0_1*dmats2[1][18] + coeff0_2*dmats2[2][18] + coeff0_3*dmats2[3][18] + coeff0_4*dmats2[4][18] + coeff0_5*dmats2[5][18] + coeff0_6*dmats2[6][18] + coeff0_7*dmats2[7][18] + coeff0_8*dmats2[8][18] + coeff0_9*dmats2[9][18] + coeff0_10*dmats2[10][18] + coeff0_11*dmats2[11][18] + coeff0_12*dmats2[12][18] + coeff0_13*dmats2[13][18] + coeff0_14*dmats2[14][18] + coeff0_15*dmats2[15][18] + coeff0_16*dmats2[16][18] + coeff0_17*dmats2[17][18] + coeff0_18*dmats2[18][18] + coeff0_19*dmats2[19][18];
3467
 
            new_coeff0_19 = coeff0_0*dmats2[0][19] + coeff0_1*dmats2[1][19] + coeff0_2*dmats2[2][19] + coeff0_3*dmats2[3][19] + coeff0_4*dmats2[4][19] + coeff0_5*dmats2[5][19] + coeff0_6*dmats2[6][19] + coeff0_7*dmats2[7][19] + coeff0_8*dmats2[8][19] + coeff0_9*dmats2[9][19] + coeff0_10*dmats2[10][19] + coeff0_11*dmats2[11][19] + coeff0_12*dmats2[12][19] + coeff0_13*dmats2[13][19] + coeff0_14*dmats2[14][19] + coeff0_15*dmats2[15][19] + coeff0_16*dmats2[16][19] + coeff0_17*dmats2[17][19] + coeff0_18*dmats2[18][19] + coeff0_19*dmats2[19][19];
3468
 
          }
3469
 
    
3470
 
        }
3471
 
        // Compute derivatives on reference element as dot product of coefficients and basisvalues
3472
 
        derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9 + new_coeff0_10*basisvalue10 + new_coeff0_11*basisvalue11 + new_coeff0_12*basisvalue12 + new_coeff0_13*basisvalue13 + new_coeff0_14*basisvalue14 + new_coeff0_15*basisvalue15 + new_coeff0_16*basisvalue16 + new_coeff0_17*basisvalue17 + new_coeff0_18*basisvalue18 + new_coeff0_19*basisvalue19;
3473
 
      }
3474
 
    
3475
 
      // Transform derivatives back to physical element
3476
 
      for (unsigned int row = 0; row < num_derivatives; row++)
3477
 
      {
3478
 
        for (unsigned int col = 0; col < num_derivatives; col++)
3479
 
        {
3480
 
          values[row] += transform[row][col]*derivatives[col];
3481
 
        }
3482
 
      }
3483
 
      // Delete pointer to array of derivatives on FIAT element
3484
 
      delete [] derivatives;
3485
 
    
3486
 
      // Delete pointer to array of combinations of derivatives and transform
3487
 
      for (unsigned int row = 0; row < num_derivatives; row++)
3488
 
      {
3489
 
        delete [] combinations[row];
3490
 
        delete [] transform[row];
3491
 
      }
3492
 
    
3493
 
      delete [] combinations;
3494
 
      delete [] transform;
3495
 
    }
3496
 
    
3497
 
    if (20 <= i && i <= 39)
3498
 
    {
3499
 
      // Map degree of freedom to element degree of freedom
3500
 
      const unsigned int dof = i - 20;
3501
 
    
3502
 
      // Generate scalings
3503
 
      const double scalings_y_0 = 1;
3504
 
      const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
3505
 
      const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
3506
 
      const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
3507
 
      const double scalings_z_0 = 1;
3508
 
      const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
3509
 
      const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
3510
 
      const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
3511
 
    
3512
 
      // Compute psitilde_a
3513
 
      const double psitilde_a_0 = 1;
3514
 
      const double psitilde_a_1 = x;
3515
 
      const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
3516
 
      const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
3517
 
    
3518
 
      // Compute psitilde_bs
3519
 
      const double psitilde_bs_0_0 = 1;
3520
 
      const double psitilde_bs_0_1 = 1.5*y + 0.5;
3521
 
      const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
3522
 
      const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
3523
 
      const double psitilde_bs_1_0 = 1;
3524
 
      const double psitilde_bs_1_1 = 2.5*y + 1.5;
3525
 
      const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
3526
 
      const double psitilde_bs_2_0 = 1;
3527
 
      const double psitilde_bs_2_1 = 3.5*y + 2.5;
3528
 
      const double psitilde_bs_3_0 = 1;
3529
 
    
3530
 
      // Compute psitilde_cs
3531
 
      const double psitilde_cs_00_0 = 1;
3532
 
      const double psitilde_cs_00_1 = 2*z + 1;
3533
 
      const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
3534
 
      const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
3535
 
      const double psitilde_cs_01_0 = 1;
3536
 
      const double psitilde_cs_01_1 = 3*z + 2;
3537
 
      const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
3538
 
      const double psitilde_cs_02_0 = 1;
3539
 
      const double psitilde_cs_02_1 = 4*z + 3;
3540
 
      const double psitilde_cs_03_0 = 1;
3541
 
      const double psitilde_cs_10_0 = 1;
3542
 
      const double psitilde_cs_10_1 = 3*z + 2;
3543
 
      const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
3544
 
      const double psitilde_cs_11_0 = 1;
3545
 
      const double psitilde_cs_11_1 = 4*z + 3;
3546
 
      const double psitilde_cs_12_0 = 1;
3547
 
      const double psitilde_cs_20_0 = 1;
3548
 
      const double psitilde_cs_20_1 = 4*z + 3;
3549
 
      const double psitilde_cs_21_0 = 1;
3550
 
      const double psitilde_cs_30_0 = 1;
3551
 
    
3552
 
      // Compute basisvalues
3553
 
      const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
3554
 
      const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
3555
 
      const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
3556
 
      const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
3557
 
      const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
3558
 
      const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
3559
 
      const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
3560
 
      const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
3561
 
      const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
3562
 
      const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
3563
 
      const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
3564
 
      const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
3565
 
      const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
3566
 
      const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
3567
 
      const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
3568
 
      const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
3569
 
      const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
3570
 
      const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
3571
 
      const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
3572
 
      const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
3573
 
    
3574
 
      // Table(s) of coefficients
3575
 
      const static double coefficients0[20][20] =   \
3576
 
      {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
3577
 
      {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
3578
 
      {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
3579
 
      {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
3580
 
      {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
3581
 
      {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
3582
 
      {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
3583
 
      {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
3584
 
      {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
3585
 
      {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
3586
 
      {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
3587
 
      {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
3588
 
      {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
3589
 
      {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
3590
 
      {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
3591
 
      {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
3592
 
      {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
3593
 
      {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
3594
 
      {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
3595
 
      {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
3596
 
    
3597
 
      // Interesting (new) part
3598
 
      // Tables of derivatives of the polynomial base (transpose)
3599
 
      const static double dmats0[20][20] =   \
3600
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3601
 
      {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3602
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3603
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3604
 
      {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3605
 
      {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3606
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3607
 
      {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3608
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3609
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3610
 
      {5.49909083394701, 0, -3.3466401061363, -2.36643191323985, 15.4919333848297, 0, 0.692820323027551, 0, 0.565685424949239, 0.400000000000001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3611
 
      {0, 4.89897948556636, 0, 0, 0, 14.1985914794391, 0, -0.82807867121083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3612
 
      {3.6, 0, 8.76356092008266, -1.54919333848297, 0, 0, 9.52470471983253, 0, -1.48131215963608, 0.261861468283192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3613
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3614
 
      {0, 4.24264068711928, 0, 0, 0, 0, 0, 14.3427433120127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3615
 
      {3.11769145362398, 0, 3.16227766016838, 4.91934955049954, 0, 0, 0, 0, 10.690449676497, -2.41897262725906, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3616
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3617
 
      {2.54558441227157, 0, 0, 7.66811580507233, 0, 0, 0, 0, 0, 10.3691851174526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3618
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3619
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3620
 
    
3621
 
      const static double dmats1[20][20] =   \
3622
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3623
 
      {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3624
 
      {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3625
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3626
 
      {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3627
 
      {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309959, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3628
 
      {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3629
 
      {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3630
 
      {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3631
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3632
 
      {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.28284271247462, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3633
 
      {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 9.16515138991168, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3634
 
      {1.8, -5.69209978830308, 4.38178046004133, -0.774596669241487, 0, 10.998181667894, 4.76235235991626, 0.962140470884726, -0.740656079818041, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3635
 
      {5.19615242270664, 0, -3.16227766016838, -2.23606797749979, 0, 0, 13.7477270848675, 0, 0.534522483824849, 0.37796447300923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3636
 
      {2.01246117974981, 2.12132034355964, -0.408248290463864, 3.17542648054294, 0, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3637
 
      {1.55884572681199, 2.73861278752583, 1.58113883008419, 2.45967477524977, 0, 0, 0, 9.25820099772551, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3638
 
      {-1.8, 0, 3.65148371670111, -2.84018778721878, 0, 0, 0, 0, 12.3442679969674, 1.39659449751035, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3639
 
      {1.27279220613579, 0, 0, 3.83405790253616, 0, 0, 0, 0, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3640
 
      {2.20454076850486, 0, 0, 6.6407830863536, 0, 0, 0, 0, 0, 8.97997772825746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3641
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3642
 
    
3643
 
      const static double dmats2[20][20] =   \
3644
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3645
 
      {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3646
 
      {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3647
 
      {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3648
 
      {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3649
 
      {2.29128784747792, 1.44913767461895, 4.18330013267038, -0.59160797830996, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3650
 
      {1.32287565553229, 0, 3.86436713231718, -0.341565025531987, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3651
 
      {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3652
 
      {1.08012344973464, 0, 7.09929573971954, 2.50998007960222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3653
 
      {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3654
 
      {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.282842712474619, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3655
 
      {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 1.30930734141595, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3656
 
      {1.8, 0.632455532033675, 4.38178046004133, -0.774596669241484, 0, 3.14233761939829, 4.76235235991626, -0.10690449676497, -0.740656079818042, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3657
 
      {1.03923048454133, 0, 3.16227766016838, -0.447213595499959, 0, 0, 5.8918830363718, 0, -0.53452248382485, 0.0755928946018459, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3658
 
      {2.01246117974981, 2.12132034355964, -0.408248290463863, 3.17542648054294, 9.07114735222145, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3659
 
      {1.55884572681199, 0.547722557505165, 1.58113883008419, 2.45967477524977, 0, 9.07114735222145, 0, 1.8516401995451, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3660
 
      {0.900000000000001, 0, 1.46059348668045, 1.42009389360939, 0, 0, 9.07114735222145, 0, 4.93770719878694, -0.698297248755175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3661
 
      {1.27279220613578, -6.26099033699941, 0, 3.83405790253616, 0, 0, 0, 10.5830052442584, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3662
 
      {0.734846922834954, 0, -6.26099033699941, 2.21359436211787, 0, 0, 0, 0, 10.5830052442584, 2.99332590941915, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3663
 
      {5.7157676649773, 0, 0, -4.69574275274955, 0, 0, 0, 0, 0, 12.69960629311, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3664
 
    
3665
 
      // Compute reference derivatives
3666
 
      // Declare pointer to array of derivatives on FIAT element
3667
 
      double *derivatives = new double [num_derivatives];
3668
 
    
3669
 
      // Declare coefficients
3670
 
      double coeff0_0 = 0;
3671
 
      double coeff0_1 = 0;
3672
 
      double coeff0_2 = 0;
3673
 
      double coeff0_3 = 0;
3674
 
      double coeff0_4 = 0;
3675
 
      double coeff0_5 = 0;
3676
 
      double coeff0_6 = 0;
3677
 
      double coeff0_7 = 0;
3678
 
      double coeff0_8 = 0;
3679
 
      double coeff0_9 = 0;
3680
 
      double coeff0_10 = 0;
3681
 
      double coeff0_11 = 0;
3682
 
      double coeff0_12 = 0;
3683
 
      double coeff0_13 = 0;
3684
 
      double coeff0_14 = 0;
3685
 
      double coeff0_15 = 0;
3686
 
      double coeff0_16 = 0;
3687
 
      double coeff0_17 = 0;
3688
 
      double coeff0_18 = 0;
3689
 
      double coeff0_19 = 0;
3690
 
    
3691
 
      // Declare new coefficients
3692
 
      double new_coeff0_0 = 0;
3693
 
      double new_coeff0_1 = 0;
3694
 
      double new_coeff0_2 = 0;
3695
 
      double new_coeff0_3 = 0;
3696
 
      double new_coeff0_4 = 0;
3697
 
      double new_coeff0_5 = 0;
3698
 
      double new_coeff0_6 = 0;
3699
 
      double new_coeff0_7 = 0;
3700
 
      double new_coeff0_8 = 0;
3701
 
      double new_coeff0_9 = 0;
3702
 
      double new_coeff0_10 = 0;
3703
 
      double new_coeff0_11 = 0;
3704
 
      double new_coeff0_12 = 0;
3705
 
      double new_coeff0_13 = 0;
3706
 
      double new_coeff0_14 = 0;
3707
 
      double new_coeff0_15 = 0;
3708
 
      double new_coeff0_16 = 0;
3709
 
      double new_coeff0_17 = 0;
3710
 
      double new_coeff0_18 = 0;
3711
 
      double new_coeff0_19 = 0;
3712
 
    
3713
 
      // Loop possible derivatives
3714
 
      for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
3715
 
      {
3716
 
        // Get values from coefficients array
3717
 
        new_coeff0_0 = coefficients0[dof][0];
3718
 
        new_coeff0_1 = coefficients0[dof][1];
3719
 
        new_coeff0_2 = coefficients0[dof][2];
3720
 
        new_coeff0_3 = coefficients0[dof][3];
3721
 
        new_coeff0_4 = coefficients0[dof][4];
3722
 
        new_coeff0_5 = coefficients0[dof][5];
3723
 
        new_coeff0_6 = coefficients0[dof][6];
3724
 
        new_coeff0_7 = coefficients0[dof][7];
3725
 
        new_coeff0_8 = coefficients0[dof][8];
3726
 
        new_coeff0_9 = coefficients0[dof][9];
3727
 
        new_coeff0_10 = coefficients0[dof][10];
3728
 
        new_coeff0_11 = coefficients0[dof][11];
3729
 
        new_coeff0_12 = coefficients0[dof][12];
3730
 
        new_coeff0_13 = coefficients0[dof][13];
3731
 
        new_coeff0_14 = coefficients0[dof][14];
3732
 
        new_coeff0_15 = coefficients0[dof][15];
3733
 
        new_coeff0_16 = coefficients0[dof][16];
3734
 
        new_coeff0_17 = coefficients0[dof][17];
3735
 
        new_coeff0_18 = coefficients0[dof][18];
3736
 
        new_coeff0_19 = coefficients0[dof][19];
3737
 
    
3738
 
        // Loop derivative order
3739
 
        for (unsigned int j = 0; j < n; j++)
3740
 
        {
3741
 
          // Update old coefficients
3742
 
          coeff0_0 = new_coeff0_0;
3743
 
          coeff0_1 = new_coeff0_1;
3744
 
          coeff0_2 = new_coeff0_2;
3745
 
          coeff0_3 = new_coeff0_3;
3746
 
          coeff0_4 = new_coeff0_4;
3747
 
          coeff0_5 = new_coeff0_5;
3748
 
          coeff0_6 = new_coeff0_6;
3749
 
          coeff0_7 = new_coeff0_7;
3750
 
          coeff0_8 = new_coeff0_8;
3751
 
          coeff0_9 = new_coeff0_9;
3752
 
          coeff0_10 = new_coeff0_10;
3753
 
          coeff0_11 = new_coeff0_11;
3754
 
          coeff0_12 = new_coeff0_12;
3755
 
          coeff0_13 = new_coeff0_13;
3756
 
          coeff0_14 = new_coeff0_14;
3757
 
          coeff0_15 = new_coeff0_15;
3758
 
          coeff0_16 = new_coeff0_16;
3759
 
          coeff0_17 = new_coeff0_17;
3760
 
          coeff0_18 = new_coeff0_18;
3761
 
          coeff0_19 = new_coeff0_19;
3762
 
    
3763
 
          if(combinations[deriv_num][j] == 0)
3764
 
          {
3765
 
            new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0] + coeff0_10*dmats0[10][0] + coeff0_11*dmats0[11][0] + coeff0_12*dmats0[12][0] + coeff0_13*dmats0[13][0] + coeff0_14*dmats0[14][0] + coeff0_15*dmats0[15][0] + coeff0_16*dmats0[16][0] + coeff0_17*dmats0[17][0] + coeff0_18*dmats0[18][0] + coeff0_19*dmats0[19][0];
3766
 
            new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1] + coeff0_10*dmats0[10][1] + coeff0_11*dmats0[11][1] + coeff0_12*dmats0[12][1] + coeff0_13*dmats0[13][1] + coeff0_14*dmats0[14][1] + coeff0_15*dmats0[15][1] + coeff0_16*dmats0[16][1] + coeff0_17*dmats0[17][1] + coeff0_18*dmats0[18][1] + coeff0_19*dmats0[19][1];
3767
 
            new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2] + coeff0_10*dmats0[10][2] + coeff0_11*dmats0[11][2] + coeff0_12*dmats0[12][2] + coeff0_13*dmats0[13][2] + coeff0_14*dmats0[14][2] + coeff0_15*dmats0[15][2] + coeff0_16*dmats0[16][2] + coeff0_17*dmats0[17][2] + coeff0_18*dmats0[18][2] + coeff0_19*dmats0[19][2];
3768
 
            new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3] + coeff0_10*dmats0[10][3] + coeff0_11*dmats0[11][3] + coeff0_12*dmats0[12][3] + coeff0_13*dmats0[13][3] + coeff0_14*dmats0[14][3] + coeff0_15*dmats0[15][3] + coeff0_16*dmats0[16][3] + coeff0_17*dmats0[17][3] + coeff0_18*dmats0[18][3] + coeff0_19*dmats0[19][3];
3769
 
            new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4] + coeff0_10*dmats0[10][4] + coeff0_11*dmats0[11][4] + coeff0_12*dmats0[12][4] + coeff0_13*dmats0[13][4] + coeff0_14*dmats0[14][4] + coeff0_15*dmats0[15][4] + coeff0_16*dmats0[16][4] + coeff0_17*dmats0[17][4] + coeff0_18*dmats0[18][4] + coeff0_19*dmats0[19][4];
3770
 
            new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5] + coeff0_10*dmats0[10][5] + coeff0_11*dmats0[11][5] + coeff0_12*dmats0[12][5] + coeff0_13*dmats0[13][5] + coeff0_14*dmats0[14][5] + coeff0_15*dmats0[15][5] + coeff0_16*dmats0[16][5] + coeff0_17*dmats0[17][5] + coeff0_18*dmats0[18][5] + coeff0_19*dmats0[19][5];
3771
 
            new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6] + coeff0_10*dmats0[10][6] + coeff0_11*dmats0[11][6] + coeff0_12*dmats0[12][6] + coeff0_13*dmats0[13][6] + coeff0_14*dmats0[14][6] + coeff0_15*dmats0[15][6] + coeff0_16*dmats0[16][6] + coeff0_17*dmats0[17][6] + coeff0_18*dmats0[18][6] + coeff0_19*dmats0[19][6];
3772
 
            new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7] + coeff0_10*dmats0[10][7] + coeff0_11*dmats0[11][7] + coeff0_12*dmats0[12][7] + coeff0_13*dmats0[13][7] + coeff0_14*dmats0[14][7] + coeff0_15*dmats0[15][7] + coeff0_16*dmats0[16][7] + coeff0_17*dmats0[17][7] + coeff0_18*dmats0[18][7] + coeff0_19*dmats0[19][7];
3773
 
            new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8] + coeff0_10*dmats0[10][8] + coeff0_11*dmats0[11][8] + coeff0_12*dmats0[12][8] + coeff0_13*dmats0[13][8] + coeff0_14*dmats0[14][8] + coeff0_15*dmats0[15][8] + coeff0_16*dmats0[16][8] + coeff0_17*dmats0[17][8] + coeff0_18*dmats0[18][8] + coeff0_19*dmats0[19][8];
3774
 
            new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9] + coeff0_10*dmats0[10][9] + coeff0_11*dmats0[11][9] + coeff0_12*dmats0[12][9] + coeff0_13*dmats0[13][9] + coeff0_14*dmats0[14][9] + coeff0_15*dmats0[15][9] + coeff0_16*dmats0[16][9] + coeff0_17*dmats0[17][9] + coeff0_18*dmats0[18][9] + coeff0_19*dmats0[19][9];
3775
 
            new_coeff0_10 = coeff0_0*dmats0[0][10] + coeff0_1*dmats0[1][10] + coeff0_2*dmats0[2][10] + coeff0_3*dmats0[3][10] + coeff0_4*dmats0[4][10] + coeff0_5*dmats0[5][10] + coeff0_6*dmats0[6][10] + coeff0_7*dmats0[7][10] + coeff0_8*dmats0[8][10] + coeff0_9*dmats0[9][10] + coeff0_10*dmats0[10][10] + coeff0_11*dmats0[11][10] + coeff0_12*dmats0[12][10] + coeff0_13*dmats0[13][10] + coeff0_14*dmats0[14][10] + coeff0_15*dmats0[15][10] + coeff0_16*dmats0[16][10] + coeff0_17*dmats0[17][10] + coeff0_18*dmats0[18][10] + coeff0_19*dmats0[19][10];
3776
 
            new_coeff0_11 = coeff0_0*dmats0[0][11] + coeff0_1*dmats0[1][11] + coeff0_2*dmats0[2][11] + coeff0_3*dmats0[3][11] + coeff0_4*dmats0[4][11] + coeff0_5*dmats0[5][11] + coeff0_6*dmats0[6][11] + coeff0_7*dmats0[7][11] + coeff0_8*dmats0[8][11] + coeff0_9*dmats0[9][11] + coeff0_10*dmats0[10][11] + coeff0_11*dmats0[11][11] + coeff0_12*dmats0[12][11] + coeff0_13*dmats0[13][11] + coeff0_14*dmats0[14][11] + coeff0_15*dmats0[15][11] + coeff0_16*dmats0[16][11] + coeff0_17*dmats0[17][11] + coeff0_18*dmats0[18][11] + coeff0_19*dmats0[19][11];
3777
 
            new_coeff0_12 = coeff0_0*dmats0[0][12] + coeff0_1*dmats0[1][12] + coeff0_2*dmats0[2][12] + coeff0_3*dmats0[3][12] + coeff0_4*dmats0[4][12] + coeff0_5*dmats0[5][12] + coeff0_6*dmats0[6][12] + coeff0_7*dmats0[7][12] + coeff0_8*dmats0[8][12] + coeff0_9*dmats0[9][12] + coeff0_10*dmats0[10][12] + coeff0_11*dmats0[11][12] + coeff0_12*dmats0[12][12] + coeff0_13*dmats0[13][12] + coeff0_14*dmats0[14][12] + coeff0_15*dmats0[15][12] + coeff0_16*dmats0[16][12] + coeff0_17*dmats0[17][12] + coeff0_18*dmats0[18][12] + coeff0_19*dmats0[19][12];
3778
 
            new_coeff0_13 = coeff0_0*dmats0[0][13] + coeff0_1*dmats0[1][13] + coeff0_2*dmats0[2][13] + coeff0_3*dmats0[3][13] + coeff0_4*dmats0[4][13] + coeff0_5*dmats0[5][13] + coeff0_6*dmats0[6][13] + coeff0_7*dmats0[7][13] + coeff0_8*dmats0[8][13] + coeff0_9*dmats0[9][13] + coeff0_10*dmats0[10][13] + coeff0_11*dmats0[11][13] + coeff0_12*dmats0[12][13] + coeff0_13*dmats0[13][13] + coeff0_14*dmats0[14][13] + coeff0_15*dmats0[15][13] + coeff0_16*dmats0[16][13] + coeff0_17*dmats0[17][13] + coeff0_18*dmats0[18][13] + coeff0_19*dmats0[19][13];
3779
 
            new_coeff0_14 = coeff0_0*dmats0[0][14] + coeff0_1*dmats0[1][14] + coeff0_2*dmats0[2][14] + coeff0_3*dmats0[3][14] + coeff0_4*dmats0[4][14] + coeff0_5*dmats0[5][14] + coeff0_6*dmats0[6][14] + coeff0_7*dmats0[7][14] + coeff0_8*dmats0[8][14] + coeff0_9*dmats0[9][14] + coeff0_10*dmats0[10][14] + coeff0_11*dmats0[11][14] + coeff0_12*dmats0[12][14] + coeff0_13*dmats0[13][14] + coeff0_14*dmats0[14][14] + coeff0_15*dmats0[15][14] + coeff0_16*dmats0[16][14] + coeff0_17*dmats0[17][14] + coeff0_18*dmats0[18][14] + coeff0_19*dmats0[19][14];
3780
 
            new_coeff0_15 = coeff0_0*dmats0[0][15] + coeff0_1*dmats0[1][15] + coeff0_2*dmats0[2][15] + coeff0_3*dmats0[3][15] + coeff0_4*dmats0[4][15] + coeff0_5*dmats0[5][15] + coeff0_6*dmats0[6][15] + coeff0_7*dmats0[7][15] + coeff0_8*dmats0[8][15] + coeff0_9*dmats0[9][15] + coeff0_10*dmats0[10][15] + coeff0_11*dmats0[11][15] + coeff0_12*dmats0[12][15] + coeff0_13*dmats0[13][15] + coeff0_14*dmats0[14][15] + coeff0_15*dmats0[15][15] + coeff0_16*dmats0[16][15] + coeff0_17*dmats0[17][15] + coeff0_18*dmats0[18][15] + coeff0_19*dmats0[19][15];
3781
 
            new_coeff0_16 = coeff0_0*dmats0[0][16] + coeff0_1*dmats0[1][16] + coeff0_2*dmats0[2][16] + coeff0_3*dmats0[3][16] + coeff0_4*dmats0[4][16] + coeff0_5*dmats0[5][16] + coeff0_6*dmats0[6][16] + coeff0_7*dmats0[7][16] + coeff0_8*dmats0[8][16] + coeff0_9*dmats0[9][16] + coeff0_10*dmats0[10][16] + coeff0_11*dmats0[11][16] + coeff0_12*dmats0[12][16] + coeff0_13*dmats0[13][16] + coeff0_14*dmats0[14][16] + coeff0_15*dmats0[15][16] + coeff0_16*dmats0[16][16] + coeff0_17*dmats0[17][16] + coeff0_18*dmats0[18][16] + coeff0_19*dmats0[19][16];
3782
 
            new_coeff0_17 = coeff0_0*dmats0[0][17] + coeff0_1*dmats0[1][17] + coeff0_2*dmats0[2][17] + coeff0_3*dmats0[3][17] + coeff0_4*dmats0[4][17] + coeff0_5*dmats0[5][17] + coeff0_6*dmats0[6][17] + coeff0_7*dmats0[7][17] + coeff0_8*dmats0[8][17] + coeff0_9*dmats0[9][17] + coeff0_10*dmats0[10][17] + coeff0_11*dmats0[11][17] + coeff0_12*dmats0[12][17] + coeff0_13*dmats0[13][17] + coeff0_14*dmats0[14][17] + coeff0_15*dmats0[15][17] + coeff0_16*dmats0[16][17] + coeff0_17*dmats0[17][17] + coeff0_18*dmats0[18][17] + coeff0_19*dmats0[19][17];
3783
 
            new_coeff0_18 = coeff0_0*dmats0[0][18] + coeff0_1*dmats0[1][18] + coeff0_2*dmats0[2][18] + coeff0_3*dmats0[3][18] + coeff0_4*dmats0[4][18] + coeff0_5*dmats0[5][18] + coeff0_6*dmats0[6][18] + coeff0_7*dmats0[7][18] + coeff0_8*dmats0[8][18] + coeff0_9*dmats0[9][18] + coeff0_10*dmats0[10][18] + coeff0_11*dmats0[11][18] + coeff0_12*dmats0[12][18] + coeff0_13*dmats0[13][18] + coeff0_14*dmats0[14][18] + coeff0_15*dmats0[15][18] + coeff0_16*dmats0[16][18] + coeff0_17*dmats0[17][18] + coeff0_18*dmats0[18][18] + coeff0_19*dmats0[19][18];
3784
 
            new_coeff0_19 = coeff0_0*dmats0[0][19] + coeff0_1*dmats0[1][19] + coeff0_2*dmats0[2][19] + coeff0_3*dmats0[3][19] + coeff0_4*dmats0[4][19] + coeff0_5*dmats0[5][19] + coeff0_6*dmats0[6][19] + coeff0_7*dmats0[7][19] + coeff0_8*dmats0[8][19] + coeff0_9*dmats0[9][19] + coeff0_10*dmats0[10][19] + coeff0_11*dmats0[11][19] + coeff0_12*dmats0[12][19] + coeff0_13*dmats0[13][19] + coeff0_14*dmats0[14][19] + coeff0_15*dmats0[15][19] + coeff0_16*dmats0[16][19] + coeff0_17*dmats0[17][19] + coeff0_18*dmats0[18][19] + coeff0_19*dmats0[19][19];
3785
 
          }
3786
 
          if(combinations[deriv_num][j] == 1)
3787
 
          {
3788
 
            new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0] + coeff0_10*dmats1[10][0] + coeff0_11*dmats1[11][0] + coeff0_12*dmats1[12][0] + coeff0_13*dmats1[13][0] + coeff0_14*dmats1[14][0] + coeff0_15*dmats1[15][0] + coeff0_16*dmats1[16][0] + coeff0_17*dmats1[17][0] + coeff0_18*dmats1[18][0] + coeff0_19*dmats1[19][0];
3789
 
            new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1] + coeff0_10*dmats1[10][1] + coeff0_11*dmats1[11][1] + coeff0_12*dmats1[12][1] + coeff0_13*dmats1[13][1] + coeff0_14*dmats1[14][1] + coeff0_15*dmats1[15][1] + coeff0_16*dmats1[16][1] + coeff0_17*dmats1[17][1] + coeff0_18*dmats1[18][1] + coeff0_19*dmats1[19][1];
3790
 
            new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2] + coeff0_10*dmats1[10][2] + coeff0_11*dmats1[11][2] + coeff0_12*dmats1[12][2] + coeff0_13*dmats1[13][2] + coeff0_14*dmats1[14][2] + coeff0_15*dmats1[15][2] + coeff0_16*dmats1[16][2] + coeff0_17*dmats1[17][2] + coeff0_18*dmats1[18][2] + coeff0_19*dmats1[19][2];
3791
 
            new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3] + coeff0_10*dmats1[10][3] + coeff0_11*dmats1[11][3] + coeff0_12*dmats1[12][3] + coeff0_13*dmats1[13][3] + coeff0_14*dmats1[14][3] + coeff0_15*dmats1[15][3] + coeff0_16*dmats1[16][3] + coeff0_17*dmats1[17][3] + coeff0_18*dmats1[18][3] + coeff0_19*dmats1[19][3];
3792
 
            new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4] + coeff0_10*dmats1[10][4] + coeff0_11*dmats1[11][4] + coeff0_12*dmats1[12][4] + coeff0_13*dmats1[13][4] + coeff0_14*dmats1[14][4] + coeff0_15*dmats1[15][4] + coeff0_16*dmats1[16][4] + coeff0_17*dmats1[17][4] + coeff0_18*dmats1[18][4] + coeff0_19*dmats1[19][4];
3793
 
            new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5] + coeff0_10*dmats1[10][5] + coeff0_11*dmats1[11][5] + coeff0_12*dmats1[12][5] + coeff0_13*dmats1[13][5] + coeff0_14*dmats1[14][5] + coeff0_15*dmats1[15][5] + coeff0_16*dmats1[16][5] + coeff0_17*dmats1[17][5] + coeff0_18*dmats1[18][5] + coeff0_19*dmats1[19][5];
3794
 
            new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6] + coeff0_10*dmats1[10][6] + coeff0_11*dmats1[11][6] + coeff0_12*dmats1[12][6] + coeff0_13*dmats1[13][6] + coeff0_14*dmats1[14][6] + coeff0_15*dmats1[15][6] + coeff0_16*dmats1[16][6] + coeff0_17*dmats1[17][6] + coeff0_18*dmats1[18][6] + coeff0_19*dmats1[19][6];
3795
 
            new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7] + coeff0_10*dmats1[10][7] + coeff0_11*dmats1[11][7] + coeff0_12*dmats1[12][7] + coeff0_13*dmats1[13][7] + coeff0_14*dmats1[14][7] + coeff0_15*dmats1[15][7] + coeff0_16*dmats1[16][7] + coeff0_17*dmats1[17][7] + coeff0_18*dmats1[18][7] + coeff0_19*dmats1[19][7];
3796
 
            new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8] + coeff0_10*dmats1[10][8] + coeff0_11*dmats1[11][8] + coeff0_12*dmats1[12][8] + coeff0_13*dmats1[13][8] + coeff0_14*dmats1[14][8] + coeff0_15*dmats1[15][8] + coeff0_16*dmats1[16][8] + coeff0_17*dmats1[17][8] + coeff0_18*dmats1[18][8] + coeff0_19*dmats1[19][8];
3797
 
            new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9] + coeff0_10*dmats1[10][9] + coeff0_11*dmats1[11][9] + coeff0_12*dmats1[12][9] + coeff0_13*dmats1[13][9] + coeff0_14*dmats1[14][9] + coeff0_15*dmats1[15][9] + coeff0_16*dmats1[16][9] + coeff0_17*dmats1[17][9] + coeff0_18*dmats1[18][9] + coeff0_19*dmats1[19][9];
3798
 
            new_coeff0_10 = coeff0_0*dmats1[0][10] + coeff0_1*dmats1[1][10] + coeff0_2*dmats1[2][10] + coeff0_3*dmats1[3][10] + coeff0_4*dmats1[4][10] + coeff0_5*dmats1[5][10] + coeff0_6*dmats1[6][10] + coeff0_7*dmats1[7][10] + coeff0_8*dmats1[8][10] + coeff0_9*dmats1[9][10] + coeff0_10*dmats1[10][10] + coeff0_11*dmats1[11][10] + coeff0_12*dmats1[12][10] + coeff0_13*dmats1[13][10] + coeff0_14*dmats1[14][10] + coeff0_15*dmats1[15][10] + coeff0_16*dmats1[16][10] + coeff0_17*dmats1[17][10] + coeff0_18*dmats1[18][10] + coeff0_19*dmats1[19][10];
3799
 
            new_coeff0_11 = coeff0_0*dmats1[0][11] + coeff0_1*dmats1[1][11] + coeff0_2*dmats1[2][11] + coeff0_3*dmats1[3][11] + coeff0_4*dmats1[4][11] + coeff0_5*dmats1[5][11] + coeff0_6*dmats1[6][11] + coeff0_7*dmats1[7][11] + coeff0_8*dmats1[8][11] + coeff0_9*dmats1[9][11] + coeff0_10*dmats1[10][11] + coeff0_11*dmats1[11][11] + coeff0_12*dmats1[12][11] + coeff0_13*dmats1[13][11] + coeff0_14*dmats1[14][11] + coeff0_15*dmats1[15][11] + coeff0_16*dmats1[16][11] + coeff0_17*dmats1[17][11] + coeff0_18*dmats1[18][11] + coeff0_19*dmats1[19][11];
3800
 
            new_coeff0_12 = coeff0_0*dmats1[0][12] + coeff0_1*dmats1[1][12] + coeff0_2*dmats1[2][12] + coeff0_3*dmats1[3][12] + coeff0_4*dmats1[4][12] + coeff0_5*dmats1[5][12] + coeff0_6*dmats1[6][12] + coeff0_7*dmats1[7][12] + coeff0_8*dmats1[8][12] + coeff0_9*dmats1[9][12] + coeff0_10*dmats1[10][12] + coeff0_11*dmats1[11][12] + coeff0_12*dmats1[12][12] + coeff0_13*dmats1[13][12] + coeff0_14*dmats1[14][12] + coeff0_15*dmats1[15][12] + coeff0_16*dmats1[16][12] + coeff0_17*dmats1[17][12] + coeff0_18*dmats1[18][12] + coeff0_19*dmats1[19][12];
3801
 
            new_coeff0_13 = coeff0_0*dmats1[0][13] + coeff0_1*dmats1[1][13] + coeff0_2*dmats1[2][13] + coeff0_3*dmats1[3][13] + coeff0_4*dmats1[4][13] + coeff0_5*dmats1[5][13] + coeff0_6*dmats1[6][13] + coeff0_7*dmats1[7][13] + coeff0_8*dmats1[8][13] + coeff0_9*dmats1[9][13] + coeff0_10*dmats1[10][13] + coeff0_11*dmats1[11][13] + coeff0_12*dmats1[12][13] + coeff0_13*dmats1[13][13] + coeff0_14*dmats1[14][13] + coeff0_15*dmats1[15][13] + coeff0_16*dmats1[16][13] + coeff0_17*dmats1[17][13] + coeff0_18*dmats1[18][13] + coeff0_19*dmats1[19][13];
3802
 
            new_coeff0_14 = coeff0_0*dmats1[0][14] + coeff0_1*dmats1[1][14] + coeff0_2*dmats1[2][14] + coeff0_3*dmats1[3][14] + coeff0_4*dmats1[4][14] + coeff0_5*dmats1[5][14] + coeff0_6*dmats1[6][14] + coeff0_7*dmats1[7][14] + coeff0_8*dmats1[8][14] + coeff0_9*dmats1[9][14] + coeff0_10*dmats1[10][14] + coeff0_11*dmats1[11][14] + coeff0_12*dmats1[12][14] + coeff0_13*dmats1[13][14] + coeff0_14*dmats1[14][14] + coeff0_15*dmats1[15][14] + coeff0_16*dmats1[16][14] + coeff0_17*dmats1[17][14] + coeff0_18*dmats1[18][14] + coeff0_19*dmats1[19][14];
3803
 
            new_coeff0_15 = coeff0_0*dmats1[0][15] + coeff0_1*dmats1[1][15] + coeff0_2*dmats1[2][15] + coeff0_3*dmats1[3][15] + coeff0_4*dmats1[4][15] + coeff0_5*dmats1[5][15] + coeff0_6*dmats1[6][15] + coeff0_7*dmats1[7][15] + coeff0_8*dmats1[8][15] + coeff0_9*dmats1[9][15] + coeff0_10*dmats1[10][15] + coeff0_11*dmats1[11][15] + coeff0_12*dmats1[12][15] + coeff0_13*dmats1[13][15] + coeff0_14*dmats1[14][15] + coeff0_15*dmats1[15][15] + coeff0_16*dmats1[16][15] + coeff0_17*dmats1[17][15] + coeff0_18*dmats1[18][15] + coeff0_19*dmats1[19][15];
3804
 
            new_coeff0_16 = coeff0_0*dmats1[0][16] + coeff0_1*dmats1[1][16] + coeff0_2*dmats1[2][16] + coeff0_3*dmats1[3][16] + coeff0_4*dmats1[4][16] + coeff0_5*dmats1[5][16] + coeff0_6*dmats1[6][16] + coeff0_7*dmats1[7][16] + coeff0_8*dmats1[8][16] + coeff0_9*dmats1[9][16] + coeff0_10*dmats1[10][16] + coeff0_11*dmats1[11][16] + coeff0_12*dmats1[12][16] + coeff0_13*dmats1[13][16] + coeff0_14*dmats1[14][16] + coeff0_15*dmats1[15][16] + coeff0_16*dmats1[16][16] + coeff0_17*dmats1[17][16] + coeff0_18*dmats1[18][16] + coeff0_19*dmats1[19][16];
3805
 
            new_coeff0_17 = coeff0_0*dmats1[0][17] + coeff0_1*dmats1[1][17] + coeff0_2*dmats1[2][17] + coeff0_3*dmats1[3][17] + coeff0_4*dmats1[4][17] + coeff0_5*dmats1[5][17] + coeff0_6*dmats1[6][17] + coeff0_7*dmats1[7][17] + coeff0_8*dmats1[8][17] + coeff0_9*dmats1[9][17] + coeff0_10*dmats1[10][17] + coeff0_11*dmats1[11][17] + coeff0_12*dmats1[12][17] + coeff0_13*dmats1[13][17] + coeff0_14*dmats1[14][17] + coeff0_15*dmats1[15][17] + coeff0_16*dmats1[16][17] + coeff0_17*dmats1[17][17] + coeff0_18*dmats1[18][17] + coeff0_19*dmats1[19][17];
3806
 
            new_coeff0_18 = coeff0_0*dmats1[0][18] + coeff0_1*dmats1[1][18] + coeff0_2*dmats1[2][18] + coeff0_3*dmats1[3][18] + coeff0_4*dmats1[4][18] + coeff0_5*dmats1[5][18] + coeff0_6*dmats1[6][18] + coeff0_7*dmats1[7][18] + coeff0_8*dmats1[8][18] + coeff0_9*dmats1[9][18] + coeff0_10*dmats1[10][18] + coeff0_11*dmats1[11][18] + coeff0_12*dmats1[12][18] + coeff0_13*dmats1[13][18] + coeff0_14*dmats1[14][18] + coeff0_15*dmats1[15][18] + coeff0_16*dmats1[16][18] + coeff0_17*dmats1[17][18] + coeff0_18*dmats1[18][18] + coeff0_19*dmats1[19][18];
3807
 
            new_coeff0_19 = coeff0_0*dmats1[0][19] + coeff0_1*dmats1[1][19] + coeff0_2*dmats1[2][19] + coeff0_3*dmats1[3][19] + coeff0_4*dmats1[4][19] + coeff0_5*dmats1[5][19] + coeff0_6*dmats1[6][19] + coeff0_7*dmats1[7][19] + coeff0_8*dmats1[8][19] + coeff0_9*dmats1[9][19] + coeff0_10*dmats1[10][19] + coeff0_11*dmats1[11][19] + coeff0_12*dmats1[12][19] + coeff0_13*dmats1[13][19] + coeff0_14*dmats1[14][19] + coeff0_15*dmats1[15][19] + coeff0_16*dmats1[16][19] + coeff0_17*dmats1[17][19] + coeff0_18*dmats1[18][19] + coeff0_19*dmats1[19][19];
3808
 
          }
3809
 
          if(combinations[deriv_num][j] == 2)
3810
 
          {
3811
 
            new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0] + coeff0_10*dmats2[10][0] + coeff0_11*dmats2[11][0] + coeff0_12*dmats2[12][0] + coeff0_13*dmats2[13][0] + coeff0_14*dmats2[14][0] + coeff0_15*dmats2[15][0] + coeff0_16*dmats2[16][0] + coeff0_17*dmats2[17][0] + coeff0_18*dmats2[18][0] + coeff0_19*dmats2[19][0];
3812
 
            new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1] + coeff0_10*dmats2[10][1] + coeff0_11*dmats2[11][1] + coeff0_12*dmats2[12][1] + coeff0_13*dmats2[13][1] + coeff0_14*dmats2[14][1] + coeff0_15*dmats2[15][1] + coeff0_16*dmats2[16][1] + coeff0_17*dmats2[17][1] + coeff0_18*dmats2[18][1] + coeff0_19*dmats2[19][1];
3813
 
            new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2] + coeff0_10*dmats2[10][2] + coeff0_11*dmats2[11][2] + coeff0_12*dmats2[12][2] + coeff0_13*dmats2[13][2] + coeff0_14*dmats2[14][2] + coeff0_15*dmats2[15][2] + coeff0_16*dmats2[16][2] + coeff0_17*dmats2[17][2] + coeff0_18*dmats2[18][2] + coeff0_19*dmats2[19][2];
3814
 
            new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3] + coeff0_10*dmats2[10][3] + coeff0_11*dmats2[11][3] + coeff0_12*dmats2[12][3] + coeff0_13*dmats2[13][3] + coeff0_14*dmats2[14][3] + coeff0_15*dmats2[15][3] + coeff0_16*dmats2[16][3] + coeff0_17*dmats2[17][3] + coeff0_18*dmats2[18][3] + coeff0_19*dmats2[19][3];
3815
 
            new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4] + coeff0_10*dmats2[10][4] + coeff0_11*dmats2[11][4] + coeff0_12*dmats2[12][4] + coeff0_13*dmats2[13][4] + coeff0_14*dmats2[14][4] + coeff0_15*dmats2[15][4] + coeff0_16*dmats2[16][4] + coeff0_17*dmats2[17][4] + coeff0_18*dmats2[18][4] + coeff0_19*dmats2[19][4];
3816
 
            new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5] + coeff0_10*dmats2[10][5] + coeff0_11*dmats2[11][5] + coeff0_12*dmats2[12][5] + coeff0_13*dmats2[13][5] + coeff0_14*dmats2[14][5] + coeff0_15*dmats2[15][5] + coeff0_16*dmats2[16][5] + coeff0_17*dmats2[17][5] + coeff0_18*dmats2[18][5] + coeff0_19*dmats2[19][5];
3817
 
            new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6] + coeff0_10*dmats2[10][6] + coeff0_11*dmats2[11][6] + coeff0_12*dmats2[12][6] + coeff0_13*dmats2[13][6] + coeff0_14*dmats2[14][6] + coeff0_15*dmats2[15][6] + coeff0_16*dmats2[16][6] + coeff0_17*dmats2[17][6] + coeff0_18*dmats2[18][6] + coeff0_19*dmats2[19][6];
3818
 
            new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7] + coeff0_10*dmats2[10][7] + coeff0_11*dmats2[11][7] + coeff0_12*dmats2[12][7] + coeff0_13*dmats2[13][7] + coeff0_14*dmats2[14][7] + coeff0_15*dmats2[15][7] + coeff0_16*dmats2[16][7] + coeff0_17*dmats2[17][7] + coeff0_18*dmats2[18][7] + coeff0_19*dmats2[19][7];
3819
 
            new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8] + coeff0_10*dmats2[10][8] + coeff0_11*dmats2[11][8] + coeff0_12*dmats2[12][8] + coeff0_13*dmats2[13][8] + coeff0_14*dmats2[14][8] + coeff0_15*dmats2[15][8] + coeff0_16*dmats2[16][8] + coeff0_17*dmats2[17][8] + coeff0_18*dmats2[18][8] + coeff0_19*dmats2[19][8];
3820
 
            new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9] + coeff0_10*dmats2[10][9] + coeff0_11*dmats2[11][9] + coeff0_12*dmats2[12][9] + coeff0_13*dmats2[13][9] + coeff0_14*dmats2[14][9] + coeff0_15*dmats2[15][9] + coeff0_16*dmats2[16][9] + coeff0_17*dmats2[17][9] + coeff0_18*dmats2[18][9] + coeff0_19*dmats2[19][9];
3821
 
            new_coeff0_10 = coeff0_0*dmats2[0][10] + coeff0_1*dmats2[1][10] + coeff0_2*dmats2[2][10] + coeff0_3*dmats2[3][10] + coeff0_4*dmats2[4][10] + coeff0_5*dmats2[5][10] + coeff0_6*dmats2[6][10] + coeff0_7*dmats2[7][10] + coeff0_8*dmats2[8][10] + coeff0_9*dmats2[9][10] + coeff0_10*dmats2[10][10] + coeff0_11*dmats2[11][10] + coeff0_12*dmats2[12][10] + coeff0_13*dmats2[13][10] + coeff0_14*dmats2[14][10] + coeff0_15*dmats2[15][10] + coeff0_16*dmats2[16][10] + coeff0_17*dmats2[17][10] + coeff0_18*dmats2[18][10] + coeff0_19*dmats2[19][10];
3822
 
            new_coeff0_11 = coeff0_0*dmats2[0][11] + coeff0_1*dmats2[1][11] + coeff0_2*dmats2[2][11] + coeff0_3*dmats2[3][11] + coeff0_4*dmats2[4][11] + coeff0_5*dmats2[5][11] + coeff0_6*dmats2[6][11] + coeff0_7*dmats2[7][11] + coeff0_8*dmats2[8][11] + coeff0_9*dmats2[9][11] + coeff0_10*dmats2[10][11] + coeff0_11*dmats2[11][11] + coeff0_12*dmats2[12][11] + coeff0_13*dmats2[13][11] + coeff0_14*dmats2[14][11] + coeff0_15*dmats2[15][11] + coeff0_16*dmats2[16][11] + coeff0_17*dmats2[17][11] + coeff0_18*dmats2[18][11] + coeff0_19*dmats2[19][11];
3823
 
            new_coeff0_12 = coeff0_0*dmats2[0][12] + coeff0_1*dmats2[1][12] + coeff0_2*dmats2[2][12] + coeff0_3*dmats2[3][12] + coeff0_4*dmats2[4][12] + coeff0_5*dmats2[5][12] + coeff0_6*dmats2[6][12] + coeff0_7*dmats2[7][12] + coeff0_8*dmats2[8][12] + coeff0_9*dmats2[9][12] + coeff0_10*dmats2[10][12] + coeff0_11*dmats2[11][12] + coeff0_12*dmats2[12][12] + coeff0_13*dmats2[13][12] + coeff0_14*dmats2[14][12] + coeff0_15*dmats2[15][12] + coeff0_16*dmats2[16][12] + coeff0_17*dmats2[17][12] + coeff0_18*dmats2[18][12] + coeff0_19*dmats2[19][12];
3824
 
            new_coeff0_13 = coeff0_0*dmats2[0][13] + coeff0_1*dmats2[1][13] + coeff0_2*dmats2[2][13] + coeff0_3*dmats2[3][13] + coeff0_4*dmats2[4][13] + coeff0_5*dmats2[5][13] + coeff0_6*dmats2[6][13] + coeff0_7*dmats2[7][13] + coeff0_8*dmats2[8][13] + coeff0_9*dmats2[9][13] + coeff0_10*dmats2[10][13] + coeff0_11*dmats2[11][13] + coeff0_12*dmats2[12][13] + coeff0_13*dmats2[13][13] + coeff0_14*dmats2[14][13] + coeff0_15*dmats2[15][13] + coeff0_16*dmats2[16][13] + coeff0_17*dmats2[17][13] + coeff0_18*dmats2[18][13] + coeff0_19*dmats2[19][13];
3825
 
            new_coeff0_14 = coeff0_0*dmats2[0][14] + coeff0_1*dmats2[1][14] + coeff0_2*dmats2[2][14] + coeff0_3*dmats2[3][14] + coeff0_4*dmats2[4][14] + coeff0_5*dmats2[5][14] + coeff0_6*dmats2[6][14] + coeff0_7*dmats2[7][14] + coeff0_8*dmats2[8][14] + coeff0_9*dmats2[9][14] + coeff0_10*dmats2[10][14] + coeff0_11*dmats2[11][14] + coeff0_12*dmats2[12][14] + coeff0_13*dmats2[13][14] + coeff0_14*dmats2[14][14] + coeff0_15*dmats2[15][14] + coeff0_16*dmats2[16][14] + coeff0_17*dmats2[17][14] + coeff0_18*dmats2[18][14] + coeff0_19*dmats2[19][14];
3826
 
            new_coeff0_15 = coeff0_0*dmats2[0][15] + coeff0_1*dmats2[1][15] + coeff0_2*dmats2[2][15] + coeff0_3*dmats2[3][15] + coeff0_4*dmats2[4][15] + coeff0_5*dmats2[5][15] + coeff0_6*dmats2[6][15] + coeff0_7*dmats2[7][15] + coeff0_8*dmats2[8][15] + coeff0_9*dmats2[9][15] + coeff0_10*dmats2[10][15] + coeff0_11*dmats2[11][15] + coeff0_12*dmats2[12][15] + coeff0_13*dmats2[13][15] + coeff0_14*dmats2[14][15] + coeff0_15*dmats2[15][15] + coeff0_16*dmats2[16][15] + coeff0_17*dmats2[17][15] + coeff0_18*dmats2[18][15] + coeff0_19*dmats2[19][15];
3827
 
            new_coeff0_16 = coeff0_0*dmats2[0][16] + coeff0_1*dmats2[1][16] + coeff0_2*dmats2[2][16] + coeff0_3*dmats2[3][16] + coeff0_4*dmats2[4][16] + coeff0_5*dmats2[5][16] + coeff0_6*dmats2[6][16] + coeff0_7*dmats2[7][16] + coeff0_8*dmats2[8][16] + coeff0_9*dmats2[9][16] + coeff0_10*dmats2[10][16] + coeff0_11*dmats2[11][16] + coeff0_12*dmats2[12][16] + coeff0_13*dmats2[13][16] + coeff0_14*dmats2[14][16] + coeff0_15*dmats2[15][16] + coeff0_16*dmats2[16][16] + coeff0_17*dmats2[17][16] + coeff0_18*dmats2[18][16] + coeff0_19*dmats2[19][16];
3828
 
            new_coeff0_17 = coeff0_0*dmats2[0][17] + coeff0_1*dmats2[1][17] + coeff0_2*dmats2[2][17] + coeff0_3*dmats2[3][17] + coeff0_4*dmats2[4][17] + coeff0_5*dmats2[5][17] + coeff0_6*dmats2[6][17] + coeff0_7*dmats2[7][17] + coeff0_8*dmats2[8][17] + coeff0_9*dmats2[9][17] + coeff0_10*dmats2[10][17] + coeff0_11*dmats2[11][17] + coeff0_12*dmats2[12][17] + coeff0_13*dmats2[13][17] + coeff0_14*dmats2[14][17] + coeff0_15*dmats2[15][17] + coeff0_16*dmats2[16][17] + coeff0_17*dmats2[17][17] + coeff0_18*dmats2[18][17] + coeff0_19*dmats2[19][17];
3829
 
            new_coeff0_18 = coeff0_0*dmats2[0][18] + coeff0_1*dmats2[1][18] + coeff0_2*dmats2[2][18] + coeff0_3*dmats2[3][18] + coeff0_4*dmats2[4][18] + coeff0_5*dmats2[5][18] + coeff0_6*dmats2[6][18] + coeff0_7*dmats2[7][18] + coeff0_8*dmats2[8][18] + coeff0_9*dmats2[9][18] + coeff0_10*dmats2[10][18] + coeff0_11*dmats2[11][18] + coeff0_12*dmats2[12][18] + coeff0_13*dmats2[13][18] + coeff0_14*dmats2[14][18] + coeff0_15*dmats2[15][18] + coeff0_16*dmats2[16][18] + coeff0_17*dmats2[17][18] + coeff0_18*dmats2[18][18] + coeff0_19*dmats2[19][18];
3830
 
            new_coeff0_19 = coeff0_0*dmats2[0][19] + coeff0_1*dmats2[1][19] + coeff0_2*dmats2[2][19] + coeff0_3*dmats2[3][19] + coeff0_4*dmats2[4][19] + coeff0_5*dmats2[5][19] + coeff0_6*dmats2[6][19] + coeff0_7*dmats2[7][19] + coeff0_8*dmats2[8][19] + coeff0_9*dmats2[9][19] + coeff0_10*dmats2[10][19] + coeff0_11*dmats2[11][19] + coeff0_12*dmats2[12][19] + coeff0_13*dmats2[13][19] + coeff0_14*dmats2[14][19] + coeff0_15*dmats2[15][19] + coeff0_16*dmats2[16][19] + coeff0_17*dmats2[17][19] + coeff0_18*dmats2[18][19] + coeff0_19*dmats2[19][19];
3831
 
          }
3832
 
    
3833
 
        }
3834
 
        // Compute derivatives on reference element as dot product of coefficients and basisvalues
3835
 
        derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9 + new_coeff0_10*basisvalue10 + new_coeff0_11*basisvalue11 + new_coeff0_12*basisvalue12 + new_coeff0_13*basisvalue13 + new_coeff0_14*basisvalue14 + new_coeff0_15*basisvalue15 + new_coeff0_16*basisvalue16 + new_coeff0_17*basisvalue17 + new_coeff0_18*basisvalue18 + new_coeff0_19*basisvalue19;
3836
 
      }
3837
 
    
3838
 
      // Transform derivatives back to physical element
3839
 
      for (unsigned int row = 0; row < num_derivatives; row++)
3840
 
      {
3841
 
        for (unsigned int col = 0; col < num_derivatives; col++)
3842
 
        {
3843
 
          values[num_derivatives + row] += transform[row][col]*derivatives[col];
3844
 
        }
3845
 
      }
3846
 
      // Delete pointer to array of derivatives on FIAT element
3847
 
      delete [] derivatives;
3848
 
    
3849
 
      // Delete pointer to array of combinations of derivatives and transform
3850
 
      for (unsigned int row = 0; row < num_derivatives; row++)
3851
 
      {
3852
 
        delete [] combinations[row];
3853
 
        delete [] transform[row];
3854
 
      }
3855
 
    
3856
 
      delete [] combinations;
3857
 
      delete [] transform;
3858
 
    }
3859
 
    
3860
 
    if (40 <= i && i <= 59)
3861
 
    {
3862
 
      // Map degree of freedom to element degree of freedom
3863
 
      const unsigned int dof = i - 40;
3864
 
    
3865
 
      // Generate scalings
3866
 
      const double scalings_y_0 = 1;
3867
 
      const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
3868
 
      const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
3869
 
      const double scalings_y_3 = scalings_y_2*(0.5 - 0.5*y);
3870
 
      const double scalings_z_0 = 1;
3871
 
      const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
3872
 
      const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
3873
 
      const double scalings_z_3 = scalings_z_2*(0.5 - 0.5*z);
3874
 
    
3875
 
      // Compute psitilde_a
3876
 
      const double psitilde_a_0 = 1;
3877
 
      const double psitilde_a_1 = x;
3878
 
      const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
3879
 
      const double psitilde_a_3 = 1.66666666666667*x*psitilde_a_2 - 0.666666666666667*psitilde_a_1;
3880
 
    
3881
 
      // Compute psitilde_bs
3882
 
      const double psitilde_bs_0_0 = 1;
3883
 
      const double psitilde_bs_0_1 = 1.5*y + 0.5;
3884
 
      const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
3885
 
      const double psitilde_bs_0_3 = 0.05*psitilde_bs_0_2 + 1.75*y*psitilde_bs_0_2 - 0.7*psitilde_bs_0_1;
3886
 
      const double psitilde_bs_1_0 = 1;
3887
 
      const double psitilde_bs_1_1 = 2.5*y + 1.5;
3888
 
      const double psitilde_bs_1_2 = 0.54*psitilde_bs_1_1 + 2.1*y*psitilde_bs_1_1 - 0.56*psitilde_bs_1_0;
3889
 
      const double psitilde_bs_2_0 = 1;
3890
 
      const double psitilde_bs_2_1 = 3.5*y + 2.5;
3891
 
      const double psitilde_bs_3_0 = 1;
3892
 
    
3893
 
      // Compute psitilde_cs
3894
 
      const double psitilde_cs_00_0 = 1;
3895
 
      const double psitilde_cs_00_1 = 2*z + 1;
3896
 
      const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
3897
 
      const double psitilde_cs_00_3 = 0.155555555555556*psitilde_cs_00_2 + 1.86666666666667*z*psitilde_cs_00_2 - 0.711111111111111*psitilde_cs_00_1;
3898
 
      const double psitilde_cs_01_0 = 1;
3899
 
      const double psitilde_cs_01_1 = 3*z + 2;
3900
 
      const double psitilde_cs_01_2 = 0.777777777777778*psitilde_cs_01_1 + 2.33333333333333*z*psitilde_cs_01_1 - 0.555555555555556*psitilde_cs_01_0;
3901
 
      const double psitilde_cs_02_0 = 1;
3902
 
      const double psitilde_cs_02_1 = 4*z + 3;
3903
 
      const double psitilde_cs_03_0 = 1;
3904
 
      const double psitilde_cs_10_0 = 1;
3905
 
      const double psitilde_cs_10_1 = 3*z + 2;
3906
 
      const double psitilde_cs_10_2 = 0.777777777777778*psitilde_cs_10_1 + 2.33333333333333*z*psitilde_cs_10_1 - 0.555555555555556*psitilde_cs_10_0;
3907
 
      const double psitilde_cs_11_0 = 1;
3908
 
      const double psitilde_cs_11_1 = 4*z + 3;
3909
 
      const double psitilde_cs_12_0 = 1;
3910
 
      const double psitilde_cs_20_0 = 1;
3911
 
      const double psitilde_cs_20_1 = 4*z + 3;
3912
 
      const double psitilde_cs_21_0 = 1;
3913
 
      const double psitilde_cs_30_0 = 1;
3914
 
    
3915
 
      // Compute basisvalues
3916
 
      const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
3917
 
      const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
3918
 
      const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
3919
 
      const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
3920
 
      const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
3921
 
      const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
3922
 
      const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
3923
 
      const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
3924
 
      const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
3925
 
      const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
3926
 
      const double basisvalue10 = 7.93725393319377*psitilde_a_3*scalings_y_3*psitilde_bs_3_0*scalings_z_3*psitilde_cs_30_0;
3927
 
      const double basisvalue11 = 6.70820393249937*psitilde_a_2*scalings_y_2*psitilde_bs_2_1*scalings_z_3*psitilde_cs_21_0;
3928
 
      const double basisvalue12 = 5.19615242270663*psitilde_a_1*scalings_y_1*psitilde_bs_1_2*scalings_z_3*psitilde_cs_12_0;
3929
 
      const double basisvalue13 = 3*psitilde_a_0*scalings_y_0*psitilde_bs_0_3*scalings_z_3*psitilde_cs_03_0;
3930
 
      const double basisvalue14 = 5.80947501931113*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_1;
3931
 
      const double basisvalue15 = 4.5*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_1;
3932
 
      const double basisvalue16 = 2.59807621135332*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_1;
3933
 
      const double basisvalue17 = 3.67423461417477*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_2;
3934
 
      const double basisvalue18 = 2.12132034355964*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_2;
3935
 
      const double basisvalue19 = 1.5*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_3;
3936
 
    
3937
 
      // Table(s) of coefficients
3938
 
      const static double coefficients0[20][20] =   \
3939
 
      {{0.0288675134594813, 0.0130410132739325, 0.00752923252421041, 0.0053239713749995, 0.018298126367785, 0.014173667737846, 0.0081831708838497, 0.0115727512471569, 0.0066815310478106, 0.00472455591261534, -0.028347335475692, -0.0239578711874978, -0.0185576872239523, -0.0107142857142857, -0.0207481250689683, -0.0160714285714286, -0.00927884361197614, -0.0131222664791956, -0.00757614408414158, -0.00535714285714286},
3940
 
      {0, -0.117369119465393, -0.0451753951452626, -0.031943828249997, -0.0182981263677849, 0.0425210032135381, 0.0409158544192486, 0.0347182537414707, 0.033407655239053, 0.0236227795630767, 0.0850420064270761, 0.0239578711874978, -0.00618589574131743, -0.0107142857142857, 0.0207481250689683, -0.00535714285714288, -0.00927884361197612, -0.00437408882639854, -0.00757614408414157, -0.00535714285714285},
3941
 
      {0, 0.117369119465393, -0.0451753951452625, -0.031943828249997, -0.0182981263677851, -0.0425210032135381, 0.0409158544192486, -0.0347182537414707, 0.033407655239053, 0.0236227795630767, -0.0850420064270761, 0.0239578711874977, 0.00618589574131743, -0.0107142857142857, 0.0207481250689683, 0.00535714285714288, -0.00927884361197614, 0.00437408882639855, -0.0075761440841416, -0.00535714285714286},
3942
 
      {0.0288675134594813, -0.0130410132739325, 0.00752923252421041, 0.00532397137499949, 0.018298126367785, -0.014173667737846, 0.00818317088384971, -0.0115727512471569, 0.00668153104781061, 0.00472455591261534, 0.028347335475692, -0.0239578711874977, 0.0185576872239522, -0.0107142857142857, -0.0207481250689683, 0.0160714285714286, -0.00927884361197612, 0.0131222664791956, -0.00757614408414158, -0.00535714285714285},
3943
 
      {0, -0.0978075995544939, -0.0790569415042094, -0.031943828249997, 0.054894379103355, -0.014173667737846, -0.0245495126515491, 0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, 0.0618589574131742, 0.0428571428571429, -0.0069160416896561, 0.0160714285714286, 0.0154647393532936, -0.00874817765279706, 0, -0.00535714285714285},
3944
 
      {0.259807621135332, 0, 0, -0.143747227124986, -0.10978875820671, 0, -0.122747563257746, 0, 0, 0.0425210032135381, 0, -0.095831484749991, 0, 0.0428571428571429, 0.0138320833793122, 0, 0.0154647393532935, 0, 0, -0.00535714285714286},
3945
 
      {0, 0.097807599554494, -0.0790569415042095, -0.031943828249997, 0.054894379103355, 0.0141736677378461, -0.0245495126515492, -0.0462910049886276, 0.0133630620956212, 0.0236227795630767, 0, 0.0479157423749955, -0.0618589574131742, 0.0428571428571429, -0.0069160416896561, -0.0160714285714286, 0.0154647393532936, 0.00874817765279706, 0, -0.00535714285714286},
3946
 
      {0, 0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, -0.0566946709513841, 0.0245495126515491, 0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, -0.0618589574131742, -0.0642857142857143, 0, 0.0214285714285714, 0.0092788436119761, -0.00437408882639853, 0.00757614408414159, -0.00535714285714286},
3947
 
      {0, -0.0195615199108988, 0.124232336649472, -0.031943828249997, 0, 0.0566946709513841, 0.0245495126515492, -0.0115727512471569, -0.0467707173346743, 0.0236227795630767, 0, 0, 0.0618589574131742, -0.0642857142857143, 0, -0.0214285714285714, 0.00927884361197613, 0.00437408882639853, 0.00757614408414157, -0.00535714285714285},
3948
 
      {0.0288675134594813, 0, -0.0150584650484208, 0.00532397137499948, 0, 0, 0.0245495126515492, 0, -0.0133630620956212, 0.00472455591261535, 0, 0, 0, 0.0428571428571429, 0, 0, -0.0278365308359284, 0, 0.0151522881682832, -0.00535714285714285},
3949
 
      {0, -0.0978075995544939, -0.0564692439315782, -0.0638876564999939, 0.054894379103355, 0.0425210032135381, 0.0245495126515492, -0.0231455024943137, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, 0.0375, 0.021650635094611, 0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
3950
 
      {0.259807621135332, 0, -0.135526185435788, 0.0479157423749955, -0.10978875820671, 0, 0.0245495126515492, 0, -0.0801783725737273, -0.0992156741649221, 0, 0, 0, 0, -0.0968245836551855, 0, 0.021650635094611, 0, 0.0303045763365663, 0.0267857142857143},
3951
 
      {0, 0.097807599554494, -0.0564692439315782, -0.063887656499994, 0.054894379103355, -0.0425210032135381, 0.0245495126515492, 0.0231455024943138, -0.0133630620956212, -0.0236227795630767, 0, 0, 0, 0, 0.0484122918275927, -0.0375, 0.021650635094611, -0.0524890659167824, 0.0303045763365663, 0.0267857142857143},
3952
 
      {0.259807621135332, -0.117369119465393, 0.0677630927178937, 0.0479157423749955, 0, -0.0850420064270761, -0.0736485379546475, -0.0694365074829414, 0.0400891862868636, -0.0992156741649221, 0, 0, 0, 0, 0, -0.075, -0.0649519052838329, 0.0262445329583912, -0.0151522881682831, 0.0267857142857143},
3953
 
      {0.259807621135332, 0.117369119465393, 0.0677630927178939, 0.0479157423749955, 0, 0.0850420064270761, -0.0736485379546474, 0.0694365074829414, 0.0400891862868636, -0.0992156741649222, 0, 0, 0, 0, 0, 0.075, -0.0649519052838329, -0.0262445329583912, -0.0151522881682832, 0.0267857142857143},
3954
 
      {0, 0, 0.112938487863156, -0.063887656499994, 0, 0, 0.0736485379546475, 0, 0.0267261241912425, -0.0236227795630767, 0, 0, 0, 0, 0, 0, 0.0649519052838329, 0, -0.0606091526731327, 0.0267857142857143},
3955
 
      {0, 0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, -0.0578637562357845, -0.033407655239053, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, -0.065611332395978, -0.0378807204207079, -0.0535714285714285},
3956
 
      {0, -0.0195615199108988, 0.0112938487863156, 0.127775312999988, 0, 0, 0, 0.0578637562357845, -0.0334076552390531, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0.065611332395978, -0.0378807204207079, -0.0535714285714286},
3957
 
      {0, 0, -0.0225876975726313, 0.127775312999988, 0, 0, 0, 0, 0.0668153104781061, 0.0472455591261534, 0, 0, 0, 0, 0, 0, 0, 0, 0.0757614408414158, -0.0535714285714286},
3958
 
      {0.0288675134594813, 0, 0, -0.0159719141249985, 0, 0, 0, 0, 0, 0.028347335475692, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0535714285714286}};
3959
 
    
3960
 
      // Interesting (new) part
3961
 
      // Tables of derivatives of the polynomial base (transpose)
3962
 
      const static double dmats0[20][20] =   \
3963
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3964
 
      {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3965
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3966
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3967
 
      {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3968
 
      {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3969
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3970
 
      {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3971
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3972
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3973
 
      {5.49909083394701, 0, -3.3466401061363, -2.36643191323985, 15.4919333848297, 0, 0.692820323027551, 0, 0.565685424949239, 0.400000000000001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3974
 
      {0, 4.89897948556636, 0, 0, 0, 14.1985914794391, 0, -0.82807867121083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3975
 
      {3.6, 0, 8.76356092008266, -1.54919333848297, 0, 0, 9.52470471983253, 0, -1.48131215963608, 0.261861468283192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3976
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3977
 
      {0, 4.24264068711928, 0, 0, 0, 0, 0, 14.3427433120127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3978
 
      {3.11769145362398, 0, 3.16227766016838, 4.91934955049954, 0, 0, 0, 0, 10.690449676497, -2.41897262725906, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3979
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3980
 
      {2.54558441227157, 0, 0, 7.66811580507233, 0, 0, 0, 0, 0, 10.3691851174526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3981
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3982
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3983
 
    
3984
 
      const static double dmats1[20][20] =   \
3985
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3986
 
      {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3987
 
      {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3988
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3989
 
      {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3990
 
      {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309959, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3991
 
      {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3992
 
      {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3993
 
      {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3994
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3995
 
      {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.28284271247462, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3996
 
      {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 9.16515138991168, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3997
 
      {1.8, -5.69209978830308, 4.38178046004133, -0.774596669241487, 0, 10.998181667894, 4.76235235991626, 0.962140470884726, -0.740656079818041, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3998
 
      {5.19615242270664, 0, -3.16227766016838, -2.23606797749979, 0, 0, 13.7477270848675, 0, 0.534522483824849, 0.37796447300923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3999
 
      {2.01246117974981, 2.12132034355964, -0.408248290463864, 3.17542648054294, 0, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4000
 
      {1.55884572681199, 2.73861278752583, 1.58113883008419, 2.45967477524977, 0, 0, 0, 9.25820099772551, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4001
 
      {-1.8, 0, 3.65148371670111, -2.84018778721878, 0, 0, 0, 0, 12.3442679969674, 1.39659449751035, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4002
 
      {1.27279220613579, 0, 0, 3.83405790253616, 0, 0, 0, 0, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4003
 
      {2.20454076850486, 0, 0, 6.6407830863536, 0, 0, 0, 0, 0, 8.97997772825746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4004
 
      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
4005
 
    
4006
 
      const static double dmats2[20][20] =   \
4007
 
      {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4008
 
      {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4009
 
      {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4010
 
      {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4011
 
      {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4012
 
      {2.29128784747792, 1.44913767461895, 4.18330013267038, -0.59160797830996, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4013
 
      {1.32287565553229, 0, 3.86436713231718, -0.341565025531987, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4014
 
      {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4015
 
      {1.08012344973464, 0, 7.09929573971954, 2.50998007960222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4016
 
      {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4017
 
      {2.74954541697351, 5.79655069847577, -1.67332005306815, -1.18321595661992, 7.74596669241483, -1.2, 0.346410161513776, -0.979795897113271, 0.282842712474619, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4018
 
      {2.32379000772445, 2.44948974278318, 2.82842712474619, -1, 1.30930734141595, 7.09929573971954, -2.04939015319192, -0.414039335605415, -0.478091443733757, 0.169030850945704, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4019
 
      {1.8, 0.632455532033675, 4.38178046004133, -0.774596669241484, 0, 3.14233761939829, 4.76235235991626, -0.10690449676497, -0.740656079818042, 0.130930734141596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4020
 
      {1.03923048454133, 0, 3.16227766016838, -0.447213595499959, 0, 0, 5.8918830363718, 0, -0.53452248382485, 0.0755928946018459, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4021
 
      {2.01246117974981, 2.12132034355964, -0.408248290463863, 3.17542648054294, 9.07114735222145, 0, 0, 7.17137165600636, -1.38013111868471, -1.56144011671765, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4022
 
      {1.55884572681199, 0.547722557505165, 1.58113883008419, 2.45967477524977, 0, 9.07114735222145, 0, 1.8516401995451, 5.34522483824849, -1.20948631362953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4023
 
      {0.900000000000001, 0, 1.46059348668045, 1.42009389360939, 0, 0, 9.07114735222145, 0, 4.93770719878694, -0.698297248755175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4024
 
      {1.27279220613578, -6.26099033699941, 0, 3.83405790253616, 0, 0, 0, 10.5830052442584, 0, 5.18459255872629, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4025
 
      {0.734846922834954, 0, -6.26099033699941, 2.21359436211787, 0, 0, 0, 0, 10.5830052442584, 2.99332590941915, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
4026
 
      {5.7157676649773, 0, 0, -4.69574275274955, 0, 0, 0, 0, 0, 12.69960629311, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
4027
 
    
4028
 
      // Compute reference derivatives
4029
 
      // Declare pointer to array of derivatives on FIAT element
4030
 
      double *derivatives = new double [num_derivatives];
4031
 
    
4032
 
      // Declare coefficients
4033
 
      double coeff0_0 = 0;
4034
 
      double coeff0_1 = 0;
4035
 
      double coeff0_2 = 0;
4036
 
      double coeff0_3 = 0;
4037
 
      double coeff0_4 = 0;
4038
 
      double coeff0_5 = 0;
4039
 
      double coeff0_6 = 0;
4040
 
      double coeff0_7 = 0;
4041
 
      double coeff0_8 = 0;
4042
 
      double coeff0_9 = 0;
4043
 
      double coeff0_10 = 0;
4044
 
      double coeff0_11 = 0;
4045
 
      double coeff0_12 = 0;
4046
 
      double coeff0_13 = 0;
4047
 
      double coeff0_14 = 0;
4048
 
      double coeff0_15 = 0;
4049
 
      double coeff0_16 = 0;
4050
 
      double coeff0_17 = 0;
4051
 
      double coeff0_18 = 0;
4052
 
      double coeff0_19 = 0;
4053
 
    
4054
 
      // Declare new coefficients
4055
 
      double new_coeff0_0 = 0;
4056
 
      double new_coeff0_1 = 0;
4057
 
      double new_coeff0_2 = 0;
4058
 
      double new_coeff0_3 = 0;
4059
 
      double new_coeff0_4 = 0;
4060
 
      double new_coeff0_5 = 0;
4061
 
      double new_coeff0_6 = 0;
4062
 
      double new_coeff0_7 = 0;
4063
 
      double new_coeff0_8 = 0;
4064
 
      double new_coeff0_9 = 0;
4065
 
      double new_coeff0_10 = 0;
4066
 
      double new_coeff0_11 = 0;
4067
 
      double new_coeff0_12 = 0;
4068
 
      double new_coeff0_13 = 0;
4069
 
      double new_coeff0_14 = 0;
4070
 
      double new_coeff0_15 = 0;
4071
 
      double new_coeff0_16 = 0;
4072
 
      double new_coeff0_17 = 0;
4073
 
      double new_coeff0_18 = 0;
4074
 
      double new_coeff0_19 = 0;
4075
 
    
4076
 
      // Loop possible derivatives
4077
 
      for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
4078
 
      {
4079
 
        // Get values from coefficients array
4080
 
        new_coeff0_0 = coefficients0[dof][0];
4081
 
        new_coeff0_1 = coefficients0[dof][1];
4082
 
        new_coeff0_2 = coefficients0[dof][2];
4083
 
        new_coeff0_3 = coefficients0[dof][3];
4084
 
        new_coeff0_4 = coefficients0[dof][4];
4085
 
        new_coeff0_5 = coefficients0[dof][5];
4086
 
        new_coeff0_6 = coefficients0[dof][6];
4087
 
        new_coeff0_7 = coefficients0[dof][7];
4088
 
        new_coeff0_8 = coefficients0[dof][8];
4089
 
        new_coeff0_9 = coefficients0[dof][9];
4090
 
        new_coeff0_10 = coefficients0[dof][10];
4091
 
        new_coeff0_11 = coefficients0[dof][11];
4092
 
        new_coeff0_12 = coefficients0[dof][12];
4093
 
        new_coeff0_13 = coefficients0[dof][13];
4094
 
        new_coeff0_14 = coefficients0[dof][14];
4095
 
        new_coeff0_15 = coefficients0[dof][15];
4096
 
        new_coeff0_16 = coefficients0[dof][16];
4097
 
        new_coeff0_17 = coefficients0[dof][17];
4098
 
        new_coeff0_18 = coefficients0[dof][18];
4099
 
        new_coeff0_19 = coefficients0[dof][19];
4100
 
    
4101
 
        // Loop derivative order
4102
 
        for (unsigned int j = 0; j < n; j++)
4103
 
        {
4104
 
          // Update old coefficients
4105
 
          coeff0_0 = new_coeff0_0;
4106
 
          coeff0_1 = new_coeff0_1;
4107
 
          coeff0_2 = new_coeff0_2;
4108
 
          coeff0_3 = new_coeff0_3;
4109
 
          coeff0_4 = new_coeff0_4;
4110
 
          coeff0_5 = new_coeff0_5;
4111
 
          coeff0_6 = new_coeff0_6;
4112
 
          coeff0_7 = new_coeff0_7;
4113
 
          coeff0_8 = new_coeff0_8;
4114
 
          coeff0_9 = new_coeff0_9;
4115
 
          coeff0_10 = new_coeff0_10;
4116
 
          coeff0_11 = new_coeff0_11;
4117
 
          coeff0_12 = new_coeff0_12;
4118
 
          coeff0_13 = new_coeff0_13;
4119
 
          coeff0_14 = new_coeff0_14;
4120
 
          coeff0_15 = new_coeff0_15;
4121
 
          coeff0_16 = new_coeff0_16;
4122
 
          coeff0_17 = new_coeff0_17;
4123
 
          coeff0_18 = new_coeff0_18;
4124
 
          coeff0_19 = new_coeff0_19;
4125
 
    
4126
 
          if(combinations[deriv_num][j] == 0)
4127
 
          {
4128
 
            new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0] + coeff0_10*dmats0[10][0] + coeff0_11*dmats0[11][0] + coeff0_12*dmats0[12][0] + coeff0_13*dmats0[13][0] + coeff0_14*dmats0[14][0] + coeff0_15*dmats0[15][0] + coeff0_16*dmats0[16][0] + coeff0_17*dmats0[17][0] + coeff0_18*dmats0[18][0] + coeff0_19*dmats0[19][0];
4129
 
            new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1] + coeff0_10*dmats0[10][1] + coeff0_11*dmats0[11][1] + coeff0_12*dmats0[12][1] + coeff0_13*dmats0[13][1] + coeff0_14*dmats0[14][1] + coeff0_15*dmats0[15][1] + coeff0_16*dmats0[16][1] + coeff0_17*dmats0[17][1] + coeff0_18*dmats0[18][1] + coeff0_19*dmats0[19][1];
4130
 
            new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2] + coeff0_10*dmats0[10][2] + coeff0_11*dmats0[11][2] + coeff0_12*dmats0[12][2] + coeff0_13*dmats0[13][2] + coeff0_14*dmats0[14][2] + coeff0_15*dmats0[15][2] + coeff0_16*dmats0[16][2] + coeff0_17*dmats0[17][2] + coeff0_18*dmats0[18][2] + coeff0_19*dmats0[19][2];
4131
 
            new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3] + coeff0_10*dmats0[10][3] + coeff0_11*dmats0[11][3] + coeff0_12*dmats0[12][3] + coeff0_13*dmats0[13][3] + coeff0_14*dmats0[14][3] + coeff0_15*dmats0[15][3] + coeff0_16*dmats0[16][3] + coeff0_17*dmats0[17][3] + coeff0_18*dmats0[18][3] + coeff0_19*dmats0[19][3];
4132
 
            new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4] + coeff0_10*dmats0[10][4] + coeff0_11*dmats0[11][4] + coeff0_12*dmats0[12][4] + coeff0_13*dmats0[13][4] + coeff0_14*dmats0[14][4] + coeff0_15*dmats0[15][4] + coeff0_16*dmats0[16][4] + coeff0_17*dmats0[17][4] + coeff0_18*dmats0[18][4] + coeff0_19*dmats0[19][4];
4133
 
            new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5] + coeff0_10*dmats0[10][5] + coeff0_11*dmats0[11][5] + coeff0_12*dmats0[12][5] + coeff0_13*dmats0[13][5] + coeff0_14*dmats0[14][5] + coeff0_15*dmats0[15][5] + coeff0_16*dmats0[16][5] + coeff0_17*dmats0[17][5] + coeff0_18*dmats0[18][5] + coeff0_19*dmats0[19][5];
4134
 
            new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6] + coeff0_10*dmats0[10][6] + coeff0_11*dmats0[11][6] + coeff0_12*dmats0[12][6] + coeff0_13*dmats0[13][6] + coeff0_14*dmats0[14][6] + coeff0_15*dmats0[15][6] + coeff0_16*dmats0[16][6] + coeff0_17*dmats0[17][6] + coeff0_18*dmats0[18][6] + coeff0_19*dmats0[19][6];
4135
 
            new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7] + coeff0_10*dmats0[10][7] + coeff0_11*dmats0[11][7] + coeff0_12*dmats0[12][7] + coeff0_13*dmats0[13][7] + coeff0_14*dmats0[14][7] + coeff0_15*dmats0[15][7] + coeff0_16*dmats0[16][7] + coeff0_17*dmats0[17][7] + coeff0_18*dmats0[18][7] + coeff0_19*dmats0[19][7];
4136
 
            new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8] + coeff0_10*dmats0[10][8] + coeff0_11*dmats0[11][8] + coeff0_12*dmats0[12][8] + coeff0_13*dmats0[13][8] + coeff0_14*dmats0[14][8] + coeff0_15*dmats0[15][8] + coeff0_16*dmats0[16][8] + coeff0_17*dmats0[17][8] + coeff0_18*dmats0[18][8] + coeff0_19*dmats0[19][8];
4137
 
            new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9] + coeff0_10*dmats0[10][9] + coeff0_11*dmats0[11][9] + coeff0_12*dmats0[12][9] + coeff0_13*dmats0[13][9] + coeff0_14*dmats0[14][9] + coeff0_15*dmats0[15][9] + coeff0_16*dmats0[16][9] + coeff0_17*dmats0[17][9] + coeff0_18*dmats0[18][9] + coeff0_19*dmats0[19][9];
4138
 
            new_coeff0_10 = coeff0_0*dmats0[0][10] + coeff0_1*dmats0[1][10] + coeff0_2*dmats0[2][10] + coeff0_3*dmats0[3][10] + coeff0_4*dmats0[4][10] + coeff0_5*dmats0[5][10] + coeff0_6*dmats0[6][10] + coeff0_7*dmats0[7][10] + coeff0_8*dmats0[8][10] + coeff0_9*dmats0[9][10] + coeff0_10*dmats0[10][10] + coeff0_11*dmats0[11][10] + coeff0_12*dmats0[12][10] + coeff0_13*dmats0[13][10] + coeff0_14*dmats0[14][10] + coeff0_15*dmats0[15][10] + coeff0_16*dmats0[16][10] + coeff0_17*dmats0[17][10] + coeff0_18*dmats0[18][10] + coeff0_19*dmats0[19][10];
4139
 
            new_coeff0_11 = coeff0_0*dmats0[0][11] + coeff0_1*dmats0[1][11] + coeff0_2*dmats0[2][11] + coeff0_3*dmats0[3][11] + coeff0_4*dmats0[4][11] + coeff0_5*dmats0[5][11] + coeff0_6*dmats0[6][11] + coeff0_7*dmats0[7][11] + coeff0_8*dmats0[8][11] + coeff0_9*dmats0[9][11] + coeff0_10*dmats0[10][11] + coeff0_11*dmats0[11][11] + coeff0_12*dmats0[12][11] + coeff0_13*dmats0[13][11] + coeff0_14*dmats0[14][11] + coeff0_15*dmats0[15][11] + coeff0_16*dmats0[16][11] + coeff0_17*dmats0[17][11] + coeff0_18*dmats0[18][11] + coeff0_19*dmats0[19][11];
4140
 
            new_coeff0_12 = coeff0_0*dmats0[0][12] + coeff0_1*dmats0[1][12] + coeff0_2*dmats0[2][12] + coeff0_3*dmats0[3][12] + coeff0_4*dmats0[4][12] + coeff0_5*dmats0[5][12] + coeff0_6*dmats0[6][12] + coeff0_7*dmats0[7][12] + coeff0_8*dmats0[8][12] + coeff0_9*dmats0[9][12] + coeff0_10*dmats0[10][12] + coeff0_11*dmats0[11][12] + coeff0_12*dmats0[12][12] + coeff0_13*dmats0[13][12] + coeff0_14*dmats0[14][12] + coeff0_15*dmats0[15][12] + coeff0_16*dmats0[16][12] + coeff0_17*dmats0[17][12] + coeff0_18*dmats0[18][12] + coeff0_19*dmats0[19][12];
4141
 
            new_coeff0_13 = coeff0_0*dmats0[0][13] + coeff0_1*dmats0[1][13] + coeff0_2*dmats0[2][13] + coeff0_3*dmats0[3][13] + coeff0_4*dmats0[4][13] + coeff0_5*dmats0[5][13] + coeff0_6*dmats0[6][13] + coeff0_7*dmats0[7][13] + coeff0_8*dmats0[8][13] + coeff0_9*dmats0[9][13] + coeff0_10*dmats0[10][13] + coeff0_11*dmats0[11][13] + coeff0_12*dmats0[12][13] + coeff0_13*dmats0[13][13] + coeff0_14*dmats0[14][13] + coeff0_15*dmats0[15][13] + coeff0_16*dmats0[16][13] + coeff0_17*dmats0[17][13] + coeff0_18*dmats0[18][13] + coeff0_19*dmats0[19][13];
4142
 
            new_coeff0_14 = coeff0_0*dmats0[0][14] + coeff0_1*dmats0[1][14] + coeff0_2*dmats0[2][14] + coeff0_3*dmats0[3][14] + coeff0_4*dmats0[4][14] + coeff0_5*dmats0[5][14] + coeff0_6*dmats0[6][14] + coeff0_7*dmats0[7][14] + coeff0_8*dmats0[8][14] + coeff0_9*dmats0[9][14] + coeff0_10*dmats0[10][14] + coeff0_11*dmats0[11][14] + coeff0_12*dmats0[12][14] + coeff0_13*dmats0[13][14] + coeff0_14*dmats0[14][14] + coeff0_15*dmats0[15][14] + coeff0_16*dmats0[16][14] + coeff0_17*dmats0[17][14] + coeff0_18*dmats0[18][14] + coeff0_19*dmats0[19][14];
4143
 
            new_coeff0_15 = coeff0_0*dmats0[0][15] + coeff0_1*dmats0[1][15] + coeff0_2*dmats0[2][15] + coeff0_3*dmats0[3][15] + coeff0_4*dmats0[4][15] + coeff0_5*dmats0[5][15] + coeff0_6*dmats0[6][15] + coeff0_7*dmats0[7][15] + coeff0_8*dmats0[8][15] + coeff0_9*dmats0[9][15] + coeff0_10*dmats0[10][15] + coeff0_11*dmats0[11][15] + coeff0_12*dmats0[12][15] + coeff0_13*dmats0[13][15] + coeff0_14*dmats0[14][15] + coeff0_15*dmats0[15][15] + coeff0_16*dmats0[16][15] + coeff0_17*dmats0[17][15] + coeff0_18*dmats0[18][15] + coeff0_19*dmats0[19][15];
4144
 
            new_coeff0_16 = coeff0_0*dmats0[0][16] + coeff0_1*dmats0[1][16] + coeff0_2*dmats0[2][16] + coeff0_3*dmats0[3][16] + coeff0_4*dmats0[4][16] + coeff0_5*dmats0[5][16] + coeff0_6*dmats0[6][16] + coeff0_7*dmats0[7][16] + coeff0_8*dmats0[8][16] + coeff0_9*dmats0[9][16] + coeff0_10*dmats0[10][16] + coeff0_11*dmats0[11][16] + coeff0_12*dmats0[12][16] + coeff0_13*dmats0[13][16] + coeff0_14*dmats0[14][16] + coeff0_15*dmats0[15][16] + coeff0_16*dmats0[16][16] + coeff0_17*dmats0[17][16] + coeff0_18*dmats0[18][16] + coeff0_19*dmats0[19][16];
4145
 
            new_coeff0_17 = coeff0_0*dmats0[0][17] + coeff0_1*dmats0[1][17] + coeff0_2*dmats0[2][17] + coeff0_3*dmats0[3][17] + coeff0_4*dmats0[4][17] + coeff0_5*dmats0[5][17] + coeff0_6*dmats0[6][17] + coeff0_7*dmats0[7][17] + coeff0_8*dmats0[8][17] + coeff0_9*dmats0[9][17] + coeff0_10*dmats0[10][17] + coeff0_11*dmats0[11][17] + coeff0_12*dmats0[12][17] + coeff0_13*dmats0[13][17] + coeff0_14*dmats0[14][17] + coeff0_15*dmats0[15][17] + coeff0_16*dmats0[16][17] + coeff0_17*dmats0[17][17] + coeff0_18*dmats0[18][17] + coeff0_19*dmats0[19][17];
4146
 
            new_coeff0_18 = coeff0_0*dmats0[0][18] + coeff0_1*dmats0[1][18] + coeff0_2*dmats0[2][18] + coeff0_3*dmats0[3][18] + coeff0_4*dmats0[4][18] + coeff0_5*dmats0[5][18] + coeff0_6*dmats0[6][18] + coeff0_7*dmats0[7][18] + coeff0_8*dmats0[8][18] + coeff0_9*dmats0[9][18] + coeff0_10*dmats0[10][18] + coeff0_11*dmats0[11][18] + coeff0_12*dmats0[12][18] + coeff0_13*dmats0[13][18] + coeff0_14*dmats0[14][18] + coeff0_15*dmats0[15][18] + coeff0_16*dmats0[16][18] + coeff0_17*dmats0[17][18] + coeff0_18*dmats0[18][18] + coeff0_19*dmats0[19][18];
4147
 
            new_coeff0_19 = coeff0_0*dmats0[0][19] + coeff0_1*dmats0[1][19] + coeff0_2*dmats0[2][19] + coeff0_3*dmats0[3][19] + coeff0_4*dmats0[4][19] + coeff0_5*dmats0[5][19] + coeff0_6*dmats0[6][19] + coeff0_7*dmats0[7][19] + coeff0_8*dmats0[8][19] + coeff0_9*dmats0[9][19] + coeff0_10*dmats0[10][19] + coeff0_11*dmats0[11][19] + coeff0_12*dmats0[12][19] + coeff0_13*dmats0[13][19] + coeff0_14*dmats0[14][19] + coeff0_15*dmats0[15][19] + coeff0_16*dmats0[16][19] + coeff0_17*dmats0[17][19] + coeff0_18*dmats0[18][19] + coeff0_19*dmats0[19][19];
4148
 
          }
4149
 
          if(combinations[deriv_num][j] == 1)
4150
 
          {
4151
 
            new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0] + coeff0_10*dmats1[10][0] + coeff0_11*dmats1[11][0] + coeff0_12*dmats1[12][0] + coeff0_13*dmats1[13][0] + coeff0_14*dmats1[14][0] + coeff0_15*dmats1[15][0] + coeff0_16*dmats1[16][0] + coeff0_17*dmats1[17][0] + coeff0_18*dmats1[18][0] + coeff0_19*dmats1[19][0];
4152
 
            new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1] + coeff0_10*dmats1[10][1] + coeff0_11*dmats1[11][1] + coeff0_12*dmats1[12][1] + coeff0_13*dmats1[13][1] + coeff0_14*dmats1[14][1] + coeff0_15*dmats1[15][1] + coeff0_16*dmats1[16][1] + coeff0_17*dmats1[17][1] + coeff0_18*dmats1[18][1] + coeff0_19*dmats1[19][1];
4153
 
            new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2] + coeff0_10*dmats1[10][2] + coeff0_11*dmats1[11][2] + coeff0_12*dmats1[12][2] + coeff0_13*dmats1[13][2] + coeff0_14*dmats1[14][2] + coeff0_15*dmats1[15][2] + coeff0_16*dmats1[16][2] + coeff0_17*dmats1[17][2] + coeff0_18*dmats1[18][2] + coeff0_19*dmats1[19][2];
4154
 
            new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3] + coeff0_10*dmats1[10][3] + coeff0_11*dmats1[11][3] + coeff0_12*dmats1[12][3] + coeff0_13*dmats1[13][3] + coeff0_14*dmats1[14][3] + coeff0_15*dmats1[15][3] + coeff0_16*dmats1[16][3] + coeff0_17*dmats1[17][3] + coeff0_18*dmats1[18][3] + coeff0_19*dmats1[19][3];
4155
 
            new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4] + coeff0_10*dmats1[10][4] + coeff0_11*dmats1[11][4] + coeff0_12*dmats1[12][4] + coeff0_13*dmats1[13][4] + coeff0_14*dmats1[14][4] + coeff0_15*dmats1[15][4] + coeff0_16*dmats1[16][4] + coeff0_17*dmats1[17][4] + coeff0_18*dmats1[18][4] + coeff0_19*dmats1[19][4];
4156
 
            new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5] + coeff0_10*dmats1[10][5] + coeff0_11*dmats1[11][5] + coeff0_12*dmats1[12][5] + coeff0_13*dmats1[13][5] + coeff0_14*dmats1[14][5] + coeff0_15*dmats1[15][5] + coeff0_16*dmats1[16][5] + coeff0_17*dmats1[17][5] + coeff0_18*dmats1[18][5] + coeff0_19*dmats1[19][5];
4157
 
            new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6] + coeff0_10*dmats1[10][6] + coeff0_11*dmats1[11][6] + coeff0_12*dmats1[12][6] + coeff0_13*dmats1[13][6] + coeff0_14*dmats1[14][6] + coeff0_15*dmats1[15][6] + coeff0_16*dmats1[16][6] + coeff0_17*dmats1[17][6] + coeff0_18*dmats1[18][6] + coeff0_19*dmats1[19][6];
4158
 
            new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7] + coeff0_10*dmats1[10][7] + coeff0_11*dmats1[11][7] + coeff0_12*dmats1[12][7] + coeff0_13*dmats1[13][7] + coeff0_14*dmats1[14][7] + coeff0_15*dmats1[15][7] + coeff0_16*dmats1[16][7] + coeff0_17*dmats1[17][7] + coeff0_18*dmats1[18][7] + coeff0_19*dmats1[19][7];
4159
 
            new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8] + coeff0_10*dmats1[10][8] + coeff0_11*dmats1[11][8] + coeff0_12*dmats1[12][8] + coeff0_13*dmats1[13][8] + coeff0_14*dmats1[14][8] + coeff0_15*dmats1[15][8] + coeff0_16*dmats1[16][8] + coeff0_17*dmats1[17][8] + coeff0_18*dmats1[18][8] + coeff0_19*dmats1[19][8];
4160
 
            new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9] + coeff0_10*dmats1[10][9] + coeff0_11*dmats1[11][9] + coeff0_12*dmats1[12][9] + coeff0_13*dmats1[13][9] + coeff0_14*dmats1[14][9] + coeff0_15*dmats1[15][9] + coeff0_16*dmats1[16][9] + coeff0_17*dmats1[17][9] + coeff0_18*dmats1[18][9] + coeff0_19*dmats1[19][9];
4161
 
            new_coeff0_10 = coeff0_0*dmats1[0][10] + coeff0_1*dmats1[1][10] + coeff0_2*dmats1[2][10] + coeff0_3*dmats1[3][10] + coeff0_4*dmats1[4][10] + coeff0_5*dmats1[5][10] + coeff0_6*dmats1[6][10] + coeff0_7*dmats1[7][10] + coeff0_8*dmats1[8][10] + coeff0_9*dmats1[9][10] + coeff0_10*dmats1[10][10] + coeff0_11*dmats1[11][10] + coeff0_12*dmats1[12][10] + coeff0_13*dmats1[13][10] + coeff0_14*dmats1[14][10] + coeff0_15*dmats1[15][10] + coeff0_16*dmats1[16][10] + coeff0_17*dmats1[17][10] + coeff0_18*dmats1[18][10] + coeff0_19*dmats1[19][10];
4162
 
            new_coeff0_11 = coeff0_0*dmats1[0][11] + coeff0_1*dmats1[1][11] + coeff0_2*dmats1[2][11] + coeff0_3*dmats1[3][11] + coeff0_4*dmats1[4][11] + coeff0_5*dmats1[5][11] + coeff0_6*dmats1[6][11] + coeff0_7*dmats1[7][11] + coeff0_8*dmats1[8][11] + coeff0_9*dmats1[9][11] + coeff0_10*dmats1[10][11] + coeff0_11*dmats1[11][11] + coeff0_12*dmats1[12][11] + coeff0_13*dmats1[13][11] + coeff0_14*dmats1[14][11] + coeff0_15*dmats1[15][11] + coeff0_16*dmats1[16][11] + coeff0_17*dmats1[17][11] + coeff0_18*dmats1[18][11] + coeff0_19*dmats1[19][11];
4163
 
            new_coeff0_12 = coeff0_0*dmats1[0][12] + coeff0_1*dmats1[1][12] + coeff0_2*dmats1[2][12] + coeff0_3*dmats1[3][12] + coeff0_4*dmats1[4][12] + coeff0_5*dmats1[5][12] + coeff0_6*dmats1[6][12] + coeff0_7*dmats1[7][12] + coeff0_8*dmats1[8][12] + coeff0_9*dmats1[9][12] + coeff0_10*dmats1[10][12] + coeff0_11*dmats1[11][12] + coeff0_12*dmats1[12][12] + coeff0_13*dmats1[13][12] + coeff0_14*dmats1[14][12] + coeff0_15*dmats1[15][12] + coeff0_16*dmats1[16][12] + coeff0_17*dmats1[17][12] + coeff0_18*dmats1[18][12] + coeff0_19*dmats1[19][12];
4164
 
            new_coeff0_13 = coeff0_0*dmats1[0][13] + coeff0_1*dmats1[1][13] + coeff0_2*dmats1[2][13] + coeff0_3*dmats1[3][13] + coeff0_4*dmats1[4][13] + coeff0_5*dmats1[5][13] + coeff0_6*dmats1[6][13] + coeff0_7*dmats1[7][13] + coeff0_8*dmats1[8][13] + coeff0_9*dmats1[9][13] + coeff0_10*dmats1[10][13] + coeff0_11*dmats1[11][13] + coeff0_12*dmats1[12][13] + coeff0_13*dmats1[13][13] + coeff0_14*dmats1[14][13] + coeff0_15*dmats1[15][13] + coeff0_16*dmats1[16][13] + coeff0_17*dmats1[17][13] + coeff0_18*dmats1[18][13] + coeff0_19*dmats1[19][13];
4165
 
            new_coeff0_14 = coeff0_0*dmats1[0][14] + coeff0_1*dmats1[1][14] + coeff0_2*dmats1[2][14] + coeff0_3*dmats1[3][14] + coeff0_4*dmats1[4][14] + coeff0_5*dmats1[5][14] + coeff0_6*dmats1[6][14] + coeff0_7*dmats1[7][14] + coeff0_8*dmats1[8][14] + coeff0_9*dmats1[9][14] + coeff0_10*dmats1[10][14] + coeff0_11*dmats1[11][14] + coeff0_12*dmats1[12][14] + coeff0_13*dmats1[13][14] + coeff0_14*dmats1[14][14] + coeff0_15*dmats1[15][14] + coeff0_16*dmats1[16][14] + coeff0_17*dmats1[17][14] + coeff0_18*dmats1[18][14] + coeff0_19*dmats1[19][14];
4166
 
            new_coeff0_15 = coeff0_0*dmats1[0][15] + coeff0_1*dmats1[1][15] + coeff0_2*dmats1[2][15] + coeff0_3*dmats1[3][15] + coeff0_4*dmats1[4][15] + coeff0_5*dmats1[5][15] + coeff0_6*dmats1[6][15] + coeff0_7*dmats1[7][15] + coeff0_8*dmats1[8][15] + coeff0_9*dmats1[9][15] + coeff0_10*dmats1[10][15] + coeff0_11*dmats1[11][15] + coeff0_12*dmats1[12][15] + coeff0_13*dmats1[13][15] + coeff0_14*dmats1[14][15] + coeff0_15*dmats1[15][15] + coeff0_16*dmats1[16][15] + coeff0_17*dmats1[17][15] + coeff0_18*dmats1[18][15] + coeff0_19*dmats1[19][15];
4167
 
            new_coeff0_16 = coeff0_0*dmats1[0][16] + coeff0_1*dmats1[1][16] + coeff0_2*dmats1[2][16] + coeff0_3*dmats1[3][16] + coeff0_4*dmats1[4][16] + coeff0_5*dmats1[5][16] + coeff0_6*dmats1[6][16] + coeff0_7*dmats1[7][16] + coeff0_8*dmats1[8][16] + coeff0_9*dmats1[9][16] + coeff0_10*dmats1[10][16] + coeff0_11*dmats1[11][16] + coeff0_12*dmats1[12][16] + coeff0_13*dmats1[13][16] + coeff0_14*dmats1[14][16] + coeff0_15*dmats1[15][16] + coeff0_16*dmats1[16][16] + coeff0_17*dmats1[17][16] + coeff0_18*dmats1[18][16] + coeff0_19*dmats1[19][16];
4168
 
            new_coeff0_17 = coeff0_0*dmats1[0][17] + coeff0_1*dmats1[1][17] + coeff0_2*dmats1[2][17] + coeff0_3*dmats1[3][17] + coeff0_4*dmats1[4][17] + coeff0_5*dmats1[5][17] + coeff0_6*dmats1[6][17] + coeff0_7*dmats1[7][17] + coeff0_8*dmats1[8][17] + coeff0_9*dmats1[9][17] + coeff0_10*dmats1[10][17] + coeff0_11*dmats1[11][17] + coeff0_12*dmats1[12][17] + coeff0_13*dmats1[13][17] + coeff0_14*dmats1[14][17] + coeff0_15*dmats1[15][17] + coeff0_16*dmats1[16][17] + coeff0_17*dmats1[17][17] + coeff0_18*dmats1[18][17] + coeff0_19*dmats1[19][17];
4169
 
            new_coeff0_18 = coeff0_0*dmats1[0][18] + coeff0_1*dmats1[1][18] + coeff0_2*dmats1[2][18] + coeff0_3*dmats1[3][18] + coeff0_4*dmats1[4][18] + coeff0_5*dmats1[5][18] + coeff0_6*dmats1[6][18] + coeff0_7*dmats1[7][18] + coeff0_8*dmats1[8][18] + coeff0_9*dmats1[9][18] + coeff0_10*dmats1[10][18] + coeff0_11*dmats1[11][18] + coeff0_12*dmats1[12][18] + coeff0_13*dmats1[13][18] + coeff0_14*dmats1[14][18] + coeff0_15*dmats1[15][18] + coeff0_16*dmats1[16][18] + coeff0_17*dmats1[17][18] + coeff0_18*dmats1[18][18] + coeff0_19*dmats1[19][18];
4170
 
            new_coeff0_19 = coeff0_0*dmats1[0][19] + coeff0_1*dmats1[1][19] + coeff0_2*dmats1[2][19] + coeff0_3*dmats1[3][19] + coeff0_4*dmats1[4][19] + coeff0_5*dmats1[5][19] + coeff0_6*dmats1[6][19] + coeff0_7*dmats1[7][19] + coeff0_8*dmats1[8][19] + coeff0_9*dmats1[9][19] + coeff0_10*dmats1[10][19] + coeff0_11*dmats1[11][19] + coeff0_12*dmats1[12][19] + coeff0_13*dmats1[13][19] + coeff0_14*dmats1[14][19] + coeff0_15*dmats1[15][19] + coeff0_16*dmats1[16][19] + coeff0_17*dmats1[17][19] + coeff0_18*dmats1[18][19] + coeff0_19*dmats1[19][19];
4171
 
          }
4172
 
          if(combinations[deriv_num][j] == 2)
4173
 
          {
4174
 
            new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0] + coeff0_10*dmats2[10][0] + coeff0_11*dmats2[11][0] + coeff0_12*dmats2[12][0] + coeff0_13*dmats2[13][0] + coeff0_14*dmats2[14][0] + coeff0_15*dmats2[15][0] + coeff0_16*dmats2[16][0] + coeff0_17*dmats2[17][0] + coeff0_18*dmats2[18][0] + coeff0_19*dmats2[19][0];
4175
 
            new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1] + coeff0_10*dmats2[10][1] + coeff0_11*dmats2[11][1] + coeff0_12*dmats2[12][1] + coeff0_13*dmats2[13][1] + coeff0_14*dmats2[14][1] + coeff0_15*dmats2[15][1] + coeff0_16*dmats2[16][1] + coeff0_17*dmats2[17][1] + coeff0_18*dmats2[18][1] + coeff0_19*dmats2[19][1];
4176
 
            new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2] + coeff0_10*dmats2[10][2] + coeff0_11*dmats2[11][2] + coeff0_12*dmats2[12][2] + coeff0_13*dmats2[13][2] + coeff0_14*dmats2[14][2] + coeff0_15*dmats2[15][2] + coeff0_16*dmats2[16][2] + coeff0_17*dmats2[17][2] + coeff0_18*dmats2[18][2] + coeff0_19*dmats2[19][2];
4177
 
            new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3] + coeff0_10*dmats2[10][3] + coeff0_11*dmats2[11][3] + coeff0_12*dmats2[12][3] + coeff0_13*dmats2[13][3] + coeff0_14*dmats2[14][3] + coeff0_15*dmats2[15][3] + coeff0_16*dmats2[16][3] + coeff0_17*dmats2[17][3] + coeff0_18*dmats2[18][3] + coeff0_19*dmats2[19][3];
4178
 
            new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4] + coeff0_10*dmats2[10][4] + coeff0_11*dmats2[11][4] + coeff0_12*dmats2[12][4] + coeff0_13*dmats2[13][4] + coeff0_14*dmats2[14][4] + coeff0_15*dmats2[15][4] + coeff0_16*dmats2[16][4] + coeff0_17*dmats2[17][4] + coeff0_18*dmats2[18][4] + coeff0_19*dmats2[19][4];
4179
 
            new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5] + coeff0_10*dmats2[10][5] + coeff0_11*dmats2[11][5] + coeff0_12*dmats2[12][5] + coeff0_13*dmats2[13][5] + coeff0_14*dmats2[14][5] + coeff0_15*dmats2[15][5] + coeff0_16*dmats2[16][5] + coeff0_17*dmats2[17][5] + coeff0_18*dmats2[18][5] + coeff0_19*dmats2[19][5];
4180
 
            new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6] + coeff0_10*dmats2[10][6] + coeff0_11*dmats2[11][6] + coeff0_12*dmats2[12][6] + coeff0_13*dmats2[13][6] + coeff0_14*dmats2[14][6] + coeff0_15*dmats2[15][6] + coeff0_16*dmats2[16][6] + coeff0_17*dmats2[17][6] + coeff0_18*dmats2[18][6] + coeff0_19*dmats2[19][6];
4181
 
            new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7] + coeff0_10*dmats2[10][7] + coeff0_11*dmats2[11][7] + coeff0_12*dmats2[12][7] + coeff0_13*dmats2[13][7] + coeff0_14*dmats2[14][7] + coeff0_15*dmats2[15][7] + coeff0_16*dmats2[16][7] + coeff0_17*dmats2[17][7] + coeff0_18*dmats2[18][7] + coeff0_19*dmats2[19][7];
4182
 
            new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8] + coeff0_10*dmats2[10][8] + coeff0_11*dmats2[11][8] + coeff0_12*dmats2[12][8] + coeff0_13*dmats2[13][8] + coeff0_14*dmats2[14][8] + coeff0_15*dmats2[15][8] + coeff0_16*dmats2[16][8] + coeff0_17*dmats2[17][8] + coeff0_18*dmats2[18][8] + coeff0_19*dmats2[19][8];
4183
 
            new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9] + coeff0_10*dmats2[10][9] + coeff0_11*dmats2[11][9] + coeff0_12*dmats2[12][9] + coeff0_13*dmats2[13][9] + coeff0_14*dmats2[14][9] + coeff0_15*dmats2[15][9] + coeff0_16*dmats2[16][9] + coeff0_17*dmats2[17][9] + coeff0_18*dmats2[18][9] + coeff0_19*dmats2[19][9];
4184
 
            new_coeff0_10 = coeff0_0*dmats2[0][10] + coeff0_1*dmats2[1][10] + coeff0_2*dmats2[2][10] + coeff0_3*dmats2[3][10] + coeff0_4*dmats2[4][10] + coeff0_5*dmats2[5][10] + coeff0_6*dmats2[6][10] + coeff0_7*dmats2[7][10] + coeff0_8*dmats2[8][10] + coeff0_9*dmats2[9][10] + coeff0_10*dmats2[10][10] + coeff0_11*dmats2[11][10] + coeff0_12*dmats2[12][10] + coeff0_13*dmats2[13][10] + coeff0_14*dmats2[14][10] + coeff0_15*dmats2[15][10] + coeff0_16*dmats2[16][10] + coeff0_17*dmats2[17][10] + coeff0_18*dmats2[18][10] + coeff0_19*dmats2[19][10];
4185
 
            new_coeff0_11 = coeff0_0*dmats2[0][11] + coeff0_1*dmats2[1][11] + coeff0_2*dmats2[2][11] + coeff0_3*dmats2[3][11] + coeff0_4*dmats2[4][11] + coeff0_5*dmats2[5][11] + coeff0_6*dmats2[6][11] + coeff0_7*dmats2[7][11] + coeff0_8*dmats2[8][11] + coeff0_9*dmats2[9][11] + coeff0_10*dmats2[10][11] + coeff0_11*dmats2[11][11] + coeff0_12*dmats2[12][11] + coeff0_13*dmats2[13][11] + coeff0_14*dmats2[14][11] + coeff0_15*dmats2[15][11] + coeff0_16*dmats2[16][11] + coeff0_17*dmats2[17][11] + coeff0_18*dmats2[18][11] + coeff0_19*dmats2[19][11];
4186
 
            new_coeff0_12 = coeff0_0*dmats2[0][12] + coeff0_1*dmats2[1][12] + coeff0_2*dmats2[2][12] + coeff0_3*dmats2[3][12] + coeff0_4*dmats2[4][12] + coeff0_5*dmats2[5][12] + coeff0_6*dmats2[6][12] + coeff0_7*dmats2[7][12] + coeff0_8*dmats2[8][12] + coeff0_9*dmats2[9][12] + coeff0_10*dmats2[10][12] + coeff0_11*dmats2[11][12] + coeff0_12*dmats2[12][12] + coeff0_13*dmats2[13][12] + coeff0_14*dmats2[14][12] + coeff0_15*dmats2[15][12] + coeff0_16*dmats2[16][12] + coeff0_17*dmats2[17][12] + coeff0_18*dmats2[18][12] + coeff0_19*dmats2[19][12];
4187
 
            new_coeff0_13 = coeff0_0*dmats2[0][13] + coeff0_1*dmats2[1][13] + coeff0_2*dmats2[2][13] + coeff0_3*dmats2[3][13] + coeff0_4*dmats2[4][13] + coeff0_5*dmats2[5][13] + coeff0_6*dmats2[6][13] + coeff0_7*dmats2[7][13] + coeff0_8*dmats2[8][13] + coeff0_9*dmats2[9][13] + coeff0_10*dmats2[10][13] + coeff0_11*dmats2[11][13] + coeff0_12*dmats2[12][13] + coeff0_13*dmats2[13][13] + coeff0_14*dmats2[14][13] + coeff0_15*dmats2[15][13] + coeff0_16*dmats2[16][13] + coeff0_17*dmats2[17][13] + coeff0_18*dmats2[18][13] + coeff0_19*dmats2[19][13];
4188
 
            new_coeff0_14 = coeff0_0*dmats2[0][14] + coeff0_1*dmats2[1][14] + coeff0_2*dmats2[2][14] + coeff0_3*dmats2[3][14] + coeff0_4*dmats2[4][14] + coeff0_5*dmats2[5][14] + coeff0_6*dmats2[6][14] + coeff0_7*dmats2[7][14] + coeff0_8*dmats2[8][14] + coeff0_9*dmats2[9][14] + coeff0_10*dmats2[10][14] + coeff0_11*dmats2[11][14] + coeff0_12*dmats2[12][14] + coeff0_13*dmats2[13][14] + coeff0_14*dmats2[14][14] + coeff0_15*dmats2[15][14] + coeff0_16*dmats2[16][14] + coeff0_17*dmats2[17][14] + coeff0_18*dmats2[18][14] + coeff0_19*dmats2[19][14];
4189
 
            new_coeff0_15 = coeff0_0*dmats2[0][15] + coeff0_1*dmats2[1][15] + coeff0_2*dmats2[2][15] + coeff0_3*dmats2[3][15] + coeff0_4*dmats2[4][15] + coeff0_5*dmats2[5][15] + coeff0_6*dmats2[6][15] + coeff0_7*dmats2[7][15] + coeff0_8*dmats2[8][15] + coeff0_9*dmats2[9][15] + coeff0_10*dmats2[10][15] + coeff0_11*dmats2[11][15] + coeff0_12*dmats2[12][15] + coeff0_13*dmats2[13][15] + coeff0_14*dmats2[14][15] + coeff0_15*dmats2[15][15] + coeff0_16*dmats2[16][15] + coeff0_17*dmats2[17][15] + coeff0_18*dmats2[18][15] + coeff0_19*dmats2[19][15];
4190
 
            new_coeff0_16 = coeff0_0*dmats2[0][16] + coeff0_1*dmats2[1][16] + coeff0_2*dmats2[2][16] + coeff0_3*dmats2[3][16] + coeff0_4*dmats2[4][16] + coeff0_5*dmats2[5][16] + coeff0_6*dmats2[6][16] + coeff0_7*dmats2[7][16] + coeff0_8*dmats2[8][16] + coeff0_9*dmats2[9][16] + coeff0_10*dmats2[10][16] + coeff0_11*dmats2[11][16] + coeff0_12*dmats2[12][16] + coeff0_13*dmats2[13][16] + coeff0_14*dmats2[14][16] + coeff0_15*dmats2[15][16] + coeff0_16*dmats2[16][16] + coeff0_17*dmats2[17][16] + coeff0_18*dmats2[18][16] + coeff0_19*dmats2[19][16];
4191
 
            new_coeff0_17 = coeff0_0*dmats2[0][17] + coeff0_1*dmats2[1][17] + coeff0_2*dmats2[2][17] + coeff0_3*dmats2[3][17] + coeff0_4*dmats2[4][17] + coeff0_5*dmats2[5][17] + coeff0_6*dmats2[6][17] + coeff0_7*dmats2[7][17] + coeff0_8*dmats2[8][17] + coeff0_9*dmats2[9][17] + coeff0_10*dmats2[10][17] + coeff0_11*dmats2[11][17] + coeff0_12*dmats2[12][17] + coeff0_13*dmats2[13][17] + coeff0_14*dmats2[14][17] + coeff0_15*dmats2[15][17] + coeff0_16*dmats2[16][17] + coeff0_17*dmats2[17][17] + coeff0_18*dmats2[18][17] + coeff0_19*dmats2[19][17];
4192
 
            new_coeff0_18 = coeff0_0*dmats2[0][18] + coeff0_1*dmats2[1][18] + coeff0_2*dmats2[2][18] + coeff0_3*dmats2[3][18] + coeff0_4*dmats2[4][18] + coeff0_5*dmats2[5][18] + coeff0_6*dmats2[6][18] + coeff0_7*dmats2[7][18] + coeff0_8*dmats2[8][18] + coeff0_9*dmats2[9][18] + coeff0_10*dmats2[10][18] + coeff0_11*dmats2[11][18] + coeff0_12*dmats2[12][18] + coeff0_13*dmats2[13][18] + coeff0_14*dmats2[14][18] + coeff0_15*dmats2[15][18] + coeff0_16*dmats2[16][18] + coeff0_17*dmats2[17][18] + coeff0_18*dmats2[18][18] + coeff0_19*dmats2[19][18];
4193
 
            new_coeff0_19 = coeff0_0*dmats2[0][19] + coeff0_1*dmats2[1][19] + coeff0_2*dmats2[2][19] + coeff0_3*dmats2[3][19] + coeff0_4*dmats2[4][19] + coeff0_5*dmats2[5][19] + coeff0_6*dmats2[6][19] + coeff0_7*dmats2[7][19] + coeff0_8*dmats2[8][19] + coeff0_9*dmats2[9][19] + coeff0_10*dmats2[10][19] + coeff0_11*dmats2[11][19] + coeff0_12*dmats2[12][19] + coeff0_13*dmats2[13][19] + coeff0_14*dmats2[14][19] + coeff0_15*dmats2[15][19] + coeff0_16*dmats2[16][19] + coeff0_17*dmats2[17][19] + coeff0_18*dmats2[18][19] + coeff0_19*dmats2[19][19];
4194
 
          }
4195
 
    
4196
 
        }
4197
 
        // Compute derivatives on reference element as dot product of coefficients and basisvalues
4198
 
        derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9 + new_coeff0_10*basisvalue10 + new_coeff0_11*basisvalue11 + new_coeff0_12*basisvalue12 + new_coeff0_13*basisvalue13 + new_coeff0_14*basisvalue14 + new_coeff0_15*basisvalue15 + new_coeff0_16*basisvalue16 + new_coeff0_17*basisvalue17 + new_coeff0_18*basisvalue18 + new_coeff0_19*basisvalue19;
4199
 
      }
4200
 
    
4201
 
      // Transform derivatives back to physical element
4202
 
      for (unsigned int row = 0; row < num_derivatives; row++)
4203
 
      {
4204
 
        for (unsigned int col = 0; col < num_derivatives; col++)
4205
 
        {
4206
 
          values[2*num_derivatives + row] += transform[row][col]*derivatives[col];
4207
 
        }
4208
 
      }
4209
 
      // Delete pointer to array of derivatives on FIAT element
4210
 
      delete [] derivatives;
4211
 
    
4212
 
      // Delete pointer to array of combinations of derivatives and transform
4213
 
      for (unsigned int row = 0; row < num_derivatives; row++)
4214
 
      {
4215
 
        delete [] combinations[row];
4216
 
        delete [] transform[row];
4217
 
      }
4218
 
    
4219
 
      delete [] combinations;
4220
 
      delete [] transform;
4221
 
    }
4222
 
    
4223
 
  }
4224
 
 
4225
 
  /// Evaluate order n derivatives of all basis functions at given point in cell
4226
 
  virtual void evaluate_basis_derivatives_all(unsigned int n,
4227
 
                                              double* values,
4228
 
                                              const double* coordinates,
4229
 
                                              const ufc::cell& c) const
4230
 
  {
4231
 
    throw std::runtime_error("The vectorised version of evaluate_basis_derivatives() is not yet implemented.");
4232
 
  }
4233
 
 
4234
 
  /// Evaluate linear functional for dof i on the function f
4235
 
  virtual double evaluate_dof(unsigned int i,
4236
 
                              const ufc::function& f,
4237
 
                              const ufc::cell& c) const
4238
 
  {
4239
 
    // The reference points, direction and weights:
4240
 
    const static double X[60][1][3] = {{{0, 0, 0}}, {{0.333333333333333, 0, 0}}, {{0.666666666666667, 0, 0}}, {{1, 0, 0}}, {{0, 0.333333333333333, 0}}, {{0.333333333333333, 0.333333333333333, 0}}, {{0.666666666666667, 0.333333333333333, 0}}, {{0, 0.666666666666667, 0}}, {{0.333333333333333, 0.666666666666667, 0}}, {{0, 1, 0}}, {{0, 0, 0.333333333333333}}, {{0.333333333333333, 0, 0.333333333333333}}, {{0.666666666666667, 0, 0.333333333333333}}, {{0, 0.333333333333333, 0.333333333333333}}, {{0.333333333333333, 0.333333333333333, 0.333333333333333}}, {{0, 0.666666666666667, 0.333333333333333}}, {{0, 0, 0.666666666666667}}, {{0.333333333333333, 0, 0.666666666666667}}, {{0, 0.333333333333333, 0.666666666666667}}, {{0, 0, 1}}, {{0, 0, 0}}, {{0.333333333333333, 0, 0}}, {{0.666666666666667, 0, 0}}, {{1, 0, 0}}, {{0, 0.333333333333333, 0}}, {{0.333333333333333, 0.333333333333333, 0}}, {{0.666666666666667, 0.333333333333333, 0}}, {{0, 0.666666666666667, 0}}, {{0.333333333333333, 0.666666666666667, 0}}, {{0, 1, 0}}, {{0, 0, 0.333333333333333}}, {{0.333333333333333, 0, 0.333333333333333}}, {{0.666666666666667, 0, 0.333333333333333}}, {{0, 0.333333333333333, 0.333333333333333}}, {{0.333333333333333, 0.333333333333333, 0.333333333333333}}, {{0, 0.666666666666667, 0.333333333333333}}, {{0, 0, 0.666666666666667}}, {{0.333333333333333, 0, 0.666666666666667}}, {{0, 0.333333333333333, 0.666666666666667}}, {{0, 0, 1}}, {{0, 0, 0}}, {{0.333333333333333, 0, 0}}, {{0.666666666666667, 0, 0}}, {{1, 0, 0}}, {{0, 0.333333333333333, 0}}, {{0.333333333333333, 0.333333333333333, 0}}, {{0.666666666666667, 0.333333333333333, 0}}, {{0, 0.666666666666667, 0}}, {{0.333333333333333, 0.666666666666667, 0}}, {{0, 1, 0}}, {{0, 0, 0.333333333333333}}, {{0.333333333333333, 0, 0.333333333333333}}, {{0.666666666666667, 0, 0.333333333333333}}, {{0, 0.333333333333333, 0.333333333333333}}, {{0.333333333333333, 0.333333333333333, 0.333333333333333}}, {{0, 0.666666666666667, 0.333333333333333}}, {{0, 0, 0.666666666666667}}, {{0.333333333333333, 0, 0.666666666666667}}, {{0, 0.333333333333333, 0.666666666666667}}, {{0, 0, 1}}};
4241
 
    const static double W[60][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
4242
 
    const static double D[60][1][3] = {{{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}};
4243
 
    
4244
 
    const double * const * x = c.coordinates;
4245
 
    double result = 0.0;
4246
 
    // Iterate over the points:
4247
 
    // Evaluate basis functions for affine mapping
4248
 
    const double w0 = 1.0 - X[i][0][0] - X[i][0][1] - X[i][0][2];
4249
 
    const double w1 = X[i][0][0];
4250
 
    const double w2 = X[i][0][1];
4251
 
    const double w3 = X[i][0][2];
4252
 
    
4253
 
    // Compute affine mapping y = F(X)
4254
 
    double y[3];
4255
 
    y[0] = w0*x[0][0] + w1*x[1][0] + w2*x[2][0] + w3*x[3][0];
4256
 
    y[1] = w0*x[0][1] + w1*x[1][1] + w2*x[2][1] + w3*x[3][1];
4257
 
    y[2] = w0*x[0][2] + w1*x[1][2] + w2*x[2][2] + w3*x[3][2];
4258
 
    
4259
 
    // Evaluate function at physical points
4260
 
    double values[3];
4261
 
    f.evaluate(values, y, c);
4262
 
    
4263
 
    // Map function values using appropriate mapping
4264
 
    // Affine map: Do nothing
4265
 
    
4266
 
    // Note that we do not map the weights (yet).
4267
 
    
4268
 
    // Take directional components
4269
 
    for(int k = 0; k < 3; k++)
4270
 
      result += values[k]*D[i][0][k];
4271
 
    // Multiply by weights 
4272
 
    result *= W[i][0];
4273
 
    
4274
 
    return result;
4275
 
  }
4276
 
 
4277
 
  /// Evaluate linear functionals for all dofs on the function f
4278
 
  virtual void evaluate_dofs(double* values,
4279
 
                             const ufc::function& f,
4280
 
                             const ufc::cell& c) const
4281
 
  {
4282
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4283
 
  }
4284
 
 
4285
 
  /// Interpolate vertex values from dof values
4286
 
  virtual void interpolate_vertex_values(double* vertex_values,
4287
 
                                         const double* dof_values,
4288
 
                                         const ufc::cell& c) const
4289
 
  {
4290
 
    // Evaluate at vertices and use affine mapping
4291
 
    vertex_values[0] = dof_values[0];
4292
 
    vertex_values[1] = dof_values[3];
4293
 
    vertex_values[2] = dof_values[9];
4294
 
    vertex_values[3] = dof_values[19];
4295
 
    // Evaluate at vertices and use affine mapping
4296
 
    vertex_values[4] = dof_values[20];
4297
 
    vertex_values[5] = dof_values[23];
4298
 
    vertex_values[6] = dof_values[29];
4299
 
    vertex_values[7] = dof_values[39];
4300
 
    // Evaluate at vertices and use affine mapping
4301
 
    vertex_values[8] = dof_values[40];
4302
 
    vertex_values[9] = dof_values[43];
4303
 
    vertex_values[10] = dof_values[49];
4304
 
    vertex_values[11] = dof_values[59];
4305
 
  }
4306
 
 
4307
 
  /// Return the number of sub elements (for a mixed element)
4308
 
  virtual unsigned int num_sub_elements() const
4309
 
  {
4310
 
    return 3;
4311
 
  }
4312
 
 
4313
 
  /// Create a new finite element for sub element i (for a mixed element)
4314
 
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
4315
 
  {
4316
 
    switch ( i )
4317
 
    {
4318
 
    case 0:
4319
 
      return new ffc_25_finite_element_0_0();
4320
 
      break;
4321
 
    case 1:
4322
 
      return new ffc_25_finite_element_0_1();
4323
 
      break;
4324
 
    case 2:
4325
 
      return new ffc_25_finite_element_0_2();
4326
 
      break;
4327
 
    }
4328
 
    return 0;
4329
 
  }
4330
 
 
4331
 
};
4332
 
 
4333
 
/// This class defines the interface for a local-to-global mapping of
4334
 
/// degrees of freedom (dofs).
4335
 
 
4336
 
class ffc_25_dof_map_0_0: public ufc::dof_map
4337
 
{
4338
 
private:
4339
 
 
4340
 
  unsigned int __global_dimension;
4341
 
 
4342
 
public:
4343
 
 
4344
 
  /// Constructor
4345
 
  ffc_25_dof_map_0_0() : ufc::dof_map()
4346
 
  {
4347
 
    __global_dimension = 0;
4348
 
  }
4349
 
 
4350
 
  /// Destructor
4351
 
  virtual ~ffc_25_dof_map_0_0()
4352
 
  {
4353
 
    // Do nothing
4354
 
  }
4355
 
 
4356
 
  /// Return a string identifying the dof map
4357
 
  virtual const char* signature() const
4358
 
  {
4359
 
    return "FFC dof map for Discontinuous Lagrange finite element of degree 3 on a tetrahedron";
4360
 
  }
4361
 
 
4362
 
  /// Return true iff mesh entities of topological dimension d are needed
4363
 
  virtual bool needs_mesh_entities(unsigned int d) const
4364
 
  {
4365
 
    switch ( d )
4366
 
    {
4367
 
    case 0:
4368
 
      return false;
4369
 
      break;
4370
 
    case 1:
4371
 
      return false;
4372
 
      break;
4373
 
    case 2:
4374
 
      return false;
4375
 
      break;
4376
 
    case 3:
4377
 
      return true;
4378
 
      break;
4379
 
    }
4380
 
    return false;
4381
 
  }
4382
 
 
4383
 
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
4384
 
  virtual bool init_mesh(const ufc::mesh& m)
4385
 
  {
4386
 
    __global_dimension = 20*m.num_entities[3];
4387
 
    return false;
4388
 
  }
4389
 
 
4390
 
  /// Initialize dof map for given cell
4391
 
  virtual void init_cell(const ufc::mesh& m,
4392
 
                         const ufc::cell& c)
4393
 
  {
4394
 
    // Do nothing
4395
 
  }
4396
 
 
4397
 
  /// Finish initialization of dof map for cells
4398
 
  virtual void init_cell_finalize()
4399
 
  {
4400
 
    // Do nothing
4401
 
  }
4402
 
 
4403
 
  /// Return the dimension of the global finite element function space
4404
 
  virtual unsigned int global_dimension() const
4405
 
  {
4406
 
    return __global_dimension;
4407
 
  }
4408
 
 
4409
 
  /// Return the dimension of the local finite element function space
4410
 
  virtual unsigned int local_dimension() const
4411
 
  {
4412
 
    return 20;
4413
 
  }
4414
 
 
4415
 
  // Return the geometric dimension of the coordinates this dof map provides
4416
 
  virtual unsigned int geometric_dimension() const
4417
 
  {
4418
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4419
 
  }
4420
 
 
4421
 
  /// Return the number of dofs on each cell facet
4422
 
  virtual unsigned int num_facet_dofs() const
4423
 
  {
4424
 
    return 0;
4425
 
  }
4426
 
 
4427
 
  /// Return the number of dofs associated with each cell entity of dimension d
4428
 
  virtual unsigned int num_entity_dofs(unsigned int d) const
4429
 
  {
4430
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4431
 
  }
4432
 
 
4433
 
  /// Tabulate the local-to-global mapping of dofs on a cell
4434
 
  virtual void tabulate_dofs(unsigned int* dofs,
4435
 
                             const ufc::mesh& m,
4436
 
                             const ufc::cell& c) const
4437
 
  {
4438
 
    dofs[0] = 20*c.entity_indices[3][0];
4439
 
    dofs[1] = 20*c.entity_indices[3][0] + 1;
4440
 
    dofs[2] = 20*c.entity_indices[3][0] + 2;
4441
 
    dofs[3] = 20*c.entity_indices[3][0] + 3;
4442
 
    dofs[4] = 20*c.entity_indices[3][0] + 4;
4443
 
    dofs[5] = 20*c.entity_indices[3][0] + 5;
4444
 
    dofs[6] = 20*c.entity_indices[3][0] + 6;
4445
 
    dofs[7] = 20*c.entity_indices[3][0] + 7;
4446
 
    dofs[8] = 20*c.entity_indices[3][0] + 8;
4447
 
    dofs[9] = 20*c.entity_indices[3][0] + 9;
4448
 
    dofs[10] = 20*c.entity_indices[3][0] + 10;
4449
 
    dofs[11] = 20*c.entity_indices[3][0] + 11;
4450
 
    dofs[12] = 20*c.entity_indices[3][0] + 12;
4451
 
    dofs[13] = 20*c.entity_indices[3][0] + 13;
4452
 
    dofs[14] = 20*c.entity_indices[3][0] + 14;
4453
 
    dofs[15] = 20*c.entity_indices[3][0] + 15;
4454
 
    dofs[16] = 20*c.entity_indices[3][0] + 16;
4455
 
    dofs[17] = 20*c.entity_indices[3][0] + 17;
4456
 
    dofs[18] = 20*c.entity_indices[3][0] + 18;
4457
 
    dofs[19] = 20*c.entity_indices[3][0] + 19;
4458
 
  }
4459
 
 
4460
 
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
4461
 
  virtual void tabulate_facet_dofs(unsigned int* dofs,
4462
 
                                   unsigned int facet) const
4463
 
  {
4464
 
    switch ( facet )
4465
 
    {
4466
 
    case 0:
4467
 
      
4468
 
      break;
4469
 
    case 1:
4470
 
      
4471
 
      break;
4472
 
    case 2:
4473
 
      
4474
 
      break;
4475
 
    case 3:
4476
 
      
4477
 
      break;
4478
 
    }
4479
 
  }
4480
 
 
4481
 
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
4482
 
  virtual void tabulate_entity_dofs(unsigned int* dofs,
4483
 
                                    unsigned int d, unsigned int i) const
4484
 
  {
4485
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4486
 
  }
4487
 
 
4488
 
  /// Tabulate the coordinates of all dofs on a cell
4489
 
  virtual void tabulate_coordinates(double** coordinates,
4490
 
                                    const ufc::cell& c) const
4491
 
  {
4492
 
    const double * const * x = c.coordinates;
4493
 
    coordinates[0][0] = x[0][0];
4494
 
    coordinates[0][1] = x[0][1];
4495
 
    coordinates[0][2] = x[0][2];
4496
 
    coordinates[1][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[1][0];
4497
 
    coordinates[1][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[1][1];
4498
 
    coordinates[1][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[1][2];
4499
 
    coordinates[2][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[1][0];
4500
 
    coordinates[2][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[1][1];
4501
 
    coordinates[2][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[1][2];
4502
 
    coordinates[3][0] = x[1][0];
4503
 
    coordinates[3][1] = x[1][1];
4504
 
    coordinates[3][2] = x[1][2];
4505
 
    coordinates[4][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[2][0];
4506
 
    coordinates[4][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[2][1];
4507
 
    coordinates[4][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[2][2];
4508
 
    coordinates[5][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
4509
 
    coordinates[5][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
4510
 
    coordinates[5][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2];
4511
 
    coordinates[6][0] = 0.666666666666666*x[1][0] + 0.333333333333333*x[2][0];
4512
 
    coordinates[6][1] = 0.666666666666666*x[1][1] + 0.333333333333333*x[2][1];
4513
 
    coordinates[6][2] = 0.666666666666666*x[1][2] + 0.333333333333333*x[2][2];
4514
 
    coordinates[7][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[2][0];
4515
 
    coordinates[7][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[2][1];
4516
 
    coordinates[7][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[2][2];
4517
 
    coordinates[8][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[2][0];
4518
 
    coordinates[8][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[2][1];
4519
 
    coordinates[8][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[2][2];
4520
 
    coordinates[9][0] = x[2][0];
4521
 
    coordinates[9][1] = x[2][1];
4522
 
    coordinates[9][2] = x[2][2];
4523
 
    coordinates[10][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[3][0];
4524
 
    coordinates[10][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[3][1];
4525
 
    coordinates[10][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[3][2];
4526
 
    coordinates[11][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[3][0];
4527
 
    coordinates[11][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[3][1];
4528
 
    coordinates[11][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[3][2];
4529
 
    coordinates[12][0] = 0.666666666666667*x[1][0] + 0.333333333333333*x[3][0];
4530
 
    coordinates[12][1] = 0.666666666666667*x[1][1] + 0.333333333333333*x[3][1];
4531
 
    coordinates[12][2] = 0.666666666666667*x[1][2] + 0.333333333333333*x[3][2];
4532
 
    coordinates[13][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
4533
 
    coordinates[13][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
4534
 
    coordinates[13][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
4535
 
    coordinates[14][0] = 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
4536
 
    coordinates[14][1] = 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
4537
 
    coordinates[14][2] = 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
4538
 
    coordinates[15][0] = 0.666666666666667*x[2][0] + 0.333333333333333*x[3][0];
4539
 
    coordinates[15][1] = 0.666666666666667*x[2][1] + 0.333333333333333*x[3][1];
4540
 
    coordinates[15][2] = 0.666666666666667*x[2][2] + 0.333333333333333*x[3][2];
4541
 
    coordinates[16][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[3][0];
4542
 
    coordinates[16][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[3][1];
4543
 
    coordinates[16][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[3][2];
4544
 
    coordinates[17][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[3][0];
4545
 
    coordinates[17][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[3][1];
4546
 
    coordinates[17][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[3][2];
4547
 
    coordinates[18][0] = 0.333333333333333*x[2][0] + 0.666666666666667*x[3][0];
4548
 
    coordinates[18][1] = 0.333333333333333*x[2][1] + 0.666666666666667*x[3][1];
4549
 
    coordinates[18][2] = 0.333333333333333*x[2][2] + 0.666666666666667*x[3][2];
4550
 
    coordinates[19][0] = x[3][0];
4551
 
    coordinates[19][1] = x[3][1];
4552
 
    coordinates[19][2] = x[3][2];
4553
 
  }
4554
 
 
4555
 
  /// Return the number of sub dof maps (for a mixed element)
4556
 
  virtual unsigned int num_sub_dof_maps() const
4557
 
  {
4558
 
    return 1;
4559
 
  }
4560
 
 
4561
 
  /// Create a new dof_map for sub dof map i (for a mixed element)
4562
 
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
4563
 
  {
4564
 
    return new ffc_25_dof_map_0_0();
4565
 
  }
4566
 
 
4567
 
};
4568
 
 
4569
 
/// This class defines the interface for a local-to-global mapping of
4570
 
/// degrees of freedom (dofs).
4571
 
 
4572
 
class ffc_25_dof_map_0_1: public ufc::dof_map
4573
 
{
4574
 
private:
4575
 
 
4576
 
  unsigned int __global_dimension;
4577
 
 
4578
 
public:
4579
 
 
4580
 
  /// Constructor
4581
 
  ffc_25_dof_map_0_1() : ufc::dof_map()
4582
 
  {
4583
 
    __global_dimension = 0;
4584
 
  }
4585
 
 
4586
 
  /// Destructor
4587
 
  virtual ~ffc_25_dof_map_0_1()
4588
 
  {
4589
 
    // Do nothing
4590
 
  }
4591
 
 
4592
 
  /// Return a string identifying the dof map
4593
 
  virtual const char* signature() const
4594
 
  {
4595
 
    return "FFC dof map for Discontinuous Lagrange finite element of degree 3 on a tetrahedron";
4596
 
  }
4597
 
 
4598
 
  /// Return true iff mesh entities of topological dimension d are needed
4599
 
  virtual bool needs_mesh_entities(unsigned int d) const
4600
 
  {
4601
 
    switch ( d )
4602
 
    {
4603
 
    case 0:
4604
 
      return false;
4605
 
      break;
4606
 
    case 1:
4607
 
      return false;
4608
 
      break;
4609
 
    case 2:
4610
 
      return false;
4611
 
      break;
4612
 
    case 3:
4613
 
      return true;
4614
 
      break;
4615
 
    }
4616
 
    return false;
4617
 
  }
4618
 
 
4619
 
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
4620
 
  virtual bool init_mesh(const ufc::mesh& m)
4621
 
  {
4622
 
    __global_dimension = 20*m.num_entities[3];
4623
 
    return false;
4624
 
  }
4625
 
 
4626
 
  /// Initialize dof map for given cell
4627
 
  virtual void init_cell(const ufc::mesh& m,
4628
 
                         const ufc::cell& c)
4629
 
  {
4630
 
    // Do nothing
4631
 
  }
4632
 
 
4633
 
  /// Finish initialization of dof map for cells
4634
 
  virtual void init_cell_finalize()
4635
 
  {
4636
 
    // Do nothing
4637
 
  }
4638
 
 
4639
 
  /// Return the dimension of the global finite element function space
4640
 
  virtual unsigned int global_dimension() const
4641
 
  {
4642
 
    return __global_dimension;
4643
 
  }
4644
 
 
4645
 
  /// Return the dimension of the local finite element function space
4646
 
  virtual unsigned int local_dimension() const
4647
 
  {
4648
 
    return 20;
4649
 
  }
4650
 
 
4651
 
  // Return the geometric dimension of the coordinates this dof map provides
4652
 
  virtual unsigned int geometric_dimension() const
4653
 
  {
4654
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4655
 
  }
4656
 
 
4657
 
  /// Return the number of dofs on each cell facet
4658
 
  virtual unsigned int num_facet_dofs() const
4659
 
  {
4660
 
    return 0;
4661
 
  }
4662
 
 
4663
 
  /// Return the number of dofs associated with each cell entity of dimension d
4664
 
  virtual unsigned int num_entity_dofs(unsigned int d) const
4665
 
  {
4666
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4667
 
  }
4668
 
 
4669
 
  /// Tabulate the local-to-global mapping of dofs on a cell
4670
 
  virtual void tabulate_dofs(unsigned int* dofs,
4671
 
                             const ufc::mesh& m,
4672
 
                             const ufc::cell& c) const
4673
 
  {
4674
 
    dofs[0] = 20*c.entity_indices[3][0];
4675
 
    dofs[1] = 20*c.entity_indices[3][0] + 1;
4676
 
    dofs[2] = 20*c.entity_indices[3][0] + 2;
4677
 
    dofs[3] = 20*c.entity_indices[3][0] + 3;
4678
 
    dofs[4] = 20*c.entity_indices[3][0] + 4;
4679
 
    dofs[5] = 20*c.entity_indices[3][0] + 5;
4680
 
    dofs[6] = 20*c.entity_indices[3][0] + 6;
4681
 
    dofs[7] = 20*c.entity_indices[3][0] + 7;
4682
 
    dofs[8] = 20*c.entity_indices[3][0] + 8;
4683
 
    dofs[9] = 20*c.entity_indices[3][0] + 9;
4684
 
    dofs[10] = 20*c.entity_indices[3][0] + 10;
4685
 
    dofs[11] = 20*c.entity_indices[3][0] + 11;
4686
 
    dofs[12] = 20*c.entity_indices[3][0] + 12;
4687
 
    dofs[13] = 20*c.entity_indices[3][0] + 13;
4688
 
    dofs[14] = 20*c.entity_indices[3][0] + 14;
4689
 
    dofs[15] = 20*c.entity_indices[3][0] + 15;
4690
 
    dofs[16] = 20*c.entity_indices[3][0] + 16;
4691
 
    dofs[17] = 20*c.entity_indices[3][0] + 17;
4692
 
    dofs[18] = 20*c.entity_indices[3][0] + 18;
4693
 
    dofs[19] = 20*c.entity_indices[3][0] + 19;
4694
 
  }
4695
 
 
4696
 
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
4697
 
  virtual void tabulate_facet_dofs(unsigned int* dofs,
4698
 
                                   unsigned int facet) const
4699
 
  {
4700
 
    switch ( facet )
4701
 
    {
4702
 
    case 0:
4703
 
      
4704
 
      break;
4705
 
    case 1:
4706
 
      
4707
 
      break;
4708
 
    case 2:
4709
 
      
4710
 
      break;
4711
 
    case 3:
4712
 
      
4713
 
      break;
4714
 
    }
4715
 
  }
4716
 
 
4717
 
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
4718
 
  virtual void tabulate_entity_dofs(unsigned int* dofs,
4719
 
                                    unsigned int d, unsigned int i) const
4720
 
  {
4721
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4722
 
  }
4723
 
 
4724
 
  /// Tabulate the coordinates of all dofs on a cell
4725
 
  virtual void tabulate_coordinates(double** coordinates,
4726
 
                                    const ufc::cell& c) const
4727
 
  {
4728
 
    const double * const * x = c.coordinates;
4729
 
    coordinates[0][0] = x[0][0];
4730
 
    coordinates[0][1] = x[0][1];
4731
 
    coordinates[0][2] = x[0][2];
4732
 
    coordinates[1][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[1][0];
4733
 
    coordinates[1][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[1][1];
4734
 
    coordinates[1][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[1][2];
4735
 
    coordinates[2][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[1][0];
4736
 
    coordinates[2][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[1][1];
4737
 
    coordinates[2][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[1][2];
4738
 
    coordinates[3][0] = x[1][0];
4739
 
    coordinates[3][1] = x[1][1];
4740
 
    coordinates[3][2] = x[1][2];
4741
 
    coordinates[4][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[2][0];
4742
 
    coordinates[4][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[2][1];
4743
 
    coordinates[4][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[2][2];
4744
 
    coordinates[5][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
4745
 
    coordinates[5][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
4746
 
    coordinates[5][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2];
4747
 
    coordinates[6][0] = 0.666666666666666*x[1][0] + 0.333333333333333*x[2][0];
4748
 
    coordinates[6][1] = 0.666666666666666*x[1][1] + 0.333333333333333*x[2][1];
4749
 
    coordinates[6][2] = 0.666666666666666*x[1][2] + 0.333333333333333*x[2][2];
4750
 
    coordinates[7][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[2][0];
4751
 
    coordinates[7][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[2][1];
4752
 
    coordinates[7][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[2][2];
4753
 
    coordinates[8][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[2][0];
4754
 
    coordinates[8][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[2][1];
4755
 
    coordinates[8][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[2][2];
4756
 
    coordinates[9][0] = x[2][0];
4757
 
    coordinates[9][1] = x[2][1];
4758
 
    coordinates[9][2] = x[2][2];
4759
 
    coordinates[10][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[3][0];
4760
 
    coordinates[10][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[3][1];
4761
 
    coordinates[10][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[3][2];
4762
 
    coordinates[11][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[3][0];
4763
 
    coordinates[11][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[3][1];
4764
 
    coordinates[11][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[3][2];
4765
 
    coordinates[12][0] = 0.666666666666667*x[1][0] + 0.333333333333333*x[3][0];
4766
 
    coordinates[12][1] = 0.666666666666667*x[1][1] + 0.333333333333333*x[3][1];
4767
 
    coordinates[12][2] = 0.666666666666667*x[1][2] + 0.333333333333333*x[3][2];
4768
 
    coordinates[13][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
4769
 
    coordinates[13][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
4770
 
    coordinates[13][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
4771
 
    coordinates[14][0] = 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
4772
 
    coordinates[14][1] = 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
4773
 
    coordinates[14][2] = 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
4774
 
    coordinates[15][0] = 0.666666666666667*x[2][0] + 0.333333333333333*x[3][0];
4775
 
    coordinates[15][1] = 0.666666666666667*x[2][1] + 0.333333333333333*x[3][1];
4776
 
    coordinates[15][2] = 0.666666666666667*x[2][2] + 0.333333333333333*x[3][2];
4777
 
    coordinates[16][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[3][0];
4778
 
    coordinates[16][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[3][1];
4779
 
    coordinates[16][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[3][2];
4780
 
    coordinates[17][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[3][0];
4781
 
    coordinates[17][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[3][1];
4782
 
    coordinates[17][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[3][2];
4783
 
    coordinates[18][0] = 0.333333333333333*x[2][0] + 0.666666666666667*x[3][0];
4784
 
    coordinates[18][1] = 0.333333333333333*x[2][1] + 0.666666666666667*x[3][1];
4785
 
    coordinates[18][2] = 0.333333333333333*x[2][2] + 0.666666666666667*x[3][2];
4786
 
    coordinates[19][0] = x[3][0];
4787
 
    coordinates[19][1] = x[3][1];
4788
 
    coordinates[19][2] = x[3][2];
4789
 
  }
4790
 
 
4791
 
  /// Return the number of sub dof maps (for a mixed element)
4792
 
  virtual unsigned int num_sub_dof_maps() const
4793
 
  {
4794
 
    return 1;
4795
 
  }
4796
 
 
4797
 
  /// Create a new dof_map for sub dof map i (for a mixed element)
4798
 
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
4799
 
  {
4800
 
    return new ffc_25_dof_map_0_1();
4801
 
  }
4802
 
 
4803
 
};
4804
 
 
4805
 
/// This class defines the interface for a local-to-global mapping of
4806
 
/// degrees of freedom (dofs).
4807
 
 
4808
 
class ffc_25_dof_map_0_2: public ufc::dof_map
4809
 
{
4810
 
private:
4811
 
 
4812
 
  unsigned int __global_dimension;
4813
 
 
4814
 
public:
4815
 
 
4816
 
  /// Constructor
4817
 
  ffc_25_dof_map_0_2() : ufc::dof_map()
4818
 
  {
4819
 
    __global_dimension = 0;
4820
 
  }
4821
 
 
4822
 
  /// Destructor
4823
 
  virtual ~ffc_25_dof_map_0_2()
4824
 
  {
4825
 
    // Do nothing
4826
 
  }
4827
 
 
4828
 
  /// Return a string identifying the dof map
4829
 
  virtual const char* signature() const
4830
 
  {
4831
 
    return "FFC dof map for Discontinuous Lagrange finite element of degree 3 on a tetrahedron";
4832
 
  }
4833
 
 
4834
 
  /// Return true iff mesh entities of topological dimension d are needed
4835
 
  virtual bool needs_mesh_entities(unsigned int d) const
4836
 
  {
4837
 
    switch ( d )
4838
 
    {
4839
 
    case 0:
4840
 
      return false;
4841
 
      break;
4842
 
    case 1:
4843
 
      return false;
4844
 
      break;
4845
 
    case 2:
4846
 
      return false;
4847
 
      break;
4848
 
    case 3:
4849
 
      return true;
4850
 
      break;
4851
 
    }
4852
 
    return false;
4853
 
  }
4854
 
 
4855
 
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
4856
 
  virtual bool init_mesh(const ufc::mesh& m)
4857
 
  {
4858
 
    __global_dimension = 20*m.num_entities[3];
4859
 
    return false;
4860
 
  }
4861
 
 
4862
 
  /// Initialize dof map for given cell
4863
 
  virtual void init_cell(const ufc::mesh& m,
4864
 
                         const ufc::cell& c)
4865
 
  {
4866
 
    // Do nothing
4867
 
  }
4868
 
 
4869
 
  /// Finish initialization of dof map for cells
4870
 
  virtual void init_cell_finalize()
4871
 
  {
4872
 
    // Do nothing
4873
 
  }
4874
 
 
4875
 
  /// Return the dimension of the global finite element function space
4876
 
  virtual unsigned int global_dimension() const
4877
 
  {
4878
 
    return __global_dimension;
4879
 
  }
4880
 
 
4881
 
  /// Return the dimension of the local finite element function space
4882
 
  virtual unsigned int local_dimension() const
4883
 
  {
4884
 
    return 20;
4885
 
  }
4886
 
 
4887
 
  // Return the geometric dimension of the coordinates this dof map provides
4888
 
  virtual unsigned int geometric_dimension() const
4889
 
  {
4890
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4891
 
  }
4892
 
 
4893
 
  /// Return the number of dofs on each cell facet
4894
 
  virtual unsigned int num_facet_dofs() const
4895
 
  {
4896
 
    return 0;
4897
 
  }
4898
 
 
4899
 
  /// Return the number of dofs associated with each cell entity of dimension d
4900
 
  virtual unsigned int num_entity_dofs(unsigned int d) const
4901
 
  {
4902
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4903
 
  }
4904
 
 
4905
 
  /// Tabulate the local-to-global mapping of dofs on a cell
4906
 
  virtual void tabulate_dofs(unsigned int* dofs,
4907
 
                             const ufc::mesh& m,
4908
 
                             const ufc::cell& c) const
4909
 
  {
4910
 
    dofs[0] = 20*c.entity_indices[3][0];
4911
 
    dofs[1] = 20*c.entity_indices[3][0] + 1;
4912
 
    dofs[2] = 20*c.entity_indices[3][0] + 2;
4913
 
    dofs[3] = 20*c.entity_indices[3][0] + 3;
4914
 
    dofs[4] = 20*c.entity_indices[3][0] + 4;
4915
 
    dofs[5] = 20*c.entity_indices[3][0] + 5;
4916
 
    dofs[6] = 20*c.entity_indices[3][0] + 6;
4917
 
    dofs[7] = 20*c.entity_indices[3][0] + 7;
4918
 
    dofs[8] = 20*c.entity_indices[3][0] + 8;
4919
 
    dofs[9] = 20*c.entity_indices[3][0] + 9;
4920
 
    dofs[10] = 20*c.entity_indices[3][0] + 10;
4921
 
    dofs[11] = 20*c.entity_indices[3][0] + 11;
4922
 
    dofs[12] = 20*c.entity_indices[3][0] + 12;
4923
 
    dofs[13] = 20*c.entity_indices[3][0] + 13;
4924
 
    dofs[14] = 20*c.entity_indices[3][0] + 14;
4925
 
    dofs[15] = 20*c.entity_indices[3][0] + 15;
4926
 
    dofs[16] = 20*c.entity_indices[3][0] + 16;
4927
 
    dofs[17] = 20*c.entity_indices[3][0] + 17;
4928
 
    dofs[18] = 20*c.entity_indices[3][0] + 18;
4929
 
    dofs[19] = 20*c.entity_indices[3][0] + 19;
4930
 
  }
4931
 
 
4932
 
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
4933
 
  virtual void tabulate_facet_dofs(unsigned int* dofs,
4934
 
                                   unsigned int facet) const
4935
 
  {
4936
 
    switch ( facet )
4937
 
    {
4938
 
    case 0:
4939
 
      
4940
 
      break;
4941
 
    case 1:
4942
 
      
4943
 
      break;
4944
 
    case 2:
4945
 
      
4946
 
      break;
4947
 
    case 3:
4948
 
      
4949
 
      break;
4950
 
    }
4951
 
  }
4952
 
 
4953
 
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
4954
 
  virtual void tabulate_entity_dofs(unsigned int* dofs,
4955
 
                                    unsigned int d, unsigned int i) const
4956
 
  {
4957
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
4958
 
  }
4959
 
 
4960
 
  /// Tabulate the coordinates of all dofs on a cell
4961
 
  virtual void tabulate_coordinates(double** coordinates,
4962
 
                                    const ufc::cell& c) const
4963
 
  {
4964
 
    const double * const * x = c.coordinates;
4965
 
    coordinates[0][0] = x[0][0];
4966
 
    coordinates[0][1] = x[0][1];
4967
 
    coordinates[0][2] = x[0][2];
4968
 
    coordinates[1][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[1][0];
4969
 
    coordinates[1][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[1][1];
4970
 
    coordinates[1][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[1][2];
4971
 
    coordinates[2][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[1][0];
4972
 
    coordinates[2][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[1][1];
4973
 
    coordinates[2][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[1][2];
4974
 
    coordinates[3][0] = x[1][0];
4975
 
    coordinates[3][1] = x[1][1];
4976
 
    coordinates[3][2] = x[1][2];
4977
 
    coordinates[4][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[2][0];
4978
 
    coordinates[4][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[2][1];
4979
 
    coordinates[4][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[2][2];
4980
 
    coordinates[5][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
4981
 
    coordinates[5][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
4982
 
    coordinates[5][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2];
4983
 
    coordinates[6][0] = 0.666666666666666*x[1][0] + 0.333333333333333*x[2][0];
4984
 
    coordinates[6][1] = 0.666666666666666*x[1][1] + 0.333333333333333*x[2][1];
4985
 
    coordinates[6][2] = 0.666666666666666*x[1][2] + 0.333333333333333*x[2][2];
4986
 
    coordinates[7][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[2][0];
4987
 
    coordinates[7][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[2][1];
4988
 
    coordinates[7][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[2][2];
4989
 
    coordinates[8][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[2][0];
4990
 
    coordinates[8][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[2][1];
4991
 
    coordinates[8][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[2][2];
4992
 
    coordinates[9][0] = x[2][0];
4993
 
    coordinates[9][1] = x[2][1];
4994
 
    coordinates[9][2] = x[2][2];
4995
 
    coordinates[10][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[3][0];
4996
 
    coordinates[10][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[3][1];
4997
 
    coordinates[10][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[3][2];
4998
 
    coordinates[11][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[3][0];
4999
 
    coordinates[11][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[3][1];
5000
 
    coordinates[11][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[3][2];
5001
 
    coordinates[12][0] = 0.666666666666667*x[1][0] + 0.333333333333333*x[3][0];
5002
 
    coordinates[12][1] = 0.666666666666667*x[1][1] + 0.333333333333333*x[3][1];
5003
 
    coordinates[12][2] = 0.666666666666667*x[1][2] + 0.333333333333333*x[3][2];
5004
 
    coordinates[13][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
5005
 
    coordinates[13][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
5006
 
    coordinates[13][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
5007
 
    coordinates[14][0] = 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
5008
 
    coordinates[14][1] = 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
5009
 
    coordinates[14][2] = 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
5010
 
    coordinates[15][0] = 0.666666666666667*x[2][0] + 0.333333333333333*x[3][0];
5011
 
    coordinates[15][1] = 0.666666666666667*x[2][1] + 0.333333333333333*x[3][1];
5012
 
    coordinates[15][2] = 0.666666666666667*x[2][2] + 0.333333333333333*x[3][2];
5013
 
    coordinates[16][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[3][0];
5014
 
    coordinates[16][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[3][1];
5015
 
    coordinates[16][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[3][2];
5016
 
    coordinates[17][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[3][0];
5017
 
    coordinates[17][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[3][1];
5018
 
    coordinates[17][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[3][2];
5019
 
    coordinates[18][0] = 0.333333333333333*x[2][0] + 0.666666666666667*x[3][0];
5020
 
    coordinates[18][1] = 0.333333333333333*x[2][1] + 0.666666666666667*x[3][1];
5021
 
    coordinates[18][2] = 0.333333333333333*x[2][2] + 0.666666666666667*x[3][2];
5022
 
    coordinates[19][0] = x[3][0];
5023
 
    coordinates[19][1] = x[3][1];
5024
 
    coordinates[19][2] = x[3][2];
5025
 
  }
5026
 
 
5027
 
  /// Return the number of sub dof maps (for a mixed element)
5028
 
  virtual unsigned int num_sub_dof_maps() const
5029
 
  {
5030
 
    return 1;
5031
 
  }
5032
 
 
5033
 
  /// Create a new dof_map for sub dof map i (for a mixed element)
5034
 
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
5035
 
  {
5036
 
    return new ffc_25_dof_map_0_2();
5037
 
  }
5038
 
 
5039
 
};
5040
 
 
5041
 
/// This class defines the interface for a local-to-global mapping of
5042
 
/// degrees of freedom (dofs).
5043
 
 
5044
 
class ffc_25_dof_map_0: public ufc::dof_map
5045
 
{
5046
 
private:
5047
 
 
5048
 
  unsigned int __global_dimension;
5049
 
 
5050
 
public:
5051
 
 
5052
 
  /// Constructor
5053
 
  ffc_25_dof_map_0() : ufc::dof_map()
5054
 
  {
5055
 
    __global_dimension = 0;
5056
 
  }
5057
 
 
5058
 
  /// Destructor
5059
 
  virtual ~ffc_25_dof_map_0()
5060
 
  {
5061
 
    // Do nothing
5062
 
  }
5063
 
 
5064
 
  /// Return a string identifying the dof map
5065
 
  virtual const char* signature() const
5066
 
  {
5067
 
    return "FFC dof map for Mixed finite element: [Discontinuous Lagrange finite element of degree 3 on a tetrahedron, Discontinuous Lagrange finite element of degree 3 on a tetrahedron, Discontinuous Lagrange finite element of degree 3 on a tetrahedron]";
5068
 
  }
5069
 
 
5070
 
  /// Return true iff mesh entities of topological dimension d are needed
5071
 
  virtual bool needs_mesh_entities(unsigned int d) const
5072
 
  {
5073
 
    switch ( d )
5074
 
    {
5075
 
    case 0:
5076
 
      return false;
5077
 
      break;
5078
 
    case 1:
5079
 
      return false;
5080
 
      break;
5081
 
    case 2:
5082
 
      return false;
5083
 
      break;
5084
 
    case 3:
5085
 
      return true;
5086
 
      break;
5087
 
    }
5088
 
    return false;
5089
 
  }
5090
 
 
5091
 
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
5092
 
  virtual bool init_mesh(const ufc::mesh& m)
5093
 
  {
5094
 
    __global_dimension = 60*m.num_entities[3];
5095
 
    return false;
5096
 
  }
5097
 
 
5098
 
  /// Initialize dof map for given cell
5099
 
  virtual void init_cell(const ufc::mesh& m,
5100
 
                         const ufc::cell& c)
5101
 
  {
5102
 
    // Do nothing
5103
 
  }
5104
 
 
5105
 
  /// Finish initialization of dof map for cells
5106
 
  virtual void init_cell_finalize()
5107
 
  {
5108
 
    // Do nothing
5109
 
  }
5110
 
 
5111
 
  /// Return the dimension of the global finite element function space
5112
 
  virtual unsigned int global_dimension() const
5113
 
  {
5114
 
    return __global_dimension;
5115
 
  }
5116
 
 
5117
 
  /// Return the dimension of the local finite element function space
5118
 
  virtual unsigned int local_dimension() const
5119
 
  {
5120
 
    return 60;
5121
 
  }
5122
 
 
5123
 
  // Return the geometric dimension of the coordinates this dof map provides
5124
 
  virtual unsigned int geometric_dimension() const
5125
 
  {
5126
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
5127
 
  }
5128
 
 
5129
 
  /// Return the number of dofs on each cell facet
5130
 
  virtual unsigned int num_facet_dofs() const
5131
 
  {
5132
 
    return 0;
5133
 
  }
5134
 
 
5135
 
  /// Return the number of dofs associated with each cell entity of dimension d
5136
 
  virtual unsigned int num_entity_dofs(unsigned int d) const
5137
 
  {
5138
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
5139
 
  }
5140
 
 
5141
 
  /// Tabulate the local-to-global mapping of dofs on a cell
5142
 
  virtual void tabulate_dofs(unsigned int* dofs,
5143
 
                             const ufc::mesh& m,
5144
 
                             const ufc::cell& c) const
5145
 
  {
5146
 
    dofs[0] = 20*c.entity_indices[3][0];
5147
 
    dofs[1] = 20*c.entity_indices[3][0] + 1;
5148
 
    dofs[2] = 20*c.entity_indices[3][0] + 2;
5149
 
    dofs[3] = 20*c.entity_indices[3][0] + 3;
5150
 
    dofs[4] = 20*c.entity_indices[3][0] + 4;
5151
 
    dofs[5] = 20*c.entity_indices[3][0] + 5;
5152
 
    dofs[6] = 20*c.entity_indices[3][0] + 6;
5153
 
    dofs[7] = 20*c.entity_indices[3][0] + 7;
5154
 
    dofs[8] = 20*c.entity_indices[3][0] + 8;
5155
 
    dofs[9] = 20*c.entity_indices[3][0] + 9;
5156
 
    dofs[10] = 20*c.entity_indices[3][0] + 10;
5157
 
    dofs[11] = 20*c.entity_indices[3][0] + 11;
5158
 
    dofs[12] = 20*c.entity_indices[3][0] + 12;
5159
 
    dofs[13] = 20*c.entity_indices[3][0] + 13;
5160
 
    dofs[14] = 20*c.entity_indices[3][0] + 14;
5161
 
    dofs[15] = 20*c.entity_indices[3][0] + 15;
5162
 
    dofs[16] = 20*c.entity_indices[3][0] + 16;
5163
 
    dofs[17] = 20*c.entity_indices[3][0] + 17;
5164
 
    dofs[18] = 20*c.entity_indices[3][0] + 18;
5165
 
    dofs[19] = 20*c.entity_indices[3][0] + 19;
5166
 
    unsigned int offset = 20*m.num_entities[3];
5167
 
    dofs[20] = offset + 20*c.entity_indices[3][0];
5168
 
    dofs[21] = offset + 20*c.entity_indices[3][0] + 1;
5169
 
    dofs[22] = offset + 20*c.entity_indices[3][0] + 2;
5170
 
    dofs[23] = offset + 20*c.entity_indices[3][0] + 3;
5171
 
    dofs[24] = offset + 20*c.entity_indices[3][0] + 4;
5172
 
    dofs[25] = offset + 20*c.entity_indices[3][0] + 5;
5173
 
    dofs[26] = offset + 20*c.entity_indices[3][0] + 6;
5174
 
    dofs[27] = offset + 20*c.entity_indices[3][0] + 7;
5175
 
    dofs[28] = offset + 20*c.entity_indices[3][0] + 8;
5176
 
    dofs[29] = offset + 20*c.entity_indices[3][0] + 9;
5177
 
    dofs[30] = offset + 20*c.entity_indices[3][0] + 10;
5178
 
    dofs[31] = offset + 20*c.entity_indices[3][0] + 11;
5179
 
    dofs[32] = offset + 20*c.entity_indices[3][0] + 12;
5180
 
    dofs[33] = offset + 20*c.entity_indices[3][0] + 13;
5181
 
    dofs[34] = offset + 20*c.entity_indices[3][0] + 14;
5182
 
    dofs[35] = offset + 20*c.entity_indices[3][0] + 15;
5183
 
    dofs[36] = offset + 20*c.entity_indices[3][0] + 16;
5184
 
    dofs[37] = offset + 20*c.entity_indices[3][0] + 17;
5185
 
    dofs[38] = offset + 20*c.entity_indices[3][0] + 18;
5186
 
    dofs[39] = offset + 20*c.entity_indices[3][0] + 19;
5187
 
    offset = offset + 20*m.num_entities[3];
5188
 
    dofs[40] = offset + 20*c.entity_indices[3][0];
5189
 
    dofs[41] = offset + 20*c.entity_indices[3][0] + 1;
5190
 
    dofs[42] = offset + 20*c.entity_indices[3][0] + 2;
5191
 
    dofs[43] = offset + 20*c.entity_indices[3][0] + 3;
5192
 
    dofs[44] = offset + 20*c.entity_indices[3][0] + 4;
5193
 
    dofs[45] = offset + 20*c.entity_indices[3][0] + 5;
5194
 
    dofs[46] = offset + 20*c.entity_indices[3][0] + 6;
5195
 
    dofs[47] = offset + 20*c.entity_indices[3][0] + 7;
5196
 
    dofs[48] = offset + 20*c.entity_indices[3][0] + 8;
5197
 
    dofs[49] = offset + 20*c.entity_indices[3][0] + 9;
5198
 
    dofs[50] = offset + 20*c.entity_indices[3][0] + 10;
5199
 
    dofs[51] = offset + 20*c.entity_indices[3][0] + 11;
5200
 
    dofs[52] = offset + 20*c.entity_indices[3][0] + 12;
5201
 
    dofs[53] = offset + 20*c.entity_indices[3][0] + 13;
5202
 
    dofs[54] = offset + 20*c.entity_indices[3][0] + 14;
5203
 
    dofs[55] = offset + 20*c.entity_indices[3][0] + 15;
5204
 
    dofs[56] = offset + 20*c.entity_indices[3][0] + 16;
5205
 
    dofs[57] = offset + 20*c.entity_indices[3][0] + 17;
5206
 
    dofs[58] = offset + 20*c.entity_indices[3][0] + 18;
5207
 
    dofs[59] = offset + 20*c.entity_indices[3][0] + 19;
5208
 
  }
5209
 
 
5210
 
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
5211
 
  virtual void tabulate_facet_dofs(unsigned int* dofs,
5212
 
                                   unsigned int facet) const
5213
 
  {
5214
 
    switch ( facet )
5215
 
    {
5216
 
    case 0:
5217
 
      
5218
 
      break;
5219
 
    case 1:
5220
 
      
5221
 
      break;
5222
 
    case 2:
5223
 
      
5224
 
      break;
5225
 
    case 3:
5226
 
      
5227
 
      break;
5228
 
    }
5229
 
  }
5230
 
 
5231
 
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
5232
 
  virtual void tabulate_entity_dofs(unsigned int* dofs,
5233
 
                                    unsigned int d, unsigned int i) const
5234
 
  {
5235
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
5236
 
  }
5237
 
 
5238
 
  /// Tabulate the coordinates of all dofs on a cell
5239
 
  virtual void tabulate_coordinates(double** coordinates,
5240
 
                                    const ufc::cell& c) const
5241
 
  {
5242
 
    const double * const * x = c.coordinates;
5243
 
    coordinates[0][0] = x[0][0];
5244
 
    coordinates[0][1] = x[0][1];
5245
 
    coordinates[0][2] = x[0][2];
5246
 
    coordinates[1][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[1][0];
5247
 
    coordinates[1][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[1][1];
5248
 
    coordinates[1][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[1][2];
5249
 
    coordinates[2][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[1][0];
5250
 
    coordinates[2][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[1][1];
5251
 
    coordinates[2][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[1][2];
5252
 
    coordinates[3][0] = x[1][0];
5253
 
    coordinates[3][1] = x[1][1];
5254
 
    coordinates[3][2] = x[1][2];
5255
 
    coordinates[4][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[2][0];
5256
 
    coordinates[4][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[2][1];
5257
 
    coordinates[4][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[2][2];
5258
 
    coordinates[5][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
5259
 
    coordinates[5][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
5260
 
    coordinates[5][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2];
5261
 
    coordinates[6][0] = 0.666666666666666*x[1][0] + 0.333333333333333*x[2][0];
5262
 
    coordinates[6][1] = 0.666666666666666*x[1][1] + 0.333333333333333*x[2][1];
5263
 
    coordinates[6][2] = 0.666666666666666*x[1][2] + 0.333333333333333*x[2][2];
5264
 
    coordinates[7][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[2][0];
5265
 
    coordinates[7][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[2][1];
5266
 
    coordinates[7][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[2][2];
5267
 
    coordinates[8][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[2][0];
5268
 
    coordinates[8][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[2][1];
5269
 
    coordinates[8][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[2][2];
5270
 
    coordinates[9][0] = x[2][0];
5271
 
    coordinates[9][1] = x[2][1];
5272
 
    coordinates[9][2] = x[2][2];
5273
 
    coordinates[10][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[3][0];
5274
 
    coordinates[10][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[3][1];
5275
 
    coordinates[10][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[3][2];
5276
 
    coordinates[11][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[3][0];
5277
 
    coordinates[11][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[3][1];
5278
 
    coordinates[11][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[3][2];
5279
 
    coordinates[12][0] = 0.666666666666667*x[1][0] + 0.333333333333333*x[3][0];
5280
 
    coordinates[12][1] = 0.666666666666667*x[1][1] + 0.333333333333333*x[3][1];
5281
 
    coordinates[12][2] = 0.666666666666667*x[1][2] + 0.333333333333333*x[3][2];
5282
 
    coordinates[13][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
5283
 
    coordinates[13][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
5284
 
    coordinates[13][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
5285
 
    coordinates[14][0] = 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
5286
 
    coordinates[14][1] = 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
5287
 
    coordinates[14][2] = 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
5288
 
    coordinates[15][0] = 0.666666666666667*x[2][0] + 0.333333333333333*x[3][0];
5289
 
    coordinates[15][1] = 0.666666666666667*x[2][1] + 0.333333333333333*x[3][1];
5290
 
    coordinates[15][2] = 0.666666666666667*x[2][2] + 0.333333333333333*x[3][2];
5291
 
    coordinates[16][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[3][0];
5292
 
    coordinates[16][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[3][1];
5293
 
    coordinates[16][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[3][2];
5294
 
    coordinates[17][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[3][0];
5295
 
    coordinates[17][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[3][1];
5296
 
    coordinates[17][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[3][2];
5297
 
    coordinates[18][0] = 0.333333333333333*x[2][0] + 0.666666666666667*x[3][0];
5298
 
    coordinates[18][1] = 0.333333333333333*x[2][1] + 0.666666666666667*x[3][1];
5299
 
    coordinates[18][2] = 0.333333333333333*x[2][2] + 0.666666666666667*x[3][2];
5300
 
    coordinates[19][0] = x[3][0];
5301
 
    coordinates[19][1] = x[3][1];
5302
 
    coordinates[19][2] = x[3][2];
5303
 
    coordinates[20][0] = x[0][0];
5304
 
    coordinates[20][1] = x[0][1];
5305
 
    coordinates[20][2] = x[0][2];
5306
 
    coordinates[21][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[1][0];
5307
 
    coordinates[21][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[1][1];
5308
 
    coordinates[21][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[1][2];
5309
 
    coordinates[22][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[1][0];
5310
 
    coordinates[22][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[1][1];
5311
 
    coordinates[22][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[1][2];
5312
 
    coordinates[23][0] = x[1][0];
5313
 
    coordinates[23][1] = x[1][1];
5314
 
    coordinates[23][2] = x[1][2];
5315
 
    coordinates[24][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[2][0];
5316
 
    coordinates[24][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[2][1];
5317
 
    coordinates[24][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[2][2];
5318
 
    coordinates[25][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
5319
 
    coordinates[25][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
5320
 
    coordinates[25][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2];
5321
 
    coordinates[26][0] = 0.666666666666666*x[1][0] + 0.333333333333333*x[2][0];
5322
 
    coordinates[26][1] = 0.666666666666666*x[1][1] + 0.333333333333333*x[2][1];
5323
 
    coordinates[26][2] = 0.666666666666666*x[1][2] + 0.333333333333333*x[2][2];
5324
 
    coordinates[27][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[2][0];
5325
 
    coordinates[27][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[2][1];
5326
 
    coordinates[27][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[2][2];
5327
 
    coordinates[28][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[2][0];
5328
 
    coordinates[28][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[2][1];
5329
 
    coordinates[28][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[2][2];
5330
 
    coordinates[29][0] = x[2][0];
5331
 
    coordinates[29][1] = x[2][1];
5332
 
    coordinates[29][2] = x[2][2];
5333
 
    coordinates[30][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[3][0];
5334
 
    coordinates[30][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[3][1];
5335
 
    coordinates[30][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[3][2];
5336
 
    coordinates[31][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[3][0];
5337
 
    coordinates[31][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[3][1];
5338
 
    coordinates[31][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[3][2];
5339
 
    coordinates[32][0] = 0.666666666666667*x[1][0] + 0.333333333333333*x[3][0];
5340
 
    coordinates[32][1] = 0.666666666666667*x[1][1] + 0.333333333333333*x[3][1];
5341
 
    coordinates[32][2] = 0.666666666666667*x[1][2] + 0.333333333333333*x[3][2];
5342
 
    coordinates[33][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
5343
 
    coordinates[33][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
5344
 
    coordinates[33][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
5345
 
    coordinates[34][0] = 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
5346
 
    coordinates[34][1] = 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
5347
 
    coordinates[34][2] = 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
5348
 
    coordinates[35][0] = 0.666666666666667*x[2][0] + 0.333333333333333*x[3][0];
5349
 
    coordinates[35][1] = 0.666666666666667*x[2][1] + 0.333333333333333*x[3][1];
5350
 
    coordinates[35][2] = 0.666666666666667*x[2][2] + 0.333333333333333*x[3][2];
5351
 
    coordinates[36][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[3][0];
5352
 
    coordinates[36][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[3][1];
5353
 
    coordinates[36][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[3][2];
5354
 
    coordinates[37][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[3][0];
5355
 
    coordinates[37][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[3][1];
5356
 
    coordinates[37][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[3][2];
5357
 
    coordinates[38][0] = 0.333333333333333*x[2][0] + 0.666666666666667*x[3][0];
5358
 
    coordinates[38][1] = 0.333333333333333*x[2][1] + 0.666666666666667*x[3][1];
5359
 
    coordinates[38][2] = 0.333333333333333*x[2][2] + 0.666666666666667*x[3][2];
5360
 
    coordinates[39][0] = x[3][0];
5361
 
    coordinates[39][1] = x[3][1];
5362
 
    coordinates[39][2] = x[3][2];
5363
 
    coordinates[40][0] = x[0][0];
5364
 
    coordinates[40][1] = x[0][1];
5365
 
    coordinates[40][2] = x[0][2];
5366
 
    coordinates[41][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[1][0];
5367
 
    coordinates[41][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[1][1];
5368
 
    coordinates[41][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[1][2];
5369
 
    coordinates[42][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[1][0];
5370
 
    coordinates[42][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[1][1];
5371
 
    coordinates[42][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[1][2];
5372
 
    coordinates[43][0] = x[1][0];
5373
 
    coordinates[43][1] = x[1][1];
5374
 
    coordinates[43][2] = x[1][2];
5375
 
    coordinates[44][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[2][0];
5376
 
    coordinates[44][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[2][1];
5377
 
    coordinates[44][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[2][2];
5378
 
    coordinates[45][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
5379
 
    coordinates[45][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
5380
 
    coordinates[45][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2];
5381
 
    coordinates[46][0] = 0.666666666666666*x[1][0] + 0.333333333333333*x[2][0];
5382
 
    coordinates[46][1] = 0.666666666666666*x[1][1] + 0.333333333333333*x[2][1];
5383
 
    coordinates[46][2] = 0.666666666666666*x[1][2] + 0.333333333333333*x[2][2];
5384
 
    coordinates[47][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[2][0];
5385
 
    coordinates[47][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[2][1];
5386
 
    coordinates[47][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[2][2];
5387
 
    coordinates[48][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[2][0];
5388
 
    coordinates[48][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[2][1];
5389
 
    coordinates[48][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[2][2];
5390
 
    coordinates[49][0] = x[2][0];
5391
 
    coordinates[49][1] = x[2][1];
5392
 
    coordinates[49][2] = x[2][2];
5393
 
    coordinates[50][0] = 0.666666666666667*x[0][0] + 0.333333333333333*x[3][0];
5394
 
    coordinates[50][1] = 0.666666666666667*x[0][1] + 0.333333333333333*x[3][1];
5395
 
    coordinates[50][2] = 0.666666666666667*x[0][2] + 0.333333333333333*x[3][2];
5396
 
    coordinates[51][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[3][0];
5397
 
    coordinates[51][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[3][1];
5398
 
    coordinates[51][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[1][2] + 0.333333333333333*x[3][2];
5399
 
    coordinates[52][0] = 0.666666666666667*x[1][0] + 0.333333333333333*x[3][0];
5400
 
    coordinates[52][1] = 0.666666666666667*x[1][1] + 0.333333333333333*x[3][1];
5401
 
    coordinates[52][2] = 0.666666666666667*x[1][2] + 0.333333333333333*x[3][2];
5402
 
    coordinates[53][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
5403
 
    coordinates[53][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
5404
 
    coordinates[53][2] = 0.333333333333333*x[0][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
5405
 
    coordinates[54][0] = 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0] + 0.333333333333333*x[3][0];
5406
 
    coordinates[54][1] = 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1] + 0.333333333333333*x[3][1];
5407
 
    coordinates[54][2] = 0.333333333333333*x[1][2] + 0.333333333333333*x[2][2] + 0.333333333333333*x[3][2];
5408
 
    coordinates[55][0] = 0.666666666666667*x[2][0] + 0.333333333333333*x[3][0];
5409
 
    coordinates[55][1] = 0.666666666666667*x[2][1] + 0.333333333333333*x[3][1];
5410
 
    coordinates[55][2] = 0.666666666666667*x[2][2] + 0.333333333333333*x[3][2];
5411
 
    coordinates[56][0] = 0.333333333333333*x[0][0] + 0.666666666666667*x[3][0];
5412
 
    coordinates[56][1] = 0.333333333333333*x[0][1] + 0.666666666666667*x[3][1];
5413
 
    coordinates[56][2] = 0.333333333333333*x[0][2] + 0.666666666666667*x[3][2];
5414
 
    coordinates[57][0] = 0.333333333333333*x[1][0] + 0.666666666666667*x[3][0];
5415
 
    coordinates[57][1] = 0.333333333333333*x[1][1] + 0.666666666666667*x[3][1];
5416
 
    coordinates[57][2] = 0.333333333333333*x[1][2] + 0.666666666666667*x[3][2];
5417
 
    coordinates[58][0] = 0.333333333333333*x[2][0] + 0.666666666666667*x[3][0];
5418
 
    coordinates[58][1] = 0.333333333333333*x[2][1] + 0.666666666666667*x[3][1];
5419
 
    coordinates[58][2] = 0.333333333333333*x[2][2] + 0.666666666666667*x[3][2];
5420
 
    coordinates[59][0] = x[3][0];
5421
 
    coordinates[59][1] = x[3][1];
5422
 
    coordinates[59][2] = x[3][2];
5423
 
  }
5424
 
 
5425
 
  /// Return the number of sub dof maps (for a mixed element)
5426
 
  virtual unsigned int num_sub_dof_maps() const
5427
 
  {
5428
 
    return 3;
5429
 
  }
5430
 
 
5431
 
  /// Create a new dof_map for sub dof map i (for a mixed element)
5432
 
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
5433
 
  {
5434
 
    switch ( i )
5435
 
    {
5436
 
    case 0:
5437
 
      return new ffc_25_dof_map_0_0();
5438
 
      break;
5439
 
    case 1:
5440
 
      return new ffc_25_dof_map_0_1();
5441
 
      break;
5442
 
    case 2:
5443
 
      return new ffc_25_dof_map_0_2();
5444
 
      break;
5445
 
    }
5446
 
    return 0;
5447
 
  }
5448
 
 
5449
 
};
5450
 
 
5451
 
#endif