class Table


The class that handles the storage and interpolation of a table of values.

Include file:

#include "scattabl.h"

Source code:

scattabl.cpp

See also:

SCATMECH Home,   dielectric_function,  

Definition of public elements:

class Table : public vector<pair<double,double> >
{
     Table();
     Table(const Table& t);
     Table(const string& filename);
     Table(double singlevalue);
     Table(double *x,double *y,int n);
     virtual ~Table();
     Table& operator=(const Table& s);
     double value(double l) const;
     int read(const string& filename, int ycol=2);
     static Table AskUser(const string& prompt,const string& deflt);
     static Table AskUser(const string& prompt,double deflt);
}

Table()
Table(const Table& t)
Table(const string& filename)
Table(double singlevalue)
Table(double *x,double *y,int n)
Table& operator=(const Table& s)

Class constructor and assignment operator. When called without any arguments, the class is considered uninitialized and an error will occur if a call to value is made. If called with a pointer to a string, the class will be initialized with the contents of the first two columns of the file. If a single double is given, then the table will have a single constant value. If the constructor is called with two pointers to double and an integer value n, then the table will contain n values pointed to by the arrays.

Top of Page

double value(double l) const

Function which returns the value of the table at a particular linearly interpolated point. Successive calls with the same l do not require new searches and interpolations; the previously obtained value is always saved and used if possible. While this function is declared as const, the contractual const is broken to enable this feature. The functionality of the class, however, is not changed by this function.

Top of Page

int read(const string& filename, int ycol=2)

Function which will read columns 1 and ycol of a file filename.

Top of Page

static Table AskUser(const string& prompt,const string& deflt)
static Table AskUser(const string& prompt,double deflt)

Functions which prompt the user for either a value or a filename.

Example:

Table reflectance = Table::AskUser("Reflectance","reflectance.dat");

Top of Page


For More Information

SCATMECH Technical Information and Questions
Optical Technology Division (OTD) Home Page
OTD Technical Inquiries
OTD Website Comments

Current SCATMECH version: 6.00 (February 2008)
This page first online: Version 3.00 (December 2001)
This page last modified: Version 6.00 (February 2008)