## 5 Reputation

0 years, 165 days

## CodeGeneration in C throws Error: Error,...

Maple 2019

Hi, can someone explain me why CodeGeneration in C throws the error : Error, (in Print) improper op or subscript selector ? Interestingly, CodeGeneration in Python or Matlab works. Source code is attached. Thanks in advance!

Membrane Energy

 Define variables Vectors for vertices of current position  =    =  = Vector for vertices of next position  =  =  =

Define Transformation

=

=

Note we have  and if the current triangle is not degenerate, then . As we can pre-compute  we define a new matrix for it:

=

 (1.2.1)

=

 Define Energy

 Gradient and Hessian = t1 = v2n_i[0] - v1n_i[0]; t2 = v2n_i[1] - v1n_i[1]; t3 = v2n_i[2] - v1n_i[2]; t4 = t1 * Vinv_ij[0][0] + t2 * Vinv_ij[1][0] + t3 * Vinv_ij[2][0]; t5 = t1 * Vinv_ij[0][1] + t2 * Vinv_ij[1][1] + t3 * Vinv_ij[2][1]; t6 = t1 * Vinv_ij[0][2] + t2 * Vinv_ij[1][2] + t3 * Vinv_ij[2][2]; t7 = v3n_i[0] - v1n_i[0]; t8 = v3n_i[1] - v1n_i[1]; t9 = v3n_i[2] - v1n_i[2]; t10 = t7 * Vinv_ij[0][0] + t8 * Vinv_ij[1][0] + t9 * Vinv_ij[2][0]; t11 = t7 * Vinv_ij[0][1] + t8 * Vinv_ij[1][1] + t9 * Vinv_ij[2][1]; t12 = t7 * Vinv_ij[0][2] + t8 * Vinv_ij[1][2] + t9 * Vinv_ij[2][2]; t13 = t2 * t9 - t3 * t8; t14 = fabs(t13); t15 = t1 * t9 - t3 * t7; t16 = fabs(t15); t17 = t1 * t8 - t2 * t7; t18 = fabs(t17); t19 = pow(t14, 0.2e1) + pow(t16, 0.2e1) + pow(t18, 0.2e1); t20 = pow(t19, -0.5e1 / 0.4e1); t19 = t19 * t20; t21 = Vinv_ij[0][0] * t13; t22 = Vinv_ij[1][0] * t15; t23 = Vinv_ij[2][0] * t17; t24 = (t23 + t21 - t22) * t19; t25 = -v2n_i[2] + v3n_i[2]; t26 = fabs(t15) / t15; t27 = -v2n_i[1] + v3n_i[1]; t28 = fabs(t17) / t17; t21 = t23 + t21 - t22; t22 = (t16 * t25 * t26 + t18 * t27 * t28) * t20; t23 = 0.1e1 / 0.2e1; t29 = Vinv_ij[0][1] * t13; t30 = Vinv_ij[1][1] * t15; t31 = Vinv_ij[2][1] * t17; t32 = (t31 + t29 - t30) * t19; t29 = t31 + t29 - t30; t30 = Vinv_ij[0][2] * t13; t15 = Vinv_ij[1][2] * t15; t17 = Vinv_ij[2][2] * t17; t31 = (t17 + t30 - t15) * t19; t15 = t17 + t30 - t15; t17 = t6 + t12; t30 = t5 + t11; t33 = t4 + t10; t13 = fabs(t13) / t13; t34 = -v2n_i[0] + v3n_i[0]; t35 = (t14 * t25 * t13 - t18 * t34 * t28) * t20; t35 = t17 * Vinv_ij[1][2] - t24 * (t23 * t35 * t21 - t19 * (t25 * Vinv_ij[0][0] - t34 * Vinv_ij[2][0])) + t30 * Vinv_ij[1][1] - t31 * (t23 * t35 * t15 - t19 * (t25 * Vinv_ij[0][2] - t34 * Vinv_ij[2][2])) - t32 * (t23 * t35 * t29 - t19 * (t25 * Vinv_ij[0][1] - t34 * Vinv_ij[2][1])) + t33 * Vinv_ij[1][0]; t36 = (t14 * t27 * t13 + t16 * t34 * t26) * t20; t34 = Vinv_ij[2][2] * t17 - t24 * (-t23 * t36 * t21 + t19 * (t27 * Vinv_ij[0][0] - t34 * Vinv_ij[1][0])) + t30 * Vinv_ij[2][1] - t31 * (-t23 * t36 * t15 + t19 * (t27 * Vinv_ij[0][2] - t34 * Vinv_ij[1][2])) - t32 * (-t23 * t36 * t29 + t19 * (t27 * Vinv_ij[0][1] - t34 * Vinv_ij[1][1])) + t33 * Vinv_ij[2][0]; t36 = (t16 * t9 * t26 + t18 * t8 * t28) * t20; t36 = t24 * (-t23 * t36 * t21 - t19 * (-t8 * Vinv_ij[2][0] + t9 * Vinv_ij[1][0])) + t31 * (-t23 * t36 * t15 - t19 * (-t8 * Vinv_ij[2][2] + t9 * Vinv_ij[1][2])) + t32 * (-t23 * t36 * t29 - t19 * (-t8 * Vinv_ij[2][1] + t9 * Vinv_ij[1][1])) + t4 * Vinv_ij[0][0] + t5 * Vinv_ij[0][1] + t6 * Vinv_ij[0][2]; t37 = (t14 * t9 * t13 - t18 * t7 * t28) * t20; t9 = t24 * (-t23 * t37 * t21 + t19 * (-t7 * Vinv_ij[2][0] + t9 * Vinv_ij[0][0])) + t31 * (-t15 * t23 * t37 + t19 * (-t7 * Vinv_ij[2][2] + t9 * Vinv_ij[0][2])) + t32 * (-t23 * t29 * t37 + t19 * (-t7 * Vinv_ij[2][1] + t9 * Vinv_ij[0][1])) + t4 * Vinv_ij[1][0] + t5 * Vinv_ij[1][1] + t6 * Vinv_ij[1][2]; t37 = (t14 * t8 * t13 + t16 * t7 * t26) * t20; t4 = t24 * (t23 * t37 * t21 - t19 * (-t7 * Vinv_ij[1][0] + t8 * Vinv_ij[0][0])) + t31 * (t15 * t23 * t37 - t19 * (-t7 * Vinv_ij[1][2] + t8 * Vinv_ij[0][2])) + t32 * (t23 * t29 * t37 - t19 * (-t7 * Vinv_ij[1][1] + t8 * Vinv_ij[0][1])) + t4 * Vinv_ij[2][0] + t5 * Vinv_ij[2][1] + t6 * Vinv_ij[2][2]; t5 = (t16 * t3 * t26 + t18 * t2 * t28) * t20; t5 = t10 * Vinv_ij[0][0] + t11 * Vinv_ij[0][1] + t12 * Vinv_ij[0][2] + t24 * (t21 * t23 * t5 + t19 * (-t2 * Vinv_ij[2][0] + t3 * Vinv_ij[1][0])) + t31 * (t15 * t23 * t5 + t19 * (-t2 * Vinv_ij[2][2] + t3 * Vinv_ij[1][2])) + t32 * (t23 * t29 * t5 + t19 * (-t2 * Vinv_ij[2][1] + t3 * Vinv_ij[1][1])); t6 = (-t18 * t1 * t28 + t14 * t3 * t13) * t20; t3 = t10 * Vinv_ij[1][0] + t11 * Vinv_ij[1][1] + t12 * Vinv_ij[1][2] + t24 * (t21 * t23 * t6 - t19 * (-t1 * Vinv_ij[2][0] + t3 * Vinv_ij[0][0])) + t31 * (t15 * t23 * t6 - t19 * (-t1 * Vinv_ij[2][2] + t3 * Vinv_ij[0][2])) + t32 * (t23 * t29 * t6 - t19 * (-t1 * Vinv_ij[2][1] + t3 * Vinv_ij[0][1])); t6 = (t16 * t1 * t26 + t14 * t2 * t13) * t20; t1 = t10 * Vinv_ij[2][0] + t11 * Vinv_ij[2][1] + t12 * Vinv_ij[2][2] + t24 * (-t21 * t23 * t6 + t19 * (-t1 * Vinv_ij[1][0] + t2 * Vinv_ij[0][0])) + t31 * (-t15 * t23 * t6 + t19 * (-t1 * Vinv_ij[1][2] + t2 * Vinv_ij[0][2])) + t32 * (-t23 * t29 * t6 + t19 * (-t1 * Vinv_ij[1][1] + t2 * Vinv_ij[0][1])); t2 = 0.2e1; gradE[0] = -t2 * (-t24 * (t23 * t22 * t21 + t19 * (t25 * Vinv_ij[1][0] - t27 * Vinv_ij[2][0])) + t33 * Vinv_ij[0][0] + t30 * Vinv_ij[0][1] + t17 * Vinv_ij[0][2] - t32 * (t23 * t22 * t29 + t19 * (t25 * Vinv_ij[1][1] - t27 * Vinv_ij[2][1])) - t31 * (t23 * t22 * t15 + t19 * (t25 * Vinv_ij[1][2] - t27 * Vinv_ij[2][2]))); gradE[1] = -t2 * t35; gradE[2] = -t2 * t34; gradE[3] = t2 * t36; gradE[4] = t2 * t9; gradE[5] = t2 * t4; gradE[6] = t2 * t5; gradE[7] = t2 * t3; gradE[8] = t2 * t1;

Hessian

 (1.5.1)