bicgstab_kernels_naive.h

Go to the documentation of this file.
00001 #ifndef BICGSTAB_KERNELS_NAIVE_H
00002 #define BICGSTAB_KERNELS_NAIVE_H
00003 #include "chromabase.h"
00004 
00005 
00006 /* The funky kernels used by BiCGStab.
00007    These versions should always work... */
00008 
00009 namespace Chroma { 
00010 
00011   namespace BiCGStabKernels { 
00012 
00013    
00014     template<typename T>
00015       void xymz_normx(T& x, const T& y, const T& z, Double& x_norm,
00016                          const Subset& s)
00017     {
00018       x[s] = y-z;
00019       x_norm = norm2(x,s);
00020     }
00021 
00022     template<typename T, typename C>
00023       void yxpaymabz(T& x, T&y, T&z, const C& a, const C& b, const Subset& s)
00024     {
00025       T tmp;
00026       tmp[s] = y - b*z;
00027       y[s] = x + a*tmp;
00028     }
00029 
00030     template<typename T>
00031       void norm2x_cdotxy(const T&x, const T&y, Double& norm2x, DComplex& cdotxy,  const Subset& s) 
00032       {
00033         norm2x = norm2(x,s);
00034         cdotxy = innerProduct(x,y,s);
00035       }
00036     
00037     template<typename T, typename C>
00038       void xpaypbz(T& x, T& y, T&z, C& a, C& b, const Subset& s)
00039     {
00040       T tmp;
00041       tmp[s] = x + a*y;
00042       x[s] = tmp + b*z;
00043     }
00044     
00045     template<typename T, typename C> 
00046       void xmay_normx_cdotzx(T& x,const T& y, const T& z, C& a, Double& normx, DComplex& cdotzx, const Subset& s) 
00047     {
00048       x[s] -= a*y;
00049       normx = norm2(x,s);
00050       cdotzx = innerProduct(z,x,s);
00051     }
00052 
00053 
00054     template<typename T, typename C>
00055       void cxmay(T& x, const T& y, const C& a, const Subset& s)
00056     {
00057       x[s] -= a*y;
00058     } 
00059 
00060 
00061 
00062     template<typename T, typename C>
00063       inline
00064       void ibicgstab_zvupdates(const T& r, T& z, T &v,
00065                                const T& u, const T& q,
00066                                const C& alpha,
00067                                const C& alpha_rat_beta,
00068                                const C& alpha_delta, 
00069                                const C& beta,
00070                                const C& delta,
00071                                const Subset& s)
00072     {
00073       T tmp;
00074       tmp[s] = alpha_rat_beta*z;
00075       z[s] = tmp  + alpha*r ;
00076       z[s] -= alpha_delta*v;
00077       
00078       tmp = v;
00079       v[s] = u+beta*tmp;
00080       v[s]-= delta*q;
00081     }
00082 
00083     template<typename T, typename C, typename F>
00084       void ibicgstab_stupdates_reduces(const C& alpha,
00085                                        const T& r,
00086                                        const T& u,
00087                                        const T& v,
00088                                        const T& q,
00089                                        const T& r0,
00090                                        const T& f0,
00091                                        T& s,
00092                                        T& t,
00093                                        C& phi,
00094                                        C& pi,
00095                                        C& gamma,
00096                                        C& eta,
00097                                        C& theta,
00098                                        F& kappa,
00099                                        F& rnorm,
00100                                        const Subset& sub)
00101     {
00102       s[sub] = r - alpha*v;
00103       t[sub] = u - alpha*q;
00104 
00105       phi = innerProduct(r0,s,sub);
00106       gamma = innerProduct(f0,s,sub);
00107       pi = innerProduct(r0,q,sub);
00108       eta = innerProduct(f0,t,sub);
00109       theta = innerProduct(t,s,sub);
00110       kappa=norm2(t,sub);
00111       rnorm = norm2(r,sub);
00112     }
00113         
00114     template<typename T, typename C>
00115       void ibicgstab_rxupdate(const C& omega,
00116                               const T& s,
00117                               const T& t,
00118                               const T& z,
00119                               T& r,
00120                               T& x,
00121                               const Subset& sub)
00122     {
00123       r[sub] = s - omega*t;
00124       x[sub] += omega*s;
00125       x[sub] += z;
00126     }
00127                 
00128   }
00129     
00130 
00131 
00132 }
00133 
00134 
00135 
00136 #endif

Generated on Sun Mar 14 04:29:00 2010 for CHROMA by  doxygen 1.4.7