ParameterVector Class Reference

#include <parameter_vector.h>

List of all members.

Public Member Functions

 ParameterVector ()
 ParameterVector (const std::vector< Number * > &params)
void deep_copy (ParameterVector &target) const
void shallow_copy (ParameterVector &target) const
void value_copy (const ParameterVector &target) const
void clear ()
unsigned int size () const
void resize (unsigned int s)
Numberoperator[] (unsigned int i) const
Number *& operator[] (unsigned int i)
ParameterVectoroperator*= (const Number a)
ParameterVectoroperator+= (const ParameterVector &a)
const ParameterVectoroperator+= (const ParameterVector &a) const

Private Attributes

std::vector< Number * > _params
std::vector< Number_my_data


Detailed Description

Data structure for specifying which Parameters should be independent variables in a parameter sensitivity calculation.

Definition at line 39 of file parameter_vector.h.


Constructor & Destructor Documentation

ParameterVector::ParameterVector (  )  [inline]

Default constructor: "no parameters"

Definition at line 45 of file parameter_vector.h.

00045 {}

ParameterVector::ParameterVector ( const std::vector< Number * > &  params  )  [inline]

Constructor-from-vector-of-Number*: each points to a parameter

Definition at line 50 of file parameter_vector.h.

00050 : _params(params) {}


Member Function Documentation

void ParameterVector::clear (  )  [inline]

Resets to "no parameters"

Definition at line 74 of file parameter_vector.h.

References _params.

00074 { _params.clear(); }

void ParameterVector::deep_copy ( ParameterVector target  )  const

Deep copy constructor: the target will now own new copies of all the parameter values I'm pointing to

Definition at line 34 of file parameter_vector.C.

References _my_data, and _params.

Referenced by ImplicitSystem::qoi_parameter_hessian_vector_product(), ImplicitSystem::weighted_sensitivity_adjoint_solve(), and ImplicitSystem::weighted_sensitivity_solve().

00035 {
00036   const unsigned int Np = this->_params.size();
00037   target._params.resize(Np);
00038   target._my_data.resize(Np);
00039   for (unsigned int i=0; i != Np; ++i)
00040     {
00041       target._params[i] = &target._my_data[i];
00042       target._my_data[i] = *(this->_params[i]);
00043     }
00044 }

ParameterVector & ParameterVector::operator*= ( const Number  a  ) 

Multiplication operator; acts individually on each parameter.

Definition at line 67 of file parameter_vector.C.

References _params.

00068 {
00069   const unsigned int Np = this->_params.size();
00070   for (unsigned int i=0; i != Np; ++i)
00071     *(this->_params[i]) *= a;
00072   return *this;
00073 }

const ParameterVector & ParameterVector::operator+= ( const ParameterVector a  )  const

Addition operator. The parameter vector to be added in must have the same number of values.

Definition at line 77 of file parameter_vector.C.

References _params.

00078 {
00079   const unsigned int Np = this->_params.size();
00080   libmesh_assert(a._params.size() == Np);
00081   for (unsigned int i=0; i != Np; ++i)
00082     *(this->_params[i]) += *(a._params[i]);
00083   return *this;
00084 }

ParameterVector & ParameterVector::operator+= ( const ParameterVector a  ) 

Addition operator. The parameter vector to be added in must have the same number of values.

Definition at line 87 of file parameter_vector.C.

00088 {
00089   (*this) += a;
00090   return *this;
00091 }

Number *& ParameterVector::operator[] ( unsigned int  i  )  [inline]

Returns a reference to a pointer to a parameter value, suitable for repointing it to a different address.

Definition at line 144 of file parameter_vector.h.

References _params.

00145 {
00146   libmesh_assert(_params.size() > i);
00147 
00148   return _params[i];
00149 }

Number * ParameterVector::operator[] ( unsigned int  i  )  const [inline]

Returns a pointer to a parameter value

Definition at line 134 of file parameter_vector.h.

References _params.

00135 {
00136   libmesh_assert(_params.size() > i);
00137 
00138   return _params[i];
00139 }

void ParameterVector::resize ( unsigned int  s  )  [inline]

Sets the number of parameters to be used

Definition at line 84 of file parameter_vector.h.

References _params.

00084 { _params.resize(s); }

void ParameterVector::shallow_copy ( ParameterVector target  )  const

Shallow copy constructor: the target will now point to all the parameter values I'm pointing to

Definition at line 48 of file parameter_vector.C.

References _my_data, and _params.

00049 {
00050   target._my_data.clear();
00051   target._params = this->_params;
00052 }

void ParameterVector::value_copy ( const ParameterVector target  )  const

Value copy method: the target, which should already have as many parameters as I do, will now have those parameters set to my values.

Definition at line 56 of file parameter_vector.C.

References _params.

Referenced by ImplicitSystem::qoi_parameter_hessian_vector_product(), ImplicitSystem::weighted_sensitivity_adjoint_solve(), and ImplicitSystem::weighted_sensitivity_solve().

00057 {
00058   const unsigned int Np = this->_params.size();
00059   libmesh_assert(target._params.size() == Np);
00060 
00061   for (unsigned int i=0; i != Np; ++i)
00062     *(this->_params[i]) = *(target._params[i]);
00063 }


Member Data Documentation

std::vector<Number> ParameterVector::_my_data [private]

Parameters which I own; e.g. as the result of a deep copy

Definition at line 123 of file parameter_vector.h.

Referenced by deep_copy(), and shallow_copy().

std::vector<Number *> ParameterVector::_params [private]

Pointers to parameters which may exist elsewhere

Definition at line 118 of file parameter_vector.h.

Referenced by clear(), deep_copy(), operator*=(), operator+=(), operator[](), resize(), shallow_copy(), size(), and value_copy().


The documentation for this class was generated from the following files:

Site Created By: libMesh Developers
Last modified: November 25 2009 03:44:43.

Hosted By:
SourceForge.net Logo