Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
smooth_medial.C File Reference
#include "Rocmop.h"
#include "roccom.h"
#include "Pane.h"
#include "Rocblas.h"
#include "Rocmap.h"
#include "geometry.h"
#include "Rocsurf.h"
#include "Generic_element_2.h"
Include dependency graph for smooth_medial.C:

Go to the source code of this file.

Macros

#define EXPORT_DEBUG_INFO   1
 

Functions

double SQR (double x)
 
void dsytrd3 (double A[3][3], double Q[3][3], double d[3], double e[2])
 
int dsyevq3 (double A[3][3], double Q[3][3], double w[3])
 

Variables

static const double half_pi = 1.5707963267949
 
static const double pi = 3.14159265358979
 

Macro Definition Documentation

#define EXPORT_DEBUG_INFO   1

Definition at line 40 of file smooth_medial.C.

Function Documentation

int dsyevq3 ( double  A[3][3],
double  Q[3][3],
double  w[3] 
)

Definition at line 124 of file smooth_medial.C.

References dsytrd3(), i, k, s, SQR(), and sqrt().

Referenced by FaceOffset_3::compute_eigenvectors(), and Rocmop::compute_eigenvectors().

146 {
147  double e[3]; // The third element is used only as temporary workspace
148  double g, r, p, f, b, s, c, t; // Intermediate storage
149  int nIter;
150  int m;
151 
152  // Transform A to real tridiagonal form by the Householder method
153  dsytrd3(A, Q, w, e);
154 
155  // Calculate eigensystem of the remaining real symmetric tridiagonal matrix
156  // with the QL method
157  //
158  // Loop over all off-diagonal elements
159  for (int l=0; l < 2; l++)
160  {
161  nIter = 0;
162  for (;;)
163  {
164  // Check for convergence and exit iteration loop if off-diagonal
165  // element e(l) is zero
166  for (m=l; m < 2; m++)
167  {
168  g = fabs(w[m])+fabs(w[m+1]);
169  if (fabs(e[m]) + g == g)
170  break;
171  }
172  if (m == l)
173  break;
174 
175  if (nIter++ >= 30)
176  return -1;
177 
178  // Calculate g = d_m - k
179  g = (w[l+1] - w[l]) / (e[l] + e[l]);
180  r = sqrt(SQR(g) + 1.0);
181  if (g > 0)
182  g = w[m] - w[l] + e[l]/(g + r);
183  else
184  g = w[m] - w[l] + e[l]/(g - r);
185 
186  s = c = 1.0;
187  p = 0.0;
188  for (int i=m-1; i >= l; i--)
189  {
190  f = s * e[i];
191  b = c * e[i];
192  if (fabs(f) > fabs(g))
193  {
194  c = g / f;
195  r = sqrt(SQR(c) + 1.0);
196  e[i+1] = f * r;
197  c *= (s = 1.0/r);
198  }
199  else
200  {
201  s = f / g;
202  r = sqrt(SQR(s) + 1.0);
203  e[i+1] = g * r;
204  s *= (c = 1.0/r);
205  }
206 
207  g = w[i+1] - p;
208  r = (w[i] - g)*s + 2.0*c*b;
209  p = s * r;
210  w[i+1] = g + p;
211  g = c*r - b;
212 
213  // Form eigenvectors
214  for (int k=0; k < 3; k++)
215  {
216  t = Q[k][i+1];
217  Q[k][i+1] = s*Q[k][i] + c*t;
218  Q[k][i] = c*Q[k][i] - s*t;
219  }
220  }
221  w[l] -= p;
222  e[l] = g;
223  e[m] = 0.0;
224  }
225  }
226 
227  return 0;
228 }
j indices k indices k
Definition: Indexing.h:6
double s
Definition: blastest.C:80
double sqrt(double d)
Definition: double.h:73
rational * A
Definition: vinci_lass.c:67
double SQR(double x)
Definition: smooth_medial.C:45
blockLoc i
Definition: read.cpp:79
void dsytrd3(double A[3][3], double Q[3][3], double d[3], double e[2])
Definition: smooth_medial.C:48

Here is the call graph for this function:

Here is the caller graph for this function:

void dsytrd3 ( double  A[3][3],
double  Q[3][3],
double  d[3],
double  e[2] 
)

Definition at line 48 of file smooth_medial.C.

References i, j, q, SQR(), and sqrt().

Referenced by dsyevq3().

60 {
61  double u[3], q[3];
62  double omega, f;
63  double K, h, g;
64 
65  // Initialize Q to the identitity matrix
66  for (int i=0; i < 3; i++)
67  {
68  Q[i][i] = 1.0;
69  for (int j=0; j < i; j++)
70  Q[i][j] = Q[j][i] = 0.0;
71  }
72 
73  // Bring first row and column to the desired form
74  h = SQR(A[0][1]) + SQR(A[0][2]);
75  if (A[0][1] > 0)
76  g = -sqrt(h);
77  else
78  g = sqrt(h);
79  e[0] = g;
80  f = g * A[0][1];
81  u[1] = A[0][1] - g;
82  u[2] = A[0][2];
83 
84  omega = h - f;
85  if (omega > 0.0)
86  {
87  omega = 1.0 / omega;
88  K = 0.0;
89  for (int i=1; i < 3; i++)
90  {
91  f = A[1][i] * u[1] + A[i][2] * u[2];
92  q[i] = omega * f; // p
93  K += u[i] * f; // u* A u
94  }
95  K *= 0.5 * SQR(omega);
96 
97  for (int i=1; i < 3; i++)
98  q[i] = q[i] - K * u[i];
99 
100  d[0] = A[0][0];
101  d[1] = A[1][1] - 2.0*q[1]*u[1];
102  d[2] = A[2][2] - 2.0*q[2]*u[2];
103 
104  // Store inverse Householder transformation in Q
105  for (int j=1; j < 3; j++)
106  {
107  f = omega * u[j];
108  for (int i=1; i < 3; i++)
109  Q[i][j] = Q[i][j] - f*u[i];
110  }
111 
112  // Calculate updated A[1][2] and store it in e[1]
113  e[1] = A[1][2] - q[1]*u[2] - u[1]*q[2];
114  }
115  else
116  {
117  for (int i=0; i < 3; i++)
118  d[i] = A[i][i];
119  e[1] = A[1][2];
120  }
121 }
const NT & d
double sqrt(double d)
Definition: double.h:73
rational * A
Definition: vinci_lass.c:67
double SQR(double x)
Definition: smooth_medial.C:45
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
NT q

Here is the call graph for this function:

Here is the caller graph for this function:

double SQR ( double  x)
inline

Definition at line 45 of file smooth_medial.C.

Referenced by dsyevq3(), and dsytrd3().

45 { return (x*x); }
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

Variable Documentation

const double half_pi = 1.5707963267949
static