From edeec7b788a8fdaaafb2d1488fdf2dd2721959a7 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 11 Sep 2012 13:57:57 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8763 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- lib/atc/GMRES.h | 60 ++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/atc/GMRES.h b/lib/atc/GMRES.h index 3233445434..97ee273439 100644 --- a/lib/atc/GMRES.h +++ b/lib/atc/GMRES.h @@ -45,6 +45,36 @@ abs(Real x) return (x > 0 ? x : -x); } +#include + + +template +void GeneratePlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn) +{ + if (dy == 0.0) { + cs = 1.0; + sn = 0.0; + } else if (abs(dy) > abs(dx)) { + Real temp = dx / dy; + sn = 1.0 / sqrt( 1.0 + temp*temp ); + cs = temp * sn; + } else { + Real temp = dy / dx; + cs = 1.0 / sqrt( 1.0 + temp*temp ); + sn = temp * cs; + } +} + + +template +void ApplyPlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn) +{ + Real temp = cs * dx + sn * dy; + dy = -sn * dx + cs * dy; + dx = temp; +} + + template < class Operator, class Vector, class Preconditioner, class Matrix, class Real > @@ -118,33 +148,3 @@ GMRES(const Operator &A, Vector &x, const Vector &b, return 1; } - -#include - - -template -void GeneratePlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn) -{ - if (dy == 0.0) { - cs = 1.0; - sn = 0.0; - } else if (abs(dy) > abs(dx)) { - Real temp = dx / dy; - sn = 1.0 / sqrt( 1.0 + temp*temp ); - cs = temp * sn; - } else { - Real temp = dy / dx; - cs = 1.0 / sqrt( 1.0 + temp*temp ); - sn = temp * cs; - } -} - - -template -void ApplyPlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn) -{ - Real temp = cs * dx + sn * dy; - dy = -sn * dx + cs * dy; - dx = temp; -} -