Skip to main content

NAO


NAO Class NAIrregularDiscreteLine

Overview


An "IrregularDiscreteLine" is a partition of the real line into a number of subintervals. The partitioning is done by placing a number of vertices (not necessarily evenly spaced) on the line:


The resulting grid has n vertices and n-1 edges.

The implementation provides a means of adding points to the discretization, so that the grid can be built up incrementally, or updated.


User's Guide


To use this class, you must include the header file
NAO/IrrDLine.h
and link against library
libNAOBase.a
The following constructors are provided:

The following member functions are available in addition to those provided by the abstract interface NARegion:


Programmer's Guide


The IrregularDiscreteLine keeps an array of doubles which stores the vertices which have been set. When a new point is added, the interval containing the new point is found, and the list shifted to make room for the new point. In this way the list is always kept sorted.

addPoint returns the index of the vertex just added. Note that once other points are added, this index may no longer be valid.

Be careful with the getPointList member function, that returns a pointer to the list of points. If you change the value of the array, the grid will change. If you do not violate the ordering this can be done, but the assumption is that the array is sorted in increasing order, and user beware if the array is changed to violate this assumption. (Is that dire enough?)


Example


The example follows a basic pattern for creating a new object. First several include files are used.
NAO/IrrDLine.h
Contains the definition of the NAIrregularDiscreteLine. We can tell which file to include from the documentation for the NAIrregularDiscreteLine class.
NAO/NADblPt.h
Definition of points with double precision coordinates.
NAO/UTDrMfld.h
The Utilities for drawing manifolds.
NAO/UTGraph.h
The Utilities for graphics (Pause, Clear, Close).

#include <NAO/IrrDLine.h>
#include <NAO/UTDrMfld.h>
#include <NAO/UTGraph.h>
#include <NAO/NADblPt.h>

int main (int argc, char *argv[])
 {
  int i,n;

  NAIrregularDiscreteLine *Line=new NAIrregularDiscreteLine();

  Line->addPoint(0.);
  Line->addPoint(1.);

  n=Line->getNumberOfVertices();
  cout << "There are " << n << " vertices" << endl << flush;
  NAPointOnManifold *x=new NADoublePointOnManifold(1);
  for(i=0;i<n;i++)
   {
    Line->getVertex(i,x);
    cout << " " << i << " " << x->getCoordinate(0).Double() << endl << flush;
   }
  x->unReference();
  n=Line->getNumberOfCells(1);
  cout << "There are " << n << " 1-cells" << endl << flush;
  for(i=0;i<n;i++)
   {
    cout << i << " (" << Line->getCellFace(1,i,0) << "," << Line->getCellFace(1,i,1) << ")" << endl << flush;
   }

  NADraw(Line,"blue");
  NAGraphicsPause();

  Line->addPoint(.3);
  Line->addPoint(.6);
  Line->addPoint(.1);

  n=Line->getNumberOfVertices();
  cout << "There are " << n << " vertices" << endl << flush;
  x=new NADoublePointOnManifold(1);
  for(i=0;i<n;i++)
   {
    Line->getVertex(i,x);
    cout << " " << i << " " << x->getCoordinate(0).Double() << endl << flush;
   }
  x->unReference();
  n=Line->getNumberOfCells(1);
  cout << "There are " << n << " 1-cells" << endl << flush;
  for(i=0;i<n;i++)
   {
    cout << i << " (" << Line->getCellFace(1,i,0) << "," << Line->getCellFace(1,i,1) << ")" << endl << flush;
   }

  NAGraphicsClear();
  NADraw(Line,"blue");
  NAGraphicsPause();

  Line->unReference();
  NAGraphicsClose();

  return(0);
 }

This is what I see when I run this:

There are 2 vertices
 0 0
 1 1
There are 1 1-cells
0 (0,1)
 drawing a discrete 1-Manifold in 1-Space! (IrregularDiscreteLine)
shpause: Hit enter when you are ready to continue. "q" quits.


There are 5 vertices
 0 0
 1 0.1
 2 0.3
 3 0.6
 4 1
There are 4 1-cells
0 (0,1)
1 (1,2)
2 (2,3)
3 (3,4)
 drawing a discrete 1-Manifold in 1-Space! (IrregularDiscreteLine)
shpause: Hit enter when you are ready to continue. "q" quits.


~NATopLevel: Just deleted the last NATopLevel Object
    total TopLevels allocated 7
          PointOnManifolds    6     smartPtr's 0
          Manifolds           1     smartPtr's 0
          FunctionSpaces      0     smartPtr's 0
          Functions           0     smartPtr's 0
          OperatorSpaces      0     smartPtr's 0
          Operators           0     smartPtr's 0
          Algorithms          0     
          Problems            0     
          Lists               0     


Related Classes and Subroutines


The parent of this class:

Siblings of this class:

The NA1dLinearInterpolatedFunction uses this grid to store the domain of the function.


Created: Fri Oct 9 10:38:08 EDT 1998

[Comments | NAO home page ]

[Research home page]

[ IBM home page | Order | Privacy | ContactIBM | Legal ]