59 vorticity[0] = A[2+1*3] - A[1+2*3];
60 vorticity[1] = A[0+2*3] - A[2+0*3];
61 vorticity[2] = A[1+0*3] - A[0+1*3];
65 printf(
"the vorticity vector is: [ %lf, %lf, %lf ]\n",
66 vorticity[0], vorticity[1], vorticity[2]);
86 printf(
" %s:\n",
"A");
88 for (i = 0; i < 3; i++) {
90 for (j = 0; j < 3; j++) {
91 printf(
" %13.6f ", A[j*3+i]);
95 printf(
"a, b, c, d: %lf, %lf, %lf, %lf\n", a, b, c, d);
100 VA_COMPLEX x1, x2, x3;
103 VA_REAL lambda_r, lambda_ci;
113 else if (info == 0) {
115 lambda_r = creal(x1);
116 lambda_ci = cimag(x2);
120 printf(
"The solve of the cubic equation has failed with info: %d \n", info);
132 for (
int i = 0; i < 9; i++)
134 for (
int i = 0; i < 3; i++)
135 B[i+i*3] -= lambda_r;
139 printf(
"Something is wrong, find_nullspace returned with info %d.\n", info);
148 printf(
"the real eigenvector is: [ %lf, %lf, %lf ]\n",
149 rortex[0], rortex[1], rortex[2]);
155 for (
int i = 0; i < 3; i++)
156 rortex[i] = -rortex[i];
161 printf(
"Something is wrong, the scalar product of vorticity and rortex should be positive, %lf.\n", vr);
169 VA_REAL diff = vr*vr - 4.*lambda_ci*lambda_ci;
177 for (
int i = 0; i < 3; i++)
VA_DEVICE_FUN void valib_solve_cubic_equation(VA_REAL a, VA_REAL b, VA_REAL c, VA_REAL d, VA_COMPLEX *x1, VA_COMPLEX *x2, VA_COMPLEX *x3, int *info)