Overview
Requirements
SeldonData is based on Blitz++ 0.6 (see http://www.oonumerics.org/blitz/) or Blitz++ 0.7. A rather good C++ compiler is required (mainly to support partial ordering of member templates). It has been tested with g++ (GNU GCC) version 3.2 and 3.3 and icc (Intel compiler) 8.0.
Basic ideas
SeldonData mainly provides a class called Data
. This
class is associated with grids which describe at which points data is
provided. For instance, on a 2D cartesian mesh whose points are (Xi,
Yj) = (i, 3j), data would be associated with a regular grid (0, 1, 2,
3, ...) along X and a regular grid (0, 3, 6, 9, ...) along Y. Grids
are represented by instances of class Grid
. Two classes
are provided: RegularGrid
for grids (along one
coordinate) that are independent of other coordinates, and
GeneralGrid
for grids depending on several coordinates.
Class Data
has several methods for: interpolation,
statistics, ... Those methods are described in the documentation.
Input / output operations depend on the format in which data was /
is written. For each format, a class is defined. For instance, there
are classes FormatText
for text files (sometimes refered
as "ascii files") and FormatBinary
for binary files. Any
new format may be defined in the same way, i.e. through a class. Then,
reading or writing files in a given format is easy.
Example
The example example1.cpp should be read as follows:
- Debug options are defined to check indices, dimensions, etc.
- SeldonData is included.
- Grids and data objects are defined. The first grid has 25 points from 0 to 24 (increment: 1). The second has 10 elements from 2.5 to 7 (increment: 0.5).
- The input data is filled with -1.0.
- The input data is interpolated onto the output data grid, the result being stored in the output data.
- The output data is displayed on the screen.
- The output data is stored in file "example1.dat".
#define SELDONDATA_DEBUG_CHECK_INDICES
#define SELDONDATA_DEBUG_CHECK_IO
#define SELDONDATA_DEBUG_CHECK_DIMENSIONS
#define SELDONDATA_DEBUG_CHECK_MEMORY
#include "SeldonData.hxx"
using namespace SeldonData;
int main()
{
TRY;
RegularGrid<double> GridX_in(25), GridX_out(2.5, 0.5, 10);
Data<double, 1> DataIn(GridX_in), DataOut(GridX_out);
DataIn.Fill(-1.0);
LinearInterpolationRegular(DataIn, DataOut);
DataOut.Print();
FormatText Output;
Output.Write(DataOut, "example.dat");
END;
return 0;
}
The output is:
10
[ -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 ]
TRY
and END
are macros that enable exception
handling (thanks to a try
/ catch
structure.).
The following makefile was used (command: make
example1
):
CC = g++
# Put the paths to Blitz++, Talos and SeldonData.
INCPATH = -I/home/vivien/codes/MyBlitz++-0.7 \
-I/home/vivien/codes/Talos-0.3 \
-I/home/vivien/codes/SeldonData-1.4
LINK = g++
TARGETS = example1 example2 example3
all: $(TARGETS)
$(TARGETS): % : %.o
$(LINK) -o $@ $<
%.o : %.cpp
$(CC) $(INCPATH) -c -o $@ $<
clean:
rm -f $(TARGETS) $(TARGETS:%=%.o)