From 628f7bb8ad573a06a700c6e7e3045bdd008c808c Mon Sep 17 00:00:00 2001 From: Thomas Forbriger Date: Tue, 3 Nov 2015 10:52:38 +0100 Subject: [PATCH] [TASK] (import_Seitosh): discard contrib/aff/tests Code in contrib/aff/tests is not required as part of Seitosh. However, the test code requires additional settings like proper interlanguage linking (C++ and Fortran). To reduce the constraints on the installation environment, discard the subdirectory tests in contrib/aff entirely, as well as all references to the test code made in the Makefile. --- contrib/aff/Makefile | 40 +--- contrib/aff/tests/.gitignore | 15 -- contrib/aff/tests/Makefile | 140 ----------- contrib/aff/tests/arraytest.cc | 240 ------------------- contrib/aff/tests/f77common.inc | 43 ---- contrib/aff/tests/f77interface.cc | 157 ------------- contrib/aff/tests/f77procs.f | 141 ----------- contrib/aff/tests/f77proto.h | 110 --------- contrib/aff/tests/f77test.cc | 243 ------------------- contrib/aff/tests/functionstest.cc | 97 -------- contrib/aff/tests/helpertest.cc | 339 --------------------------- contrib/aff/tests/operatortest.cc | 159 ------------- contrib/aff/tests/reprtest.cc | 140 ----------- contrib/aff/tests/seriestest.cc | 99 -------- contrib/aff/tests/shapetest.cc | 217 ----------------- contrib/aff/tests/simplearraytest.cc | 220 ----------------- 16 files changed, 3 insertions(+), 2397 deletions(-) delete mode 100644 contrib/aff/tests/.gitignore delete mode 100644 contrib/aff/tests/Makefile delete mode 100644 contrib/aff/tests/arraytest.cc delete mode 100644 contrib/aff/tests/f77common.inc delete mode 100644 contrib/aff/tests/f77interface.cc delete mode 100644 contrib/aff/tests/f77procs.f delete mode 100644 contrib/aff/tests/f77proto.h delete mode 100644 contrib/aff/tests/f77test.cc delete mode 100644 contrib/aff/tests/functionstest.cc delete mode 100644 contrib/aff/tests/helpertest.cc delete mode 100644 contrib/aff/tests/operatortest.cc delete mode 100644 contrib/aff/tests/reprtest.cc delete mode 100644 contrib/aff/tests/seriestest.cc delete mode 100644 contrib/aff/tests/shapetest.cc delete mode 100644 contrib/aff/tests/simplearraytest.cc diff --git a/contrib/aff/Makefile b/contrib/aff/Makefile index de2559f..242cea9 100644 --- a/contrib/aff/Makefile +++ b/contrib/aff/Makefile @@ -118,9 +118,8 @@ CPPFLAGS=$(addprefix -I,$(LOCINCLUDEDIR) $(subst :, ,$(SERVERINCLUDEDIR))) \ # ------- # files which are to be edited -flist: Makefile tests/Makefile doxydoc.cfg $(README) COPYING \ - $(HEADERS) $(SRC) $(TESTS) $(wildcard doxy*.cfg) $(DOXYTXT) \ - tests/f77common.inc tests/f77procs.f $(TF_EDIT) +flist: Makefile doxydoc.cfg $(README) COPYING \ + $(HEADERS) $(SRC) $(TESTS) $(wildcard doxy*.cfg) $(DOXYTXT) echo $(filter-out lib/% tests/%,$^) | tr ' ' '\n' | sort > $@ echo $(filter lib/%,$^) | tr ' ' '\n' | sort >> $@ echo $(filter tests/%,$^) | tr ' ' '\n' | sort >> $@ @@ -138,7 +137,6 @@ clean: ; -find . -name \*.o | xargs --no-run-if-empty /bin/rm -v -find . -name \*.d | xargs --no-run-if-empty /bin/rm -v -/bin/rm -vf flist *.o install-include *.xxx junk* *.a *.so - cd tests; $(MAKE) clean #====================================================================== # library part @@ -228,9 +226,7 @@ DOXYWWWPATH=$(TF_WWWBASEDIR)/libaff doxyclean: ;/bin/rm -rfv $(TF_WWWBASEDIR)/libaff doxydoc.xxx -DOXYSRC=$(DOXYTXT) $(HEADERS) $(SRC) \ - tests/f77procs.P tests/f77procs.f \ - tests/f77common.inc tests/f77common_com.P +DOXYSRC=$(DOXYTXT) $(HEADERS) $(SRC) # create doxygen intermediate configuration PWD=$(shell env pwd) @@ -262,36 +258,6 @@ kdocview: kdoc; $(TF_BROWSER) file:$(KDOCDIR)/index.html & showsections: $(README) egrep -n '\\subsection|\\section|\\page' $^ -#====================================================================== -# delegate test targets -# --------------------- - -tests/%.P: - cd tests; echo "#############################"; $(MAKE) $(notdir $@) - -tests/f2ctest: tests/f77test.cc install-include libaff.a - cd tests; echo "#############################"; $(MAKE) $(notdir $@) - -tests/%: tests/%.cc install-include libaff.a - cd tests; echo "#############################"; $(MAKE) $(notdir $@) - -tests/bin%: tests/bin%.cc install-include libaff.a - cd tests; echo "#############################"; $(MAKE) $(notdir $@) - -tests/%.run: tests/% - echo "#############################" - $< $(ARG) - /bin/rm -fv $< $<.o - -# after each modification to the library this target should be used -compile-tests: \ - tests/shapetest.run \ - tests/reprtest.run \ - tests/arraytest.run \ - tests/operatortest.run \ - tests/helpertest.run \ - tests/f77test.run - #====================================================================== # create package # -------------- diff --git a/contrib/aff/tests/.gitignore b/contrib/aff/tests/.gitignore deleted file mode 100644 index cace133..0000000 --- a/contrib/aff/tests/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -*.P -f77common_com.c -f2ctest -f77test -arraytest -subscriptortest -shapetest -simplearraytest -reprtest -seriestest -helpertest -operatortest -functionstest -binarraytest - diff --git a/contrib/aff/tests/Makefile b/contrib/aff/tests/Makefile deleted file mode 100644 index 2621c6a..0000000 --- a/contrib/aff/tests/Makefile +++ /dev/null @@ -1,140 +0,0 @@ -# this is -# ---------------------------------------------------------------------------- -# -# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) -# -# how to compile libaff tests -# -# ---- -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# ---- -# -# -# arguments to test programs can be passed through variable ARG -# -# REVISIONS and CHANGES -# 06/12/2002 V1.0 Thomas Forbriger (copied from libcontxx) -# 17/12/2002 V1.1 introduced seriestest -# 22/12/2002 V1.2 started interface test to Fortran 77 -# 12/01/2014 V1.3 use FFLAGS instead of FCFLAGS conforming to GNU make -# default rules -# -# ============================================================================ -# -CONTRIBDIR=../.. -include $(CONTRIBDIR)/Makefile_var - -CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1))) -CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var))) - -$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR LOCBINDIR) -$(call CHECKVARS,TF_LINK_FORTRAN) - -# ---------------------------------------------------------------------- - -CPPFLAGS=-I$(LOCINCLUDEDIR) -LDFLAGS=-L$(LOCLIBDIR) - -CXXFLAGS=-fhonor-std -Wall $(FLAGS) -CXXFLAGS=-Wall -pedantic $(FLAGS) -CXXFLAGS=-Wall $(FLAGS) - -ARG= - -all: - -flist: Makefile - echo $^ | tr ' ' '\n' | sort > $@ - -.PHONY: edit -edit: flist; vim $< - -.PHONY: clean -clean: ; - -find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v - -/bin/rm -vf flist *.P *.code *.o *.bak - -find . -type f -perm +0111 | xargs --no-run-if-empty /bin/rm -v - -STANDARDTEST=arraytest subscriptortest shapetest simplearraytest reprtest \ - seriestest helpertest operatortest functionstest -BINARYTEST=binarraytest -F77TEST=f77test -EXECUTABLES=$(STANDARDTEST) $(BINARYTEST) $(F77TEST) - -$(addsuffix .o,$(STANDARDTEST) $(BINARYTEST) $(F77TEST)): %.o: %.cc - $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) $(FLAGS) - -$(STANDARDTEST): %: %.o; $(CXX) -o $@ $< $(LDFLAGS) -laff -$(BINARYTEST): %: %.o; $(CXX) -o $@ $< $(LDFLAGS) -laff - -$(addsuffix .run,$(EXECUTABLES)): %.run: %; $< $(ARG); rm -fv $< $<.o - -#====================================================================== -# -# Fortran 77 interface test -# ------------------------- -F2C=f2c - -%.f2c.o: %.f f77common.inc - $(F2C) -C++ -f -u $< - $(CXX) -c -o $@ $(<:.f=.c) $(CXXFLAGS) $(CPPFLAGS) $(FLAGS) - /bin/rm -fv $(<:.f=.c) - -%.o: %.f f77common.inc - $(FC) -o $@ -c $< $(FFLAGS) $(FLAGS) - -%.code: %.f f77common.inc - $(F2C) -C++ -f -u $< - -/bin/mv -v $(patsubst %.f,%.c,$<) $(patsubst %.f,%.code,$<) - -%.P: %.f f77common.inc - $(F2C) -C++ -f -u -P -\!c $< - -f77common_com.P: f77procs.f f77common.inc - $(F2C) -C++ -f -u -ec $< - /bin/rm -fv $(patsubst %.f,%.c,$<) - sed -e 's/^struct/extern struct/' $(patsubst %.P,%.c,$@) > $@ - -f77interface.o: f77interface.cc f77proto.h f77procs.P f77common_com.P - $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) $(FLAGS) - -f2ctest: f77test.o f77procs.f2c.o f77interface.o - $(CXX) -o $@ $^ $(LDFLAGS) -laff -lf2c -lm - -f77test: f77test.o f77procs.o f77interface.o - $(CXX) -o $@ $^ $(LDFLAGS) -laff $(TF_LINK_FORTRAN) -lm - -#====================================================================== -# test illegal conditions -illegal: - -$(MAKE) reprtest FLAGS=-DILLEGAL1 - -$(MAKE) seriestest FLAGS=-DILLEGAL1 - -$(MAKE) shapetest FLAGS=-DILLEGAL1 - -$(MAKE) simplearraytest FLAGS=-DILLEGAL1 - -$(MAKE) simplearraytest FLAGS=-DILLEGAL2 - -$(MAKE) arraytest FLAGS=-DILLEGAL1 - -$(MAKE) arraytest FLAGS=-DILLEGAL2 - -$(MAKE) arraytest FLAGS=-DILLEGAL3 - -$(MAKE) arraytest FLAGS=-DILLEGAL4 - -$(MAKE) arraytest FLAGS=-DILLEGAL5 - -$(MAKE) arraytest FLAGS=-DILLEGAL6 - -$(MAKE) arraytest FLAGS=-DILLEGAL7 - -$(MAKE) f77test FLAGS=-DILLEGAL1 - -$(MAKE) f77test FLAGS=-DILLEGAL2 - -$(MAKE) f77test FLAGS=-DILLEGAL3 - -$(MAKE) f77test FLAGS=-DILLEGAL4 - -$(MAKE) f77test FLAGS=-DILLEGAL5 - -# ----- END OF Makefile ----- diff --git a/contrib/aff/tests/arraytest.cc b/contrib/aff/tests/arraytest.cc deleted file mode 100644 index 500cce5..0000000 --- a/contrib/aff/tests/arraytest.cc +++ /dev/null @@ -1,240 +0,0 @@ -/*! \file arraytest.cc - * \brief test array class template (implementation) - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 09/06/2002 - * - * test array class template (implementation) - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) - * - * REVISIONS and CHANGES - * - 09/06/2002 V1.0 Thomas Forbriger - * - 25/11/2002 V1.1 whole array assign - * - 19/12/2002 V1.2 now works for libaff - * - 28/12/2002 V1.3 (thof) - * - new term for containers of const elements - * - 03/01/2003 V1.4 (thof) - * - now tests copyout function - * - * ============================================================================ - */ - -/*! \example tests/arraytest.cc - * - * Here you can learn about how to use the aff::Array class. - * - * This test program gives an example of the usage of the following classes, - * functions, and preprocessor macros: - * - aff::Array - * - aff::ConstArray - * - aff::Shaper - * - aff::dump - * - aff::dump_array - * - #DUMP - * - #CODE - * - * \sa tests/arraytest.cc - */ - -#define AFF_ARRAYTEST_CC_VERSION \ - "AFF_ARRAYTEST_CC V1.3" -#define AFF_ARRAYTEST_CC_CVSID \ - "$Id$" - -#define CONT_INDEXCHECK - -#include -#include -#include -#include - -using std::cout; -using std::endl; -using namespace aff; - -/*----------------------------------------------------------------------*/ - -//! print headline -void section(const char* s, const char l='-') -{ - cout << endl << s << endl; - const char* p=s; - while (*p) { cout << l; ++p; } - cout << endl; -} - -/*======================================================================*/ - -//! test array functionality -int main() -{ - cout << AFF_ARRAYTEST_CC_VERSION << endl; - cout << AFF_ARRAYTEST_CC_CVSID << endl; - - section("Test constructors", '='); - section("size-constructor"); - { - CODE( Array A(3,4); ) - DUMP( A ); - } - section("shape-constructor"); - { - CODE( Array A(Shaper(4,14)(12)(-5,5)); ) - DUMP( A ); - } - - /*----------------------------------------------------------------------*/ - - section("Test assignment", '='); - { - CODE( Array A(3,4); ); - CODE( A=15.5; ); - CODE( dump_array(A); ); - CODE( A(2,3)=-2.; ); - CODE( A(3,1)=-5.; ); - CODE( dump_array(A); ); - } - - /*----------------------------------------------------------------------*/ - - section("Test access operators", '='); - { - CODE( Array A(Shaper(-2,2)(10,16)(2)(-1,0)); ); - section("fill array"); - for(int i=A.f(0); i<=A.l(0); i++) - { - for(int j=A.f(1); j<=A.l(1); j++) - { - for(int k=A.f(2); k<=A.l(2); k++) - { - for(int l=A.f(3); l<=A.l(3); l++) - { - A(i,j,k,l)=(i-A.f(0)+1)+(j-A.f(1)+1)*10 - +(k-A.f(2)+1)*100+(l-A.f(3)+1)*1000; - } - } - } - } - CODE( dump_array(A,3); ); - CODE( dump_array(A,2); ); - CODE( dump_array(A,1); ); - CODE( dump_array(A,0); ); - DUMP( A.representation() ); - } - - /*----------------------------------------------------------------------*/ - - section("Test copy", '='); - section("non-const copy"); - { - CODE( Array A(3,4); ); - CODE( Array B(A); ); - CODE( Array C; ); - CODE( C=B; ); - CODE( A=15.5; ); - CODE( A(2,3)=-2.; ); - CODE( A(3,1)=-5.; ); - CODE( dump_array(C); ); - } - section("const copy"); - { - CODE( Array A(3,4); ); - CODE( A=15.5; ); - CODE( ConstArray B(A); ); - CODE( dump_array(B); ); - CODE( A(2,3)=-2.; ); - CODE( A(3,1)=-5.; ); - CODE( Array::Trepresentation H; ); - CODE( H=A.representation(); ); - CODE( H[5]=-12.; ); - CODE( dump_array(B); ); - CODE( ConstArray::Trepresentation H2; ); - CODE( H2=B.representation(); ); - DUMP( H2 ); - -#ifdef ILLEGAL1 -#warning compiling supposedly illegal code - CODE( Array C(B); ); -#endif - -#ifdef ILLEGAL2 -#warning compiling supposedly illegal code - CODE( Array C; ); - CODE( C=B; ); -#endif - -#ifdef ILLEGAL3 -#warning compiling supposedly illegal code - CODE( B(1,2)=12.; ); -#endif - -#ifdef ILLEGAL4 -#warning compiling supposedly illegal code - CODE( B=12.; ); -#endif - -#ifdef ILLEGAL5 -#warning compiling supposedly illegal code - CODE( H=B; ); -#endif - -#ifdef ILLEGAL6 -#warning compiling supposedly illegal code - CODE( H2[5]=-12.; ); -#endif - } - - section("read access to ConstArray and const Array"); - { - CODE( Array A(3,3) ); - CODE( ConstArray B(A) ); - CODE( const Array C(A) ); - CODE( A=123 ); - CODE( cout << A(2,2) << ", " << B(2,2) << ", " << C(2,2) << endl ); - -#ifdef ILLEGAL7 -#warning compiling supposedly illegal code - CODE( C(1,1)=12; ); -#endif - } - - section("test copyout function"); - { - CODE( Array A(8,8)); - section("fill array"); - for(int i=A.f(0); i<=A.l(0); i++) - { - for(int j=A.f(1); j<=A.l(1); j++) - { - A(i,j)=(i-A.f(0)+1)+(j-A.f(1)+1)*10; - } - } - CODE( dump_array(A); ); - CODE( ConstArray CA(subarray(A)(4,6)(3,5))); - CODE( dump_array(CA); ); - CODE( Array B=CA.copyout()); - CODE( dump_array(B); ); - } -} - -/* ----- END OF arraytest.cc ----- */ diff --git a/contrib/aff/tests/f77common.inc b/contrib/aff/tests/f77common.inc deleted file mode 100644 index a8a064f..0000000 --- a/contrib/aff/tests/f77common.inc +++ /dev/null @@ -1,43 +0,0 @@ -c this is -c ---------------------------------------------------------------------------- -c ($Id$) -c -c Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) -c -c common block for Fortran test -c -c ---- -c This program is free software; you can redistribute it and/or modify -c it under the terms of the GNU General Public License as published by -c the Free Software Foundation; either version 2 of the License, or -c (at your option) any later version. -c -c This program is distributed in the hope that it will be useful, -c but WITHOUT ANY WARRANTY; without even the implied warranty of -c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -c GNU General Public License for more details. -c -c You should have received a copy of the GNU General Public License -c along with this program; if not, write to the Free Software -c Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -c ---- -c -c REVISIONS and CHANGES -c 22/12/2002 V1.0 Thomas Forbriger -c -c ============================================================================ -c -c dimensions for arrays - integer amax, bmax - parameter(amax=10,bmax=20) -c -c used elements in each dimension - integer na, nb -c -c complex array - double complex array(amax,bmax) -c -c common block - common /f77common/ array,na,nb -c -c ----- END OF f77common.inc ----- diff --git a/contrib/aff/tests/f77interface.cc b/contrib/aff/tests/f77interface.cc deleted file mode 100644 index 3d95fb0..0000000 --- a/contrib/aff/tests/f77interface.cc +++ /dev/null @@ -1,157 +0,0 @@ -/*! \file f77interface.cc - * \brief interface functions (implementation) - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 23/12/2002 - * - * interface functions (implementation) - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * \sa \ref page_fortran - * - * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) - * - * REVISIONS and CHANGES - * - 23/12/2002 V1.0 Thomas Forbriger - * - 29/12/2002 V1.1 now uses aff::subarray - * - 03/01/2003 V1.2 (thof) - * - use aff::util::SizeCheckedCast - * - FortranArray now takes container type as template - * argument - * - * ============================================================================ - */ -#define AFF_F77INTERFACE_CC_VERSION \ - "AFF_F77INTERFACE_CC V1.2" -#define AFF_F77INTERFACE_CC_CVSID \ - "$Id$" - -// include assertions -#include -// include FortranArray stuff -#include -#include -#include -#include - -/*----------------------------------------------------------------------*/ - -// include interface prototypes -#include"f77proto.h" - -/*----------------------------------------------------------------------*/ - -// get common block -#include"f77common_com.P" - -/*----------------------------------------------------------------------*/ - -// f2c declarations -#include "f2c.h" - -#ifdef __cplusplus - extern "C" { -#endif - -// include prototypes of Fortran subroutines -#include"f77procs.P" - -//! essential definitions to satisfy linker -int MAIN__() -{ - AFF_abort("should never be called!"); -} - -#ifdef __cplusplus - } -#endif - -/*======================================================================*/ - -namespace f77interface { - -//! interface function to Fortran77 subroutine fill -int fill(const aff::Array& a) -{ - aff::FortranArray > fa(a); - integer* pa=fa.castedpointer(); - integer n1=fa.last(0); - integer n2=fa.last(1); - integer n3=fa.last(2); - integer l1=fa.dimlast(0); - integer l2=fa.dimlast(1); - integer l3=fa.dimlast(2); - return(fill_(pa, &l1, &n1, &l2, &n2, &l3, &n3)); -} - -/*----------------------------------------------------------------------*/ - -//! fill common block through Fortran subroutine -int fillarray(const aff::Array& v1, - const aff::Array& v2) -{ - aff::FortranArray > fv1(v1),fv2(v2); - real* p1=fv1.castedpointer(); - real* p2=fv2.castedpointer(); - integer n1=fv1.last(0); - integer n2=fv2.last(0); - return(fillarray_(p1, p2, &n1, &n2)); -} - -/*----------------------------------------------------------------------*/ - -//! read from common block through Fortran subroutine -Tcarray sums() -{ - typedef Tcarray::Tvalue Tcvalue; - // prepare array that is large enough - integer maxa,maxb; - comdim_(&maxa, &maxb); - Tcarray result(maxa); - // prepare Fortran view - aff::FortranArray fa(result); - complex* p=fa.castedpointer(); - integer size; - sums_(p, &maxa, &size); - return(aff::subarray(result)(size)); -} - -/*----------------------------------------------------------------------*/ - -//! create view from common -Tzarray viewcommon() -{ - typedef Tzarray::Tvalue Tzvalue; - typedef aff::util::SizeCheckedCast Tcast; - integer maxa,maxb; - comdim_(&maxa, &maxb); - Tzvalue* p=Tcast::cast(f77common_.array); - // create a shape - aff::Strided shape(aff::Shaper(1,f77common_.na,maxa)(1,f77common_.nb,maxb)); - // create a representation - aff::SharedHeap repr(p, shape.memory_size()); - // create array and return - return Tzarray(shape, repr); -} - -} // namespace f77interface - -/* ----- END OF f77interface.cc ----- */ diff --git a/contrib/aff/tests/f77procs.f b/contrib/aff/tests/f77procs.f deleted file mode 100644 index bcc5805..0000000 --- a/contrib/aff/tests/f77procs.f +++ /dev/null @@ -1,141 +0,0 @@ -c this is -c ---------------------------------------------------------------------------- -c ($Id$) -c -c Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) -c -c Fortran 77 subroutines -c -c ---- -c This program is free software; you can redistribute it and/or modify -c it under the terms of the GNU General Public License as published by -c the Free Software Foundation; either version 2 of the License, or -c (at your option) any later version. -c -c This program is distributed in the hope that it will be useful, -c but WITHOUT ANY WARRANTY; without even the implied warranty of -c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -c GNU General Public License for more details. -c -c You should have received a copy of the GNU General Public License -c along with this program; if not, write to the Free Software -c Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -c ---- -c -c REVISIONS and CHANGES -c 22/12/2002 V1.0 Thomas Forbriger -c -c ============================================================================ -c - subroutine fillarray(vec1, vec2, n1, n2) -c -c writes to common block -c - include 'f77common.inc' -c - integer n1,n2 - real vec1(n1),vec2(n2) -c - double complex ime - parameter(ime=(0.d0,1.d0)) -c - integer i,j -c - if (n1.gt.amax) stop 'ERROR: first dimension is too large' - if (n2.gt.bmax) stop 'ERROR: second dimension is too large' - na=n1 - nb=n2 - do i=1,n1 - do j=1,n2 - array(i,j)=vec1(i)+ime*vec2(j) - enddo - enddo - return - end -c -c---------------------------------------------------------------------- -c - subroutine sums(vec,nmax,n) -c -c reads from common block -c - include 'f77common.inc' -c - complex vec(nmax) - integer n,nmax -c - integer i,j -c - if (nb.gt.nmax) stop 'ERROR: vector too small' - n=nb - do i=1,nb - vec(i)=(0.,0.) - do j=1,na - vec(i)=vec(i)+array(j,i) - enddo - enddo - return - end -c -c---------------------------------------------------------------------- -c - double complex function total(i) -c -c returns a value derived from common block -c - include 'f77common.inc' -c - integer i -c - double complex result - integer j -c - if ((i.lt.1).or.(i.gt.na)) stop 'ERROR: illegal index' - result=(0.d0,0.d0) - do j=1,nb - result=result+array(i,j) - enddo - total=result - return - end -c -c---------------------------------------------------------------------- -c - subroutine fill(a, ld1, n1, ld2, n2, ld3, n3) -c -c fill a three-domensional array that was passed to the subroutine -c - integer ld1,n1,ld2,n2,ld3,n3 - integer a(ld1,ld2,ld3) -c - integer i,j,k -c - do i=1,n1 - do j=1,n2 - do k=1,n3 - a(i,j,k)=i+10*j+100*k - enddo - enddo - enddo -c - return - end -c -c---------------------------------------------------------------------- -c - subroutine comdim(maxa, maxb) -c -c we have no access to the defined dimensions of the common block -c this subroutines passes the values to the rest of the world -c - integer maxa,maxb -c - include 'f77common.inc' -c - maxa=amax - maxb=bmax -c - return - end -c -c ----- END OF f77procs.f ----- diff --git a/contrib/aff/tests/f77proto.h b/contrib/aff/tests/f77proto.h deleted file mode 100644 index 0a9bd4a..0000000 --- a/contrib/aff/tests/f77proto.h +++ /dev/null @@ -1,110 +0,0 @@ -/*! \file f77proto.h - * \brief prototypes for Fortran interface (prototypes) - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 22/12/2002 - * - * prototypes for Fortran interface (prototypes) - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * \sa \ref page_fortran - * \sa f77interface - * - * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) - * - * REVISIONS and CHANGES - * - 22/12/2002 V1.0 Thomas Forbriger - * - 27/12/2002 V1.1 (thof) - * - now provides some documentation - * - * ============================================================================ - */ - -// include guard -#ifndef AFF_F77PROTO_H_VERSION - -#define AFF_F77PROTO_H_VERSION \ - "AFF_F77PROTO_H V1.1" -#define AFF_F77PROTO_H_CVSID \ - "$Id$" - -#include - -#include - -/*! \brief This namespace collects all test functions for interfacing Fortran 77 - * - * \sa \ref page_fortran - * \sa tests/f77test.cc - * \sa tests/f77interface.cc - */ -namespace f77interface { - -typedef aff::Array > Tcarray; -typedef aff::Array > Tzarray; - -/*! \brief fill an AFF array thorugh a Fortran subroutine - * - * An aff::Array object is passed to the Fortran subroutine fill and is - * filled with values there. - * The concept is discussed on page "\ref page_fortran". - */ -int fill(const aff::Array& fa); - -/*! \brief fill the Fortran common-block array - * - * Two aff::Array objects are passed to the Fortran subroutine - * fillarray which calculates complex values from the elements of these arrays - * and fills the array in common-block \c f77common which is defined in - * tests/f77common.inc. - * - * The concept is discussed on page "\ref page_fortran". - */ -int fillarray(const aff::Array& v1, - const aff::Array& v2); - -/*! \brief returns results from Fortran subroutine sums - * - * The Fortran subroutine sums calculates column-sums from the array in the - * common block. These values are return in an - * \code aff::Array > \endcode object. - * - * The concept is discussed on page "\ref page_fortran". - */ -Tcarray sums(); - -/*! \brief returns direct access to Fortran common block - * - * This function returns a - * \code aff::Array > \endcode object, which offers - * direct read/write access to the array in the Fortran common block - * f77common. - * - * The concept is discussed on page "\ref page_fortran". - */ -Tzarray viewcommon(); - -} // namespace f77interface - - -#endif // AFF_F77PROTO_H_VERSION (includeguard) - -/* ----- END OF f77proto.h ----- */ diff --git a/contrib/aff/tests/f77test.cc b/contrib/aff/tests/f77test.cc deleted file mode 100644 index edf1450..0000000 --- a/contrib/aff/tests/f77test.cc +++ /dev/null @@ -1,243 +0,0 @@ -/*! \file f77test.cc - * \brief test interfacing Fortran code (implementation) - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 22/12/2002 - * - * test interfacing Fortran code (implementation) - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * Activate sections for testing illegal constructs by passing macros - * ILLEGAL1, ILLEGAL2, ILLEGAL3, ILLEGAL4, ILLEGAL5 to the preprocessor. Use - * option -DILLEGAL1 etc. - * - * \sa \ref page_fortran - * - * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) - * - * REVISIONS and CHANGES - * - 22/12/2002 V1.0 Thomas Forbriger - * - 29/12/2002 V1.1 (thof) - * - new uses new function aff::subarray - * - new uses new function aff::slice - * - 03/01/2003 V1.2 (thof) - * - test aff::util::SizeCheckedCast - * - * ============================================================================ - */ - -/*! \example tests/f77test.cc - * - * Passing arrays to Fortran 77 code and retrieving array structures - * from Fortran 77 common blocks. - * - * This test program gives an example of the usage of the following classes, - * functions, and preprocessor macros: - * - aff::FortranArray - * - aff::FortranShape - * - aff::Array - * - aff::util::SizeCheckedCast - * - #DUMP - * - #CODE - * - * \sa tests/f77test.cc - * \sa \ref page_fortran - */ - -#define AFF_F77TEST_CC_VERSION \ - "AFF_F77TEST_CC V1.2" -#define AFF_F77TEST_CC_CVSID \ - "$Id$" - -#include -#include -#include -#include -#include -#include -#include -#include "f77proto.h" - -using std::cout; -using std::endl; -using namespace aff; - -/*----------------------------------------------------------------------*/ - -//! print headline -void section(const char* s, const char l='-') -{ - cout << endl << s << endl; - const char* p=s; - while (*p) { cout << l; ++p; } - cout << endl; -} - -/*======================================================================*/ - -/*! \brief test array interface to Fortran 77 - * - * \sa \ref page_fortran - */ -int main() -{ - cout << AFF_F77TEST_CC_VERSION << endl; - cout << AFF_F77TEST_CC_CVSID << endl; - - // First we test the shape class that should support passing arrays to - // Fortran 77 functions - section("FortranShape:", '='); - { - section("Full Layout"); - // we create a test array with known Fortran layout - CODE(Strided strided(Shaper(1,10,20)(1,5,10)(1,30)(20))); - // dump this shape - DUMP(strided); - // create Fortran shape from this (should be identical to known) - CODE(aff::util::FortranShape fs1(strided)); - // and dump this - DUMP(fs1.first()); - DUMP(fs1.last()); - DUMP(fs1.dimlast()); - cout << "fs1.offset(): " << fs1.offset() << endl; - - section("Sliced Subshape"); - // now take shape of a subarray - CODE(Strided subshape(strided)); - CODE(subshape.shrink(0,2).shrink(1,3,5).shrink(3,10,20)); - CODE(subshape.collapse(2,15)); - // create Fortran shape from this - CODE(aff::util::FortranShape fs2(subshape)); - // and dump this - DUMP(fs2.first()); - DUMP(fs2.last()); - DUMP(fs2.dimlast()); - cout << "fs2.offset(): " << fs2.offset() << endl; - } - - /*----------------------------------------------------------------------*/ - - section("Pass array to Fortran via subroutine arguments:", '='); - { - // create an array and fill it - CODE(Array A(Shaper(-3,3)(9)(-1,1))); - CODE(A=-55); - // create a subarray view and fill this through Fortran - CODE(Array B=subarray(A)(-2,2)(3,7)(0)); - CODE(f77interface::fill(B)); - // dump the result - CODE(dump_array(A)); - // do it again for a slice - CODE(f77interface::fill(slice(A)()(2))); - CODE(dump_array(A)); - } - - /*----------------------------------------------------------------------*/ - - section("Access to common block:", '='); - { - // prepare to vectors to pass to fillarray - CODE(Array v1(5)); - CODE(Array v2(3)); - CODE(for(int i=v1.f(0); i<=v1.l(0); i++) { v1(i)=2.*i; }); - CODE(for(int i=v2.f(0); i<=v2.l(0); i++) { v2(i)=.5*i; }); - // fill common block through Fortran 77 subroutine - CODE(f77interface::fillarray(v1, v2)); - // get a view on the common block and dump it - CODE(f77interface::Tzarray Z(f77interface::viewcommon())); - CODE(dump_array(Z)); - // call Fortran subroutine sum and dump result - CODE(dump_array(f77interface::sums())); - CODE(typedef f77interface::Tzarray::Tvalue Tzvalue); - // write directly to common block through a subarray - CODE(subarray(Z)(2,4)=Tzvalue(-10.)); - // and dump the effect - CODE(dump_array(Z)); - CODE(dump_array(f77interface::sums())); - } - - /*----------------------------------------------------------------------*/ - - section("Size-checked casts:", '='); - { - CODE(typedef std::complex Ticvalue); - CODE(typedef std::complex Tcvalue); - CODE(Array v1(1)); - CODE(ConstArray v2(v1)); - CODE(FortranArray > fv1(v1)); - CODE(FortranArray > fv2(v2)); - CODE(v1(1)=Ticvalue(3,7)); - CODE(cout << v1(1) << ", " << v2(1) << endl); - CODE(Ticvalue *icp=fv1.castedpointer()); - CODE(*icp=Ticvalue(35,60)); - CODE(cout << v1(1) << ", " << v2(1) << endl); - CODE(const Ticvalue *cicp1=fv1.castedpointer()); - CODE(const Ticvalue *cicp2=fv2.castedpointer()); - CODE(cout << *cicp1 << ", " << *cicp2 << endl); - section("That's dangerous:",' '); - CODE(Tcvalue *cp=fv1.castedpointer()); - CODE(*cp=Ticvalue(35,60)); - CODE(cout << v1(1) << ", " << v2(1) << endl); - CODE(double *dp=fv1.castedpointer()); - CODE(*dp=35.e12); - CODE(cout << v1(1) << ", " << v2(1) << endl); - - section("Test illegal usage (only if activated through macro-definition):", - ' '); - CODE(Array iv1(1)); - CODE(ConstArray iv2(iv1)); - CODE(FortranArray > fiv1(iv1)); - CODE(FortranArray > fiv2(iv2)); - CODE(iv1(1)=50); - CODE(cout << iv1(1) << ", " << iv2(1) << endl); - CODE(int *iv1p=fiv1.pointer()); - CODE(const int *iv2p=fiv2.pointer()); - CODE(cout << *iv1p << ", " << *iv2p << endl); -#ifdef ILLEGAL1 -#warning intentionally compiling illegal code: -#warning direct discard of const qualifier in conversion from non-const - CODE(int *ip1=fiv1.castedpointer()); -#endif -#ifdef ILLEGAL2 -#warning intentionally compiling illegal code: -#warning direct discard of const qualifier in conversion from const array - CODE(int *ip2=fiv2.castedpointer()); -#endif -#ifdef ILLEGAL3 -#warning intentionally compiling illegal code: -#warning discards const in conversion (reinterpret_cast) - CODE(int *ip3=fiv2.castedpointer()); -#endif -#ifdef ILLEGAL4 -#warning intentionally compiling illegal code: -#warning direct type mismatch - CODE(float *ip4=fiv1.castedpointer()); -#endif -#ifdef ILLEGAL5 -#warning intentionally compiling illegal code: -#warning wrong type size in conversion through reinterpret_cast - CODE(double *ip5=fiv1.castedpointer()); -#endif - } - -} // main - -/* ----- END OF f77test.cc ----- */ diff --git a/contrib/aff/tests/functionstest.cc b/contrib/aff/tests/functionstest.cc deleted file mode 100644 index 829bae5..0000000 --- a/contrib/aff/tests/functionstest.cc +++ /dev/null @@ -1,97 +0,0 @@ -/*! \file functionstest.cc - * \brief test function templates - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 20/03/2005 - * - * test function templates - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach) - * - * REVISIONS and CHANGES - * - 20/03/2005 V1.0 Thomas Forbriger - * - 19/06/2006 V1.1 check functions with containers of const - * - * ============================================================================ - */ -#define FUNCTIONSTEST_VERSION \ - "FUNCTIONSTEST V1.1 test function templates" -#define FUNCTIONSTEST_CVSID \ - "$Id$" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace aff; - -using std::cout; -using std::cerr; -using std::endl; - -typedef std::map Tvalmap; - -int main(int iargc, char* argv[]) -{ - CODE( typedef aff::Array Tarray ); - CODE( Tarray A(3,4) ); - CODE( A=5 ); - CODE( Tarray::Tcoc AC=A ); - CODE( subarray(A)(1,1)(2,4)=2. ); - CODE( subarray(A)(2,3)(1,2)=1. ); - CODE( subarray(A)(2,3)(3,4)=-7. ); - CODE( dump_array(A) ); - CODE( cout << aff::func::avg(A) << endl ); - CODE( cout << aff::func::rms(A) << endl ); - CODE( cout << aff::func::max(A) << endl ); - CODE( cout << aff::func::min(A) << endl ); - CODE( cout << aff::func::absmax(A) << endl ); - CODE( cout << aff::func::min(AC) << endl ); - CODE( cout << aff::func::sum(A) << endl ); - CODE( cout << aff::func::sqrsum(A) << endl ); - CODE( typedef aff::func::util::Extracthisto::Tmap Tmap ); - CODE( Tmap mymap=aff::func::histo(A) ); - CODE( typedef Tmap::const_iterator Tmapit ); - CODE( for (Tmapit i=mymap.begin(); i!=mymap.end(); ++i) \ - { cout << i->first << "\t" << i->second << endl; } ); - CODE( Tvalmap avalmap ); - CODE( avalmap[-4.]=1 ); - CODE( avalmap[1.]=2 ); - CODE( avalmap[2.]=3 ); - CODE( avalmap[5.]=4 ); - CODE( aff::Array B= - aff::func::valmap(A, avalmap) ); - CODE( dump_array(B) ); -} - -/* ----- END OF functionstest.cc ----- */ diff --git a/contrib/aff/tests/helpertest.cc b/contrib/aff/tests/helpertest.cc deleted file mode 100644 index d651a23..0000000 --- a/contrib/aff/tests/helpertest.cc +++ /dev/null @@ -1,339 +0,0 @@ -/*! \file helpertest.cc - * \brief test helpers like iterator, subarray and slice (implementation) - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 23/12/2002 - * - * test helpers like iterator, subarray and slice (implementation) - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) - * - * REVISIONS and CHANGES - * - 23/12/2002 V1.0 Thomas Forbriger - * - 28/12/2002 V1.1 (thof) - * - new term for containers of const elements - * - 29/12/2002 V1.2 (thof) - * - new subarray function - * - test subarray of ConstArray - * - new slice function - * - test slice of ConstArray - * - now no resolution conflicts with const containers - * are experienced anymore - * - 10/12/2007 V1.3 (thof) - * - scanning a const array requires a Browser - * - 15/05/2011 V1.4 (thof) - * - test aff::CArray - * - test helpers in converters.h - * - * ============================================================================ - */ -#define AFF_HELPERTEST_CC_VERSION \ - "AFF_HELPERTEST_CC V1.4" -#define AFF_HELPERTEST_CC_CVSID \ - "$Id$" - -/*! \example tests/helpertest.cc - * - * Test helper classes. - * - * This test program gives an example of the usage of the following classes, - * functions, and preprocessor macros: - * - \ref group_array_extensions - * - \ref group_series_extensions - * - aff::CArray - * - aff::Iterator - * - aff::util::Subarray - * - aff::subarray - * - aff::utl::Slice - * - aff::slice - * - aff::Array - * - aff::ConstArray - * - aff::Shaper - * - aff::dump - * - aff::dump_array - * - #DUMP - * - #CODE - * - * \sa tests/helpertest.cc - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using std::cout; -using std::endl; -using namespace aff; - -/*----------------------------------------------------------------------*/ - -//! print headline -void section(const char* s, const char l='-') -{ - cout << endl << s << endl; - const char* p=s; - while (*p) { cout << l; ++p; } - cout << endl; -} - -/*----------------------------------------------------------------------*/ - -//! test for passing subarrays and slices -template -void printarray(const ConstArray& array) -{ - cout << endl; - cout << "Received array in function:" << endl; - dump_array(array); -} - -/*======================================================================*/ - -//! test helper classes -int main() -{ - cout << AFF_HELPERTEST_CC_VERSION << endl; - cout << AFF_HELPERTEST_CC_CVSID << endl; - - section("Preparing test array"); - CODE( Array A(Shaper(-2,2)(-3,3)) ); - CODE( dump_array(A) ); - - section("Tests for class Iterator", '='); - { - CODE(int i=0); - CODE(for( Iterator > I(A); I.valid(); ++I) - { *I=i; i++; }); - CODE( dump_array(A) ); - CODE( ConstArray CA(A.copyout()) ); - CODE( i=1); - // use a browser here - CODE(for( Browser > I(CA); I.valid(); ++I) - { cout << i << ", " << *I << endl; i++; }); - } - - CODE( ConstArray OrigA(A.copyout()) ); - - /*----------------------------------------------------------------------*/ - - section("Tests for class Subarray", '='); - { - section("First mode: Use a Subarray object just for initialization",'.'); - CODE(Array B=aff::util::Subarray >(A)(-1,1)(-2,2)); - CODE( dump_array(B) ); - CODE(B=-5); - CODE( dump_array(A) ); - // you must explicitely create an array through member function array() - CODE(printarray(aff::util::Subarray >(A)(-2,0)(-3,0).array())); - } - - section("Tests of subarray function", '-'); - { - CODE( A.copyin(OrigA) ); - section("First mode: Use a Subarray object just for initialization",'.'); - CODE(Array B=subarray(A)(-1,1)(-2,2)); - CODE( dump_array(B) ); - CODE(B=-5); - CODE( dump_array(A) ); - section("Second mode: Create a Subarray object to which you can assign", - '.'); - CODE(subarray(A)()(1,2)=100); - CODE(subarray(A)(1,1)=-200); - CODE( dump_array(A) ); - // you must explicitely create an array through member function array() - CODE(printarray(subarray(A)(-2,0)(-3,0).array())); - } - - section("Test for subarray of ConstArray",'-'); - { - CODE( dump_array(OrigA) ); - CODE(ConstArray B=subarray(OrigA)(-1,1)(-2,2)); - CODE( dump_array(B) ); - // you must explicitely create an array through member function array() - CODE(printarray(subarray(OrigA)(-2,0)(-3,0).array())); - } - - /*----------------------------------------------------------------------*/ - - section("Tests for class Slice", '='); - { - CODE( A.copyin(OrigA) ); - section("First mode: Use a Slice object just for initialization",'.'); - CODE(Array B=aff::util::Slice >(A)(1,-1)); - CODE( dump_array(B) ); - CODE(B=555); - CODE( dump_array(A) ); - // you must explicitely create an array through member function array() - CODE(printarray(aff::util::Slice >(A)(-2).array())); - } - - section("Test slice function", '-'); - { - CODE( A.copyin(OrigA) ); - section("First mode: Use a Slice object just for initialization",'.'); - CODE(Array B=slice(A)(1,-1)); - CODE( dump_array(B) ); - CODE(B=555); - CODE( dump_array(A) ); - section("Second mode: Create a Slice object to which you can assign", - '.'); - CODE(slice(A)()(1)=666); - CODE(slice(A)(0)=-777); - CODE( dump_array(A) ); - // you must explicitely create an array through member function array() - CODE(printarray(slice(A)(-2).array())); - } - - section("Test slice of ConstArray",'-'); - { - CODE( dump_array(OrigA) ); - CODE(ConstArray B=slice(OrigA)(1,-1)); - CODE( dump_array(B) ); - // you must explicitely create an array through member function array() - CODE(printarray(slice(OrigA)(-2).array())); - } - - /*----------------------------------------------------------------------*/ - - section("Mixed tests", '='); - - section("Iterator on a Subarray"); - { - CODE(int i=501); - CODE(Array B=subarray(A)(-1,1)(-2,2)); - CODE(for( Iterator > I(B); I.valid(); ++I) - { *I=i; i++; }); - CODE( dump_array(A) ); - } - - section("Iterator on a Slice"); - { - CODE(int i=-801); - CODE(Array B=slice(A)(1)); - CODE(for( Iterator > I(B); I.valid(); ++I) - { *I=i; i++; }); - CODE( dump_array(A) ); - } - - section("Extract copy of subarray"); - { - CODE(Array B=subarray(A)(-1,1)(-1,1)); - CODE(dump_array(B)); - CODE(Array C=B.copyout()); - CODE(dump_array(C)); - } - - /*----------------------------------------------------------------------*/ - - section("Test external access interfaces", '='); - - section("Test interface to raw memory array: aff::CArray"); - { - CODE( Array A(Shaper(2)(10,16)(-2,2)(-1,0)); ); - section("fill array"); - for(int i=A.f(0); i<=A.l(0); i++) - { - for(int j=A.f(1); j<=A.l(1); j++) - { - for(int k=A.f(2); k<=A.l(2); k++) - { - for(int l=A.f(3); l<=A.l(3); l++) - { - A(i,j,k,l)=(i-A.f(0)+1)+(j-A.f(1)+1)*10 - +(k-A.f(2)+1)*100+(l-A.f(3)+1)*1000; - } - } - } - } - CODE( dump_array(A,3); ); - CODE( Array B=aff::slice(A)(0,2)(2,-1); ) - CODE( printarray(B) ); - CODE( CArray C(B); ) - section("fill C array"); - CODE( int* p=C.pointer(); ) - CODE( - for (unsigned i=0; i A(-3,4); ) - CODE( for (int i=A.f(); i<=A.l(); ++i) { A(i)=i; }) - CODE( dump(A); ) - CODE( aff::CSeries CS(A); ) - CODE( int* p=CS.pointer(); ) - CODE( for (int i=0; i S=series_from_raw_memory(p, CS.size()); ) - CODE( dump(S); ) - } - - /*----------------------------------------------------------------------*/ - - section("Test converters", '='); - - section("Test conversion from Array to Series"); - { - CODE( Array A(Shaper(2,9)(10,12)(0,2)(2,4)); ); - section("fill array"); - for(int i=A.f(0); i<=A.l(0); i++) - { - for(int j=A.f(1); j<=A.l(1); j++) - { - for(int k=A.f(2); k<=A.l(2); k++) - { - for(int l=A.f(3); l<=A.l(3); l++) - { - A(i,j,k,l)=(i-A.f(0)+1)+(j-A.f(1)+1)*10 - +(k-A.f(2)+1)*100+(l-A.f(3)+1)*1000; - } - } - } - } - CODE( dump_array(A,3); ); - CODE( Array B=aff::slice(A)(1,11)(1,1)(1,3); ) - CODE( printarray(B) ); - CODE( Series C=series_from_array(B); ) - CODE( dump(C); ) - CODE( ConstArray D=B; ) - CODE( ConstSeries E=series_from_array(D); ) - CODE( dump(E); ) - } -} - -/* ----- END OF helpertest.cc ----- */ diff --git a/contrib/aff/tests/operatortest.cc b/contrib/aff/tests/operatortest.cc deleted file mode 100644 index 7eb40bc..0000000 --- a/contrib/aff/tests/operatortest.cc +++ /dev/null @@ -1,159 +0,0 @@ -/*! \file operatortest.cc - * \brief test operator functions - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 10/02/2004 - * - * test operator functions - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach) - * - * REVISIONS and CHANGES - * - 10/02/2004 V1.0 Thomas Forbriger - * - 05/07/2005 V1.1 check operators on containers declared const - * - * ============================================================================ - */ -#define OPERATORTEST_VERSION \ - "OPERATORTEST V1.1 test operator functions" -#define OPERATORTEST_CVSID \ - "$Id$" - -#include -#include -#include -#include -#include -#include -#include -#include - -using std::cout; -using std::cerr; -using std::endl; - -/*----------------------------------------------------------------------*/ - -//! print headline -void section(const char* s, const char l='-') -{ - cout << endl << s << endl; - const char* p=s; - while (*p) { cout << l; ++p; } - cout << endl; -} - -/*======================================================================*/ - -/*! \example tests/operatortest.cc - * - * Here you can learn how to use operators with aff classes. - * - * This test program gives an example of the usage of the following classes, - * functions, and preprocessor macros: - * - aff::Array - * - aff::ConstArray - * - aff::dump - * - aff::dump_array - * - #DUMP - * - #CODE - * - * \sa tests/operatortest.cc - */ - -int main(int iargc, char* argv[]) -{ - cout << OPERATORTEST_VERSION << endl; - cout << OPERATORTEST_CVSID << endl; - - section("Test array operators", '='); - section("Normal array with unary operator"); - CODE(aff::Array A(4,4)); - CODE(A=14.); - CODE(dump_array(A)); - CODE(A+=500.); - CODE(dump_array(A)); - - section("Access through subarray"); - CODE(aff::Array Asub=aff::subarray(A)(2,3)(2,3)); - CODE(Asub/=200); - CODE(dump_array(A)); - - section("binary operator"); - CODE(aff::Array B(A)); - CODE(B=A*5); - CODE(dump_array(B)); - - section("test implicit type conversion"); - CODE(B=10.); - CODE(dump_array(B)); - CODE(B*=0.2); - CODE(dump_array(B)); - CODE(B*=4L); - CODE(dump_array(B)); - CODE(B*=0xa0); - CODE(dump_array(B)); - - section("test advanced type conversion"); - CODE(aff::Array > C(3,3);) - CODE(C=std::complex(14.,2.);) - CODE(dump_array(C)); - CODE(C*=0.2); - CODE(dump_array(C)); - - section("test binary operator with constant input"); - CODE(aff::ConstArray D(A)); - CODE(aff::Array E(D*2.)); - CODE(dump_array(E)); - - section("mixed implicit operations"); - CODE(dump_array((D*5.)-12L)); - - section("Test series operators", '='); - section("test scalar operators"); - CODE(aff::Series F(-3,3)); - CODE(F=5.); - DUMP(F); - CODE(F/=25.); - DUMP(F); - - section("test vector operators"); - CODE(aff::Series G(5)); - CODE(G=5.); - DUMP(G); - DUMP(F+G); - CODE(aff::Series H); - CODE(H=F+G); - DUMP(H); - CODE(H -= F); - DUMP(H); - DUMP((H *= G + 0.2) + 0.2); - DUMP(H); - DUMP(100+H); - DUMP(H+100); - CODE(const aff::Series CH(H)); - DUMP(CH+100); - DUMP(CH -= 10); - DUMP(CH); -} - -/* ----- END OF operatortest.cc ----- */ diff --git a/contrib/aff/tests/reprtest.cc b/contrib/aff/tests/reprtest.cc deleted file mode 100644 index 9a8f207..0000000 --- a/contrib/aff/tests/reprtest.cc +++ /dev/null @@ -1,140 +0,0 @@ -/*! \file reprtest.cc - * \brief test representation classes (implementation) - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 10/05/2002 - * - * test representation classes (implementation) - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * \todo - * Test ALL constructors etc intensively! - * - * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) - * - * REVISIONS and CHANGES - * - 10/05/2002 V1.0 Thomas Forbriger - * - 16/12/2002 V1.1 (thof) - * - compiles and works - * - 28/12/2002 V1.2 (thof) - * - new term for containers of const elements - * - 31/12/2002 V1.3 (thof) - * - initializing an aff::ConstSharedHeap to a defined - * size is a useless exercise - * - * ============================================================================ - */ -#define AFF_REPRTEST_CC_VERSION \ - "AFF_REPRTEST_CC V1.3" -#define AFF_REPRTEST_CC_CVSID \ - "$Id$" - -#include -#include - -using std::cout; -using std::endl; - -/*! \example tests/reprtest.cc - * - * Test representation class aff::SharedHeap. - * - * This test program gives an example of the usage of the following classes - * and preprocessor macros: - * - aff::SharedHeap - * - aff::ConstSharedHeap - * - #DUMP - * - #CODE - * - * \sa tests/reprtest.cc - */ - -//! print headline -void section(const char* s) -{ - cout << endl - << s << endl; - const char* p=s; - while (*p) { - cout << "-"; - ++p; - } - cout << endl; -} - -//! testing SharedHeap -int main() -{ - cout << AFF_REPRTEST_CC_VERSION << endl; - cout << AFF_REPRTEST_CC_CVSID << endl; - - section("array dimensions"); - CODE( const int N=10; ) - CODE( const int N2=23; ) - - section("instantiate arrays"); - CODE( aff::SharedHeap A(N); ) - CODE( aff::SharedHeap B(N2); ) -#ifdef SENSELESS -#warning intentionally compiling senseless code - CODE( aff::ConstSharedHeap Cuseless(N2); ) -#endif - CODE( aff::ConstSharedHeap C; ) - CODE( aff::SharedHeap D(N2); ) - - section("create a const reference to D"); - CODE( aff::SharedHeap::Tcoc E(D); ) - - section("const int array should share memory with int array"); - CODE( C=B; ) - - section("fill arrays"); - CODE( for (int i=0; i::Tcontainer_of_const(A) ); - DUMP( B ); - DUMP( C ); - DUMP( E ); - - section("modify C through B"); - CODE( B[8]=632; ) - DUMP( C ); - -#ifdef ILLEGAL1 - // you may activate this section by passing -DILLEGAL1 to the compiler - section("modify C directly - is illegal"); - C[9]=354; - DUMP( C ); -#endif - - section("make B a reference to A"); - CODE( B=A; ) - section("modification should be visible through B"); - CODE( A[5]=453; ) - DUMP( B ); - section("but C holds the original values"); - DUMP( C ); -} - -/* ----- END OF reprtest.cc ----- */ diff --git a/contrib/aff/tests/seriestest.cc b/contrib/aff/tests/seriestest.cc deleted file mode 100644 index ca49f7c..0000000 --- a/contrib/aff/tests/seriestest.cc +++ /dev/null @@ -1,99 +0,0 @@ -/*! \file seriestest.cc - * \brief test aff::Series class (implementation) - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 17/12/2002 - * - * test aff::Series class (implementation) - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) - * - * REVISIONS and CHANGES - * - 17/12/2002 V1.0 Thomas Forbriger - * - 28/12/2002 V1.1 (thof) - * - new term for containers of const elements - * - 19/12/2003 V1.2 (thof) - * - working on series container - * - * ============================================================================ - */ -#define AFF_SERIESTEST_CC_VERSION \ - "AFF_SERIESTEST_CC V1.2" -#define AFF_SERIESTEST_CC_CVSID \ - "$Id$" - -#include -#include - -using std::cout; -using std::endl; - -/*! \example tests/seriestest.cc - * - * Test series class aff::Series. - * - * \sa tests/seriestest.cc - */ - -//! print headline -void section(const char* s) -{ - cout << endl - << s << endl; - const char* p=s; - while (*p) { - cout << "-"; - ++p; - } - cout << endl; -} - -//! testing SharedHeap -int main() -{ - cout << AFF_SERIESTEST_CC_VERSION << endl; - cout << AFF_SERIESTEST_CC_CVSID << endl; - - section("array dimensions"); - CODE( const int N=5 ); - CODE( const int N2=-5 ); - - section("create a series container"); - CODE( aff::Series A ); - CODE( aff::Series B(N) ); - CODE( aff::Series C(N2,N) ); - DUMP( A ); - DUMP( B ); - DUMP( C ); - CODE( A=B ); - DUMP( A ); - CODE( aff::ConstSeries D(C) ); - CODE( for (int i=C.first(); i<=C.last(); i++) { C(i)=i; } ); - DUMP( D ); -#ifdef ILLEGAL1 - CODE( D(6)=10 ); -#endif - CODE( D.shift(300) ); - DUMP( D ); -} - -/* ----- END OF seriestest.cc ----- */ diff --git a/contrib/aff/tests/shapetest.cc b/contrib/aff/tests/shapetest.cc deleted file mode 100644 index adc1aca..0000000 --- a/contrib/aff/tests/shapetest.cc +++ /dev/null @@ -1,217 +0,0 @@ -/*! \file shapetest.cc - * \brief test shape classes (implementation) - * - * ---------------------------------------------------------------------------- - * - * $Id$ - * \author Thomas Forbriger - * \date 25/05/2002 - * - * test shape classes (implementation) - * - * ---- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * ---- - * - * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) - * - * REVISIONS and CHANGES - * - 25/05/2002 V1.0 Thomas Forbriger - * - 18/12/2002 V1.1 (thof) - * - started test of Strided (aff) - * - test works - * - 19/12/2002 V1.2 (thof) - * - print valid() of stepper too - * - 09/01/2003 V1.3 (thof) - * - using too many bracket operators now triggers - * an exception in aff::Shaper - * - * ============================================================================ - */ -#define AFF_SHAPETEST_CC_VERSION \ - "AFF_SHAPETEST_CC V1.3" -#define AFF_SHAPETEST_CC_CVSID \ - "$Id$" - -#include -#include -#include -#include - -using std::cout; -using std::endl; -using namespace aff; - -/*! \example tests/shapetest.cc - * - * Test shape aff::Strided, the shaper class aff::Shaper, - * and the helper class aff::util::StridedStepper - * - * This test program gives an example of the usage of the following classes, - * functions, and preprocessor macros: - * - aff::Strided - * - aff::StridedStepper - * - aff::Shaper - * - aff::dump - * - aff::dump_map - * - #DUMP - * - #CODE - * - * \sa tests/shapetest.cc - */ - -/*----------------------------------------------------------------------*/ - -//! print headline -void section(const char* s, const char l='-') -{ - cout << endl << s << endl; - const char* p=s; - while (*p) { cout << l; ++p; } - cout << endl; -} - -/*----------------------------------------------------------------------*/ - -//! print value of a bool -const char* bvalue(const bool& b) -{ if (b) return("true"); return("false"); } - -/*----------------------------------------------------------------------*/ - -//! print value of a bool -#define BOOLIS( S ) cout << " *** " << #S << ": " << bvalue(S); - -/*----------------------------------------------------------------------*/ - -//! cycle steppers -void steppers(const Strided& shape, const int& nmax=30) -{ - StridedStepper s1(shape), s2(shape); - s2.tolast(); - for (int i=0; i