Thyra_VectorStdOpsTester.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef THYRA_VECTOR_STD_OPS_TESTER_HPP
00030 #define THYRA_VECTOR_STD_OPS_TESTER_HPP
00031 
00032 #include "Thyra_VectorStdOpsTesterDecl.hpp"
00033 #include "Thyra_TestingTools.hpp"
00034 #include "Teuchos_arrayArg.hpp"
00035 
00036 //#define THYRA_VECTOR_STD_OPS_TESTER_DUMP
00037 
00038 #ifdef THYRA_VECTOR_STD_OPS_TESTER_DUMP
00039 #  include "RTOpPack_SPMD_apply_op_decl.hpp"
00040 #  include "Thyra_SpmdVectorBase.hpp"
00041 #endif // THYRA_VECTOR_STD_OPS_TESTER_DUMP
00042 
00043 namespace Thyra {
00044 
00045 // VectorStdOpsTesterComparable (using partial specialization to only do tests in some cases)
00046 
00047 template <bool isComparable, class Scalar>
00048 class VectorStdOpsTesterComparable {
00049 public:
00050   static bool checkComparableStdOps(
00051     const VectorSpaceBase<Scalar>                                 &vecSpc
00052     ,VectorBase<Scalar>                                           *z
00053     ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &error_tol
00054     ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &warning_tol
00055     ,std::ostream                                                 *out
00056     ,const bool                                                   &dumpAll
00057     )
00058     {
00059       return Teuchos::ScalarTraits<Scalar>::ThisShouldNotCompile();
00060     }
00061 };
00062 
00063 template <class Scalar>
00064 class VectorStdOpsTesterComparable<false,Scalar> {
00065 public:
00066   static bool checkComparableStdOps(
00067     const VectorSpaceBase<Scalar>                                 &vecSpc
00068     ,VectorBase<Scalar>                                           *z
00069     ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &error_tol
00070     ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &warning_tol
00071     ,std::ostream                                                 *out
00072     ,const bool                                                   &dumpAll
00073     )
00074     {
00075       if(out) *out << "\nThis scalar type does not support comparable operations so we can not test min(), max() and other such functions.\n";
00076       return true;
00077     }
00078 };
00079 
00080 template <class Scalar>
00081 class VectorStdOpsTesterComparable<true,Scalar> {
00082 public:
00083   static bool checkComparableStdOps(
00084     const VectorSpaceBase<Scalar>                                 &vecSpc
00085     ,VectorBase<Scalar>                                           *z
00086     ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &error_tol
00087     ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &warning_tol
00088     ,std::ostream                                                 *out
00089     ,const bool                                                   &dumpAll
00090     )
00091     {
00092       typedef Teuchos::ScalarTraits<Scalar> ST;
00093 
00094       bool success = true, result;
00095       
00096       if(out) *out << "\nTesting comparable operations ...\n";
00097       
00098       const Scalar scalarSmall(1e-5), scalarMedium(2.0), scalarLarge(100.0);
00099       if(out) *out << "\nassign(&*z,"<<scalarMedium<<");\n";
00100       assign(&*z,Scalar(scalarMedium));
00101       if(out && dumpAll) *out << "\nz =\n" << *z;
00102       if(out) *out << "\nset_ele(0,"<<scalarSmall<<",&*z);\n";
00103       set_ele(0,scalarSmall,&*z);
00104       if(out && dumpAll) *out << "\nz =\n" << *z;
00105       if(out) *out << "\nset_ele(1,"<<scalarLarge<<",&*z);\n";
00106       set_ele(1,scalarLarge,&*z);
00107       if(out && dumpAll) *out << "\nz =\n" << *z;
00108       if(out) *out << "\nset_ele(vecSpc.dim()-2,"<<scalarSmall<<",&*z);\n";
00109       set_ele(vecSpc.dim()-2,scalarSmall,&*z);
00110       if(out && dumpAll) *out << "\nz =\n" << *z;
00111       if(out) *out << "\nset_ele(vecSpc.dim()-1,"<<scalarLarge<<",&*z);\n";
00112       set_ele(vecSpc.dim()-1,scalarLarge,&*z);
00113       if(out && dumpAll) *out << "\nz =\n" << *z;
00114 
00115       Scalar minEle; Index minIndex;
00116       Scalar maxEle; Index maxIndex;
00117 
00118       if(!testRelErr<Scalar>(
00119            "min(*z)",min(*z),"scalarSmall",scalarSmall
00120            ,"error_tol",error_tol,"warning_tol",warning_tol,out
00121            )
00122         ) success=false;
00123 
00124       if(out) *out << "\nmin(*z,&minEle,&minIndex);\n";
00125       minEle = ST::zero(); minIndex = 0;
00126       min(*z,&minEle,&minIndex);
00127       if(!testRelErr<Scalar>(
00128            "minEle",minEle,"scalarSmall",scalarSmall
00129            ,"error_tol",error_tol,"warning_tol",warning_tol,out
00130            )
00131         ) success=false;
00132       result = minIndex == 0;
00133       if(out) *out << "\nminIndex = " << minIndex << " == 0 ? " << passfail(result) << std::endl;
00134       if(!result) success = false;
00135 
00136       if(out) *out << "\nminGreaterThanBound(*z,"<<scalarMedium<<",&minEle,&minIndex);\n";
00137       minEle = ST::zero(); minIndex = 0;
00138       minGreaterThanBound(*z,scalarMedium,&minEle,&minIndex);
00139       if(!testRelErr<Scalar>(
00140            "minEle",minEle,"scalarLarge",scalarLarge
00141            ,"error_tol",error_tol,"warning_tol",warning_tol,out
00142            )
00143         ) success=false;
00144       result = minIndex == 1;
00145       if(out) *out << "\nminIndex = " << minIndex << " == 1 ? " << passfail(result) << std::endl;
00146       if(!result) success = false;
00147 
00148       if(out) *out << "\nminGreaterThanBound(*z,"<<scalarLarge<<",&minEle,&minIndex);\n";
00149       minEle = ST::zero(); minIndex = 0;
00150       minGreaterThanBound(*z,scalarLarge,&minEle,&minIndex);
00151       result = minIndex < 0;
00152       if(out) *out << "\nminIndex = " << minIndex << " < 0 ? " << passfail(result) << std::endl;
00153       if(!result) success = false;
00154     
00155       if(!testRelErr<Scalar>(
00156            "max(*z)",max(*z),"scalarLarge",scalarLarge
00157            ,"error_tol",error_tol,"warning_tol",warning_tol,out)
00158         ) success=false;
00159 
00160       if(out) *out << "\nmax(*z,&maxEle,&maxIndex);\n";
00161       maxEle = ST::zero(); maxIndex = 0;
00162       max(*z,&maxEle,&maxIndex);
00163       if(!testRelErr<Scalar>(
00164            "maxEle",maxEle,"scalarLarge",scalarLarge
00165            ,"error_tol",error_tol,"warning_tol",warning_tol,out)
00166         ) success=false;
00167       result = maxIndex == 1;
00168       if(out) *out << "\nmaxIndex = " << maxIndex << " == 1 ? " << passfail(result) << std::endl;
00169       if(!result) success = false;
00170 
00171       if(out) *out << "\nmaxLessThanBound(*z,"<<scalarMedium<<",&maxEle,&maxIndex);\n";
00172       maxEle = ST::zero(); maxIndex = 0;
00173       maxLessThanBound(*z,scalarMedium,&maxEle,&maxIndex);
00174       if(!testRelErr<Scalar>(
00175            "maxEle",maxEle,"scalarSmall",scalarSmall
00176            ,"error_tol",error_tol,"warning_tol",warning_tol,out)
00177         ) success=false;
00178       result = maxIndex == 0;
00179       if(out) *out << "\nmaxIndex = " << maxIndex << " == 0 ? " << passfail(result) << std::endl;
00180       if(!result) success = false;
00181 
00182       if(out) *out << "\nmaxLessThanBound(*z,"<<scalarSmall<<",&maxEle,&maxIndex);\n";
00183       maxEle = ST::zero(); maxIndex = 0;
00184       maxLessThanBound(*z,scalarSmall,&maxEle,&maxIndex);
00185       result = ( maxIndex < 0 );
00186       if(out) *out << "\nmaxIndex = " << maxIndex << " < 0 ? " << passfail(result) << std::endl;
00187       if(!result) success = false;
00188       
00189       return success;
00190     }
00191 };
00192 
00193 // VectorStdOpsTester
00194 
00195 
00196 template <class Scalar>
00197 VectorStdOpsTester<Scalar>::VectorStdOpsTester(
00198   const ScalarMag    &warning_tol
00199   ,const ScalarMag   &error_tol
00200   )
00201   :warning_tol_(warning_tol)
00202   ,error_tol_(error_tol)
00203 {}
00204 
00205 template <class Scalar>
00206 bool VectorStdOpsTester<Scalar>::checkStdOps(
00207   const VectorSpaceBase<Scalar>    &vecSpc
00208   ,std::ostream                    *out
00209   ,const bool                      &dumpAll
00210   )
00211 {
00212   using Teuchos::arrayArg;
00213   typedef Teuchos::ScalarTraits<Scalar> ST;
00214 
00215   if(out)
00216     *out << "\n*** Entering VectorStdOpsTester<"<<ST::name()<<">::checkStdOps(...) ...\n"
00217          << "using a \'" << vecSpc.description() << "\' object ...\n";
00218 
00219   bool success = true;
00220   if(out) *out << "\nvecSpc.dim() = " << vecSpc.dim() << std::endl;
00221 
00222   if(out) *out << "\nCreating vectors v1, v2, v3, v4, x and z ...\n";
00223   Teuchos::RefCountPtr<VectorBase<Scalar> >
00224     v1 = createMember(vecSpc),
00225     v2 = createMember(vecSpc),
00226     v3 = createMember(vecSpc),
00227     v4 = createMember(vecSpc),
00228     x  = createMember(vecSpc),
00229     z  = createMember(vecSpc);
00230 
00231   if(out) *out << "\nassign(&*v1,-2.0);\n";
00232   assign(&*v1,Scalar(-2.0));
00233   if(out) *out << "\nassign(&*v2,-3.0);\n";
00234   assign(&*v2,Scalar(-3.0));
00235   if(out) *out << "\nassign(&*v3,-4.0);\n";
00236   assign(&*v3,Scalar(-4.0));
00237 
00238   if(!testRelErr<Scalar>(
00239        "norm_inf(*v1)",norm_inf(*v1),"2.0",Scalar(2.0)
00240        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out)
00241     ) success=false;
00242 
00243   if(!testRelErr<Scalar>(
00244        "norm_2(*v1)",norm_2(*v1),"2.0*sqrt(vecSpc.dim())",Scalar(2.0)*ST::squareroot(vecSpc.dim())
00245        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out)
00246     ) success=false;
00247 
00248   if(!testRelErr<Scalar>(
00249        "norm_1(*v1)",norm_1(*v1),"2.0*vecSpc.dim()",Scalar(2.0)*Scalar(vecSpc.dim())
00250        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out)
00251     ) success=false;
00252   
00253   if(out) *out << "\nabs(&*z,*v1);\n";
00254   abs(&*z,*v1);
00255 #ifdef THYRA_VECTOR_STD_OPS_TESTER_DUMP
00256   SpmdVectorBase<Scalar>::show_dump = true;
00257   RTOpPack::show_spmd_apply_op_dump = true;
00258 #endif // THYRA_VECTOR_STD_OPS_TESTER_DUMP
00259   if(!testRelErr<Scalar>(
00260        "sum(*z)",sum(*z),"2.0*vecSpc.dim()",Scalar(2.0)*Scalar(vecSpc.dim())
00261        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out)
00262     ) success=false;
00263 #ifdef THYRA_VECTOR_STD_OPS_TESTER_DUMP
00264   SpmdVectorBase<Scalar>::show_dump = false;
00265   RTOpPack::show_spmd_apply_op_dump = false;
00266 #endif // THYRA_VECTOR_STD_OPS_TESTER_DUMP
00267   
00268   if(out) *out << "\nreciprocal(&*z,*v1);\n";
00269   reciprocal(&*z,*v1);
00270   if(!testRelErr<Scalar>(
00271        "sum(*z)",sum(*z),"-0.5*vecSpc.dim()",Scalar(-0.5)*Scalar(vecSpc.dim())
00272        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out)
00273     ) success=false;
00274 
00275   if(out) *out << "\nlinear_combination(2,{0.5,0.25},{&*v1,&*v2},0.0,&*z);\n";
00276   linear_combination(2,arrayArg<Scalar>(0.5,0.25)(),arrayArg<const VectorBase<Scalar>*>(&*v1,&*v2)(),Scalar(0.0),&*z);
00277   if(!testRelErr<Scalar>(
00278        "sum(*z)",sum(*z),"(-0.5*2.0-0.25*3.0)*vecSpc.dim()",Scalar(-0.5*2.0-0.25*3.0)*Scalar(vecSpc.dim())
00279        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out)
00280     ) success=false;
00281 
00282   if(out) *out << "\nassign(&*z,2.0);\n";
00283   assign(&*z,Scalar(2.0));
00284   if(out) *out << "\nlinear_combination(3,{0.5,0.25,0.125},{&*v1,&*v2,&*v2},0.5,&*z);\n";
00285   linear_combination(3,arrayArg<Scalar>(0.5,0.25,0.125)(),arrayArg<const VectorBase<Scalar>*>(&*v1,&*v2,&*v3)(),Scalar(0.5),&*z);
00286   if(!testRelErr<Scalar>(
00287        "sum(*z)",sum(*z)
00288        ,"(0.5*2.0-0.5*2.0-0.25*3.0-0.125*4.0)*vecSpc.dim()",Scalar(0.5*2.0-0.5*2.0-0.25*3.0-0.125*4.0)*Scalar(vecSpc.dim())
00289        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00290        )
00291     ) success=false;
00292 
00293   if(out) *out << "\nassign(&*z,2.0);\n";
00294   assign(&*z,Scalar(2.0));
00295   if(!testRelErr<Scalar>(
00296        "norm_2(*z,*v2)",norm_2(*z,*v2)
00297        ,"sqrt(2.0*3.0*3.0*vecSpc.dim())",ST::magnitude(ST::squareroot(Scalar(2.0*3.0*3.0)*Scalar(vecSpc.dim())))
00298        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00299        )
00300     ) success=false;
00301 
00302   if(!VectorStdOpsTesterComparable<ST::isComparable,Scalar>::checkComparableStdOps(
00303        vecSpc,&*z,error_tol(),warning_tol(),out,dumpAll)
00304     ) success=false;
00305 
00306   // ToDo: Add tests for *all* standard operators!
00307   
00308   Scalar alpha;
00309   Scalar beta;
00310 
00311   // Test Vt_S
00312   if(out) *out << "\nTesting Vt_S(&*z,alpha) ...\n";
00313   v1  = createMember(vecSpc);
00314   v2  = createMember(vecSpc);
00315 /* RAB: I commented this out since it was not setting
00316  * (real,imag) but just the real part.
00317  */
00318 /*
00319   if (ST::isComplex)
00320     alpha = (Scalar(1.2345), Scalar(1.2345));
00321   else
00322     alpha = Scalar(1.2345);
00323 */
00324   alpha = Scalar(1.2345);
00325   seed_randomize<Scalar>(12345);
00326   randomize(Scalar(-ST::one()),ST::one(),&*v1);
00327   V_V(&*v2,*v1);
00328   Vt_S(&*v1,alpha);
00329   Scalar norm_alpha_v1 = norm_2(*v1);
00330   Scalar alpha_norm_v1 = ST::magnitude(alpha)*norm_2(*v2);
00331   if(!testMaxErr<Scalar>(
00332        "norm_alpha_v1 - alpha_norm_v1",ST::magnitude(norm_alpha_v1-alpha_norm_v1)
00333        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00334        )
00335     ) success=false;
00336   
00337   // Test V_StV
00338   if(out) *out << "\nTesting V_StV(&*z,alpha,*v) ...\n";
00339   v1  = createMember(vecSpc);
00340   v2  = createMember(vecSpc);
00341   z   = createMember(vecSpc);
00342   alpha = Scalar(-1.2345);
00343   seed_randomize<Scalar>(12345);
00344   randomize(Scalar(-ST::one()),ST::one(),&*v1);
00345   V_StV(&*v2,alpha,*v1);
00346   Vt_S(&*v1,alpha);
00347   V_V(&*z,*v1);
00348   Vp_V(&*z,*v2,Scalar(-ST::one()));
00349   if(!testMaxErr<Scalar>(
00350        "norm_2(*z)",norm_2(*z)
00351        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00352        )
00353     ) success=false;
00354 
00355 
00356   // Test Vp_StV
00357   if(out) *out << "\nTesting Vp_StV(&*z,alpha,*v) ...\n";
00358   v1  = createMember(vecSpc);
00359   v2  = createMember(vecSpc);
00360   v3  = createMember(vecSpc);
00361   z   = createMember(vecSpc);
00362   alpha = Scalar(-1.2345);
00363   seed_randomize<Scalar>(12345);
00364   randomize(Scalar(-ST::one()),ST::one(),&*v1); // v1 = rand
00365   randomize(Scalar(-ST::one()),ST::one(),&*v2); // v2 = rand
00366   V_V(&*v3,*v1); // v3 = v1
00367   Vp_StV(&*v1,alpha,*v2); // v1 += alpha*v2
00368   V_StV(&*z,alpha,*v2); // z = alpha*v2
00369   Vp_V(&*z,*v3); // z += v3
00370   V_V(&*v3,*v1); // v3 = v1
00371   Vp_V(&*v3,*z,Scalar(-ST::one())); // v3 -= z
00372   if(!testMaxErr<Scalar>(
00373        "norm_2(*v3)",norm_2(*v3)
00374        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00375        )
00376     ) success=false;
00377   
00378   // Test ele_wise_prod
00379   if(out) *out << "\nTesting ele_wise_prod(alpha,*v1, *v2, &*z) ...\n";
00380   v1  = createMember(vecSpc);
00381   v2  = createMember(vecSpc);
00382   v3  = createMember(vecSpc);
00383   z   = createMember(vecSpc);
00384   alpha = Scalar(-1.2345);
00385   seed_randomize<Scalar>(12345);
00386   randomize(Scalar(-ST::one()),ST::one(),&*v1); // v1 = rand
00387   randomize(Scalar(-ST::one()),ST::one(),&*v2); // v2 = rand
00388   randomize(Scalar(-ST::one()),ST::one(),&*v3); // v3 = rand
00389   V_V(&*v4, *v1); // v4 = v1
00390   V_V(&*z, *v2); // z = v2
00391   ele_wise_prod(alpha, *v2, *v3, &*v1); // v1 += alpha * v2 * v3
00392   ele_wise_prod_update(alpha, *v3, &*z); // z *= alpha * v3
00393   Vp_V(&*z, *v4); // z += v4
00394   V_V(&*v2, *v1); // v2 = v1
00395   Vp_V(&*v2, *z, Scalar(-ST::one())); // v2 -= z
00396   if(!testMaxErr<Scalar>(
00397        "norm_2(*v2)",norm_2(*v2)
00398        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00399        )
00400     ) success=false;
00401 
00402   // Test Vt_StV
00403   if(out) *out << "\nTesting Vt_StV(&*z, alpha, *v) ...\n";
00404   v1  = createMember(vecSpc);
00405   v2  = createMember(vecSpc);
00406   v3  = createMember(vecSpc);
00407   z   = createMember(vecSpc);
00408   alpha = Scalar(-1.2345);
00409   seed_randomize<Scalar>(12345);
00410   randomize(Scalar(-ST::one()),ST::one(),&*v1); // v1 = rand
00411   randomize(Scalar(-ST::one()),ST::one(),&*v2); // v2 = rand
00412   V_V(&*v3,*v1); // v3 = v1
00413   Vt_StV(&*v1,alpha,*v2); // v1 *= alpha*v2
00414   V_S(&*z,ST::zero()); // z = 0
00415   Vp_StVtV(&*z,alpha,*v3,*v2); // z += alpha*v3*v2
00416   V_V(&*v2,*v1); // v2 = v1
00417   Vp_V(&*v2,*z,Scalar(-ST::one())); // v2 -= z
00418   if(!testMaxErr<Scalar>(
00419        "norm_2(*v2)",norm_2(*v2)
00420        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00421        )
00422     ) success=false;
00423 
00424   // Test V_StVpV
00425   if(out) *out << "\nTesting V_StVpV(&*z,alpha,*v1,*v2) ...\n";
00426   v1 = createMember(vecSpc);
00427   v2 = createMember(vecSpc);
00428   v3 = createMember(vecSpc);
00429   x  = createMember(vecSpc);
00430   z  = createMember(vecSpc);
00431   alpha = Scalar(1.2345);
00432   seed_randomize<Scalar>(12345);
00433   randomize(Scalar(Scalar(-10)*ST::one()),Scalar(Scalar(10)*ST::one()),&*v1);
00434   randomize(Scalar(Scalar(-10)*ST::one()),Scalar(Scalar(10)*ST::one()),&*v2);
00435   V_StVpV(&*v3,alpha,*v1,*v2);
00436   V_V(&*z,*v1);
00437   Vp_V(&*z,*v2,alpha);
00438   V_V(&*x,*v3);
00439   Vp_V(&*x,*z,Scalar(-ST::one()));
00440   if(!testMaxErr<Scalar>(
00441        "norm_2(*x)",norm_2(*x)
00442        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00443        )
00444     ) success=false;
00445   
00446   // Test V_StVpStV
00447   if(out) *out << "\nTesting V_StVpStV(&*z,alpha,*v1,beta,*v2) ...\n";
00448   v1 = createMember(vecSpc);
00449   v2 = createMember(vecSpc);
00450   v3 = createMember(vecSpc);
00451   x  = createMember(vecSpc);
00452   z  = createMember(vecSpc);
00453   alpha = Scalar(1.2345);
00454   beta = Scalar(5.4321);
00455   seed_randomize<Scalar>(12345);
00456   randomize(Scalar(Scalar(-10)*ST::one()),Scalar(Scalar(10)*ST::one()),&*v1);
00457   randomize(Scalar(Scalar(-10)*ST::one()),Scalar(Scalar(10)*ST::one()),&*v2);
00458   V_StVpStV(&*v3,alpha,*v1,beta,*v2);
00459   V_StV(&*z,alpha,*v1);
00460   Vp_StV(&*z,beta,*v2);
00461   V_V(&*x,*v3);
00462   Vp_V(&*x,*z,Scalar(-ST::one()));
00463   if(!testMaxErr<Scalar>(
00464        "norm_2(*x)",norm_2(*x)
00465        ,"10*error_tol",ScalarMag(ScalarMag(10)*error_tol()),"warning_tol",warning_tol(),out
00466        )
00467     ) success=false;
00468 
00469   // Test Vp_V
00470   if(out) *out << "\nTesting Vp_V(&*v1,*v2,beta) ...\n";
00471   v1 = createMember(vecSpc);
00472   v2 = createMember(vecSpc);
00473   v3 = createMember(vecSpc);
00474   x  = createMember(vecSpc);
00475   z  = createMember(vecSpc);
00476   alpha = Scalar(-2.0);
00477   beta = Scalar(10.0);
00478   V_S(&*v1,alpha);
00479   seed_randomize<Scalar>(12345);
00480   randomize(Scalar(Scalar(-10)*ST::one()),Scalar(Scalar(10)*ST::one()),&*v2);
00481   Vp_V(&*v1,*v2,beta); 
00482   V_S(&*v3,alpha);
00483   V_StVpV(&*z,beta,*v3,*v2);
00484   V_StVpV(&*x,Scalar(-ST::one()),*z,*v1);
00485   if(!testMaxErr<Scalar>(
00486        "norm_2(*x)",norm_2(*x)
00487        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00488        )
00489     ) success=false;
00490   
00491   // Test Vp_V
00492   if(out) *out << "\nTesting Vp_V(&*v1,*v2) ...\n";
00493   v1 = createMember(vecSpc);
00494   v2 = createMember(vecSpc);
00495   v3 = createMember(vecSpc);
00496   x  = createMember(vecSpc);
00497   z  = createMember(vecSpc);
00498   alpha = Scalar(-2.0);
00499   V_S(&*v1,alpha);
00500   seed_randomize<Scalar>(12345);
00501   randomize(Scalar(Scalar(-10)*ST::one()),Scalar(Scalar(10)*ST::one()),&*v2);
00502   Vp_V(&*v1,*v2); 
00503   V_S(&*v3,alpha);
00504   V_StVpV(&*z,ST::one(),*v3,*v2);
00505   V_StVpV(&*x,Scalar(-ST::one()),*z,*v1);
00506   if(!testMaxErr<Scalar>(
00507        "norm_2(*x)",norm_2(*x)
00508        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00509        )
00510     ) success=false;
00511 
00512   // Test V_S
00513   if(out) *out << "\nTesting V_S(&*v1,alpha) ...\n";
00514   v1 = createMember(vecSpc);
00515   v2 = createMember(vecSpc);
00516   z  = createMember(vecSpc);
00517   alpha = Scalar(1.2345);
00518   assign(&*v1,alpha);
00519   V_S(&*v2,alpha);
00520   V_StVpV(&*z,Scalar(-ST::one()),*v1,*v2);
00521   if(!testMaxErr<Scalar>(
00522        "norm_2(*z)",norm_2(*z)
00523        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00524        )
00525     ) success=false;
00526 
00527   
00528   // Test V_V
00529   if(out) *out << "\nTesting V_V(&*v1,*v2) ...\n";
00530   v1 = createMember(vecSpc);
00531   v2 = createMember(vecSpc);
00532   z  = createMember(vecSpc);
00533   seed_randomize<Scalar>(12345);
00534   randomize(Scalar(Scalar(-10)*ST::one()),Scalar(Scalar(10)*ST::one()),&*v1);
00535   V_V(&*v2,*v1);
00536   V_StVpV(&*z,Scalar(-ST::one()),*v1,*v2);
00537   if(!testMaxErr<Scalar>(
00538        "norm_2(*z)",norm_2(*z)
00539        ,"error_tol",error_tol(),"warning_tol",warning_tol(),out
00540        )
00541     ) success=false;
00542   
00543 
00544 
00545   if(out) *out
00546     << "\n*** Leaving VectorStdOpsTester<"<<ST::name()<<">::checkStdOps(...) ...\n";
00547 
00548   return success;
00549 
00550 }
00551 
00552 } // namespace Thyra
00553 
00554 #endif // THYRA_VECTOR_STD_OPS_TESTER_HPP

Generated on Thu Sep 18 12:33:03 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1