Commit d35e65be authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

basic set of files (we inherit from libcontxx)

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1167
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent c4461b7a
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.1.1.1 2002-12-06 18:24:48 forbrig Exp $
# $Id: Makefile,v 1.2 2002-12-06 19:08:18 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
# libaff is the "Array Friederich Forbriger", a container for numbers
#
# A note on header files:
# We extensively comment class declarations within the header files. The
# reduce compilation time when using the library code, comments will be
# stripped from the header files that are exportet. These stripped versions
# are placed in the source code path with name *.h.strip and will be linked to
# INCINSTALLPATH with name *.h.
#
# Although comment stripping could be done by perl with an elaborate regular
# expression, we prefer the remcmmnt command by Jari Laaksonen. You can find
# the code at
# http://www.eti.pg.gda.pl/KATEDRY/kecs/lab-cpp/snippets/
# If it is not available to you, you should set REMCMMNT=cat (see below)
#
# REVISIONS and CHANGES
# 06/12/2002 V1.0 Thomas Forbriger
#
# ============================================================================
#
# environment variables
# ---------------------
#
# You will like to set the following environment variables:
#
# LOCINCLUDEDIR Defines the path where header files will be copied for
# usage in your own projects. You will pass this path to
# the precompiler with the -I option.
# LOCLIBDIR Defines the path where the binary library will be
# placed.
# WWWBASEDIR Defines the path to your personal homepage. That's the
# place where doxygen output will be written too (see
# below).
all: install-include libcontxx.a doxydoc
# files
# -----
# all header files used within this project
HEADERS=$(shell find . -name \*.h)
# all source code to be compiled to object files and to be included
# in the binary version of the library
# (see below for the configuration of a preinstantiated version of template
# code)
SRC=
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
README=$(shell find . -name README)
# place where we will copy header files
INCINSTALLPATH=$(LOCINCLUDEDIR)/aff
# place where we will copy the binary library
LIBINSTALLPATH=$(LOCLIBDIR)
all:
# name of headers with comments stripped off (these are linked to your include
# directory)
STRIPHEADER=$(addsuffix .strip,$(notdir $(HEADERS)))
# name of installed (exported) header files (these are the names in your
# include directory)
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(HEADERS))
flist: Makefile
# if defined, empty lines are kept in comment-stripped headers
# to synchronize line numbers (necessary during library debugging)
EMPTYPRINT=1
#EMPTYPRINT=0
# define this to be cat in case you do not have remcmmnt available
REMCMMNT=remcmmnt
#REMCMMNT=cat
# compiler and preprocessor flags
FLAGS=
CXXFLAGS=-Wall -pedantic $(FLAGS)
LDFLAGS=-L$(LOCLIBDIR)
CPPFLAGS=-I$(LOCINCLUDEDIR) $(FLAGS)
# the following definition is needed to make the dependency command pass
# binarray.cc
TMPPARDEF=-D BIN_TYPE -D BIN_N -D BIN_REPR -D BIN_SUBS
# targets
# -------
# files which are to be edited
flist: Makefile tests/Makefile doxybrief.cfg doxyfull.cfg $(README) \
$(HEADERS) $(SRC) $(TESTS) $(wildcard doxy*.cfg)
echo $^ | tr ' ' '\n' | sort > $@
# Offers you a list of files to edit (ask Thomas for appropriate vim
# configuration).
.PHONY: edit
edit: flist; vim $<
# Target clean removes everything except the source code, headers and
# documentation. (See also doxyclean)
.PHONY: clean
clean: ;
-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
-/bin/rm -vf flist
-find . -name \*.o | xargs --no-run-if-empty /bin/rm -v
-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
-find . -name \*.h.strip | xargs --no-run-if-empty /bin/rm -v
-/bin/rm -vf flist *.o install-include libcontxx.a *.xxx junk*
cd tests; $(MAKE) clean
#======================================================================
# library part
# ============
#
# These are code fragments from libcontxx. They are the framework for
# generating a binary library with preinstantiated template code.
# Until we make full use of this feature, the fragments are just waiting here.
#
# basic set of patterns - containing all dimensionalities
LIBPATBASIC=_TYPE_1_REPR_SUBS_ \
_TYPE_2_REPR_SUBS_ \
_TYPE_3_REPR_SUBS_ \
_TYPE_4_REPR_SUBS_ \
_TYPE_5_REPR_SUBS_
#
# all element type
LIBPATTYPE=$(patsubst _TYPE_%,_float_%,$(LIBPATBASIC)) \
$(patsubst _TYPE_%,_double_%,$(LIBPATBASIC)) \
$(patsubst _TYPE_%,_int_%,$(LIBPATBASIC)) \
$(patsubst _TYPE_%,_zdouble_%,$(LIBPATBASIC)) \
$(patsubst _TYPE_%,_cfloat_%,$(LIBPATBASIC))
#
# add const element types
LIBPATCTYPE=$(LIBPATTYPE) $(patsubst _%,_C%,$(LIBPATTYPE))
#
# add representations
LIBPATREPR=$(patsubst %_REPR_SUBS_,%_sheap_SUBS_,$(LIBPATCTYPE))
#
# add shapes
LIBPATSUBS=$(patsubst %_SUBS_,%_srep,$(LIBPATREPR)) \
$(patsubst %_SUBS_,%_dsrep,$(LIBPATREPR))
#
# create object file patterns
LIBPATFILES=$(addprefix binarray,$(LIBPATSUBS))
ALLOBS=$(addsuffix .o,$(LIBPATFILES))
# macro definitions
macro_float.xxx: ; echo "-D BIN_TYPE=float" > $@
macro_double.xxx: ; echo "-D BIN_TYPE=double" > $@
macro_int.xxx: ; echo "-D BIN_TYPE=int" > $@
macro_zdouble.xxx: ; echo "-D BIN_TYPE=\"std::complex<double>\"" > $@
macro_cfloat.xxx: ; echo "-D BIN_TYPE=\"std::complex<float>\"" > $@
macro_Cfloat.xxx: ; echo "-D BIN_TYPE=\"const float\"" > $@
macro_Cdouble.xxx: ; echo "-D BIN_TYPE=\"const double\"" > $@
macro_Cint.xxx: ; echo "-D BIN_TYPE=\"const int\"" > $@
macro_Czdouble.xxx: ; echo "-D BIN_TYPE=\"const std::complex<double>\"" > $@
macro_Ccfloat.xxx: ; echo "-D BIN_TYPE=\"const std::complex<float>\"" > $@
macro_%_1.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=1" >> $@
macro_%_2.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=2" >> $@
macro_%_3.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=3" >> $@
macro_%_4.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=4" >> $@
macro_%_5.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=5" >> $@
macro_%_sheap.xxx: macro_%.xxx
cat $< > $@; echo "-D BIN_REPR=contxx::prebuilt::representation::SharedHeap" >> $@
macro_%_srep.xxx: macro_%.xxx
cat $< > $@; echo "-D BIN_SUBS=contxx::prebuilt::subscriptor::StridedRepresentation" >> $@
macro_%_dsrep.xxx: macro_%.xxx
cat $< > $@; echo "-D BIN_SUBS=contxx::prebuilt::subscriptor::DenseStridedRepresentation" >> $@
binarray%.o: binarray.cc macro%.xxx
/bin/cat $(word 2,$^)
$(CXX) -o $@ -c $< $(CPPFLAGS) $(CXXFLAGS) $(shell /bin/cat $(word 2,$^))
#----------------------------------------------------------------------
# create the binary library
# -------------------------
libcontxx.a: install-include $(ALLOBS)
ar rcv $@ $(ALLBOS)
ranlib $@
cp -vpf $@ $(LIBINSTALLPATH)
#======================================================================
# dependencies
# ------------
#
# The compiler is used to create dependency files, which are included below.
%.d: %.cc
$(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $(TMPPARDEF) $< \
| sed '\''s,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g'\'' \
> $@; \
[ -s $@ ] || rm -f $@'
binarray_%.d: binarray.cc
echo $(patsubst %.d,%.o,$@) $@: $< > $@
-include $(patsubst %.cc,%.d,$(SRC))
# this include will be used once we initiate the precompiled library version
# until then it's just waiting here
#-include $(patsubst %.o,%.d,$(ALLOBS))
#======================================================================
# header files
# ------------
#
# Since we extensively document the class structures within the header files,
# these should be stripped for the production version (otherwise the compiler
# has to scan all comments on each compile). Stripping is done by the rule
# below and is controlled by the variables REMCMMNT and EMPTYPRINT (see
# above).
# comment stripping
# -----------------
# awk rule assumes that the first non-comment line starts with '#'
# and that the first (copyright) comment end with pattern "^ */"
%.h.strip: %.h
awk 'BEGIN {hot=1;} /^ \*\// { if (hot) { hot=2; print; next;} }\
/^#/ { hot=0; } \
{ if (hot==2) { print ""; } else if (hot) { print; } }' $< > $@
$(REMCMMNT) $< | awk 'BEGIN {hot=0;} \
/^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print; } next; } \
/^#/ { hot=1; } { if (hot) print; }' >> $@
#----------------------------------------------------------------------
.PRECIOUS: %.h.strip
$(INCINSTALLPATH)/%.h: %.h.strip
mkdir -vp $(dir $@)
-rm -fv $@
ln -svf $$(pwd)/$< $@
# install header files
install-include: $(INSTHEADER)
echo $^ | tr ' ' '\n'
touch $@
#======================================================================
# documentation part
# ------------------
#
# targets commonly used:
# ----------------------
#
# make doxyclean removes all documentation
# make doxydoc creates doxygen documentation in the DOXYWWWPATH
# make doxyview creates doxygen documentation and launches netscape to
# browse in the documentation
# make doxyfullconf edit the doxygen configuration file
#
# The targets are prepared for two documentation configurations. There is a
# "full" configuration defined in doxyfull.cfg and a "brief" configuration in
# doxybrief.cfg. However doxygen itself does not really support to distinguish
# between brief and full just due to the config-file. So just use the doxyfull
# target.
#
# If you launch "make doxyfull" the documentation will be written to
# DOXYWWWPATH (see below). This is meant to export the documentation through
# your homepage. The doxyfull directory is just a symbolic link to this
# directory.
#
DOXYWWWPATH=$(WWWBASEDIR)/libaff
.PHONY: doxyclean doxyview doxybriefview doxyfullconf doxybriefconf
doxyclean: ;/bin/rm -rfv docfull/* docbrief docfull
DOXYSRC=$(README) $(HEADERS) $(SRC)
doc%/html/index.html: doxy%.cfg $(DOXYSRC)
mkdir -vp $(DOXYWWWPATH)
ln -sfv $(DOXYWWWPATH) $(patsubst doxy%.cfg,doc%,$<)
doxygen $<
doxybriefconf doxyfullconf: doxy%conf:
doxywizard $(patsubst doxy%conf,doxy%.cfg,$@)
doxyfull doxybrief: doxy%: doxyclean doc%/html/index.html
doxydoc: doxyfull
doxyfullview doxybriefview: doxy%view: doxy%
netscape doc$(patsubst doxy%view,%,$@)/html/index.html &
doxyview: doxydoc doxyfullview
#======================================================================
# delegate test targets
# ---------------------
tests/%: tests/%.cc install-include
cd tests; echo "#############################"; $(MAKE) $(notdir $@)
tests/bin%: tests/bin%.cc install-include libcontxx.a
cd tests; echo "#############################"; $(MAKE) $(notdir $@)
tests/%.run: tests/%
echo "#############################"
$< $(ARG)
# ----- END OF Makefile -----
This diff is collapsed.
/*! \file array.h
* \brief full template array class headers (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: array.h,v 1.1 2002-12-06 19:08:18 forbrig Exp $
* \author Thomas Forbriger
* \date 01/05/2002
*
* full template array class headers (prototypes)
*
* \sa contxx
* \sa contxx::Array
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 01/05/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_ARRAY_H_VERSION
#define TF_ARRAY_H_VERSION \
"TF_ARRAY_H V1.0 "
#define TF_ARRAY_H_CVSID \
"$Id: array.h,v 1.1 2002-12-06 19:08:18 forbrig Exp $"
#define CONTXX_INLINE inline
#include<contxx/array_dec.h>
#endif // TF_ARRAY_H_VERSION (includeguard)
/* ----- END OF array.h ----- */
/*! \file array_dec.h
* \brief array class declarations (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: array_dec.h,v 1.1 2002-12-06 19:08:18 forbrig Exp $
* \author Thomas Forbriger
* \date 01/05/2002
*
* array class declarations (prototypes)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 01/05/2002 V1.0 Thomas Forbriger
* - 22/11/2002 V1.1
* - use Strided as default
* - index-constructors are deprecated (use shapers)
*
* ============================================================================
*/
// include guard
#ifndef TF_ARRAY_DEC_H_VERSION
#define TF_ARRAY_DEC_H_VERSION \
"TF_ARRAY_DEC_H V1.1 "
#define TF_ARRAY_DEC_H_CVSID \
"$Id: array_dec.h,v 1.1 2002-12-06 19:08:18 forbrig Exp $"
#include <contxx/repr/sharedheap.h>
#include <contxx/shape/strided_repr.h>
#include <contxx/shape/range.h>
namespace contxx {
#ifdef CONTXX_PREBUILT
namespace prebuilt {
#endif
#ifdef CONTXX_PREBUILT
using namespace contxx::prebuilt::util;
using namespace contxx::prebuilt::shape;
using contxx::prebuilt::representation::SharedHeap;
using contxx::prebuilt::subscriptor::StridedRepresentation;
#else
using namespace contxx::util;
using namespace contxx::shape;
using contxx::representation::SharedHeap;
using contxx::subscriptor::StridedRepresentation;
#endif
/*! \brief Full multi-dimensional array functionality.
*
* The array class highly depends on base classes from which inherts most of
* its functionality.
* The user may select from several provided array designs through template
* parameters:
* \param T element type of array (passed to Subscriptor base class)
* \param N dimensionality of array (passed to Subscriptor base class)
* \param Representation Representation (engine for memory access) base
* class type (passed to Subscriptor base class)
* \param Subscriptor Subscriptor base class type
*
* \sa \ref page_shapes_and_subscriptors
* \sa \ref page_representation
* \sa \ref sec_main_modules
* \sa tests/arraytest.cc
*/
template<class T,
Tdim N=1,
template<class TT>
class Representation=SharedHeap,
template<class TT, Tdim NN, template<class TTT> class RR>
class Subscriptor=StridedRepresentation>
class Array:
public Subscriptor<T, N, Representation>
{
public:
//! Type of representation
typedef Representation<T> Trepresentation;
//! Type of subscriptor
typedef Subscriptor<T, N, Representation> Tsubscriptor;
//! Type of shape
typedef typename Tsubscriptor::Tshape Tshape;
//! Element type
typedef typename Trepresentation::Tvalue Tvalue;
//! Type of pointer to element
typedef typename Trepresentation::Tpointer Tpointer;
//! Type of reference to element
typedef typename Trepresentation::Treference Treference;
//! Type of const reference to element
typedef typename Trepresentation::Tconst_reference Tconst_reference;
//! Type to be used as data representation
typedef typename Trepresentation::Tmutable_value Tmutable_value;
//! Type to be used as element for const version
typedef typename Trepresentation::Tconst_value Tconst_value;
//! Type of this array
typedef Array<T, N, Representation, Subscriptor> Tcontainer;
//! Type of the array of const values
typedef Array<Tconst_value, N, Representation, Subscriptor>
Tcontainer_of_const;
/*! \brief \b deprecated! Type of size array
* \deprecated
* This feature may be removed in future versions
*/
typedef SimpleRigidArray<Tsize, N> Tsizes;
/*! \brief \b deprecated! Type of range
* \deprecated
* This feature may be removed in future versions
*/
typedef Range<Tsubscript> Trange;
/*! \brief \b deprecated! Type of range array
* \deprecated
* This feature may be removed in future versions
*/
typedef SimpleRigidArray<Trange, N> Tranges;
//! construct from nothing (empty)
Array() { }
//! construct from shape and representation
Array(const Tshape& shape,
const Trepresentation& representation);
//! construct from shape
explicit Array(const Tshape& shape);
/*! \brief \b deprecated! construct from sizes
* \deprecated
* This constructor may be removed in future versions
* Use shapers instead.
*/
explicit Array(const Tsizes& size);
/*! \brief \b deprecated! construct from ranges
* \deprecated
* This constructor may be removed in future versions.
* Use shapers instead.
*/
explicit Array(const Tranges& ranges);
//! conversion to container of const values
operator Tcontainer_of_const() const
{
Tcontainer_of_const retval(*this, *this);
return(retval);
}
//! by size we mean the size defined by the shape
Tsize size(const Tsubscript& i) const
{ return(this->Tshape::size(i)); }
//! by size we mean the size defined by the shape
Tsize size() const
{ return(this->Tshape::size()); }
//! set value to whole array
Array& operator=(const T& value);
}; // class Array
#ifdef CONTXX_PREBUILT
} // namespace prebuild
#endif
} // namespace contxx
#ifndef CONTXX_NO_DEFINITIONS
#include <contxx/array_def.h>
#endif
#endif // TF_ARRAY_DEC_H_VERSION (includeguard)
/* ----- END OF array_dec.h ----- */
/*! \file array_def.h
* \brief array class definitions (definitions)
*
* ----------------------------------------------------------------------------
*
* $Id: array_def.h,v 1.1 2002-12-06 19:08:18 forbrig Exp $
* \author Thomas Forbriger
* \date 01/05/2002
*
* array class definitions (definitions)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 01/05/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#ifndef TF_ARRAY_DEC_H_VERSION
#error "include this only through array_dec.h"
#endif
// include guard
#ifndef TF_ARRAY_DEF_H_VERSION
#define TF_ARRAY_DEF_H_VERSION \
"TF_ARRAY_DEF_H V1.0 "
#define TF_ARRAY_DEF_H_CVSID \
"$Id: array_def.h,v 1.1 2002-12-06 19:08:18 forbrig Exp $"
namespace contxx {
#ifdef CONTXX_PREBUILT
namespace prebuilt {
#endif
#ifdef CONTXX_PREBUILT
using namespace contxx::prebuilt::shape;
#else
using namespace contxx::shape;
#endif
#ifdef CONTXX_PREBUILT
#ifndef TF_COMPILING_LIBRARY
#error "definition read in prebuilt mode and not during library compilation"
#endif
#endif
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,
template<class TT> class R,
template<class TT, Tdim NN, template<class TTT> class RR> class S>
Array<T,N,R,S>::Array(const Tranges& ranges)
{
typename Tshape::Tlimits first, last;
for (int i=0; i<N; i++)
{
first[i]=ranges[i].first();
last[i]=ranges[i].last();
}
this->Tshape::operator=(Tshape(first,last));
this->Trepresentation::operator=(
Trepresentation(this->Tshape::size()));
}
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,
template<class TT> class R,
template<class TT, Tdim NN, template<class TTT> class RR> class S>
Array<T,N,R,S>::Array(const Tsizes& sizes)
{
typename Tshape::Tlimits first, last;
for (int i=0; i<N; i++)
{
first[i]=0;
last[i]=sizes[i]-1;
}
this->Tshape::operator=(Tshape(first,last));
this->Trepresentation::operator=(
Trepresentation(this->Tshape::size()));
}
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,
template<class TT> class R,
template<class TT, Tdim NN, template<class TTT> class RR> class S>
Array<T,N,R,S>::Array(const Tshape& shape,
const Trepresentation& representation)
{
this->Tshape::operator=(shape);
this->Trepresentation::operator=(representation);
}
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,