next up previous [pdf]

Next: Operators Up: Operator-based object-oriented solvers Previous: Operator-based object-oriented solvers

Vector class

The solver writer doesn't need to know anything about $ \bf L$ other than how to apply it and its adjoint. In fact, the solver writer doesn't need to know much about $ \bf m$ or $ \bf d$ . The steepest descent approach described above involves only three mathematical operations. In order to find the best scaling factor $ \bf\Delta r$ , we need to calculate a dot product. In order to update the model and the residual, we will need to scale $ \bf\Delta r$ and add it to $ \bf r$ . We can define the interface for calling the forward of $ \bf L$ as
call lop (logical add, vec m, vec d)
If the vector class has the ability to perform the add, scale, and dot product functions, we can begin to write a generic solver. Two more initialization functions are needed in the vector class. We need to be able to create the gradient vector before we can apply the adjoint. As a result, we need to be able to create a vector with the same number of elements as the model. Put another way, we need to clone the model. We also need to be able to zero this vector, or set the vector to some value. It is also useful to seperate the space a vector exists in and the storage mechanism. The vector space contains thing like whether we are dealing irregular or regular dataset, the number of samples, and the locations of the samples (for example the origin and sampling of the axes). The table below gives a list of the abstract vector class components.
Function Purpose  
add(vector) Add another vector to current vector  
  ($ x=x+y$ ).  
scale(real) Scale the vector ($ x=x*a$ ).  
scale_add(scale1,vector,scale) Add another vector to current vector  
  ($ x=ax+by$ ).  
scale(vector) Calculate the dot product with another  
  vector (return $ sum_i a(i)*b(i)$ .  
set(real) Set the value of a vector ($ x=v$ ).  
mult(real)) Multiply a vector with another vector  
  ($ y=y*x$ ).  
clone(vec) Create another vector of the same type  
  with the same values.  
clone_space(vec) Create another vector of the same type  
  with no storage mechanism.  
check_same(vec) See if two of vector of the same type and exist  
  in the same space.  
alloc() Create a vector from a vector space.  
info(character(len=*),integer) Provide user specified debugging information.  

From this base class I inherit a real vector class and then 1-D to 7-D real from this class (Figure1). Further non-uniform classes would inherit form the real vector class while out-of-core classes would come directly from the vector class.

inher
inher
Figure 1.
Inheritance class for vectors. The 1-D to 7-D real vectors are inheriting from a real vector class which is inherited from the virtual vector class.
[pdf] [png]


next up previous [pdf]

Next: Operators Up: Operator-based object-oriented solvers Previous: Operator-based object-oriented solvers

2011-09-13