1 #ifndef DEF_COMMON_NOXVECTOR 2 #define DEF_COMMON_NOXVECTOR 6 #include "NOX_Common.H" 7 #include "NOX_Abstract_Vector.H" 8 #include "NOX_Random.H" 10 #include <Eigen/Dense> 11 #include <Eigen/Geometry> 13 template <
unsigned int T_DOF>
14 class NOXVector :
public virtual NOX::Abstract::Vector,
15 public Eigen::Matrix<double,T_DOF,1>
18 static const unsigned int DOF = T_DOF;
26 : Eigen::Matrix<double,T_DOF,1>()
29 template <
typename OtherDerived>
31 : Eigen::Matrix<double,T_DOF,1>(other)
34 template <
typename OtherDerived>
35 NOX::Abstract::Vector&
36 operator= (
const Eigen::MatrixBase<OtherDerived>& other)
37 { this->Eigen::Matrix<double,T_DOF,1>::operator=(other);
return *
this; }
40 template <
typename OtherDerived>
41 NOX::Abstract::Vector&
42 operator+= (
const Eigen::MatrixBase<OtherDerived>& other)
43 { this->Eigen::Matrix<double,T_DOF,1>::operator+=(other);
return *
this; }
50 NOX::Abstract::Vector&
52 { *
this = y.cwiseAbs();
return *
this; }
54 NOX::Abstract::Vector&
55 abs (
const NOX::Abstract::Vector& y)
58 Teuchos::RCP<NOX::Abstract::Vector>
59 clone (NOX::CopyType type=NOX::DeepCopy)
const 61 Teuchos::RCP<NOX::Abstract::Vector> tmp;
72 {
return this->dot(y); }
75 innerProduct (
const NOX::Abstract::Vector& y)
const 78 NOX::Abstract::Vector&
80 { this->setConstant(gamma);
return *
this; }
87 norm (NOX::Abstract::Vector::NormType type=NOX::Abstract::Vector::TwoNorm)
const 92 case NOX::Abstract::Vector::MaxNorm:
93 result = this->Eigen::Matrix<double,T_DOF,1>::maxCoeff();
95 case NOX::Abstract::Vector::OneNorm:
99 case NOX::Abstract::Vector::TwoNorm:
100 result = this->Eigen::Matrix<double,T_DOF,1>::norm();
103 result = this->Eigen::Matrix<double,T_DOF,1>::norm();
112 {
return sqrt(((this->cwiseProduct(*
this)).cwiseProduct(weights)).sum()); }
115 norm (
const NOX::Abstract::Vector& weights)
const 119 print (std::ostream& stream)
const 125 NOX::Abstract::Vector&
126 random (
bool useSeed=
false,
int seed=1)
129 NOX::Random::setSeed(seed);
131 for (
int i=0; i<T_DOF; i++)
132 (*
this)[i] = NOX::Random::number();
140 { this->Eigen::Matrix<double,T_DOF,1>::operator=(y);
return *
this; }
142 NOX::Abstract::Vector&
143 operator= (
const NOX::Abstract::Vector& y)
146 NOX::Abstract::Vector&
148 { *
this = this->cwiseInverse();
return *
this; }
150 NOX::Abstract::Vector&
151 reciprocal (
const NOX::Abstract::Vector& y)
154 NOX::Abstract::Vector&
156 { *
this = (*this)*gamma;
return *
this; }
158 NOX::Abstract::Vector&
160 { *
this = this->cwiseProduct(a);
return *
this; }
162 NOX::Abstract::Vector&
163 scale (
const NOX::Abstract::Vector& a)
166 NOX::Abstract::Vector&
168 { *
this = alpha*a + (*this)*gamma;
return *
this; }
170 NOX::Abstract::Vector&
171 update (
double alpha,
const NOX::Abstract::Vector& a,
double gamma=0.0)
174 NOX::Abstract::Vector&
175 update (
double alpha,
180 { *
this = alpha*a + beta*b + (*this)*gamma;
return *
this; }
182 NOX::Abstract::Vector&
183 update (
double alpha,
184 const NOX::Abstract::Vector& a,
186 const NOX::Abstract::Vector& b,
190 static const unsigned int 195 toNOXVector ( )
const Definition: NOXVector.hpp:14