proj home

Files   Classes   Functions   Hierarchy  

funcstate< X > Class Template Reference

Function with state. More...

#include <funcstate.h>

Inheritance diagram for funcstate< X >:
Collaboration diagram for funcstate< X >:

List of all members.

Public Member Functions

 funcstate ()
 Bad state.
 funcstate (uintc dim_, boolc mem_=true)
 Default allocates memory for state.
virtual X const operator() ()=0
 Evaluate the function and store in xi[dim].
virtual ~funcstate ()
 Free memory if allocated.
void set_position (X *xi_)
 Initialize xi[0.
void set_positionvalue (X *xi_)
 dim+1 vector.
X const fnvalue ()
 Get the last calculated function value.

Public Attributes

uint counter
 To count function evaluations.
uint dim
 Dimension.
X * xi
 Function arguments and function value, dim+1 in length.
bool mem
 Is the memory managed?


Detailed Description

template<typename X>
class funcstate< X >

Function with state.

The structure of the state xi includes one extra dimension - the functions value, so passing this function around also passes the states value.

Definition at line 18 of file funcstate.h.


Constructor & Destructor Documentation

template<typename X>
funcstate< X >::funcstate (  )  [inline]

Bad state.

Definition at line 32 of file funcstate.h.

00033     : counter(0), dim(0), xi(0), mem(false) {}

template<typename X >
funcstate< X >::funcstate ( uintc  dim_,
boolc  mem_ = true 
) [inline]

Default allocates memory for state.

Definition at line 103 of file funcstate.h.

References funcstate< X >::dim, funcstate< X >::mem, and funcstate< X >::xi.

00104   : counter(0), dim(dim_), mem(mem_)
00105 {
00106   if (mem==true)
00107   {
00108     assert(dim!=0);
00109     xi = new X[dim+1];
00110   }
00111 }

template<typename X >
funcstate< X >::~funcstate (  )  [inline, virtual]

Free memory if allocated.

Definition at line 128 of file funcstate.h.

References funcstate< X >::mem, and funcstate< X >::xi.

00129 {
00130   if (mem)
00131     delete[] xi;
00132   xi=0;  
00133 }


Member Function Documentation

template<typename X>
X const funcstate< X >::fnvalue (  )  [inline]

Get the last calculated function value.

Definition at line 52 of file funcstate.h.

Referenced by pathlinesegtest::unittest01().

00053     { return xi[dim]; }

template<typename X>
virtual X const funcstate< X >::operator() (  )  [pure virtual]

Evaluate the function and store in xi[dim].

Implemented in pathlinesegvec, prob_f001, and prob_f002.

template<typename X>
void funcstate< X >::set_position ( X *  xi_  )  [inline]

Initialize xi[0.

.n-1].

Definition at line 114 of file funcstate.h.

References funcstate< X >::dim, and funcstate< X >::xi.

00115 {
00116   for (uint i=0; i<dim; ++i)
00117     xi[i] = xi_[i];
00118 }

template<typename X>
void funcstate< X >::set_positionvalue ( X *  xi_  )  [inline]

dim+1 vector.

Definition at line 121 of file funcstate.h.

References funcstate< X >::dim, and funcstate< X >::xi.

00122 {
00123   for (uint i=0; i<=dim; ++i)
00124     xi[i] = xi_[i];
00125 }


Member Data Documentation

template<typename X>
uint funcstate< X >::counter

To count function evaluations.

Definition at line 23 of file funcstate.h.

Referenced by minexpdimtest::test01(), minexpdimtest::test02(), minexpdimtest::test03(), minexpdimtest::test04(), and minexpdimtest::test05().

template<typename X>
uint funcstate< X >::dim

template<typename X>
bool funcstate< X >::mem

Is the memory managed?

Definition at line 45 of file funcstate.h.

Referenced by funcstate< X >::funcstate(), and funcstate< X >::~funcstate().

template<typename X>
X* funcstate< X >::xi


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

Generated on Fri Mar 4 00:49:57 2011 for Chelton Evans Source by  doxygen 1.5.8