Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
quadric_analysis.C File Reference
#include "FaceOffset_3.h"
#include "../Rocblas/include/Rocblas.h"
#include "../Rocsurf/include/Rocsurf.h"
#include <algorithm>
Include dependency graph for quadric_analysis.C:

Go to the source code of this file.

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])
 

Function Documentation

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

Definition at line 462 of file quadric_analysis.C.

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

484 {
485  double e[3]; // The third element is used only as temporary workspace
486  double g, r, p, f, b, s, c, t; // Intermediate storage
487  int nIter;
488  int m;
489 
490  // Transform A to real tridiagonal form by the Householder method
491  dsytrd3(A, Q, w, e);
492 
493  // Calculate eigensystem of the remaining real symmetric tridiagonal matrix
494  // with the QL method
495  //
496  // Loop over all off-diagonal elements
497  for (int l=0; l < 2; l++)
498  {
499  nIter = 0;
500  for (;;)
501  {
502  // Check for convergence and exit iteration loop if off-diagonal
503  // element e(l) is zero
504  for (m=l; m < 2; m++)
505  {
506  g = fabs(w[m])+fabs(w[m+1]);
507  if (fabs(e[m]) + g == g)
508  break;
509  }
510  if (m == l)
511  break;
512 
513  if (nIter++ >= 30)
514  return -1;
515 
516  // Calculate g = d_m - k
517  g = (w[l+1] - w[l]) / (e[l] + e[l]);
518  r = sqrt(SQR(g) + 1.0);
519  if (g > 0)
520  g = w[m] - w[l] + e[l]/(g + r);
521  else
522  g = w[m] - w[l] + e[l]/(g - r);
523 
524  s = c = 1.0;
525  p = 0.0;
526  for (int i=m-1; i >= l; i--)
527  {
528  f = s * e[i];
529  b = c * e[i];
530  if (fabs(f) > fabs(g))
531  {
532  c = g / f;
533  r = sqrt(SQR(c) + 1.0);
534  e[i+1] = f * r;
535  c *= (s = 1.0/r);
536  }
537  else
538  {
539  s = f / g;
540  r = sqrt(SQR(s) + 1.0);
541  e[i+1] = g * r;
542  s *= (c = 1.0/r);
543  }
544 
545  g = w[i+1] - p;
546  r = (w[i] - g)*s + 2.0*c*b;
547  p = s * r;
548  w[i+1] = g + p;
549  g = c*r - b;
550 
551  // Form eigenvectors
552  for (int k=0; k < 3; k++)
553  {
554  t = Q[k][i+1];
555  Q[k][i+1] = s*Q[k][i] + c*t;
556  Q[k][i] = c*Q[k][i] - s*t;
557  }
558  }
559  w[l] -= p;
560  e[l] = g;
561  e[m] = 0.0;
562  }
563  }
564 
565  return 0;
566 }
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:

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

Definition at line 386 of file quadric_analysis.C.

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

398 {
399  double u[3], q[3];
400  double omega, f;
401  double K, h, g;
402 
403  // Initialize Q to the identitity matrix
404  for (int i=0; i < 3; i++)
405  {
406  Q[i][i] = 1.0;
407  for (int j=0; j < i; j++)
408  Q[i][j] = Q[j][i] = 0.0;
409  }
410 
411  // Bring first row and column to the desired form
412  h = SQR(A[0][1]) + SQR(A[0][2]);
413  if (A[0][1] > 0)
414  g = -sqrt(h);
415  else
416  g = sqrt(h);
417  e[0] = g;
418  f = g * A[0][1];
419  u[1] = A[0][1] - g;
420  u[2] = A[0][2];
421 
422  omega = h - f;
423  if (omega > 0.0)
424  {
425  omega = 1.0 / omega;
426  K = 0.0;
427  for (int i=1; i < 3; i++)
428  {
429  f = A[1][i] * u[1] + A[i][2] * u[2];
430  q[i] = omega * f; // p
431  K += u[i] * f; // u* A u
432  }
433  K *= 0.5 * SQR(omega);
434 
435  for (int i=1; i < 3; i++)
436  q[i] = q[i] - K * u[i];
437 
438  d[0] = A[0][0];
439  d[1] = A[1][1] - 2.0*q[1]*u[1];
440  d[2] = A[2][2] - 2.0*q[2]*u[2];
441 
442  // Store inverse Householder transformation in Q
443  for (int j=1; j < 3; j++)
444  {
445  f = omega * u[j];
446  for (int i=1; i < 3; i++)
447  Q[i][j] = Q[i][j] - f*u[i];
448  }
449 
450  // Calculate updated A[1][2] and store it in e[1]
451  e[1] = A[1][2] - q[1]*u[2] - u[1]*q[2];
452  }
453  else
454  {
455  for (int i=0; i < 3; i++)
456  d[i] = A[i][i];
457  e[1] = A[1][2];
458  }
459 }
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:

double SQR ( double  x)
inline

Definition at line 383 of file quadric_analysis.C.

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