00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "NOX_Epetra_VectorSpace_ScaledL2.H"
00043 #include "Epetra_Vector.h"
00044
00045 NOX::Epetra::VectorSpaceScaledL2::
00046 VectorSpaceScaledL2(const Teuchos::RCP<NOX::Epetra::Scaling>& s,
00047 NOX::Epetra::Scaling::ScaleType st) :
00048 scalingPtr(s),
00049 scaleType(st)
00050 {
00051
00052 }
00053
00054 NOX::Epetra::VectorSpaceScaledL2::~VectorSpaceScaledL2()
00055 {
00056
00057 }
00058
00059 double NOX::Epetra::VectorSpaceScaledL2::
00060 innerProduct(const Epetra_Vector& a, const Epetra_Vector& b) const
00061 {
00062 if ( Teuchos::is_null(tmpVectorPtr) )
00063 tmpVectorPtr = Teuchos::rcp(new Epetra_Vector(a));
00064
00065 *tmpVectorPtr = a;
00066
00067 if (scaleType == NOX::Epetra::Scaling::Left) {
00068
00069 scalingPtr->applyLeftScaling(*tmpVectorPtr, *tmpVectorPtr);
00070 scalingPtr->applyLeftScaling(*tmpVectorPtr, *tmpVectorPtr);
00071 }
00072 else {
00073
00074 scalingPtr->applyRightScaling(*tmpVectorPtr, *tmpVectorPtr);
00075 scalingPtr->applyRightScaling(*tmpVectorPtr, *tmpVectorPtr);
00076 }
00077
00078 double dot;
00079 tmpVectorPtr->Dot(b, &dot);
00080 return dot;
00081 }
00082
00083 double NOX::Epetra::VectorSpaceScaledL2::
00084 norm(const Epetra_Vector& a, NOX::Abstract::Vector::NormType type) const
00085 {
00086 if ( Teuchos::is_null(tmpVectorPtr) )
00087 tmpVectorPtr = Teuchos::rcp(new Epetra_Vector(a));
00088
00089 *tmpVectorPtr = a;
00090
00091 if (scaleType == NOX::Epetra::Scaling::Left) {
00092 scalingPtr->applyLeftScaling(*tmpVectorPtr, *tmpVectorPtr);
00093 }
00094 else {
00095 scalingPtr->applyRightScaling(*tmpVectorPtr, *tmpVectorPtr);
00096 }
00097
00098 double value;
00099 switch (type) {
00100 case NOX::Abstract::Vector::MaxNorm:
00101 tmpVectorPtr->NormInf(&value);
00102 break;
00103 case NOX::Abstract::Vector::OneNorm:
00104 tmpVectorPtr->Norm1(&value);
00105 break;
00106 case NOX::Abstract::Vector::TwoNorm:
00107 default:
00108 tmpVectorPtr->Norm2(&value);
00109 break;
00110 }
00111 return value;
00112 }