├── TODO ├── tests ├── abs.test ├── bitop.test ├── prng.test ├── genmatrix.test ├── prime.test ├── eratosthenes.test ├── rule.test ├── arithmetic.test ├── nx.test ├── toms659 │ └── Makefile.am ├── linearalgebra.test ├── shiftnet.test ├── compare_with_sobol_in_toms659.test ├── partition.test ├── compare_with_nied_2_in_toms738.test ├── compare_with_halton_in_toms659.test ├── combination.test ├── compare_with_faure_in_toms659.test ├── compare_with_nied_pp_in_toms738.test ├── compare_with_nied_prime_in_toms738.test ├── toms738 │ ├── Makefile.am │ ├── ptoi.f │ ├── plyadd.f │ ├── itop.f │ ├── charac.f │ └── plymul.f ├── tparameter.test ├── test_charsetw.cpp ├── test_arithmetic_poly2.cpp ├── test_charset.h ├── test_arithmetic_gf2.cpp ├── test_arithmetic_real.cpp ├── numericdiff.cpp ├── test_arithmetic.h └── test_arithmetic_integer.cpp ├── manual.pdf ├── ChangeLog ├── libtest ├── func.cpp ├── lib.cpp ├── include.h ├── Makefile.am ├── main.cpp └── create.sh ├── Makefile.am ├── AUTHORS ├── share ├── README ├── Makefile.am └── convert_matrix.cpp ├── README └── src ├── mcintegrator_MPI.cpp ├── qmcintegrator_MPI.cpp ├── qrnsequencebase.cpp ├── virtualprng.cpp ├── staticloadbalancer.cpp ├── linearalgebra_lf.cpp ├── linearalgebra2.cpp ├── HIntLib ├── _defaults1.h ├── faure.h ├── discrepancy.h ├── shiftnet.h ├── niederreitermatrixgen.h ├── exception_MPI.h ├── rulegauss.h ├── niederreitermatrix.h ├── integrand.h ├── galoisfield.h ├── halton.h ├── sobolmatrix.h ├── rulebasedintegrator.h ├── ruleintegrator.h ├── rule1midpoint.h ├── rule2ionescu.h ├── cubepartitioner.h ├── linearalgebra2.h ├── polynomialbase.h ├── rule2thacher.h ├── rule3ewing.h ├── compruleintegrator.h ├── defaultcubaturerulefactory.h ├── productrule.h ├── rule3simpson.h ├── rule3gauss.h ├── rule5gauss.h ├── rule75genzmalik.h ├── qmcintegrator.h ├── rule3cross.h ├── rule1trapezoidal.h ├── rule2simplex.h ├── miser.h ├── vegas.h ├── rule9stenger.h ├── staticloadbalancer.h ├── rule5hammer.h ├── rule5mustardlynessblatt.h ├── rule3octahedron.h ├── gcd.h ├── output.h ├── rule5stroud2.h ├── rule7phillips.h ├── rule5stroud.h └── adaptintegratorlocallist.h ├── polynomial2.cpp ├── polynomial_gm.cpp ├── polynomial_rational.cpp ├── polynomial_gf.cpp ├── polynomial_lf.cpp ├── kahanadd.cpp ├── polynomial_real.cpp ├── factorring_lf.cpp ├── factorring_x.cpp ├── mcpointset.cpp ├── pointset.cpp ├── hlmpi.cpp ├── polynomial_ring.cpp ├── builtinprng.cpp ├── staticloadbalancer_MPI.cpp ├── rule1midpoint.cpp ├── halton.cpp ├── integrator.cpp ├── rulebasedintegrator.cpp ├── exception_MPI.cpp ├── make.cpp ├── testintegrand.cpp ├── digitalnetgen.cpp ├── buffer.cpp ├── quotientfield.cpp ├── rule1trapezoidal.cpp ├── rule3cross.cpp ├── rule3ewing.cpp ├── rule3simpson.cpp └── create_bitop.cpp /TODO: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/abs.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_abs -s 4 | 5 | exit $? 6 | 7 | -------------------------------------------------------------------------------- /tests/bitop.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_bitop -s 4 | 5 | exit $? 6 | 7 | -------------------------------------------------------------------------------- /tests/prng.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_prng -s 4 | 5 | exit $? 6 | 7 | -------------------------------------------------------------------------------- /manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesBuchner/HIntLib/master/manual.pdf -------------------------------------------------------------------------------- /tests/genmatrix.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_genmatrix -s 4 | 5 | exit $? 6 | -------------------------------------------------------------------------------- /tests/prime.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_prime -s -n 7000 4 | 5 | exit $? 6 | 7 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2 | The old content of the ChangeLog file has been moved to the file NEWS. 3 | 4 | -------------------------------------------------------------------------------- /tests/eratosthenes.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_eratosthenes -s -n 10000 4 | 5 | exit $? 6 | 7 | -------------------------------------------------------------------------------- /tests/rule.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo RUNNING: rule.test 4 | 5 | ./test_rule -s -s -d 60 6 | 7 | exit $? 8 | 9 | -------------------------------------------------------------------------------- /tests/arithmetic.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo RUNNING: arithmetic.test 4 | 5 | ./test_arithmetic -s -n 4000 6 | 7 | exit $? 8 | 9 | -------------------------------------------------------------------------------- /libtest/func.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "include.h" 3 | 4 | 5 | A::A() : a(MAGIC) {} 6 | 7 | int f() 8 | { 9 | return MAGIC; 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | # SUBDIRS = libtest src share tests development 4 | SUBDIRS = libtest src share tests 5 | 6 | EXTRA_DIST = manual.pdf 7 | 8 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | HIntLib (c) 2002,2003,2004,2005,2006,2007,2008 is written by 2 | 3 | Rudolf Sch\"urer 4 | Department of Mathematics 5 | University of Salzburg 6 | AUSTRIA 7 | 8 | -------------------------------------------------------------------------------- /libtest/lib.cpp: -------------------------------------------------------------------------------- 1 | #include "include.h" 2 | 3 | const int X::constIntVar = f(); 4 | const double X::constDoubleVar = double (f()); 5 | int X::intVar = f(); 6 | double X::doubleVar = double (f()); 7 | 8 | A X::a; 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/nx.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | for dim in 1 2 3 4 5 6 7 4 | do 5 | ./test_qrnsequence -d $dim seq 2006 0 10000 > /dev/null 6 | 7 | if test $? -ne 0; then 8 | echo "test_qrnsequence failed!" 9 | exit 1 10 | fi 11 | done 12 | 13 | exit 0 14 | -------------------------------------------------------------------------------- /tests/toms659/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | check_PROGRAMS = sobol halton faure 4 | 5 | sobol_SOURCES = sobol.f 6 | halton_SOURCES = halton.f 7 | faure_SOURCES = faure.f 8 | 9 | EXTRA_DIST = faure_ori.f halton_ori.f sobol_ori.f original_source.txt COPYRIGHT.html 10 | 11 | -------------------------------------------------------------------------------- /share/README: -------------------------------------------------------------------------------- 1 | 2 | Niederreiter/Xing Generator Matrices 3 | ==================================== 4 | 5 | The *.cmx files in this directory are generator matrices for the 6 | Niederrieter/Xing Digital Nets in LibSeq-Format. 7 | 8 | These files were generated by Gottlib Pirsic and are available at 9 | http://www.dismat.oeaw.ac.at/pirs/niedxing.html 10 | 11 | -------------------------------------------------------------------------------- /tests/linearalgebra.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo "RUNNING: linearalgebra.test" 4 | echo -n "Base b =" 5 | 6 | for base in 2 3 4 5 7 8 9 16 17 81 7 | do 8 | echo -n " $base" 9 | 10 | for size in 1 2 3 4 5 10 20 50 100 11 | do 12 | ./test_linearalgebra -s -n 50 $base $size || exit 1 13 | done 14 | done 15 | 16 | echo 17 | 18 | exit 0 19 | 20 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | Welcome to HIntLib! 3 | =================== 4 | 5 | HIntLib is a C++ library for high-dimensional numerical integration. 6 | 7 | All the documentation on HIntLib is contained in the manual, which can be 8 | found as manual.pdf in the same directory as README. 9 | 10 | Appendix A of the manual deals with building and installing HIntLib. 11 | 12 | The official website can be found at http://mint.sbg.ac.at/HIntLib/ 13 | -------------------------------------------------------------------------------- /tests/shiftnet.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo "RUNNING: shiftnet.test" 4 | 5 | ./test_shiftnet -s -m 20 2 || { (exit 1); exit 1; } 6 | ./test_shiftnet -s -m 15 3 || { (exit 1); exit 1; } 7 | ./test_shiftnet -s -m 15 4 || { (exit 1); exit 1; } 8 | ./test_shiftnet -s -m 14 5 || { (exit 1); exit 1; } 9 | ./test_shiftnet -s -m 12 7 || { (exit 1); exit 1; } 10 | ./test_shiftnet -s -m 13 8 || { (exit 1); exit 1; } 11 | ./test_shiftnet -s -m 12 9 || { (exit 1); exit 1; } 12 | 13 | exit 0 14 | 15 | -------------------------------------------------------------------------------- /libtest/include.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INCLUDE_H 3 | #define INCLUDE_H 4 | 5 | #define MAGIC 0xaffe 6 | 7 | class A 8 | { 9 | public: 10 | A(); 11 | int get() const { return a; } 12 | 13 | private: 14 | 15 | int a; 16 | }; 17 | 18 | int f(); 19 | 20 | class X 21 | { 22 | public: 23 | 24 | static const int constIntVar; 25 | static const double constDoubleVar; 26 | static int intVar; 27 | static double doubleVar; 28 | 29 | static A a; 30 | }; 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /libtest/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | EXTRA_DIST = create.sh 4 | 5 | noinst_HEADERS = include.h 6 | 7 | lib_LTLIBRARIES = libhintlibtest.la 8 | libhintlibtest_la_SOURCES = func.cpp lib.cpp 9 | libhintlibtest_la_LDFLAGS = @NOUNDEFINED@ 10 | 11 | noinst_PROGRAMS = main 12 | main_SOURCES = main.cpp 13 | 14 | AM_CXXFLAGS = @COMPILERWARNINGS@ 15 | LDADD = libhintlibtest.la 16 | 17 | result.h: main@EXEEXT@ create.sh 18 | $(srcdir)/create.sh 19 | 20 | clean-local: 21 | rm -rf ii_files result.h 22 | 23 | -------------------------------------------------------------------------------- /tests/compare_with_sobol_in_toms659.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_qrnsequence -p 10 -s -d 40 seq 1200 1 10000 > hintlib_sobol.txt 4 | 5 | if test $? -ne 0; then 6 | echo "test_qrnsequence failed!" 7 | { (exit 1); exit 1; } 8 | fi 9 | 10 | cat < toms659_sobol.txt 11 | 40 12 | 9999 13 | EOF 14 | 15 | if test $? -ne 0; then 16 | echo "toms659/sobol failed!" 17 | { (exit 1); exit 1; } 18 | fi 19 | 20 | ./numericdiff hintlib_sobol.txt toms659_sobol.txt || exit 1 21 | 22 | rm hintlib_sobol.txt toms659_sobol.txt 23 | 24 | { (exit 0); exit 0; } 25 | 26 | -------------------------------------------------------------------------------- /tests/partition.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo RUNNING: partition.test 4 | 5 | for slots in 1 2 3 4 5 6 7 8 9 10 6 | do 7 | echo -n "$slots " 8 | 9 | for items in 0 1 2 3 4 5 6 7 8 9 10 11 10 | do 11 | res=1 12 | while test $res -le $items 13 | do 14 | mul=`expr $res \* $slots` 15 | if test $mul -ge $items 16 | then 17 | ./test_partition -s -r $res $slots $items || { (exit 1); exit 1; } 18 | fi 19 | 20 | res=`expr $res + 1` 21 | done 22 | done 23 | done 24 | 25 | echo 26 | 27 | exit 0 28 | 29 | -------------------------------------------------------------------------------- /tests/compare_with_nied_2_in_toms738.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_qrnsequence -p 10 -s -d 12 seq 1201 1 10000 > hintlib_nied2.txt 4 | 5 | if test $? -ne 0; then 6 | echo "test_qrnsequence failed!" 7 | { (exit 1); exit 1; } 8 | fi 9 | 10 | cat < toms738_nied2.txt 11 | 12 12 | 9999 13 | 1 14 | EOF 15 | 16 | if test $? -ne 0; then 17 | echo "toms738/genin2 failed!" 18 | { (exit 1); exit 1; } 19 | fi 20 | 21 | ./numericdiff hintlib_nied2.txt toms738_nied2.txt || exit 1 22 | 23 | rm hintlib_nied2.txt toms738_nied2.txt 24 | 25 | { (exit 0); exit 0; } 26 | 27 | -------------------------------------------------------------------------------- /tests/compare_with_halton_in_toms659.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ./test_qrnsequence -p 10 -s -d 40 seq 9000 1 5000 > hintlib_halton.txt 4 | 5 | if test $? -ne 0; then 6 | echo "test_qrnsequence failed!" 7 | { (exit 1); exit 1; } 8 | fi 9 | 10 | cat < toms659_halton.txt 11 | 40 12 | 4999 13 | .00000000000001 14 | EOF 15 | 16 | if test $? -ne 0; then 17 | echo "toms659/halton failed!" 18 | { (exit 1); exit 1; } 19 | fi 20 | 21 | ./numericdiff hintlib_halton.txt toms659_halton.txt || exit 1 22 | 23 | rm hintlib_halton.txt toms659_halton.txt 24 | 25 | { (exit 0); exit 0; } 26 | 27 | -------------------------------------------------------------------------------- /tests/combination.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo RUNNING: combination.test 4 | 5 | silent=-s 6 | 7 | for slots in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 8 | do 9 | echo -n "$slots " 10 | 11 | items=0 12 | while test $items -le $slots 13 | do 14 | ./test_combination $silent $slots $items || { (exit 1); exit 1; } 15 | items=`expr $items + 1` 16 | done 17 | done 18 | 19 | echo -n "32" 20 | 21 | for items in 0 1 2 3 4 5 27 28 29 30 31 32 22 | do 23 | ./test_combination $silent 32 $items || { (exit 1); exit 1; } 24 | done 25 | 26 | echo 27 | 28 | { (exit 0); exit 0; } 29 | 30 | -------------------------------------------------------------------------------- /libtest/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "include.h" 5 | 6 | int main() 7 | { 8 | bool x = true; 9 | 10 | if (X::intVar != MAGIC) 11 | { 12 | puts ("\"static int\" in library is broken!\n"); 13 | x = false; 14 | } 15 | if (X::constIntVar != MAGIC) 16 | { 17 | puts ("\"static const int\" in library is broken!\n"); 18 | x = false; 19 | } 20 | if (X::a.get() != MAGIC) 21 | { 22 | puts ("static object in library is broken!\n"); 23 | x = false; 24 | } 25 | 26 | // 110 ok 27 | // 111 failed 28 | 29 | exit (x ? 110 : 111); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /tests/compare_with_faure_in_toms659.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo RUNNING: compare_with_faure_in_toms659.test 4 | 5 | for dim in 2 3 4 5 6 7 8 9 10 11 30 31 32 40 6 | do 7 | echo "Checking dimension $dim..." 8 | 9 | ./test_qrnsequence -p 10 -s -d $dim seq 2100 0 10000 > hintlib_faure_${dim}.txt 10 | 11 | if test $? -ne 0; then 12 | echo "test_qrnsequence failed!" 13 | { (exit 1); exit 1; } 14 | fi 15 | 16 | cat < toms659_faure_${dim}.txt 17 | $dim 18 | 10000 19 | EOF 20 | 21 | if test $? -ne 0; then 22 | echo "toms659/faure failed!" 23 | { (exit 1); exit 1; } 24 | fi 25 | 26 | ./numericdiff hintlib_faure_${dim}.txt toms659_faure_${dim}.txt || exit 1 27 | 28 | rm hintlib_faure_${dim}.txt toms659_faure_${dim}.txt 29 | done 30 | 31 | { (exit 0); exit 0; } 32 | 33 | -------------------------------------------------------------------------------- /tests/compare_with_nied_pp_in_toms738.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo RUNNING: compare_with_nied_pp_in_toms738.test 4 | 5 | for p in 04 08 16 32 09 27 25 49 6 | do 7 | echo "Checking prime power base $p..." 8 | 9 | ./test_qrnsequence -p 10 -s -d 12 seq 20${p} 0 10000 > hintlib_nied${p}.txt 10 | 11 | if test $? -ne 0; then 12 | echo "test_qrnsequence failed!" 13 | { (exit 1); exit 1; } 14 | fi 15 | 16 | cat < toms738_nied${p}.txt 17 | 12 18 | ${p} 19 | 10000 20 | 0 21 | EOF 22 | 23 | if test $? -ne 0; then 24 | echo "toms738/genin failed!" 25 | { (exit 1); exit 1; } 26 | fi 27 | 28 | ./numericdiff hintlib_nied${p}.txt toms738_nied${p}.txt || exit 1 29 | 30 | rm hintlib_nied${p}.txt toms738_nied${p}.txt 31 | done 32 | 33 | { (exit 0); exit 0; } 34 | 35 | -------------------------------------------------------------------------------- /tests/compare_with_nied_prime_in_toms738.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo RUNNING: compare_with_nied_prime_in_toms738.test 4 | 5 | for p in 02 03 05 07 11 13 17 19 23 29 31 37 41 43 47 6 | do 7 | echo "Checking prime number base $p..." 8 | 9 | ./test_qrnsequence -p 10 -s -d 12 seq 20${p} 0 10000 > hintlib_nied${p}.txt 10 | 11 | if test $? -ne 0; then 12 | echo "test_qrnsequence failed!" 13 | { (exit 1); exit 1; } 14 | fi 15 | 16 | cat < toms738_nied${p}.txt 17 | 12 18 | ${p} 19 | 10000 20 | 0 21 | EOF 22 | 23 | if test $? -ne 0; then 24 | echo "toms738/genin failed!" 25 | { (exit 1); exit 1; } 26 | fi 27 | 28 | ./numericdiff hintlib_nied${p}.txt toms738_nied${p}.txt || exit 1 29 | 30 | rm hintlib_nied${p}.txt toms738_nied${p}.txt 31 | done 32 | 33 | { (exit 0); exit 0; } 34 | 35 | -------------------------------------------------------------------------------- /tests/toms738/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | check_PROGRAMS = genin2 genin gfarit gfplys 4 | 5 | genin2_SOURCES = genin2.f inlo2.f golo2.f calcc2.f calcv.f setfld.f plymul.f charac.f 6 | genin_SOURCES = genin.f inlo.f golo.f calcc.f calcv.f setfld.f plymul.f charac.f 7 | genin_DEPENDENCIES = gftabs.dat irrtabs.dat 8 | gfarit_SOURCES = gfarit.f charac.f setfld.f itop.f ptoi.f plyadd.f plymul.f plydiv.f 9 | gfplys_SOURCES = gfplys.f charac.f setfld.f itop.f ptoi.f plymul.f 10 | gfplys_DEPENDENCIES = gftabs.dat 11 | 12 | CLEANFILES = gftabs.dat irrtabs.dat 13 | EXTRA_DIST = genin2_ori.f genin_ori.f gfplys_ori.f original_source.txt COPYRIGHT.html 14 | 15 | gftabs.dat: gfarit@EXEEXT@ 16 | @echo "Creating \"gftabs.dat\"" 17 | test -x ./gfarit@EXEEXT@ || sleep 1 18 | ./gfarit@EXEEXT@ 19 | 20 | irrtabs.dat: gfplys@EXEEXT@ 21 | @echo "Creating \"irrtabs.dat\"" 22 | test -x ./gfplys@EXEEXT@ || sleep 1 23 | ./gfplys@EXEEXT@ 24 | 25 | 26 | -------------------------------------------------------------------------------- /libtest/create.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./main 4 | x=$? 5 | 6 | if test $x -eq 111; then 7 | 8 | cat>result.h << EOF 9 | 10 | /** 11 | * Class-static variables are NOT initialized properly in libraries. 12 | */ 13 | 14 | #define HINTLIB_STATIC_WORKS 0 15 | EOF 16 | 17 | else 18 | if test $x -eq 110; then 19 | 20 | cat>result.h <result.h < 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include "mcintegrator.cpp" 26 | 27 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 28 | #pragma implementation "mcintegrator.h" 29 | #endif 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/qmcintegrator_MPI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include "qmcintegrator.cpp" 26 | 27 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 28 | #pragma implementation "qmcintegrator.h" 29 | #endif 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/qrnsequencebase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 26 | #pragma implementation 27 | #endif 28 | 29 | HIntLib::QRNSequenceBase::QRNSequenceBase (const Hypercube &cube) 30 | : h (cube), n(0) 31 | {} 32 | 33 | -------------------------------------------------------------------------------- /src/virtualprng.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * PRNG 23 | * 24 | * Abstract base class for Pseudo Random Number Generators 25 | */ 26 | 27 | 28 | #define HINTLIB_LIBRARY_OBJECT 29 | 30 | #include 31 | 32 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 33 | #pragma implementation 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /src/staticloadbalancer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Real Static Load Balancer 23 | * 24 | * Distributes a task statically among all available processing nodes 25 | */ 26 | 27 | #define HINTLIB_LIBRARY_OBJECT 28 | 29 | #include 30 | 31 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 32 | #pragma implementation 33 | #endif 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/linearalgebra_lf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace HIntLib 28 | { 29 | HINTLIB_INSTANTIATE_LINEARALGEBRAGEN (ModularArithmeticField) 30 | HINTLIB_INSTANTIATE_LINEARALGEBRAGEN (ModularArithmeticField) 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/linearalgebra2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 26 | #pragma implementation 27 | #endif 28 | 29 | namespace HIntLib 30 | { 31 | HINTLIB_INSTANTIATE_LINEARALGEBRA2 (u32*) 32 | #ifdef HINTLIB_U32_NOT_EQUAL_U64 33 | HINTLIB_INSTANTIATE_LINEARALGEBRA2 (u64*) 34 | #endif 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/HIntLib/_defaults1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * defaults.h 23 | * 24 | * Defines a number of global data types, most noteworthy the type used for 25 | * normal floating-point arithmetic (real) and for counting loop iterations 26 | * for long-running loops like integrand evaluations, sequence-numbers,... 27 | */ 28 | 29 | #ifndef HINTLIB_DEFAULTS_H 30 | #define HINTLIB_DEFAULTS_H 1 31 | 32 | namespace HIntLib 33 | { 34 | 35 | -------------------------------------------------------------------------------- /src/HIntLib/faure.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_FAURE_H 22 | #define HINTLIB_FAURE_H 1 23 | 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | #pragma interface 28 | #endif 29 | 30 | namespace HIntLib 31 | { 32 | template class GeneratorMatrixGen; 33 | 34 | void initFaure (GeneratorMatrixGen&); 35 | 36 | } // namespace HIntLib 37 | 38 | #endif 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/polynomial2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | #include 25 | 26 | namespace HIntLib 27 | { 28 | HINTLIB_INSTANTIATE_POLYNOMIAL2 (u32) 29 | HINTLIB_INSTANTIATE_GF2VECTORSPACE (u32) 30 | #ifdef HINTLIB_U32_NOT_EQUAL_U64 31 | HINTLIB_INSTANTIATE_POLYNOMIAL2 (u64) 32 | HINTLIB_INSTANTIATE_GF2VECTORSPACE (u64) 33 | #endif 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/polynomial_gm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace HIntLib 28 | { 29 | HINTLIB_INSTANTIATE_POLYNOMIALRING_GF (LookupField) 30 | HINTLIB_INSTANTIATE_POLYNOMIALRING_GF (LookupFieldPow2) 31 | HINTLIB_INSTANTIATE_POLYNOMIALRING_GF (LookupFieldPrime) 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/polynomial_rational.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace HIntLib 29 | { 30 | // Polynomial<> 31 | 32 | HINTLIB_INSTANTIATE_POLYNOMIAL (Quotient) 33 | 34 | // PolynomialRing<> 35 | 36 | HINTLIB_INSTANTIATE_POLYNOMIALRING_RATIONAL(QuotientField >) 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/polynomial_gf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace HIntLib 29 | { 30 | // Polynomial<> 31 | 32 | HINTLIB_INSTANTIATE_POLYNOMIAL (Quotient >) 33 | 34 | // PolynomialRing<> 35 | 36 | HINTLIB_INSTANTIATE_POLYNOMIALRING_GF (GF2) 37 | HINTLIB_INSTANTIATE_POLYNOMIALRING_FIELD(QuotientField >) 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/polynomial_lf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace HIntLib 28 | { 29 | HINTLIB_INSTANTIATE_POLYNOMIAL (unsigned char) 30 | HINTLIB_INSTANTIATE_POLYNOMIAL (unsigned short) 31 | 32 | HINTLIB_INSTANTIATE_POLYNOMIALRING_GF 33 | (ModularArithmeticField) 34 | HINTLIB_INSTANTIATE_POLYNOMIALRING_GF 35 | (ModularArithmeticField) 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/kahanadd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * KahanAdd 23 | * 24 | * Compensated (Kahan) Summation 25 | * 26 | * This class acts like a simple real when it is used for summation (wiht +=). 27 | * However, its much more stable numerically. 28 | * 29 | * See Krommer, Ueberhuber. Computational Integration. p 333 vor details 30 | */ 31 | 32 | #define HINTLIB_LIBRARY_OBJECT 33 | 34 | #include 35 | 36 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 37 | #pragma implementation 38 | #endif 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/polynomial_real.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace HIntLib 28 | { 29 | // Polynomial<> 30 | 31 | HINTLIB_INSTANTIATE_POLYNOMIAL_NO_EQUAL (Real) 32 | HINTLIB_INSTANTIATE_POLYNOMIAL_NO_EQUAL (Complex) 33 | 34 | // PolynomialRing<> 35 | 36 | HINTLIB_INSTANTIATE_POLYNOMIALRING_REAL (RealField) 37 | HINTLIB_INSTANTIATE_POLYNOMIALRING_COMPLEX (ComplexField) 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/factorring_lf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 26 | #pragma implementation 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | namespace HIntLib 33 | { 34 | HINTLIB_INSTANTIATE_FACTORRING_POL 35 | (PolynomialRing >) 36 | HINTLIB_INSTANTIATE_FACTORRING_POL 37 | (PolynomialRing >) 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/HIntLib/discrepancy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | 22 | #ifndef HINTLIB_DISCREPANCY_H 23 | #define HINTLIB_DISCREPANCY_H 1 24 | 25 | #include 26 | 27 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 28 | #pragma interface 29 | #endif 30 | 31 | namespace HIntLib 32 | { 33 | real l2DiscrepancyWarnock (const real*, unsigned, Index); 34 | real l2DiscrepancyHeinrich (const real*, unsigned, Index); 35 | real l2Discrepancy (const real*, unsigned, Index); 36 | 37 | real starDiscrepancy (const real*, unsigned, Index); 38 | 39 | } // namespace HIntLib 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /tests/tparameter.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | echo RUNNING: tparameter.test 4 | 5 | p1="./test_tparameter -s -b -r -d 15 -m 15" 6 | p2="./test_tparameter -s -b -r -d 15 -m 7" 7 | 8 | echo "Testing Faure..." 9 | $p2 0 || 10 | { echo "tparameter test for Faure fails!"; { (exit 1); exit 1; }; } 11 | $p2 -e 0 || 12 | { echo "tparameter test for Equi-Faure fails!"; { (exit 1); exit 1; }; } 13 | 14 | echo "Testing Sobol..." 15 | $p1 1 || 16 | { echo "tparameter test for Sobol fails!"; { (exit 1); exit 1; }; } 17 | $p1 -e 1 || 18 | { echo "tparameter test for Equi-Sobol fails!"; { (exit 1); exit 1; }; } 19 | 20 | echo "Testing Niederreiter, b=2..." 21 | $p1 2 || 22 | { echo "tparameter test for Niederreiter, b=2 fails!"; { (exit 1);exit 1; }; } 23 | $p1 -e 2 || 24 | { echo "tparameter test for Equi-Niederreiter, b=2 fails!"; { (exit 1);exit 1; }; } 25 | 26 | echo "Testing Niederreiter, b=3..." 27 | $p2 3 || 28 | { echo "tparameter test for Niederreiter, b=3 fails!"; { (exit 1);exit 1; }; } 29 | $p2 -e 3 || 30 | { echo "tparameter test for Equi-Niederreiter, b=3 fails!"; { (exit 1);exit 1; }; } 31 | 32 | echo "Testing Niederreiter, b=4..." 33 | $p2 4 || 34 | { echo "tparameter test for Niederreiter, b=4 fails!"; { (exit 1);exit 1; }; } 35 | $p2 -e 4 || 36 | { echo "tparameter test for Equi-Niederreiter, b=4 fails!"; { (exit 1);exit 1; }; } 37 | 38 | echo "Testing Niederreiter/Xing..." 39 | $p1 6 || 40 | { echo "tparameter test for Niederreiter/Xing fails!"; { (exit 1);exit 1; }; } 41 | $p1 -e 6 || 42 | { echo "tparameter test for Equi-Niederreiter/Xing fails!"; { (exit 1);exit 1; }; } 43 | 44 | exit 0 45 | 46 | -------------------------------------------------------------------------------- /src/factorring_x.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 26 | #pragma implementation 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace HIntLib 35 | { 36 | HINTLIB_INSTANTIATE_FACTORRING_POLI 37 | (PolynomialRing > >) 38 | 39 | HINTLIB_INSTANTIATE_FACTORRING_POLI 40 | (PolynomialRing > >) 41 | 42 | HINTLIB_INSTANTIATE_FACTORRING_INT (IntegerRing) 43 | } 44 | 45 | -------------------------------------------------------------------------------- /share/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | files = \ 4 | fkmat04.cmx fkmat05.cmx fkmat06.cmx fkmat07.cmx fkmat08.cmx fkmat09.cmx \ 5 | fkmat10.cmx fkmat11.cmx fkmat12.cmx fkmat13.cmx fkmat14.cmx fkmat15.cmx \ 6 | fkmat16.cmx fkmat17.cmx fkmat18.cmx fkmat19.cmx fkmat20.cmx fkmat21.cmx \ 7 | fkmat22.cmx fkmat23.cmx fkmat24.cmx fkmat25.cmx fkmat26.cmx fkmat27.cmx \ 8 | fkmat28.cmx fkmat29.cmx fkmat30.cmx fkmat31.cmx fkmat32.cmx 9 | 10 | # fkmat511b64.cmx fkmat63b16.cmx 11 | 12 | filesbin = \ 13 | fkmat04.bin fkmat05.bin fkmat06.bin fkmat07.bin fkmat08.bin fkmat09.bin \ 14 | fkmat10.bin fkmat11.bin fkmat12.bin fkmat13.bin fkmat14.bin fkmat15.bin \ 15 | fkmat16.bin fkmat17.bin fkmat18.bin fkmat19.bin fkmat20.bin fkmat21.bin \ 16 | fkmat22.bin fkmat23.bin fkmat24.bin fkmat25.bin fkmat26.bin fkmat27.bin \ 17 | fkmat28.bin fkmat29.bin fkmat30.bin fkmat31.bin fkmat32.bin 18 | 19 | # fkmat511b64.bin fkmat63b16.bin 20 | 21 | pkgdata_DATA = $(filesbin) 22 | EXTRA_DIST = $(files) convert_matrix.cpp README 23 | CLEANFILES = $(filesbin) 24 | 25 | noinst_PROGRAMS = convert_matrix 26 | convert_matrix_SOURCES = convert_matrix.cpp 27 | 28 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src 29 | AM_CXXFLAGS = @COMPILERWARNINGS@ 30 | LDADD = ../src/libhintlib.la 31 | 32 | clean-local: 33 | -rm -rf ii_files 34 | 35 | SUFFIXES = .cmx .bin 36 | 37 | $(filesbin): convert_matrix@EXEEXT@ 38 | 39 | .cmx.bin: 40 | @echo Converting $< to $@ ... 41 | test -x ./convert_matrix@EXEEXT@ || sleep 1 42 | ./convert_matrix@EXEEXT@ $< $@ || { rm -f $@ ; exit 1 ; } 43 | 44 | ../src/libhintlib.la: 45 | cd ../src && $(MAKE) libhintlib.la 46 | 47 | -------------------------------------------------------------------------------- /src/HIntLib/shiftnet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_SHIFT_NET_H 22 | #define HINTLIB_SHIFT_NET_H 1 23 | 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | // #pragma interface 28 | #endif 29 | 30 | namespace HIntLib 31 | { 32 | class GeneratorMatrix; 33 | 34 | namespace Private 35 | { 36 | void initShiftNetFirstDim (GeneratorMatrix&); 37 | } 38 | 39 | template 40 | void initShiftNet (G& g) 41 | { 42 | Private::initShiftNetFirstDim (g); 43 | g.makeShiftNet(); 44 | } 45 | 46 | int maxMForShiftNet (int base); 47 | int maxBaseForShiftNet (); 48 | int optimalShiftNetT (int base, int m); 49 | 50 | } // namespace HIntLib 51 | 52 | #endif 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/mcpointset.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | 27 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 28 | #pragma implementation 29 | #pragma implementation "mcroutines.h" 30 | #endif 31 | 32 | namespace L = HIntLib; 33 | 34 | bool 35 | L::MCPointSetBase_::doJobRep (real *, ReportingJob &, Index n) 36 | { 37 | if (n == 0) return false; 38 | else throw InternalError (__FILE__, __LINE__); 39 | } 40 | 41 | L::Index 42 | L::MCPointSetBase_::getOptimalNumber (Index n, const Hypercube &) 43 | { 44 | return (n / alignment) * alignment; 45 | } 46 | 47 | void 48 | L::MCPointSetBase_::setCube (const Hypercube* cube) 49 | { 50 | h = cube; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/pointset.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 26 | #pragma implementation 27 | #endif 28 | 29 | namespace L = HIntLib; 30 | 31 | void 32 | L::PartitionablePointSet::integrate ( 33 | real *point, Integrand &f, Index num, Stat &stat) 34 | { 35 | integratePartition (point, f, num, 0, num, stat); 36 | } 37 | 38 | void 39 | L::PartitionablePointSet::integrate ( 40 | real *point, Integrand &f, Index num, StatVar &stat) 41 | { 42 | integratePartition (point, f, num, 0, num, stat); 43 | } 44 | 45 | void 46 | L::PartitionablePointSet::doJob (real *point, Job &job, Index num) 47 | { 48 | doJobPartition (point, job, num, 0, num); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /tests/test_charsetw.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2006 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #include 22 | 23 | #include "test.h" 24 | #include "test_charset.h" 25 | 26 | const char testProgramName[] = "test_charsetw"; 27 | 28 | #ifdef HINTLIB_BUILD_WCHAR 29 | void displayCharacter (unsigned long c) 30 | { 31 | std::wcout << L'\'' << wchar_t (c) << L'\''; 32 | } 33 | 34 | 35 | void test(int argc, char**) 36 | { 37 | if (argc != 0) usage("Too many arguments!"); 38 | 39 | printHeader (std::wcout); 40 | 41 | unsigned long lastC = characters[0].code - 1; 42 | 43 | for (const Data* p = characters; p != characters + numChars; ++p) 44 | { 45 | printLine (std::wcout, *p, lastC); 46 | } 47 | } 48 | #else 49 | void test(int argc, char**) 50 | { 51 | usage ("Type wchar_t is not supported!"); 52 | } 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /src/HIntLib/niederreitermatrixgen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_NIEDERREITER_MATRIX_GEN_H 22 | #define HINTLIB_NIEDERREITER_MATRIX_GEN_H 1 23 | 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | #pragma interface 28 | #endif 29 | 30 | namespace HIntLib 31 | { 32 | template class GeneratorMatrixGen; 33 | template class PolynomialRing; 34 | 35 | 36 | template 37 | void initNiederreiter (GeneratorMatrixGen &, A); 38 | 39 | template 40 | void initNiederreiter 41 | (GeneratorMatrixGen &, A, int d, 42 | const typename PolynomialRing::type &); 43 | 44 | void initNiederreiter (GeneratorMatrixGen &); 45 | 46 | } // namespace HIntLib 47 | 48 | #endif 49 | 50 | 51 | -------------------------------------------------------------------------------- /tests/test_arithmetic_poly2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | // algebraic structures to be tested 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | // The actual test templates 29 | 30 | #include "test_arithmetic_tests.h" 31 | 32 | namespace HIntLib 33 | { 34 | 35 | void testPoly2() 36 | { 37 | // GF[2], GF2(x) using PolynomialRing2<> 38 | 39 | Polynomial2Ring gf2poly; 40 | doTests (gf2poly, "Polynomial2Ring"); 41 | doTests (QuotientField > (gf2poly), 42 | "QuotientField >"); 43 | } 44 | 45 | void testGF2Vec() 46 | { 47 | // GF2^n 48 | 49 | for (unsigned d = 1; d <= 10; ++d) 50 | { 51 | doTests (GF2VectorSpace (d), "GF2VectorSpace"); 52 | } 53 | } 54 | 55 | } // namespace HIntLib 56 | 57 | -------------------------------------------------------------------------------- /tests/toms738/ptoi.f: -------------------------------------------------------------------------------- 1 | INTEGER FUNCTION PTOI (POLY) 2 | C 3 | C This version : 12 December 1991 4 | C 5 | C 6 | C ------------------------------------------------------------ 7 | C 8 | C The following COMMON block, used by many subroutines, 9 | C gives the order Q of a field, its characteristic P, and its 10 | C addition, multiplication and subtraction tables. 11 | C The parameter MAXQ gives the order of the largest field to 12 | C be handled. 13 | C 14 | INTEGER MAXQ 15 | PARAMETER (MAXQ=50) 16 | 17 | INTEGER P, Q, ADD(0:MAXQ-1,0:MAXQ-1) 18 | INTEGER MUL(0:MAXQ-1, 0:MAXQ-1), SUB(0:MAXQ-1, 0:MAXQ-1) 19 | COMMON /FIELD/ P, Q, ADD, MUL, SUB 20 | SAVE /FIELD/ 21 | C 22 | C The following definitions concern the representation of 23 | C polynomials. 24 | C 25 | INTEGER MAXDEG, DEG 26 | PARAMETER (MAXDEG=50, DEG=-1) 27 | C 28 | C The parameter MAXDEG gives the highest degree of polynomial 29 | C to be handled. Polynomials stored as arrays have the 30 | C coefficient of degree n in POLY(N), and the degree of the 31 | C polynomial in POLY(-1). The parameter DEG is just to remind 32 | C us of this last fact. A polynomial which is identically 0 33 | C is given degree -1. 34 | C 35 | C A polynomial can also be stored in an integer I, with 36 | C I = AN*Q**N + ... + A0. 37 | C Routines ITOP and PTOI convert between these two formats. 38 | C 39 | C ----------------------------------------------------------- 40 | C 41 | C 42 | C 43 | INTEGER I, J, POLY(-1:MAXDEG) 44 | C 45 | C Converts a polynomial with coefficients in the field of 46 | C order Q to an integer. 47 | C 48 | I = 0 49 | DO 10 J = POLY(DEG), 0, -1 50 | 10 I = Q * I + POLY(J) 51 | PTOI = I 52 | RETURN 53 | END 54 | C 55 | C ***** end of INTEGER FUNCTION PTOI 56 | -------------------------------------------------------------------------------- /src/hlmpi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * MPI 23 | */ 24 | 25 | #define HINTLIB_LIBRARY_OBJECT 26 | 27 | #include 28 | 29 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 30 | #pragma implementation 31 | #endif 32 | 33 | #include 34 | 35 | namespace L = HIntLib; 36 | 37 | L::MPI::MPI(int *argc, char ***argv) 38 | { 39 | int initialized; 40 | int status = MPI_Initialized (&initialized); 41 | if (status != MPI_SUCCESS || initialized) throw MPIError(status); 42 | 43 | status = MPI_Init (argc, argv); 44 | if (status != MPI_SUCCESS) throw MPIError(status); 45 | 46 | status = MPI_Comm_rank (MPI_COMM_WORLD, &rank); 47 | if (status != MPI_SUCCESS) 48 | { 49 | MPI_Finalize(); 50 | throw MPIError(status); 51 | } 52 | } 53 | 54 | L::MPI::~MPI () 55 | { 56 | int status = MPI_Finalize(); 57 | if (status != MPI_SUCCESS) throw MPIError(status); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/HIntLib/exception_MPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * exception.h 23 | * 24 | * Defines the exceptions used by HIntLib 25 | */ 26 | 27 | #ifndef HINTLIB_EXCEPTION_MPI_H 28 | #define HINTLIB_EXCEPTION_MPI_H 1 29 | 30 | #include 31 | 32 | #ifndef HINTLIB_PARALLEL 33 | #error exception_MPI.h can only be used in PARALLEL mode 34 | #endif 35 | 36 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 37 | #pragma interface 38 | #endif 39 | 40 | #include 41 | 42 | namespace HIntLib 43 | { 44 | class TooFewNodes : public IntegratorException 45 | { 46 | virtual void makeString() const; 47 | }; 48 | 49 | class MPIError : public Exception 50 | { 51 | virtual void makeString() const; 52 | const int error; 53 | public: 54 | MPIError (int _error) : error(_error) {} 55 | int getError() { return error; } 56 | }; 57 | 58 | } // namespace HIntLib 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /src/HIntLib/rulegauss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2007 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule Gauss 23 | */ 24 | 25 | #ifndef HINTLIB_RULE_GAUSS_H 26 | #define HINTLIB_RULE_GAUSS_H 1 27 | 28 | #include 29 | 30 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 31 | #pragma interface 32 | #endif 33 | 34 | #include 35 | 36 | namespace HIntLib 37 | { 38 | class CubatureRuleFactory; 39 | 40 | class RuleGauss : public ProductRule 41 | { 42 | public: 43 | RuleGauss (int dim, int numPoints); 44 | 45 | // The parameters are all trivially calculated 46 | 47 | virtual int getDegree() const { return numPoints * 2 - 1; } 48 | virtual real getSumAbsWeight() const { return 1.; } 49 | 50 | // getFactory() needs to know the number of abscissas 51 | 52 | static CubatureRuleFactory* getFactory (int numPoints); 53 | 54 | private: 55 | Point offsets; 56 | Point weights; 57 | }; 58 | 59 | } // namespace HIntLib 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/polynomial_ring.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace HIntLib 30 | { 31 | // Polynomial<> 32 | 33 | HINTLIB_INSTANTIATE_POLYNOMIAL (int) 34 | 35 | HINTLIB_INSTANTIATE_POLYNOMIAL (Polynomial) 36 | HINTLIB_INSTANTIATE_POLYNOMIAL (Polynomial) 37 | 38 | // PolynomialRing<> 39 | 40 | HINTLIB_INSTANTIATE_POLYNOMIALRING_UFD (PolynomialRing >) 41 | HINTLIB_INSTANTIATE_POLYNOMIALRING_UFD 42 | (PolynomialRing > ) 43 | 44 | HINTLIB_INSTANTIATE_POLYNOMIALRING_UFD (IntegerRing) 45 | 46 | HINTLIB_INSTANTIATE_POLYNOMIALRING_RING 47 | (ModularArithmeticRing) 48 | HINTLIB_INSTANTIATE_POLYNOMIALRING_RING 49 | (ModularArithmeticRing) 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/builtinprng.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * BuiltIn PRNG 23 | * 24 | * Makes the built-in PRNG available 25 | */ 26 | 27 | #define HINTLIB_LIBRARY_OBJECT 28 | 29 | #include 30 | 31 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 32 | #pragma implementation 33 | #endif 34 | 35 | #include 36 | 37 | 38 | namespace L = HIntLib; 39 | using L::real; 40 | 41 | #if HINTLIB_STATIC_WORKS == 1 42 | const real L::BuiltInPRNG::RANGE = real(RAND_MAX) + real(1); 43 | const real L::BuiltInPRNG::RESOLUTION = real(1) / RANGE; 44 | #else 45 | real L::BuiltInPRNG::RANGE; 46 | real L::BuiltInPRNG::RESOLUTION; 47 | #endif 48 | 49 | bool L::BuiltInPRNG::inUse = false; 50 | 51 | L::BuiltInPRNG::BuiltInPRNG (unsigned start) 52 | { 53 | #if HINTLIB_STATIC_WORKS == 0 54 | RANGE = real(RAND_MAX) + real(1); 55 | RESOLUTION = real(1) / RANGE; 56 | #endif 57 | 58 | if (inUse) throw BuiltInPRNGUsedTwice(); 59 | 60 | inUse = true; 61 | 62 | init(start); 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/staticloadbalancer_MPI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Real Static Load Balancer 23 | * 24 | * Distributes a task statically among all available processing nodes 25 | */ 26 | 27 | #define HINTLIB_LIBRARY_OBJECT 28 | 29 | #include 30 | 31 | #include 32 | 33 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 34 | #pragma implementation "staticloadbalancer.h" 35 | #endif 36 | 37 | #include 38 | 39 | namespace L = HIntLib; 40 | 41 | L::MPIStaticLoadBalancer::MPIStaticLoadBalancer(Index n, MPI_Comm comm) 42 | { 43 | MPI_Comm_rank (comm, &rank); 44 | MPI_Comm_size (comm, &size); 45 | 46 | Index junkSize = n / size; 47 | 48 | int missing = int (n - size * junkSize); // between 0 and size-1 49 | 50 | if (rank < size - missing) 51 | { 52 | begin = rank * junkSize; 53 | end = begin + junkSize; 54 | } 55 | else 56 | { 57 | begin = rank * junkSize + missing - 1; 58 | end = begin + junkSize + 1; 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /src/HIntLib/niederreitermatrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * The matrices defining the Niederreiter Digital Net 23 | */ 24 | 25 | #ifndef HINTLIB_NIEDERREITER_MATRIX_H 26 | #define HINTLIB_NIEDERREITER_MATRIX_H 1 27 | 28 | #include 29 | 30 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 31 | #pragma interface 32 | #endif 33 | 34 | #ifdef HINTLIB_HAVE_LIMITS 35 | # include 36 | #else 37 | # include 38 | #endif 39 | 40 | #include 41 | 42 | namespace HIntLib 43 | { 44 | 45 | class NiederreiterMatrix : public GeneratorMatrix2 46 | { 47 | public: 48 | NiederreiterMatrix() : GeneratorMatrix2 (MAX_DIM) 49 | { 50 | setMatrix (v_mem[0]); 51 | } 52 | 53 | enum { MAX_DIM = 200 }; 54 | 55 | private: 56 | 57 | // Vectors used to calculate the sequence 58 | 59 | static HINTLIB_DLL_IMPORT const u64 v_mem [DEFAULT_M_BASE2][MAX_DIM]; 60 | // static const unsigned t_s [MAX_DIM]; 61 | }; 62 | 63 | } // namespace HIntLib 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /src/HIntLib/integrand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Integrand 23 | * 24 | * A function R^dim -> R 25 | * 26 | * getDimension() 27 | * returns the dimension of the domain of the function 28 | * 29 | * operator() 30 | * Evaluates the function at a certain point in R^dim 31 | */ 32 | 33 | #ifndef HINTLIB_INTEGRAND_H 34 | #define HINTLIB_INTEGRAND_H 1 35 | 36 | #include 37 | 38 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 39 | #pragma interface 40 | // implementation in testintegrand.cpp 41 | #endif 42 | 43 | 44 | namespace HIntLib 45 | { 46 | 47 | /** 48 | * Abstract base class for Integrands 49 | */ 50 | 51 | class Integrand 52 | { 53 | public: 54 | explicit Integrand (int dim) : dim (dim) {} 55 | virtual ~Integrand () {}; 56 | 57 | virtual real operator() (const real []) = 0; // evaluate Integrand 58 | virtual real derivative (const real [], int); 59 | 60 | int getDimension () const { return dim; } 61 | 62 | protected: 63 | const int dim; 64 | }; 65 | 66 | } // namespace HIntLib 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /src/HIntLib/galoisfield.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_GALOIS_FIELD_H 22 | #define HINTLIB_GALOIS_FIELD_H 1 23 | 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | #pragma interface 28 | #endif 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | namespace HIntLib 36 | { 37 | 38 | /** 39 | * Galois Field 40 | */ 41 | 42 | template 43 | class GaloisField 44 | : public FactorField > > 45 | { 46 | public: 47 | GaloisField (unsigned base, int exponent, bool xPrim = false); 48 | GaloisField (unsigned size, bool xPrim = false); 49 | 50 | private: 51 | typedef ModularArithmeticField Field; 52 | typedef PolynomialRing Poly; 53 | typedef FactorField ExtensionField; 54 | typedef typename Poly::type T; 55 | 56 | T findPoly (unsigned base, int exponent, bool xPrim); 57 | T findPoly (unsigned size, bool xPrim); 58 | }; 59 | 60 | } // namespace HIntLib 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /src/HIntLib/halton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Halton 23 | * 24 | * QRNGenerator producing the Halton sequence based on the first dim 25 | * prime numbers. 26 | */ 27 | 28 | #ifndef HINTLIB_HALTON_H 29 | #define HINTLIB_HALTON_H 1 30 | 31 | #include 32 | 33 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 34 | #pragma interface 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | 41 | namespace HIntLib 42 | { 43 | 44 | class Halton : public QRNSequenceBase 45 | { 46 | public: 47 | Halton (const Hypercube &h); 48 | 49 | static Index getOptimalNumber (Index max, const Hypercube &) { return max; } 50 | 51 | void first (real* p, Index _n = 0) { n = _n-1; next(p); } 52 | void firstDontScale (real* p, Index _n = 0) { n = _n-1; nextDontScale(p); } 53 | void next (real*); 54 | void nextDontScale (real*); 55 | Index getOptimalNumber (Index max) const { return max; } 56 | 57 | private: 58 | ShiftScale ss; 59 | }; 60 | 61 | } // namespace HIntLib 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /src/rule1midpoint.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * ruleMidpoint.cpp 23 | * 24 | * Cubature rule of degree 1 with 1 point (the center of the hypercube). 25 | * 26 | * It is presented in 27 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 28 | * as formula Cn: 1-1 29 | */ 30 | 31 | #define HINTLIB_LIBRARY_OBJECT 32 | 33 | #include 34 | 35 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 36 | #pragma implementation 37 | #endif 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | namespace L = HIntLib; 44 | 45 | /** 46 | * Calculate the volume of the hypercube and multiply with integrand value 47 | * in the center. 48 | */ 49 | 50 | L::real L::Rule1Midpoint::eval (Integrand &f, const Hypercube &h) 51 | { 52 | return h.getVolume() * f(h.getCenter()); 53 | } 54 | 55 | /** 56 | * getFactory() 57 | */ 58 | 59 | L::CubatureRuleFactory* L::Rule1Midpoint::getFactory() 60 | { 61 | return new DefaultCubatureRuleFactory (); 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/halton.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | #pragma implementation 28 | #pragma implementation "qmcroutinesimp.h" 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | namespace L = HIntLib; 35 | 36 | using L::real; 37 | using L::Index; 38 | 39 | /** 40 | * Halton::Halton() 41 | */ 42 | 43 | L::Halton::Halton (const Hypercube &h) 44 | : QRNSequenceBase (h), ss(h) 45 | {} 46 | 47 | /** 48 | * Create next point 49 | */ 50 | 51 | void L::Halton::next (real points[]) 52 | { 53 | ++n; 54 | 55 | for (unsigned i = getDimension(); i; ) 56 | { 57 | --i; 58 | 59 | points [i] = ss[i] (radicalInverseFunction (n, Prime::nth(i))); 60 | } 61 | } 62 | 63 | void L::Halton::nextDontScale (real points[]) 64 | { 65 | ++n; 66 | 67 | for (unsigned i = getDimension(); i; ) 68 | { 69 | --i; 70 | 71 | points [i] = radicalInverseFunction (n, Prime::nth(i)); 72 | } 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/integrator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * AdaptIntegrator 23 | * 24 | */ 25 | 26 | #define HINTLIB_LIBRARY_OBJECT 27 | 28 | #include 29 | 30 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 31 | #pragma implementation 32 | #endif 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | namespace L = HIntLib; 40 | 41 | void 42 | L::Integrator::checkDimension (const Hypercube &h, const Integrand &f) 43 | { 44 | L::checkDimensionEqual (h.getDimension(), f.getDimension()); 45 | } 46 | 47 | void 48 | L::Integrator::checkTerminationCriteria ( 49 | Index maxEval, real reqAbsError, real reqRelError, bool maxEvalRequired) 50 | { 51 | if (reqAbsError < 0) throw RequestedErrorNegative (reqAbsError); 52 | 53 | if (reqRelError < 0) throw RequestedErrorNegative (reqRelError); 54 | 55 | if (maxEvalRequired && maxEval == 0) throw MaxEvaluationsRequired(); 56 | 57 | if (reqAbsError == 0 && reqRelError == 0 && maxEval == 0) 58 | { 59 | throw TerminationCriterionMissing(); 60 | } 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /tests/toms738/plyadd.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE PLYADD (PA, PB, PC) 2 | C 3 | C This version : 12 December 1991 4 | C 5 | C 6 | C ------------------------------------------------------------ 7 | C 8 | C The following COMMON block, used by many subroutines, 9 | C gives the order Q of a field, its characteristic P, and its 10 | C addition, multiplication and subtraction tables. 11 | C The parameter MAXQ gives the order of the largest field to 12 | C be handled. 13 | C 14 | INTEGER MAXQ 15 | PARAMETER (MAXQ=50) 16 | 17 | INTEGER P, Q, ADD(0:MAXQ-1,0:MAXQ-1) 18 | INTEGER MUL(0:MAXQ-1, 0:MAXQ-1), SUB(0:MAXQ-1, 0:MAXQ-1) 19 | COMMON /FIELD/ P, Q, ADD, MUL, SUB 20 | SAVE /FIELD/ 21 | C 22 | C The following definitions concern the representation of 23 | C polynomials. 24 | C 25 | INTEGER MAXDEG, DEG 26 | PARAMETER (MAXDEG=50, DEG=-1) 27 | C 28 | C The parameter MAXDEG gives the highest degree of polynomial 29 | C to be handled. Polynomials stored as arrays have the 30 | C coefficient of degree n in POLY(N), and the degree of the 31 | C polynomial in POLY(-1). The parameter DEG is just to remind 32 | C us of this last fact. A polynomial which is identically 0 33 | C is given degree -1. 34 | C 35 | C A polynomial can also be stored in an integer I, with 36 | C I = AN*Q**N + ... + A0. 37 | C Routines ITOP and PTOI convert between these two formats. 38 | C 39 | C ----------------------------------------------------------- 40 | C 41 | C 42 | C 43 | INTEGER I, MAXAB, DEGC 44 | INTEGER PA(-1:MAXDEG), PB(-1:MAXDEG), PC(-1:MAXDEG) 45 | C 46 | C Adds polynomials PA and PB putting result in PC. 47 | C Coefficients are elements of the field of order Q. 48 | C 49 | MAXAB = MAX (PA(DEG), PB(DEG)) 50 | DEGC = -1 51 | DO 10 I = 0, MAXAB 52 | PC(I) = ADD (PA(I), PB(I)) 53 | IF (PC(I) .NE. 0) DEGC = I 54 | 10 CONTINUE 55 | PC(DEG) = DEGC 56 | DO 20 I = MAXAB+1, MAXDEG 57 | 20 PC(I) = 0 58 | RETURN 59 | END 60 | C 61 | C ***** end of SUBROUTINE PLYADD 62 | -------------------------------------------------------------------------------- /src/HIntLib/sobolmatrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * The matrices defining the Sobol Digtal Net 23 | */ 24 | 25 | #ifndef HINTLIB_SOBOL_MATRIX_H 26 | #define HINTLIB_SOBOL_MATRIX_H 1 27 | 28 | #include 29 | 30 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 31 | #pragma interface 32 | #endif 33 | 34 | #ifdef HINTLIB_HAVE_LIMITS 35 | # include 36 | #else 37 | # include 38 | #endif 39 | 40 | #include 41 | 42 | 43 | namespace HIntLib 44 | { 45 | 46 | class SobolMatrix : public GeneratorMatrix2 47 | { 48 | public: 49 | SobolMatrix() : GeneratorMatrix2 (MAX_DIM) 50 | { 51 | setMatrix (v_mem[0]); 52 | } 53 | 54 | unsigned getT (unsigned d) const { return t_s [d]; } 55 | 56 | // We don't have data for creating the v array for dimension larger than 40 57 | 58 | enum { MAX_DIM = 40 }; 59 | 60 | private: 61 | 62 | // Vectors used to calculate the sequence 63 | 64 | static HINTLIB_DLL_IMPORT const u64 v_mem [DEFAULT_M_BASE2][MAX_DIM]; 65 | static HINTLIB_DLL_IMPORT const unsigned t_s [MAX_DIM]; 66 | }; 67 | 68 | } // namespace HIntLib 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /tests/toms738/itop.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE ITOP (IN, POLY) 2 | C 3 | C This version : 12 December 1991 4 | C 5 | C 6 | C ------------------------------------------------------------ 7 | C 8 | C The following COMMON block, used by many subroutines, 9 | C gives the order Q of a field, its characteristic P, and its 10 | C addition, multiplication, and subtraction tables. 11 | C The parameter MAXQ gives the order of the largest field to 12 | C be handled. 13 | C 14 | INTEGER MAXQ 15 | PARAMETER (MAXQ=50) 16 | 17 | INTEGER P, Q, ADD(0:MAXQ-1,0:MAXQ-1) 18 | INTEGER MUL(0:MAXQ-1, 0:MAXQ-1), SUB(0:MAXQ-1, 0:MAXQ-1) 19 | COMMON /FIELD/ P, Q, ADD, MUL, SUB 20 | SAVE /FIELD/ 21 | C 22 | C The following definitions concern the representation of 23 | C polynomials. 24 | C 25 | INTEGER MAXDEG, DEG 26 | PARAMETER (MAXDEG=50, DEG=-1) 27 | C 28 | C The parameter MAXDEG gives the highest degree of polynomial 29 | C to be handled. Polynomials stored as arrays have the 30 | C coefficient of degree n in POLY(N), and the degree of the 31 | C polynomial in POLY(-1). The parameter DEG is just to remind 32 | C us of this last fact. A polynomial which is identically 0 33 | C is given degree -1. 34 | C 35 | C A polynomial can also be stored in an integer I, with 36 | C I = AN*Q**N + ... + A0. 37 | C Routines ITOP and PTOI convert between these two formats. 38 | C 39 | C ----------------------------------------------------------- 40 | C 41 | C 42 | C 43 | INTEGER IN, I, J, POLY(-1:MAXDEG) 44 | C 45 | C Converts an integer to a polynomial with coefficients in the 46 | C field of order Q. 47 | C 48 | DO 10 J = -1, MAXDEG 49 | 10 POLY(J) = 0 50 | C 51 | I = IN 52 | J = -1 53 | 20 IF (I .GT. 0) THEN 54 | J = J + 1 55 | IF (J .GT. MAXDEG) THEN 56 | WRITE (*,*) ' ITOP : Polynomial exceeds MAXDEG' 57 | STOP 58 | ENDIF 59 | POLY(J) = MOD (I, Q) 60 | I = I / Q 61 | GOTO 20 62 | ENDIF 63 | POLY(DEG) = J 64 | RETURN 65 | END 66 | C 67 | C ***** end of SUBROUTINE ITOP 68 | -------------------------------------------------------------------------------- /src/rulebasedintegrator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | #pragma implementation 28 | #pragma implementation "cubaturerule.h" 29 | #endif 30 | 31 | 32 | namespace L = HIntLib; 33 | 34 | /** 35 | * CubatureRuleBasedIntegrator 36 | */ 37 | 38 | L::CubatureRuleBasedIntegrator::CubatureRuleBasedIntegrator 39 | (const CubatureRuleFactory *fac) 40 | : factory(fac->clone()) {} 41 | 42 | L::CubatureRuleBasedIntegrator::~CubatureRuleBasedIntegrator() 43 | { 44 | delete factory; 45 | } 46 | 47 | L::CubatureRule* L::CubatureRuleBasedIntegrator::getRule (int dim) const 48 | { 49 | return factory->create(dim); 50 | } 51 | 52 | 53 | /** 54 | * EmbeddedRuleBasedIntegrator 55 | */ 56 | 57 | L::EmbeddedRuleBasedIntegrator::EmbeddedRuleBasedIntegrator 58 | (const EmbeddedRuleFactory *fac) 59 | : factory(fac->clone()) {} 60 | 61 | L::EmbeddedRuleBasedIntegrator::~EmbeddedRuleBasedIntegrator() 62 | { 63 | delete factory; 64 | } 65 | 66 | L::EmbeddedRule* L::EmbeddedRuleBasedIntegrator::getRule (int dim) const 67 | { 68 | return factory->create(dim); 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /share/convert_matrix.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | using std::cerr; 29 | using std::endl; 30 | 31 | int main (int argc, char** argv) 32 | { 33 | if (argc != 3) 34 | { 35 | cerr << "Usage: convert libSeqMatrix BinaryMatirx\n\n"; 36 | exit (1); 37 | } 38 | 39 | try 40 | { 41 | // Read matrix from input file 42 | 43 | std::ifstream ifs (argv[1]); 44 | 45 | std::auto_ptr m (HIntLib::loadLibSeq (ifs)); 46 | 47 | if (! ifs) 48 | { 49 | cerr << "Error reading input file '" << argv[1] << "'!\n\n"; 50 | return 1; 51 | } 52 | 53 | // Write matrix to output file 54 | 55 | std::ofstream ofs (argv[2]); 56 | 57 | m->binaryExport (ofs); 58 | 59 | if (! ofs) 60 | { 61 | cerr << "Error writing output file '" << argv[2] << "'!\n\n"; 62 | return 1; 63 | } 64 | } 65 | catch (std::exception &e) 66 | { 67 | cerr << "Exception: " << e.what() << endl; 68 | } 69 | catch (...) 70 | { 71 | cerr << "Unknown exception!" << endl; 72 | } 73 | 74 | return 0; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/HIntLib/rulebasedintegrator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * RuleBasedIntegrator 23 | */ 24 | 25 | #ifndef HINTLIB_RULE_BASED_INTEGRATOR_H 26 | #define HINTLIB_RULE_BASED_INTEGRATOR_H 1 27 | 28 | #include 29 | 30 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 31 | #pragma interface 32 | #endif 33 | 34 | #include 35 | 36 | namespace HIntLib 37 | { 38 | class CubatureRule; 39 | class EmbeddedRule; 40 | class CubatureRuleFactory; 41 | class EmbeddedRuleFactory; 42 | 43 | class CubatureRuleBasedIntegrator: public Integrator 44 | { 45 | protected: 46 | CubatureRuleBasedIntegrator (const CubatureRuleFactory *); 47 | 48 | CubatureRule* getRule (int) const; 49 | 50 | public: 51 | virtual ~CubatureRuleBasedIntegrator(); 52 | 53 | private: 54 | CubatureRuleFactory *factory; 55 | }; 56 | 57 | class EmbeddedRuleBasedIntegrator: public Integrator 58 | { 59 | protected: 60 | EmbeddedRuleBasedIntegrator (const EmbeddedRuleFactory *); 61 | 62 | EmbeddedRule* getRule (int) const; 63 | 64 | public: 65 | virtual ~EmbeddedRuleBasedIntegrator(); 66 | 67 | private: 68 | EmbeddedRuleFactory *factory; 69 | }; 70 | } // namespace HIntLib 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /tests/test_charset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2006 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_TEST_CHARSET_H 22 | #define HINTLIB_TEST_CHARSET_H 23 | 24 | #include 25 | 26 | #ifdef HINTLIB_HAVE_SSTREAM 27 | # include 28 | #else 29 | # include 30 | #endif 31 | 32 | enum Type { ASCII = 1, LATIN1 = 2, WGL4 = 3, UNICODE = 4 }; 33 | 34 | std::ostream& operator<< (std::ostream&, Type); 35 | 36 | extern const struct Data 37 | { 38 | unsigned long code; 39 | Type type; 40 | const char* name; 41 | } 42 | characters []; 43 | 44 | extern const unsigned numChars; 45 | 46 | void displayCharacter (unsigned long c); 47 | void encode_utf8 (unsigned long, char*); 48 | std::string beginOfLine (const Data& data); 49 | 50 | 51 | template 52 | void printLine(OSTREAM& COUT, const Data& data, unsigned long lastC) 53 | { 54 | unsigned long c = data.code; 55 | if (c > lastC + 1) COUT << '\n'; 56 | 57 | std::string line = beginOfLine (data); 58 | 59 | COUT << line.c_str(); 60 | 61 | if (data.type <= HINTLIB_CHARACTER_SET) 62 | { 63 | displayCharacter (c); 64 | } 65 | else 66 | { 67 | COUT << "---"; 68 | } 69 | 70 | COUT << " " << data.name << '\n'; 71 | 72 | lastC = c; 73 | } 74 | 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /src/exception_MPI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #include 26 | 27 | #ifdef HINTLIB_HAVE_CSTRING 28 | # include 29 | # define HINTLIB_SSN std:: 30 | #else 31 | # include 32 | # define HINTLIB_SSN 33 | #endif 34 | 35 | #ifdef HINTLIB_HAVE_SSTREAM 36 | # include 37 | #else 38 | # include 39 | #endif 40 | 41 | #include 42 | 43 | #include 44 | 45 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 46 | #pragma implementation 47 | #endif 48 | 49 | using std::ostringstream; 50 | 51 | namespace L = HIntLib; 52 | 53 | namespace 54 | { 55 | char* ms (ostringstream &ss) 56 | { 57 | std::string s = ss.str(); 58 | 59 | char* p = new char [s.length() + 1]; 60 | HINTLIB_SSN strcpy (p, s.c_str()); 61 | 62 | return p; 63 | } 64 | } 65 | 66 | 67 | void L::TooFewNodes::makeString() const 68 | { 69 | setStringCopy ("Too few processing nodes for this Integrator!"); 70 | } 71 | 72 | void L::MPIError::makeString() const 73 | { 74 | ostringstream ss; 75 | ss << "MPI error number " << error << " encountered!"; 76 | setString (ms(ss)); 77 | } 78 | 79 | #undef HINTLIB_SSN 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/HIntLib/ruleintegrator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * RuleIntegrator 23 | * 24 | * This integrator applies a basic rule once to estimate value and result 25 | * of an integral. 26 | */ 27 | 28 | #ifndef HINTLIB_RULE_INTEGRATOR_H 29 | #define HINTLIB_RULE_INTEGRATOR_H 1 30 | 31 | #include 32 | 33 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 34 | #pragma interface 35 | #endif 36 | 37 | #include 38 | 39 | namespace HIntLib 40 | { 41 | class RuleIntegrator : public CubatureRuleBasedIntegrator 42 | { 43 | public: 44 | RuleIntegrator (const CubatureRuleFactory *fac) 45 | : CubatureRuleBasedIntegrator(fac) {} 46 | 47 | virtual 48 | Status integrate ( 49 | Integrand &, const Hypercube &, Index maxEval, 50 | real reqAbsError, real reqRelError, EstErr &); 51 | }; 52 | 53 | class RuleIntegratorErr : public EmbeddedRuleBasedIntegrator 54 | { 55 | public: 56 | RuleIntegratorErr (const EmbeddedRuleFactory *fac) 57 | : EmbeddedRuleBasedIntegrator(fac) {} 58 | 59 | virtual 60 | Status integrate ( 61 | Integrand &, const Hypercube &, Index maxEval, 62 | real reqAbsError, real reqRelError, EstErr &); 63 | }; 64 | } // namespace HIntLib 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /tests/toms738/charac.f: -------------------------------------------------------------------------------- 1 | INTEGER FUNCTION CHARAC (QIN) 2 | C 3 | C This version : 12 December 1991 4 | C 5 | C This function gives the characteristic for a field of 6 | C order QIN. If no such field exists, or if QIN is out of 7 | C the range we can handle, returns 0. 8 | C 9 | C 10 | C ------------------------------------------------------------ 11 | C 12 | C The following COMMON block, used by many subroutines, 13 | C gives the order Q of a field, its characteristic P, and its 14 | C addition, multiplication and subtraction tables. 15 | C The parameter MAXQ gives the order of the largest field to 16 | C be handled. 17 | C 18 | INTEGER MAXQ 19 | PARAMETER (MAXQ=50) 20 | 21 | INTEGER P, Q, ADD(0:MAXQ-1,0:MAXQ-1) 22 | INTEGER MUL(0:MAXQ-1, 0:MAXQ-1), SUB(0:MAXQ-1, 0:MAXQ-1) 23 | COMMON /FIELD/ P, Q, ADD, MUL, SUB 24 | SAVE /FIELD/ 25 | C 26 | C The following definitions concern the representation of 27 | C polynomials. 28 | C 29 | INTEGER MAXDEG, DEG 30 | PARAMETER (MAXDEG=50, DEG=-1) 31 | C 32 | C The parameter MAXDEG gives the highest degree of polynomial 33 | C to be handled. Polynomials stored as arrays have the 34 | C coefficient of degree n in POLY(N), and the degree of the 35 | C polynomial in POLY(-1). The parameter DEG is just to remind 36 | C us of this last fact. A polynomial which is identically 0 37 | C is given degree -1. 38 | C 39 | C A polynomial can also be stored in an integer I, with 40 | C I = AN*Q**N + ... + A0. 41 | C Routines ITOP and PTOI convert between these two formats. 42 | C 43 | C ----------------------------------------------------------- 44 | C 45 | C 46 | C 47 | INTEGER QIN, CH(MAXQ) 48 | SAVE CH 49 | C 50 | DATA CH / 0, 2, 3, 2, 5, 0, 7, 2, 3, 0, 51 | 1 11, 0, 13, 0, 0, 2, 17, 0, 19, 0, 52 | 2 0, 0, 23, 0, 5, 0, 3, 0, 29, 0, 53 | 3 31, 2, 0, 0, 0, 0, 37, 0, 0, 0, 54 | 4 41, 0, 43, 0, 0, 0, 47, 0, 7, 0/ 55 | C 56 | IF (QIN .LE. 1 .OR. QIN .GT. MAXQ) THEN 57 | CHARAC = 0 58 | ELSE 59 | CHARAC = CH(QIN) 60 | ENDIF 61 | C 62 | END 63 | C 64 | C ***** end of INTEGER FUNCTION CHARAC 65 | -------------------------------------------------------------------------------- /src/HIntLib/rule1midpoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * RuleMidpoint 23 | * 24 | * Cubature rule of degree 1 with 1 point (the center of the hypercube). 25 | * 26 | * It is presented in 27 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 28 | * as formula Cn: 1-1 29 | */ 30 | 31 | #ifndef HINTLIB_RULE_1_MIDPOINT_H 32 | #define HINTLIB_RULE_1_MIDPOINT_H 1 33 | 34 | #include 35 | 36 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 37 | #pragma interface 38 | #endif 39 | 40 | #include 41 | 42 | namespace HIntLib 43 | { 44 | class CubatureRuleFactory; 45 | 46 | class Rule1Midpoint : public CubatureRule 47 | { 48 | public: 49 | Rule1Midpoint (int d) : dim(d) {} 50 | 51 | virtual real eval (Integrand &, const Hypercube &); 52 | 53 | virtual int getDimension() const { return dim; } 54 | virtual Index getNumPoints () const { return 1; } 55 | virtual int getDegree () const { return 1; } 56 | virtual bool isAllPointsInside () const { return true; } 57 | virtual real getSumAbsWeight () const { return 1.0; } 58 | 59 | static CubatureRuleFactory* getFactory(); 60 | 61 | private: 62 | const int dim; 63 | }; 64 | 65 | } // namespace HIntLib 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /src/HIntLib/rule2ionescu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 2 Thacher 23 | * 24 | * Cubature rule of degree 2 with 2*dim + 1 points. 25 | * All points are inside the hypercube. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 2-2 30 | */ 31 | 32 | #ifndef HINTLIB_RULE_2_IONESCU_H 33 | #define HINTLIB_RULE_2_IONESCU_H 1 34 | 35 | #include 36 | 37 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 38 | #pragma interface 39 | #endif 40 | 41 | #include 42 | #include 43 | 44 | 45 | namespace HIntLib 46 | { 47 | class CubatureRuleFactory; 48 | 49 | class Rule2Ionescu : public CubatureRule 50 | { 51 | public: 52 | Rule2Ionescu (int dim); 53 | 54 | virtual real eval (Integrand &, const Hypercube &); 55 | 56 | virtual int getDimension() const { return 2; } 57 | virtual Index getNumPoints() const { return 6; } 58 | virtual int getDegree() const { return 2; } 59 | virtual bool isAllPointsInside() const { return true; } 60 | virtual real getSumAbsWeight() const { return 1.0; } 61 | 62 | static CubatureRuleFactory* getFactory(); 63 | }; 64 | 65 | } // namespace HIntLib 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /src/make.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Make 23 | */ 24 | 25 | #define HINTLIB_LIBRARY_OBJECT 26 | 27 | #include 28 | 29 | #ifdef HINTLIB_HAVE_SSTREAM 30 | # include 31 | #else 32 | # include 33 | #endif 34 | 35 | #include 36 | 37 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 38 | #pragma implementation 39 | #endif 40 | 41 | namespace L = HIntLib; 42 | 43 | 44 | /** 45 | * GeneratorMatrixDoesNotExist Exception 46 | */ 47 | 48 | void L::Make::GeneratorMatrixDoesNotExist::makeString() const 49 | { 50 | std::ostringstream ss; 51 | ss << "GeneratorMatrix(2/Gen) #" << number << " does not exist!"; 52 | setStringCopy (ss.str().c_str()); 53 | } 54 | 55 | 56 | /** 57 | * QRNSequenceDoesNotExist Exception 58 | */ 59 | 60 | void L::Make::QRNSequenceDoesNotExist::makeString() const 61 | { 62 | std::ostringstream ss; 63 | ss << "QRNSequence/QRNNet #" << number << " does not exist!"; 64 | setStringCopy (ss.str().c_str()); 65 | } 66 | 67 | 68 | /** 69 | * CubatureRuleDoesNotExist Exception 70 | */ 71 | 72 | void L::Make::CubatureRuleDoesNotExist::makeString() const 73 | { 74 | std::ostringstream ss; 75 | ss << "CubatureRule/Embeddedrule #" << number << " does not exist!"; 76 | setStringCopy (ss.str().c_str()); 77 | } 78 | 79 | 80 | -------------------------------------------------------------------------------- /tests/test_arithmetic_gf2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | // algebraic structures to be tested 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | // The actual test templates 30 | 31 | #include "test_arithmetic_tests.h" 32 | 33 | namespace HIntLib 34 | { 35 | 36 | void testGF2() 37 | { 38 | // GF2, GF2[x], GF2(x), GF2(x)[y], GF(x,y) 39 | 40 | GF2 gf2; 41 | doTests (gf2, "GF2"); 42 | 43 | typedef PolynomialRing P; 44 | P gf2poly (gf2); 45 | doTests (gf2poly, "PolynomialRing"); 46 | 47 | typedef QuotientField

Q; 48 | Q gf2quot (gf2poly); 49 | doTests (gf2quot, "QuotientField >"); 50 | 51 | typedef PolynomialRing PQ; 52 | PQ gf2quotpoly (gf2quot, 'y'); 53 | doTests (gf2quotpoly, "PolynomialRing > >"); 54 | 55 | const unsigned char coeff [] = {0, 1, 1}; 56 | const P::type p1 (coeff, coeff + 3); 57 | 58 | PQ::type p2 = gf2quotpoly.x(3); 59 | p2[2] = gf2quot.one(); 60 | p2[0] = gf2quot.makeElement(p1); 61 | 62 | typedef FactorField FF; 63 | FF gf2ff (gf2quotpoly, p2); 64 | doTests (gf2ff, "FactorField > > >"); 65 | } 66 | 67 | } // namespace HIntLib 68 | 69 | -------------------------------------------------------------------------------- /src/testintegrand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * TestIntegrand 23 | * 24 | * (C) 2001 by Rudolf Schuerer 25 | */ 26 | 27 | #define HINTLIB_LIBRARY_OBJECT 28 | 29 | #include 30 | 31 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 32 | #pragma implementation 33 | #pragma implementation "integrand.h" 34 | #endif 35 | 36 | #include 37 | #include 38 | 39 | namespace L = HIntLib; 40 | 41 | using L::TestIntegrand; 42 | using L::Hypercube; 43 | using L::real; 44 | 45 | /** 46 | * Integrand 47 | */ 48 | 49 | real L::Integrand::derivative (const real [], int) 50 | { 51 | throw DerivativeNotSupported (); 52 | } 53 | 54 | /** 55 | * DomainCheckerIntegrand 56 | */ 57 | 58 | L::DomainCheckerIntegrand::DomainCheckerIntegrand ( 59 | TestIntegrand *pf, const Hypercube *ph) 60 | : TestIntegrand (pf->getDimension()), f(*pf), h(*ph), allInside(true) 61 | { 62 | checkDimensionEqual (h.getDimension(), f.getDimension()); 63 | } 64 | 65 | real L::DomainCheckerIntegrand::operator() (const real p []) 66 | { 67 | allInside = allInside && isPointInside (h, p); 68 | 69 | return f(p); 70 | } 71 | 72 | real L::DomainCheckerIntegrand::derivative (const real p [], int a) 73 | { 74 | allInside = allInside && isPointInside (h, p); 75 | 76 | return f.derivative (p, a); 77 | } 78 | 79 | -------------------------------------------------------------------------------- /tests/test_arithmetic_real.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | // algebraic structures to be tested 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | // The actual test templates 29 | 30 | #include "test_arithmetic_tests.h" 31 | 32 | namespace HIntLib 33 | { 34 | 35 | void testComplex() 36 | { 37 | // C, C[x], C(x) 38 | 39 | ComplexField complexField; 40 | doTests (complexField, "ComplexField"); 41 | 42 | PolynomialRing > complexPolynomials (complexField); 43 | doTests (complexPolynomials, "PolynomialRing >"); 44 | 45 | doTests (QuotientField > > 46 | (complexPolynomials), 47 | "QuotientField > >"); 48 | } 49 | 50 | void testReal() 51 | { 52 | // R, R[x], R(x) 53 | 54 | RealField realField; 55 | doTests (realField, "RealField"); 56 | 57 | PolynomialRing > realPolynomials (realField); 58 | doTests (realPolynomials, "PolynomialRing >"); 59 | 60 | doTests (QuotientField > > 61 | (realPolynomials), 62 | "QuotientField > >"); 63 | } 64 | 65 | } // namespace HIntLib 66 | 67 | -------------------------------------------------------------------------------- /src/HIntLib/cubepartitioner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * CubePartitioner 23 | * 24 | * Splits a Hypercube into a given number of (almost) equally sized 25 | * sub-Hypercubes and performs an action on each of them 26 | * 27 | * The virtual method action() has to be overwritten to define the action that 28 | * should be performed on each subcube. 29 | * 30 | * DistanceType: 31 | * 32 | * Determines the position of the planes used for splitting. 33 | * 34 | * EQUIDISTANT: 35 | * The planes are spaced equidistantly along the coordinate axis. 36 | * 37 | * EQUIVOLUME: 38 | * The planes are spaced such that all resulting subcubes have identical 39 | * volume. 40 | */ 41 | 42 | #ifndef HINTLIB_CUBE_PARTITIONER_H 43 | #define HINTLIB_CUBE_PARTITIONER_H 1 44 | 45 | #include 46 | 47 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 48 | #pragma interface 49 | #endif 50 | 51 | namespace HIntLib 52 | { 53 | 54 | class Hypercube; 55 | 56 | class CubePartitioner 57 | { 58 | public: 59 | 60 | enum DistanceType {EQUIDISTANT, EQUIVOLUME}; 61 | 62 | void operator() ( 63 | const Hypercube &, Index numSubcubes, DistanceType = EQUIVOLUME); 64 | 65 | virtual void action (const Hypercube &) = 0; 66 | 67 | virtual ~CubePartitioner () {}; 68 | }; 69 | 70 | } // namespace HIntLib 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /src/HIntLib/linearalgebra2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | 22 | #ifndef HINTLIB_LINEAR_ALGEBRA_2_H 23 | #define HINTLIB_LINEAR_ALGEBRA_2_H 1 24 | 25 | #include 26 | 27 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 28 | #pragma interface 29 | #endif 30 | 31 | #include 32 | 33 | namespace HIntLib 34 | { 35 | /* 36 | * Functions for packed matrices over GF(2) 37 | */ 38 | 39 | template 40 | void packMatrix (const unsigned char*, int numCols, Bi,Bi); 41 | template 42 | void unpackMatrix (Bi,Bi, int numCols, unsigned char*); 43 | 44 | template bool isZeroMatrix (Bi,Bi); 45 | template bool isIdentityMatrix (Bi,Bi); 46 | 47 | template 48 | typename std::iterator_traits::value_type 49 | matrixVectorMul (Bi, Bi, typename std::iterator_traits::value_type); 50 | template 51 | typename std::iterator_traits::value_type 52 | vectorMatrixMul (typename std::iterator_traits::value_type, Bi, Bi); 53 | 54 | template bool isLinearlyIndependent (Bi,Bi); 55 | template int matrixRank (Bi,Bi); 56 | template int nullSpace (Bi, Bi, int, Bi); 57 | template int nullSpaceT (Bi, Bi, Bi); 58 | 59 | } // namespace HIntLib 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/HIntLib/polynomialbase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_POLYNOMIAL_BASE_H 22 | #define HINTLIB_POLYNOMIAL_BASE_H 1 23 | 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | #pragma interface 28 | #endif 29 | 30 | #include 31 | 32 | namespace HIntLib 33 | { 34 | namespace Private 35 | { 36 | 37 | /** 38 | * Polynomial Ring Base -- no template 39 | * 40 | * Non-template base class of polynomial rings 41 | */ 42 | 43 | class PRB 44 | { 45 | public: 46 | static unsigned size() { return 0; } 47 | 48 | void printVariable (std::ostream &) const; 49 | void printVariableWithBrackets (std::ostream &) const; 50 | #ifdef HINTLIB_BUILD_WCHAR 51 | void printVariable (std::wostream &) const; 52 | void printVariableWithBrackets (std::wostream &) const; 53 | #endif 54 | 55 | protected: 56 | #ifdef HINTLIB_BUILD_WCHAR 57 | PRB (char _var, wchar_t _wvar) : var (_var), wvar (_wvar) {} 58 | explicit PRB (char _var) : var (_var), wvar (_var) {} 59 | #else 60 | explicit PRB (char _var) : var (_var) {} 61 | #endif 62 | 63 | static const int squareBeatsLinear []; 64 | 65 | private: 66 | const char var; 67 | #ifdef HINTLIB_BUILD_WCHAR 68 | const wchar_t wvar; 69 | #endif 70 | }; 71 | 72 | unsigned funnySum (int, unsigned); 73 | 74 | } // namespace Private 75 | } // namespace HIntLib 76 | 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /src/HIntLib/rule2thacher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 2 Thacher 23 | * 24 | * Cubature rule of degree 2 with 2*dim + 1 points. 25 | * All points are inside the hypercube. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 2-2 30 | */ 31 | 32 | #ifndef HINTLIB_RULE_2_THACHER_H 33 | #define HINTLIB_RULE_2_THACHER_H 1 34 | 35 | #include 36 | 37 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 38 | #pragma interface 39 | #endif 40 | 41 | #include 42 | #include 43 | 44 | 45 | namespace HIntLib 46 | { 47 | class CubatureRuleFactory; 48 | 49 | class Rule2Thacher : public CubatureRule 50 | { 51 | public: 52 | Rule2Thacher (int dim); 53 | 54 | virtual real eval (Integrand &, const Hypercube &); 55 | 56 | virtual int getDimension() const { return dim; } 57 | virtual Index getNumPoints() const { return 2 * dim + 1; } 58 | virtual int getDegree() const { return 2; } 59 | virtual bool isAllPointsInside() const { return true; } 60 | virtual real getSumAbsWeight() const; 61 | 62 | static CubatureRuleFactory* getFactory(); 63 | 64 | private: 65 | const int dim; 66 | Point p; 67 | }; 68 | 69 | } // namespace HIntLib 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /src/HIntLib/rule3ewing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 3 Ewing 23 | * 24 | * Cubature rule of degree 3 with 2^n + 1 points. 25 | * All points are inside the hypercube. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 3-5 30 | */ 31 | 32 | #ifndef HINTLIB_RULE_3_EWING_H 33 | #define HINTLIB_RULE_3_EWING_H 1 34 | 35 | #include 36 | 37 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 38 | #pragma interface 39 | #endif 40 | 41 | #include 42 | #include 43 | 44 | 45 | namespace HIntLib 46 | { 47 | class CubatureRuleFactory; 48 | 49 | class Rule3Ewing : public CubatureRule, private OrbitRule 50 | { 51 | public: 52 | Rule3Ewing (int dim); 53 | 54 | virtual real eval (Integrand &, const Hypercube &); 55 | 56 | virtual int getDimension() const { return dim; } 57 | virtual Index getNumPoints() const { return numR_Rfs() + 1; } 58 | virtual int getDegree() const { return 3; } 59 | virtual bool isAllPointsInside() const { return true; } 60 | virtual real getSumAbsWeight() const { return 1.0; } 61 | 62 | static CubatureRuleFactory* getFactory(); 63 | 64 | private: 65 | const real b1; 66 | }; 67 | 68 | } // namespace HIntLib 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /tests/numericdiff.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * numeric diff 23 | * 24 | * Compares the numbers listed in two files. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | using std::cerr; 32 | using std::endl; 33 | 34 | int main (int argc, char** argv) 35 | { 36 | if (argc != 3) 37 | { 38 | cerr << "Usage: numericdiff file1 file2\n\n"; 39 | 40 | return 1; 41 | } 42 | 43 | std::ifstream f1 (argv[1]); 44 | if (! f1) 45 | { 46 | cerr << "Cannot open '" << argv[1] << "'!\n\n"; 47 | return 2; 48 | } 49 | std::ifstream f2 (argv[2]); 50 | if (! f2) 51 | { 52 | cerr << "Cannot open '" << argv[2] << "'!\n\n"; 53 | return 2; 54 | } 55 | 56 | for (unsigned n = 1; ; ++n) 57 | { 58 | double x1, x2; 59 | 60 | f1 >> x1; 61 | f2 >> x2; 62 | 63 | if (f1.eof() && f2.eof()) return 0; 64 | 65 | if (f1.eof()) 66 | { 67 | cerr << "File 1 is shorter!\n\n"; 68 | return 3; 69 | } 70 | 71 | if (f2.eof()) 72 | { 73 | cerr << "File 2 is shorter!\n\n"; 74 | return 3; 75 | } 76 | 77 | if (HIntLib::abs (x1 - x2) > 0.000001) 78 | { 79 | cerr << "Files differ! Position: " << n << ", " 80 | << x1 << " != " << x2 << endl; 81 | return 4; 82 | } 83 | } 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/HIntLib/compruleintegrator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * CompRuleIntegrator 23 | * CompRuleIntegratorEst 24 | * 25 | * This integrator splits the cube into a number of subcubes and applies a 26 | * basic rule to each of them. 27 | * 28 | * The *Est version used EmbeddedRules and produeces an error estimate. 29 | */ 30 | 31 | #ifndef HINTLIB_COMP_RULE_INTEGRATOR_H 32 | #define HINTLIB_COMP_RULE_INTEGRATOR_H 1 33 | 34 | #include 35 | 36 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 37 | #pragma interface 38 | #endif 39 | 40 | #include 41 | 42 | namespace HIntLib 43 | { 44 | class CompRuleIntegrator : public CubatureRuleBasedIntegrator 45 | { 46 | public: 47 | CompRuleIntegrator (const CubatureRuleFactory *fac) 48 | : CubatureRuleBasedIntegrator(fac) {} 49 | 50 | virtual 51 | Status integrate ( 52 | Integrand &, const Hypercube &, Index maxEval, real, real, EstErr &); 53 | }; 54 | 55 | class CompRuleIntegratorErr : public EmbeddedRuleBasedIntegrator 56 | { 57 | public: 58 | CompRuleIntegratorErr (const EmbeddedRuleFactory *fac) 59 | : EmbeddedRuleBasedIntegrator(fac) {} 60 | 61 | Status integrate ( 62 | Integrand &, const Hypercube &, Index maxEval, 63 | real reqAbsError, real reqRelError, EstErr &ee); 64 | }; 65 | } // namespace HIntLib 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/HIntLib/defaultcubaturerulefactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * DefaultCubatureRuleFactory 23 | * DefaultEmbeddedRuleFactory 24 | * 25 | * Default implementation of CubatureRuleFactory and EmbeddedRuleFactory 26 | * 27 | * This file should only be included in the *.cpp-file of cubature rules 28 | */ 29 | 30 | #ifndef HINTLIB_DEFAULT_CUBATURERULE_FACTORY_H 31 | #define HINTLIB_DEFAULT_CUBATURERULE_FACTORY_H 1 32 | 33 | #include 34 | 35 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 36 | #pragma interface 37 | #endif 38 | 39 | #include 40 | 41 | namespace HIntLib 42 | { 43 | template 44 | class DefaultCubatureRuleFactory : public CubatureRuleFactory 45 | { 46 | public: 47 | DefaultCubatureRuleFactory () {} 48 | 49 | virtual T* create (int dim) { return new T(dim); } 50 | virtual DefaultCubatureRuleFactory* clone() const 51 | { return new DefaultCubatureRuleFactory; } 52 | }; 53 | 54 | template 55 | class DefaultEmbeddedRuleFactory : public EmbeddedRuleFactory 56 | { 57 | public: 58 | DefaultEmbeddedRuleFactory () {} 59 | 60 | virtual T* create (int dim) { return new T(dim); } 61 | virtual DefaultEmbeddedRuleFactory* clone() const 62 | { return new DefaultEmbeddedRuleFactory; } 63 | }; 64 | 65 | } // namespace HIntLib 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /src/digitalnetgen.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 26 | #pragma implementation 27 | #endif 28 | 29 | /** 30 | * Digital Net 31 | */ 32 | 33 | HIntLib::DigitalNet::DigitalNet (int base, int _m) 34 | : m (std::min ( 35 | _m, 36 | logInt (std::numeric_limits::max(), Index(base)))), 37 | size (powInt (base, m)) 38 | {} 39 | 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | namespace HIntLib 47 | { 48 | HINTLIB_INSTANTIATE_DIGITALNETGEN 49 | (OneDimVectorSpace >) 50 | HINTLIB_INSTANTIATE_DIGITALNETGEN 51 | (OneDimVectorSpace >) 52 | HINTLIB_INSTANTIATE_DIGITALNETGEN 53 | (OneDimVectorSpace >) 54 | HINTLIB_INSTANTIATE_DIGITALNETGEN 55 | (OneDimVectorSpace >) 56 | HINTLIB_INSTANTIATE_DIGITALNETGEN 57 | (OneDimVectorSpace) 58 | HINTLIB_INSTANTIATE_DIGITALNETGEN (GF2VectorSpace) 59 | typedef LookupVectorSpace X1; 60 | typedef LookupVectorSpacePow2 X2; 61 | HINTLIB_INSTANTIATE_DIGITALNETGEN (X1) 62 | HINTLIB_INSTANTIATE_DIGITALNETGEN (X2) 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/HIntLib/productrule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2007 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Product Rule 23 | * 24 | * Common base class for all CubatureRules which are tensor product rules of 25 | * a one-dimensional rule with weights and abscissas stored in an array. 26 | */ 27 | 28 | #ifndef HINTLIB_PRODUCT_RULE_H 29 | #define HINTLIB_PRODUCT_RULE_H 1 30 | 31 | #include 32 | 33 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 34 | #pragma interface 35 | #endif 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | namespace HIntLib 42 | { 43 | class ProductRule : public CubatureRule 44 | { 45 | public: 46 | virtual real eval (Integrand &, const Hypercube &); 47 | 48 | // The parameters are all trivially calculated 49 | 50 | virtual int getDimension() const { return dim; } 51 | virtual Index getNumPoints() const; 52 | virtual bool isAllPointsInside() const; 53 | 54 | protected: 55 | ProductRule (int _dim, int _numPoints); 56 | 57 | void init (const real* _offsets, const real* _weights) 58 | { 59 | offsets = _offsets; 60 | weights = _weights; 61 | } 62 | 63 | const int dim; 64 | const int numPoints; 65 | 66 | private: 67 | Point p; 68 | GrayCounter counter; 69 | const real* offsets; 70 | const real* weights; 71 | }; 72 | 73 | } // namespace HIntLib 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /src/HIntLib/rule3simpson.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 3 Simpson 23 | * 24 | * Cubature rule of degree 3 with 3^n points. 25 | * All points (except the center) are on the border of the hypercube. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 3-6 30 | */ 31 | 32 | #ifndef HINTLIB_RULE_3_SIMPSON_H 33 | #define HINTLIB_RULE_3_SIMPSON_H 1 34 | 35 | #include 36 | 37 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 38 | #pragma interface 39 | #endif 40 | 41 | #include 42 | #include 43 | 44 | 45 | namespace HIntLib 46 | { 47 | class CubatureRuleFactory; 48 | 49 | class Rule3Simpson : public CubatureRule, private OrbitRule 50 | { 51 | public: 52 | Rule3Simpson (int dim); 53 | 54 | virtual real eval (Integrand &, const Hypercube &); 55 | 56 | virtual int getDimension() const { return dim; } 57 | virtual Index getNumPoints() const { return num3powS(); } 58 | virtual int getDegree() const { return 3; } 59 | virtual bool isAllPointsInside() const { return true; } 60 | virtual real getSumAbsWeight() const { return 1.0; } 61 | 62 | static CubatureRuleFactory* getFactory(); 63 | 64 | private: 65 | const real oneDivTwoPowDim; 66 | }; 67 | 68 | } // namespace HIntLib 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /src/HIntLib/rule3gauss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * rule3gauss.h 23 | * 24 | * Cubature rule of degree 3 with 2^n points. 25 | * All points are inside the hypercube. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 3-4 30 | */ 31 | 32 | #ifndef HINTLIB_RULE_3_GAUSS_H 33 | #define HINTLIB_RULE_3_GAUSS_H 1 34 | 35 | #include 36 | 37 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 38 | #pragma interface 39 | #endif 40 | 41 | #include 42 | #include 43 | 44 | 45 | namespace HIntLib 46 | { 47 | class CubatureRuleFactory; 48 | 49 | class Rule3Gauss : public CubatureRule, private OrbitRule 50 | { 51 | public: 52 | Rule3Gauss (int dim); 53 | 54 | virtual real eval (Integrand &, const Hypercube &); 55 | 56 | virtual int getDimension() const { return dim; } 57 | virtual Index getNumPoints() const { return numR_Rfs(); } 58 | virtual int getDegree() const { return 3; } 59 | virtual bool isAllPointsInside() const { return true; } 60 | virtual real getSumAbsWeight() const { return 1.0; } 61 | 62 | static CubatureRuleFactory* getFactory(); 63 | 64 | private: 65 | // Array for offsets 66 | 67 | Point a; 68 | const real oneDivTwoPowDim; 69 | }; 70 | 71 | } // namespace HIntLib 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /src/HIntLib/rule5gauss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 5 Gauss 23 | * 24 | * Cubature rule of degree 5 with 3^n points. 25 | * All points are inside the hypercube. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 5-9 30 | */ 31 | 32 | #ifndef HINTLIB_RULE_5_GAUSS_H 33 | #define HINTLIB_RULE_5_GAUSS_H 1 34 | 35 | #include 36 | 37 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 38 | #pragma interface 39 | #endif 40 | 41 | #include 42 | #include 43 | 44 | 45 | namespace HIntLib 46 | { 47 | class CubatureRuleFactory; 48 | 49 | class Rule5Gauss : public CubatureRule, private OrbitRule 50 | { 51 | public: 52 | Rule5Gauss (int dim); 53 | 54 | virtual real eval (Integrand &, const Hypercube &); 55 | 56 | virtual int getDimension() const { return dim; } 57 | virtual Index getNumPoints() const { return num3powS(); } 58 | virtual int getDegree() const { return 5; } 59 | virtual bool isAllPointsInside() const { return true; } 60 | virtual real getSumAbsWeight() const { return 1.; } 61 | 62 | static CubatureRuleFactory* getFactory(); 63 | 64 | private: 65 | // Array for offsets 66 | 67 | Point a; 68 | const real oneDivTwoPowDim; 69 | }; 70 | 71 | } // namespace HIntLib 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /src/HIntLib/rule75genzmalik.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 7-5 Genz 23 | * 24 | * An embedded cubatare rule of degree 7 (embedded rule degree 5) due to 25 | * A.Genz and Malik 26 | */ 27 | 28 | #ifndef HINTLIB_RULE_7_5_GENZ_MALIK_H 29 | #define HINTLIB_RULE_7_5_GENZ_MALIK_H 1 30 | 31 | #include 32 | 33 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 34 | #pragma interface 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | 41 | namespace HIntLib 42 | { 43 | class EmbeddedRuleFactory; 44 | 45 | class Rule75GenzMalik : public EmbeddedRule, private OrbitRule 46 | { 47 | public: 48 | 49 | Rule75GenzMalik (int dim); 50 | 51 | virtual int evalError (Integrand &f, const Hypercube &, EstErr &); 52 | 53 | virtual int getDimension() const { return dim; } 54 | virtual Index getNumPoints() const; 55 | virtual int getDegree() const { return 7; } 56 | virtual bool isAllPointsInside() const { return true; } 57 | virtual real getSumAbsWeight() const; 58 | 59 | static EmbeddedRuleFactory* getFactory(); 60 | 61 | private: 62 | 63 | // Arrays for temporary data 64 | 65 | Point widthLamda; 66 | 67 | // Dimension depending constants 68 | 69 | const real weight1,weight3, weight5; 70 | const real weightE1, weightE3; 71 | }; 72 | 73 | } // namespace HIntLib 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /src/buffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * SendBuffer 23 | * RecvBuffer 24 | */ 25 | 26 | #define HINTLIB_LIBRARY_OBJECT 27 | 28 | #include 29 | 30 | #include 31 | 32 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 33 | #pragma implementation 34 | #endif 35 | 36 | namespace L = HIntLib; 37 | 38 | 39 | /** 40 | * Send Buffer 41 | */ 42 | 43 | bool L::SendBuffer::pack (const void* buf, int n, MPI_Datatype t) 44 | { 45 | if (! full) 46 | { 47 | int maxSize; 48 | 49 | MPI_Pack_size (n, t, comm, &maxSize); 50 | 51 | full = pos + maxSize > SIZE; 52 | 53 | if (! full) 54 | { 55 | MPI_Pack (const_cast (buf), n, t, data, SIZE, &pos, comm); 56 | } 57 | } 58 | 59 | return !full; 60 | } 61 | 62 | 63 | /** 64 | * Recv Buffer 65 | */ 66 | 67 | void L::RecvBuffer::recv (int source, int tag) 68 | { 69 | MPI_Recv (data, SIZE, MPI_PACKED, source, tag, comm, &status); 70 | MPI_Get_count (&status, MPI_PACKED, &bytesReceived); 71 | } 72 | 73 | 74 | /** 75 | * bufferSendRecv() 76 | */ 77 | 78 | void L::bufferSendRecv (SendBuffer &out, int dest, int destTag, 79 | RecvBuffer &in, int source, int sourceTag) 80 | { 81 | MPI_Sendrecv ( 82 | out.data, out.pos, MPI_PACKED, dest, destTag, 83 | in.data, in.SIZE, MPI_PACKED, source, sourceTag, 84 | in.comm, &in.status); 85 | MPI_Get_count (&in.status, MPI_PACKED, &in.bytesReceived); 86 | } 87 | 88 | -------------------------------------------------------------------------------- /src/HIntLib/qmcintegrator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * QMCIntegrator 23 | * QMCIntegratorNoLB (when compiled with PARALLEL defined) 24 | * 25 | * The basic Quasi Monte Carlo integration routine 26 | * 27 | * In Parllel mode, static load balancing ist provided 28 | */ 29 | 30 | // Check different flags, depending on parallel mode 31 | 32 | #if defined(HINTLIB_PARALLEL) && !defined(HINTLIB_QMC_INTEGRATOR_MPI_H) || !defined(HINTLIB_PARALLEL) && !defined(HINTLIB_QMC_INTEGRATOR_H) 33 | 34 | #include 35 | 36 | // Define Name macro and set flag according to parallel mode 37 | 38 | #ifdef HINTLIB_PARALLEL 39 | # define HINTLIB_QMC_INTEGRATOR_MPI_H 1 40 | # define HINTLIB_NAME(x) x##StaticLB 41 | #else 42 | # define HINTLIB_QMC_INTEGRATOR_H 1 43 | # define HINTLIB_NAME(x) x 44 | #endif 45 | 46 | 47 | namespace HIntLib 48 | { 49 | 50 | class PointSet; 51 | class PartitionablePointSet; 52 | 53 | class HINTLIB_NAME(QMCIntegrator) : public Integrator 54 | { 55 | private: 56 | 57 | #if HINTLIB_PARALLEL 58 | typedef PartitionablePointSet PS; 59 | #else 60 | typedef PointSet PS; 61 | #endif 62 | 63 | public: 64 | HINTLIB_NAME(QMCIntegrator) (PS* _ps) : ps(_ps) {} 65 | 66 | virtual 67 | Status integrate ( 68 | Integrand &, const Hypercube &, Index maxEval, 69 | real reqAbsError, real reqRelError, EstErr &ee); 70 | 71 | private: 72 | PS* ps; 73 | }; 74 | 75 | } // namespace HIntLib 76 | 77 | #undef HINTLIB_NAME 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /src/HIntLib/rule3cross.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 3 Cross 23 | * 24 | * (r,0,...,0)FS 1 / 2*dim 25 | * 26 | * with r = sqrt(n/3) 27 | * 28 | * Cubature rule of degree 3 with 2n points. 29 | * There are points outside the cube for n > 3. 30 | * 31 | * It is also presented in 32 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 33 | * as formula Cn: 3-2 34 | */ 35 | 36 | #ifndef HINTLIB_RULE_3_CROSS_H 37 | #define HINTLIB_RULE_3_CROSS_H 1 38 | 39 | #include 40 | 41 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 42 | #pragma interface 43 | #endif 44 | 45 | #include 46 | #include 47 | 48 | 49 | namespace HIntLib 50 | { 51 | class CubatureRuleFactory; 52 | 53 | class Rule3Cross : public CubatureRule, private OrbitRule 54 | { 55 | public: 56 | Rule3Cross (int dim); 57 | 58 | virtual real eval (Integrand &, const Hypercube &); 59 | 60 | virtual int getDimension() const { return dim; } 61 | virtual Index getNumPoints() const { return numR0_0fs(); } 62 | virtual int getDegree() const { return 3; } 63 | virtual bool isAllPointsInside() const { return dim <= 3; } 64 | virtual real getSumAbsWeight() const { return 1.0; } 65 | 66 | static CubatureRuleFactory* getFactory(); 67 | 68 | private: 69 | const real r; 70 | const real oneOver2Dim; 71 | }; 72 | 73 | } // namespace HIntLib 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /tests/test_arithmetic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_TEST_ARITHMETIC_H 22 | #define HINTLIB_TEST_ARITHMETIC_H 1 23 | 24 | #include 25 | #include 26 | 27 | #include "test.h" 28 | 29 | #ifdef HINTLIB_HAVE_SSTREAM 30 | # include 31 | #else 32 | # include 33 | #endif 34 | 35 | #ifdef HINTLIB_BUILD_WCHAR 36 | #undef USE_WCHAR 37 | #else 38 | #undef USE_WCHAR 39 | #endif 40 | 41 | #ifdef USE_WCHAR 42 | 43 | typedef wchar_t CHAR; 44 | #define COUT std::wcout 45 | typedef std::wstring STRING; 46 | typedef std::basic_stringstream STRINGSTREAM; 47 | 48 | #else 49 | 50 | typedef char CHAR; 51 | #define COUT std::cout 52 | typedef std::string STRING; 53 | typedef std::stringstream STRINGSTREAM; 54 | #endif 55 | 56 | // Userdefined constants 57 | 58 | extern unsigned SIZE; 59 | extern bool FLUSH; 60 | extern unsigned W; 61 | 62 | // counters 63 | 64 | extern unsigned nilpotentsCounter; 65 | extern unsigned unitsCounter; 66 | extern unsigned primitivesCounter; 67 | extern unsigned lastNorm; 68 | extern int lastDegree; 69 | 70 | // function prototypes 71 | 72 | bool performTest ( 73 | const STRING& cat, const STRING& name, const std::string& type); 74 | void printNumberOrInf (unsigned n); 75 | void printInfinity (); 76 | void checkCounter (unsigned expected, unsigned actual, bool all, const char* s); 77 | void checkIndex (unsigned size, unsigned index, const char* s); 78 | void checkInfiniteInFinite (unsigned size, unsigned n, const char* s); 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /src/HIntLib/rule1trapezoidal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 1 Trapezoidal 23 | * 24 | * Cubature rule of degree 1 with 2^n points. 25 | * All points are inside the hypercube. 26 | * 27 | * A product rule based on the one-dimensional 2-point trapezoidal rule 28 | * 29 | * It is presented in 30 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 31 | * as formula Cn: 1-2 32 | */ 33 | 34 | #ifndef HINTLIB_RULE_1_TRAPEZOIDAL_H 35 | #define HINTLIB_RULE_1_TRAPEZOIDAL_H 1 36 | 37 | #include 38 | 39 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 40 | #pragma interface 41 | #endif 42 | 43 | #include 44 | #include 45 | 46 | namespace HIntLib 47 | { 48 | class CubatureRuleFactory; 49 | 50 | class Rule1Trapezoidal : public CubatureRule, private OrbitRule 51 | { 52 | public: 53 | Rule1Trapezoidal (int dim); 54 | 55 | virtual real eval (Integrand &, const Hypercube &); 56 | 57 | virtual int getDimension() const { return dim; } 58 | virtual Index getNumPoints () const { return numR_Rfs(); } 59 | virtual int getDegree () const { return 1; } 60 | virtual bool isAllPointsInside () const { return true; } 61 | virtual real getSumAbsWeight () const { return 1.0; } 62 | 63 | static CubatureRuleFactory* getFactory(); 64 | 65 | private: 66 | Point a; 67 | const real oneDivTwoPowDim; 68 | }; 69 | 70 | } // namespace HIntLib 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /src/HIntLib/rule2simplex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 2 Simplex 23 | * 24 | * Cubature rule of degree 2 with dim+1 points. 25 | * All points are inside the hypercube. All weights are positive. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 2-1 30 | */ 31 | 32 | #ifndef HINTLIB_RULE_2_SIMPLEX_H 33 | #define HINTLIB_RULE_2_SIMPLEX_H 1 34 | 35 | #include 36 | 37 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 38 | #pragma interface 39 | #endif 40 | 41 | #include 42 | #include 43 | 44 | 45 | namespace HIntLib 46 | { 47 | class CubatureRuleFactory; 48 | 49 | class Rule2Simplex : public CubatureRule 50 | { 51 | public: 52 | Rule2Simplex (int dim); 53 | 54 | virtual real eval (Integrand &, const Hypercube &); 55 | 56 | virtual int getDimension() const { return dim; } 57 | virtual Index getNumPoints() const { return dim + 1; } 58 | virtual int getDegree() const { return (dim == 1) ? 3 : 2; } 59 | virtual bool isAllPointsInside() const { return true; } 60 | virtual real getSumAbsWeight() const { return 1.0; } 61 | 62 | static CubatureRuleFactory* getFactory(); 63 | 64 | private: 65 | 66 | const int dim; 67 | 68 | // Dimension dependent constants 69 | 70 | real oneOverDimPlusOne; 71 | Point r, p; 72 | }; 73 | 74 | } // namespace HIntLib 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /src/HIntLib/miser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * MISER Integrator 23 | * 24 | * This implementation is based on: 25 | * 26 | * [1] W.H. Press, G.R. Farrar. Recursive Stratified Sampling for 27 | * Multidimensional Monte Carlo Integration. Computers in Physics, 28 | * vol. 4(2), pp. 190 - 195, 1990. 29 | * [2] W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery. 30 | * Numerical Recipes in C - The Art of Scientific Computing. 31 | * second edition. Cambrdige University Press. Chapter 7.8. 32 | */ 33 | 34 | #ifndef HINTLIB_MISER_H 35 | #define HINTLIB_MISER_H 1 36 | 37 | #include 38 | 39 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 40 | #pragma interface 41 | #endif 42 | 43 | #include 44 | 45 | namespace HIntLib 46 | { 47 | class PRNG; 48 | class PointSet; 49 | 50 | class Miser : public Integrator 51 | { 52 | public: 53 | Miser (PointSet* presample, PointSet* sample); 54 | Miser (PointSet*); 55 | void defaults(); 56 | 57 | Status integrate ( 58 | Integrand &f, const Hypercube &h, Index maxEval, 59 | real reqAbsError, real reqRelError, 60 | EstErr &ee); 61 | 62 | private: 63 | PointSet* presamplePointSet; 64 | PointSet* samplePointSet; 65 | 66 | public: 67 | Index MIN_POINTS; 68 | Index FREE_POINTS; 69 | Index MIN_PRESAMPLING_POINTS; 70 | Index MAX_PRESAMPLING_POINTS; 71 | real PRESAMPLING_RATE; 72 | }; 73 | } // namespace HIntLib 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /tests/toms738/plymul.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE PLYMUL (PA, PB, PC) 2 | C 3 | C This version : 12 December 1991 4 | C 5 | C 6 | C ------------------------------------------------------------ 7 | C 8 | C The following COMMON block, used by many subroutines, 9 | C gives the order Q of a field, its characteristic P, and its 10 | C addition, multiplication and subtraction tables. 11 | C The parameter MAXQ gives the order of the largest field to 12 | C be handled. 13 | C 14 | INTEGER MAXQ 15 | PARAMETER (MAXQ=50) 16 | 17 | INTEGER P, Q, ADD(0:MAXQ-1,0:MAXQ-1) 18 | INTEGER MUL(0:MAXQ-1, 0:MAXQ-1), SUB(0:MAXQ-1, 0:MAXQ-1) 19 | COMMON /FIELD/ P, Q, ADD, MUL, SUB 20 | SAVE /FIELD/ 21 | C 22 | C The following definitions concern the representation of 23 | C polynomials. 24 | C 25 | INTEGER MAXDEG, DEG 26 | PARAMETER (MAXDEG=50, DEG=-1) 27 | C 28 | C The parameter MAXDEG gives the highest degree of polynomial 29 | C to be handled. Polynomials stored as arrays have the 30 | C coefficient of degree n in POLY(N), and the degree of the 31 | C polynomial in POLY(-1). The parameter DEG is just to remind 32 | C us of this last fact. A polynomial which is identically 0 33 | C is given degree -1. 34 | C 35 | C A polynomial can also be stored in an integer I, with 36 | C I = AN*Q**N + ... + A0. 37 | C Routines ITOP and PTOI convert between these two formats. 38 | C 39 | C ----------------------------------------------------------- 40 | C 41 | C 42 | C 43 | INTEGER I, J, DEGA, DEGB, DEGC, TERM 44 | INTEGER PA(-1:MAXDEG), PB(-1:MAXDEG), PC(-1:MAXDEG) 45 | INTEGER PT(-1:MAXDEG) 46 | C 47 | C Multiplies polynomial PA by PB putting the result in PC. 48 | C Coefficients are elements of the field of order Q. 49 | C 50 | DEGA = PA(DEG) 51 | DEGB = PB(DEG) 52 | IF (DEGA .EQ. -1 .OR. DEGB .EQ. -1) THEN 53 | DEGC = -1 54 | ELSE 55 | DEGC = DEGA + DEGB 56 | ENDIF 57 | IF (DEGC .GT. MAXDEG) THEN 58 | WRITE (*,*) ' PLYMUL : Degree of product exceeds MAXDEG' 59 | STOP 60 | ENDIF 61 | C 62 | DO 20 I = 0, DEGC 63 | TERM = 0 64 | DO 10 J = MAX(0, I-DEGA), MIN(DEGB, I) 65 | 10 TERM = ADD(TERM, MUL(PA(I-J), PB(J))) 66 | 20 PT(I) = TERM 67 | C 68 | PC(DEG) = DEGC 69 | DO 30 I = 0, DEGC 70 | 30 PC(I) = PT(I) 71 | DO 40 I = DEGC+1, MAXDEG 72 | 40 PC(I) = 0 73 | RETURN 74 | END 75 | C 76 | C ***** end of SUBROUTINE PLYMUL 77 | -------------------------------------------------------------------------------- /src/quotientfield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #define HINTLIB_LIBRARY_OBJECT 22 | 23 | #include 24 | 25 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 26 | #pragma implementation 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | void 36 | HIntLib::Private::printDoubleStruckCapitalQ (std::ostream& o) 37 | { 38 | #if HINTLIB_CHARACTER_SET == 4 && defined (HINTLIB_UTF8_SELECT) 39 | HINTLIB_UTF8_SELECT(utf8Support(o), 40 | o << "\xe2\x84\x9a", // DOUBLE-STRUCK CAPITAL Q 41 | o << "Q") 42 | #else 43 | o << "Q"; 44 | #endif 45 | } 46 | 47 | #ifdef HINTLIB_BUILD_WCHAR 48 | void 49 | HIntLib::Private::printDoubleStruckCapitalQ (std::wostream& o) 50 | { 51 | #if HINTLIB_CHARACTER_SET == 4 52 | o << L"\x211a"; // DOUBLE-STRUCK CAPITAL Q 53 | #else 54 | o << L"Q"; 55 | #endif 56 | } 57 | #endif 58 | 59 | namespace HIntLib 60 | { 61 | HINTLIB_INSTANTIATE_QUOTIENTFIELD_INT (IntegerRing) 62 | HINTLIB_INSTANTIATE_QUOTIENTFIELD_POL (PolynomialRing >) 63 | HINTLIB_INSTANTIATE_QUOTIENTFIELD_POL (PolynomialRing >) 64 | HINTLIB_INSTANTIATE_QUOTIENTFIELD_POL 65 | (PolynomialRing > >) 66 | HINTLIB_INSTANTIATE_QUOTIENTFIELD_POL 67 | (PolynomialRing >) 68 | HINTLIB_INSTANTIATE_QUOTIENTFIELD_POL (PolynomialRing) 69 | HINTLIB_INSTANTIATE_QUOTIENTFIELD_POL (Polynomial2Ring) 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/rule1trapezoidal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 1 Trapezoidal 23 | * 24 | * Cubature rule of degree 1 with 2^n points. 25 | * All points are inside the hypercube. 26 | * 27 | * A product rule based on the one-dimensional 2-point trapezoidal rule 28 | * 29 | * It is presented in 30 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 31 | * as formula Cn: 1-2 32 | */ 33 | 34 | #define HINTLIB_LIBRARY_OBJECT 35 | 36 | #include 37 | 38 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 39 | #pragma implementation 40 | #endif 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | 47 | namespace L = HIntLib; 48 | 49 | 50 | /** 51 | * The constructor is used primarily to initialize all the dimension dependent 52 | * constatns and to allocate (dimension dependent) memory 53 | */ 54 | 55 | L::Rule1Trapezoidal::Rule1Trapezoidal (int dim) 56 | : OrbitRule (dim), a (dim), oneDivTwoPowDim (real(1) / (Index(1) << dim)) 57 | { 58 | checkDimensionNotZero (dim); 59 | checkDimensionLeq::digits - 1> (dim); 60 | } 61 | 62 | 63 | /** 64 | * Do the actual function evaluation 65 | */ 66 | 67 | L::real L::Rule1Trapezoidal::eval (Integrand &f, const Hypercube &h) 68 | { 69 | return h.getVolume() * evalR_Rfs (f, h.getCenter(), h.getWidth()) 70 | * oneDivTwoPowDim; 71 | } 72 | 73 | L::CubatureRuleFactory* L::Rule1Trapezoidal::getFactory() 74 | { 75 | return new DefaultCubatureRuleFactory (); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /src/HIntLib/vegas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * VEGAS Integrator 23 | * 24 | * An adaptive Monte Carlo integration routine 25 | * 26 | * This implementation is based on 27 | * [1] L.P. Lepage. A New Algorithm for Adaptive Multidimensional 28 | * Integration. Journal of Computational Physics, vol. 27, 29 | * pp. 192 - 203, 1978. 30 | * [2] L.P. Lepage. VEGAS: An Adaptive Multidimensional Integration 31 | * Program. Publication CLNS-80/447, Cornell Univeristy, 1980. 32 | * [3] W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery. 33 | * Numerical Recipes in C - The Art of Scientific Computing. 34 | * second edition. Cambrdige University Press. Chapter 7.8. 35 | */ 36 | 37 | #ifndef HINTLIB_VEGAS_H 38 | #define HINTLIB_VEGAS_H 1 39 | 40 | #include 41 | 42 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 43 | #pragma interface 44 | #endif 45 | 46 | #include 47 | 48 | namespace HIntLib 49 | { 50 | class PointSet; 51 | 52 | class Vegas : public Integrator 53 | { 54 | public: 55 | Vegas (PointSet* _ps) : ps(_ps), combineResults (false), ALPHA (1.5) {} 56 | 57 | Status integrate ( 58 | Integrand &f, const Hypercube &h, Index maxEval, 59 | real, real, EstErr &ee); 60 | 61 | Vegas& setAlpha (real a) { ALPHA = a; return *this; } 62 | Vegas& setCombineResults (bool b = true) 63 | { combineResults = b; return *this; } 64 | 65 | private: 66 | PointSet* const ps; 67 | bool combineResults; 68 | real ALPHA; 69 | }; 70 | } // namespace HIntLib 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/rule3cross.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 3 Cross 23 | * 24 | * (r,0,...,0)FS 1 / 2*dim 25 | * 26 | * with r = sqrt(n/3) 27 | * 28 | * Cubature rule of degree 3 with 2n points. 29 | * There are points outside the cube for n > 3. 30 | * 31 | * It is also presented in 32 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 33 | * as formula Cn: 3-2 34 | */ 35 | 36 | #define HINTLIB_LIBRARY_OBJECT 37 | 38 | #include 39 | 40 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 41 | #pragma implementation 42 | #endif 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | 49 | namespace L = HIntLib; 50 | 51 | 52 | /** 53 | * The constructor is used primarily to initialize all the dimension dependent 54 | * constatns and to allocate (dimension dependent) memory 55 | */ 56 | 57 | L::Rule3Cross::Rule3Cross (int dim) 58 | : OrbitRule (dim), 59 | r (HINTLIB_MN sqrt (real(dim) / real(3))), 60 | oneOver2Dim (real(1) / real(2 * dim)) 61 | { 62 | checkDimensionNotZero (dim); 63 | } 64 | 65 | 66 | /** 67 | * Do the actual function evaluation 68 | */ 69 | 70 | L::real L::Rule3Cross::eval (Integrand &f, const Hypercube &h) 71 | { 72 | const real* center = h.getCenter(); 73 | 74 | Scaler scaler (h.getWidth(), r); 75 | setCenter (center); 76 | return h.getVolume() * evalR0_0fs (f, center, scaler) * oneOver2Dim; 77 | } 78 | 79 | L::CubatureRuleFactory* L::Rule3Cross::getFactory() 80 | { 81 | return new DefaultCubatureRuleFactory (); 82 | } 83 | 84 | -------------------------------------------------------------------------------- /src/rule3ewing.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 3 Ewing 23 | * 24 | * Cubature rule of degree 3 with 2^n + 1 points. 25 | * All points are inside the hypercube. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 3-5 30 | */ 31 | 32 | #define HINTLIB_LIBRARY_OBJECT 33 | 34 | #include 35 | 36 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 37 | #pragma implementation 38 | #endif 39 | 40 | #include 41 | #include 42 | #include 43 | 44 | 45 | namespace L = HIntLib; 46 | 47 | using L::real; 48 | 49 | /** 50 | * The constructor is used primarily to initialize all the dimension dependent 51 | * constaints 52 | */ 53 | 54 | L::Rule3Ewing::Rule3Ewing (int dim) 55 | : OrbitRule (dim), 56 | b1 (real(1) / (real(3) * real (Index(1) << dim))) 57 | { 58 | checkDimensionNotZero (dim); 59 | checkDimensionLeq::digits - 1> (dim); 60 | } 61 | 62 | namespace 63 | { 64 | const real b0 = real(2) / real(3); 65 | } 66 | 67 | 68 | /** 69 | * Do the actual function evaluation 70 | */ 71 | 72 | L::real L::Rule3Ewing::eval (Integrand &f, const Hypercube &h) 73 | { 74 | const real* center = h.getCenter(); 75 | 76 | setCenter (center); 77 | 78 | return h.getVolume() * 79 | ( b0 * eval0_0 (f) 80 | + b1 * evalR_Rfs (f, center, h.getWidth()) 81 | ); 82 | } 83 | 84 | L::CubatureRuleFactory* L::Rule3Ewing::getFactory() 85 | { 86 | return new DefaultCubatureRuleFactory (); 87 | } 88 | 89 | -------------------------------------------------------------------------------- /src/HIntLib/rule9stenger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * rule9stenger.h 23 | * 24 | * Cubature rule of degree 9 25 | * All points are inside the hypercube. 26 | * 27 | * This rule was published in 28 | * F. Stenger: Numerical Integration in N Dimensions 29 | * M.S. theses, Univ. of Alberta, 1963 30 | * 31 | * Listet as 9-1 in Stroud71 32 | */ 33 | 34 | #ifndef HINTLIB_RULE_9_STENGER_H 35 | #define HINTLIB_RULE_9_STENGER_H 1 36 | 37 | #include 38 | 39 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 40 | #pragma interface 41 | #endif 42 | 43 | #include 44 | #include 45 | 46 | 47 | namespace HIntLib 48 | { 49 | class CubatureRuleFactory; 50 | 51 | class Rule9Stenger : public CubatureRule, private OrbitRule 52 | { 53 | public: 54 | Rule9Stenger (int dim); 55 | 56 | virtual real eval (Integrand &, const Hypercube &); 57 | 58 | virtual int getDimension() const { return dim; } 59 | virtual Index getNumPoints() const; 60 | virtual int getDegree() const { return 9; } 61 | virtual bool isAllPointsInside() const { return true; } 62 | virtual real getSumAbsWeight() const; 63 | 64 | static CubatureRuleFactory* getFactory(); 65 | 66 | private: 67 | 68 | // Arrays for temporary data 69 | 70 | Point aU; 71 | Point aV; 72 | 73 | // Dimension dependent constants 74 | 75 | real weightF, weightH, weightI, weightJ, weightE, weightD, 76 | weightC, weightB, weightA; 77 | real rU, rV; 78 | }; 79 | 80 | } // namespace HIntLib 81 | 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /src/HIntLib/staticloadbalancer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Static Load Balancer 23 | * 24 | * Distributes a task statically among all available processing nodes 25 | */ 26 | 27 | #ifndef HINTLIB_STATIC_LOAD_BALANCER_H 28 | #define HINTLIB_STATIC_LOAD_BALANCER_H 1 29 | 30 | #include 31 | 32 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 33 | #pragma interface 34 | #endif 35 | 36 | 37 | namespace HIntLib 38 | { 39 | 40 | class StaticLoadBalancerBase 41 | { 42 | public: 43 | 44 | enum OP {SUM, MIN, MAX}; 45 | 46 | Index getBegin(void) const { return begin; } 47 | Index getEnd (void) const { return end; } 48 | Index getRange(void) const { return end - begin; } 49 | int getRank (void) const { return rank; } 50 | int getSize (void) const { return size; } 51 | 52 | protected: 53 | 54 | StaticLoadBalancerBase(void) {}; 55 | StaticLoadBalancerBase(int r, int s, Index b, Index e) 56 | : rank(r), size(s), begin(b), end(e) {} 57 | 58 | int rank,size; 59 | Index begin, end; 60 | 61 | }; 62 | 63 | class DummyStaticLoadBalancer : public StaticLoadBalancerBase 64 | { 65 | public: 66 | DummyStaticLoadBalancer(Index n) 67 | : StaticLoadBalancerBase (0, 1, 0, n) {} 68 | }; 69 | 70 | #ifdef HINTLIB_PARALLEL 71 | 72 | class MPIStaticLoadBalancer : public StaticLoadBalancerBase 73 | { 74 | public: 75 | MPIStaticLoadBalancer(Index n, MPI_Comm comm = MPI_COMM_WORLD); 76 | }; 77 | 78 | typedef MPIStaticLoadBalancer StaticLoadBalancer; 79 | #else 80 | typedef DummyStaticLoadBalancer StaticLoadBalancer; 81 | #endif 82 | 83 | } // namespace HIntLib 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /src/HIntLib/rule5hammer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * rule5hammer.h 23 | * 24 | * Cubature rule of degree 5 with 2*dim^2 + 1 points. 25 | * All points are inside the hypercube. 26 | * 27 | * This rule was published in 28 | * P. C. Hammer and A. H. Stroud., Numerical Evaluation of Multiple 29 | * Integrals. Math Tables Aids Comput, V 12 (1958), 272-280 30 | * 31 | * It is also presented in 32 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 33 | * as formula Cn: 5-2 34 | */ 35 | 36 | #ifndef HINTLIB_RULE_5_HAMMER_H 37 | #define HINTLIB_RULE_5_HAMMER_H 1 38 | 39 | #include 40 | 41 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 42 | #pragma interface 43 | #endif 44 | 45 | #include 46 | #include 47 | 48 | 49 | namespace HIntLib 50 | { 51 | class CubatureRuleFactory; 52 | 53 | class Rule5Hammer : public CubatureRule, private OrbitRule 54 | { 55 | public: 56 | Rule5Hammer (int dim); 57 | 58 | virtual real eval (Integrand &f, const Hypercube &); 59 | 60 | virtual int getDimension() const { return dim; } 61 | virtual Index getNumPoints() const; 62 | virtual int getDegree() const { return 5; } 63 | virtual bool isAllPointsInside() const { return true; } 64 | virtual real getSumAbsWeight() const; 65 | 66 | static CubatureRuleFactory* getFactory(); 67 | 68 | private: 69 | Point lamda; 70 | 71 | // Dimension dependent constants 72 | 73 | const real b0; 74 | const real b1; 75 | }; 76 | 77 | } // namespace HIntLib 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /src/HIntLib/rule5mustardlynessblatt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2007 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * rule5mustardlynessblatt.h 23 | * 24 | * Cubature rule of degree 5 with 2^dim + 2*dim + 1 points. 25 | * All points are inside the hypercube. 26 | * 27 | * This rule was published in 28 | D. Mustard, J. N. Lyness, and J. M. Blatt. Numerical quadrature in n 29 | dimensions. Comp. J. 6, 75-87, 1963. 30 | * 31 | * It is also presented in 32 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 33 | * as formula Cn: 5-5 34 | */ 35 | 36 | #ifndef HINTLIB_RULE_5_MUSTARD_LYNESS_BLATT_H 37 | #define HINTLIB_RULE_5_MUSTARD_LYNESS_BLATT_H 1 38 | 39 | #include 40 | 41 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 42 | #pragma interface 43 | #endif 44 | 45 | #include 46 | #include 47 | 48 | 49 | namespace HIntLib 50 | { 51 | class CubatureRuleFactory; 52 | 53 | class Rule5MustardLynessBlatt : public CubatureRule, private OrbitRule 54 | { 55 | public: 56 | Rule5MustardLynessBlatt (int dim); 57 | 58 | virtual real eval (Integrand &, const Hypercube &); 59 | 60 | virtual int getDimension() const { return dim; } 61 | virtual Index getNumPoints() const; 62 | virtual int getDegree() const { return 5; } 63 | virtual bool isAllPointsInside() const { return true; } 64 | virtual real getSumAbsWeight() const; 65 | 66 | static CubatureRuleFactory* getFactory(); 67 | 68 | private: 69 | // Dimension dependent constants 70 | 71 | const real weight0; 72 | const real weight1; 73 | }; 74 | 75 | } // namespace HIntLib 76 | 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /src/HIntLib/rule3octahedron.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * rule3octahedron.h 23 | * 24 | * Cubature rule of degree 3 with 2 * dim points. 25 | * All points are inside the hypercube. All weights are positive. 26 | * 27 | * This rule was published in 28 | * A. H. Stroud., Remarks on the disposition of points in numerical 29 | * integration. Math Tables Aids Comput, V 11 (1957), 257-261 30 | * 31 | * It is also presented in 32 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 33 | * as formula Cn: 3-1 34 | */ 35 | 36 | #ifndef HINTLIB_RULE_3_OCTAHEDRON_H 37 | #define HINTLIB_RULE_3_OCTAHEDRON_H 1 38 | 39 | #include 40 | 41 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 42 | #pragma interface 43 | #endif 44 | 45 | #include 46 | #include 47 | 48 | 49 | namespace HIntLib 50 | { 51 | class CubatureRuleFactory; 52 | 53 | class Rule3Octahedron : public CubatureRule 54 | { 55 | public: 56 | Rule3Octahedron (int dim); 57 | 58 | virtual real eval (Integrand &, const Hypercube &); 59 | 60 | virtual int getDimension() const { return dim; } 61 | virtual Index getNumPoints() const { return 2 * dim; } 62 | virtual int getDegree() const { return 3; } 63 | virtual bool isAllPointsInside() const { return true; } 64 | virtual real getSumAbsWeight() const { return 1.0; } 65 | 66 | static CubatureRuleFactory* getFactory(); 67 | 68 | private: 69 | 70 | const int dim; 71 | const int dim2; 72 | 73 | // Dimension dependent constants 74 | 75 | Point r, p; 76 | }; 77 | 78 | } // namespace HIntLib 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /src/HIntLib/gcd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_GCD_H 22 | #define HINTLIB_GCD_H 1 23 | 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | #pragma interface 28 | #endif 29 | 30 | namespace HIntLib 31 | { 32 | 33 | /** 34 | * powerMod() 35 | */ 36 | 37 | template 38 | typename A::type 39 | powerMod (const A&, const typename A::type&, unsigned, 40 | const typename A::type&); 41 | 42 | template 43 | typename A::type 44 | powerMod 45 | (const A&, const typename A::type&, unsigned, unsigned, 46 | const typename A::type&); 47 | 48 | 49 | /** 50 | * genGcd() 51 | * 52 | * Calculates the greatest common divisor 53 | * 54 | * A has to be an Euclidean Ring 55 | */ 56 | 57 | template 58 | typename A::type 59 | genGcd (const A&, 60 | const typename A::type& u, const typename A::type& v, 61 | typename A::type& mu, typename A::type& mv); 62 | 63 | template 64 | typename A::type 65 | genGcd (const A&, 66 | const typename A::type& u, const typename A::type& v, 67 | typename A::type& mu); 68 | 69 | template 70 | typename A::type 71 | genGcd (const A&, const typename A::type& u, const typename A::type& v); 72 | 73 | 74 | /** 75 | * genLcm () 76 | */ 77 | 78 | template 79 | inline 80 | typename A::type 81 | genLcm (const A&a, const typename A::type& u, const typename A::type& v) 82 | { 83 | return a.mul (a.div (u, genGcd (a, u, v)), v); 84 | } 85 | 86 | 87 | /** 88 | * genIsCoprime () 89 | */ 90 | 91 | template 92 | bool 93 | genIsCoprime (const A&, const typename A::type&, const typename A::type&); 94 | 95 | } // namespace HIntLib 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /src/rule3simpson.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * Rule 3 Simpson 23 | * 24 | * Cubature rule of degree 3 with 3^n points. 25 | * All points (except the center) are on the border of the hypercube. 26 | * 27 | * It is also presented in 28 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 29 | * as formula Cn: 3-6 30 | */ 31 | 32 | #define HINTLIB_LIBRARY_OBJECT 33 | 34 | #include 35 | 36 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 37 | #pragma implementation 38 | #endif 39 | 40 | #include 41 | #include 42 | #include 43 | 44 | 45 | namespace L = HIntLib; 46 | 47 | using L::real; 48 | 49 | namespace 50 | { 51 | const real w0 = real(4) / real(3); 52 | const real w1 = real(1) / real(3); 53 | } 54 | 55 | 56 | /** 57 | * The constructor is used primarily to initialize all the dimension dependent 58 | * constatns and to allocate (dimension dependent) memory 59 | */ 60 | 61 | L::Rule3Simpson::Rule3Simpson (int dim) 62 | : OrbitRule (dim), oneDivTwoPowDim (real(1) / real(Index(1) << dim)) 63 | { 64 | checkDimensionNotZero (dim); 65 | 66 | int maxDim = logInt(std::numeric_limits::max(), Index(3)); 67 | 68 | if (dim > maxDim) throw DimensionTooHigh (dim, maxDim); 69 | } 70 | 71 | 72 | /** 73 | * Do the actual function evaluation 74 | */ 75 | 76 | real L::Rule3Simpson::eval (Integrand &f, const Hypercube &h) 77 | { 78 | return h.getVolume() * eval3powS (f, h.getCenter(), h.getWidth(), w0, w1) 79 | * oneDivTwoPowDim; 80 | } 81 | 82 | L::CubatureRuleFactory* L::Rule3Simpson::getFactory() 83 | { 84 | return new DefaultCubatureRuleFactory (); 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/HIntLib/output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | #ifndef HINTLIB_OUTPUT_H 22 | #define HINTLIB_OUTPUT_H 1 23 | 24 | #include 25 | 26 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 27 | #pragma interface 28 | #endif 29 | 30 | #ifdef HINTLIB_HAVE_SSTREAM 31 | # include 32 | #else 33 | # include 34 | #endif 35 | 36 | namespace HIntLib 37 | { 38 | namespace Private 39 | { 40 | 41 | #ifdef HINTLIB_STREAMS_SUPPORT_LOCALE 42 | bool utf8Support (const std::ostream&); 43 | #endif 44 | 45 | template 46 | class PrinterSelector 47 | {}; 48 | 49 | class Printer : public std::ostringstream 50 | { 51 | public: 52 | Printer (std::ostream &); 53 | ~Printer (); 54 | 55 | #ifdef HINTLIB_ENCODING_LOCALE 56 | bool utf8 (); 57 | #endif 58 | void power (unsigned i); 59 | void subscript (unsigned i); 60 | void minusSign(); 61 | 62 | private: 63 | std::ostream& o; 64 | #ifdef HINTLIB_ENCODING_LOCALE 65 | enum { UNKNOWN, YES, NO } haveUtf8Support; 66 | #endif 67 | }; 68 | 69 | template<> 70 | class PrinterSelector 71 | { 72 | public: 73 | typedef Printer printer; 74 | }; 75 | 76 | #ifdef HINTLIB_BUILD_WCHAR 77 | class WPrinter : public std::wostringstream 78 | { 79 | public: 80 | WPrinter (std::wostream &); 81 | ~WPrinter (); 82 | 83 | void power (unsigned i); 84 | void subscript (unsigned i); 85 | void minusSign(); 86 | 87 | private: 88 | std::wostream& o; 89 | }; 90 | 91 | template<> 92 | class PrinterSelector 93 | { 94 | public: 95 | typedef WPrinter printer; 96 | }; 97 | #endif 98 | 99 | 100 | } // namespace Private 101 | } // namespace HIntLib 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /src/HIntLib/rule5stroud2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2007 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * rule5stroud2.h 23 | * 24 | * Cubature rule of degree 5 with 2^dim + 2*dim points. 25 | * All points are inside the hypercube for 2 <= dim <= 5. 26 | * 27 | * This rule was published in 28 | * A. H. Stroud., Some fifth degree integration formulas for symmetric 29 | * regions. Math. Comp. 20, 90-97, 1966. 30 | * 31 | * It is also presented in 32 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 33 | * as formula Cn: 5-4 34 | */ 35 | 36 | #ifndef HINTLIB_RULE_5_STROUD_2_H 37 | #define HINTLIB_RULE_5_STROUD_2_H 1 38 | 39 | #include 40 | 41 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 42 | #pragma interface 43 | #endif 44 | 45 | #include 46 | #include 47 | 48 | 49 | namespace HIntLib 50 | { 51 | class CubatureRuleFactory; 52 | 53 | class Rule5Stroud2 : public CubatureRule, private OrbitRule 54 | { 55 | public: 56 | Rule5Stroud2 (int dim); 57 | 58 | virtual real eval (Integrand &, const Hypercube &); 59 | 60 | virtual int getDimension() const { return dim; } 61 | virtual Index getNumPoints() const; 62 | virtual int getDegree() const { return 5; } 63 | virtual bool isAllPointsInside() const; 64 | virtual real getSumAbsWeight() const { return 1.; } 65 | 66 | static CubatureRuleFactory* getFactory(); 67 | 68 | private: 69 | // Dimension dependent constants 70 | 71 | const real alpha; 72 | const real beta; 73 | const real weightAlpha; 74 | const real weightBeta; 75 | 76 | // Array for temporary data 77 | 78 | Point scaledBeta; 79 | }; 80 | 81 | } // namespace HIntLib 82 | 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /src/HIntLib/rule7phillips.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * rule7phillips.h 23 | * 24 | * Cubature rule of degree 7 25 | * All points are inside the hypercube. 26 | * 27 | * This rule was published in 28 | * G.M.Phillips: 29 | * Numerical Integration over an N-Dimensional Rectangular Region 30 | * The Computer Journal 10 (1967), 297-299. 31 | * 32 | * It is also presented in 33 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 34 | * as formula Cn: 7-1 35 | */ 36 | 37 | #ifndef HINTLIB_RULE_7_PHILLIPS_H 38 | #define HINTLIB_RULE_7_PHILLIPS_H 1 39 | 40 | #include 41 | 42 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 43 | #pragma interface 44 | #endif 45 | 46 | #include 47 | #include 48 | 49 | 50 | namespace HIntLib 51 | { 52 | class CubatureRuleFactory; 53 | 54 | class Rule7Phillips : public CubatureRule, private OrbitRule 55 | { 56 | public: 57 | Rule7Phillips (int dim); 58 | 59 | virtual real eval (Integrand &, const Hypercube &); 60 | 61 | virtual int getDimension() const { return dim; } 62 | virtual Index getNumPoints() const; 63 | virtual int getDegree() const { return 7; } 64 | virtual bool isAllPointsInside() const { return true; } 65 | virtual real getSumAbsWeight() const; 66 | 67 | static CubatureRuleFactory* getFactory(); 68 | 69 | private: 70 | 71 | // Arrays for temporary data 72 | 73 | Point aCD; 74 | 75 | // Dimension dependent constants 76 | 77 | const real eN; 78 | const real temp; 79 | const real rB2; 80 | const real weightB1, weightB2, weightC, weightA; 81 | }; 82 | 83 | } // namespace HIntLib 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /tests/test_arithmetic_integer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | // algebraic structures to be tested 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | // The actual test templates 30 | 31 | #include "test_arithmetic_tests.h" 32 | 33 | namespace HIntLib 34 | { 35 | 36 | void testInteger() 37 | { 38 | // Z, Z[x], Z[x,y], Q, Q[x], Q(x) 39 | 40 | typedef IntegerRing<> Z; 41 | Z z; 42 | doTests (z, "IntegerRing"); 43 | 44 | typedef PolynomialRing PZ; 45 | PZ pz (z); 46 | doTests (pz, "PolynomialRing >"); 47 | 48 | doTests (PolynomialRing (pz, 'y'), 49 | "PolynomialRing > >"); 50 | 51 | typedef QuotientField Q; 52 | Q q (z); 53 | doTests (q, "QuotientField >"); 54 | 55 | typedef PolynomialRing PQ; 56 | PQ pq (q); 57 | doTests (pq, "PolynomialRing > >"); 58 | 59 | doTests (QuotientField (pq), 60 | "QuotientField > > >"); 61 | 62 | // Q(i) 63 | 64 | PQ pq_i (q, 'i'); 65 | PQ::type p2 = pq_i.x(2); 66 | p2[0] = q.makeElement (1); 67 | doTests (FactorField (pq_i, p2), 68 | "FactorField > > >"); 69 | 70 | // Q(Sqrt(2)) 71 | 72 | #ifdef USE_WCHAR 73 | PQ pq_r (q, 'r', 0x03b1); // GREEK SMALL LETTER ALPHA 74 | #else 75 | PQ pq_r (q, 'r'); 76 | #endif 77 | 78 | PQ::type p3 = pq_r.x(2); 79 | p3[0] = q.makeElement(-2); 80 | doTests (FactorField (pq_r, p3), 81 | "FactorField > > >"); 82 | } 83 | 84 | } // namespace HIntLib 85 | 86 | -------------------------------------------------------------------------------- /src/HIntLib/rule5stroud.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * rule5stroud.h 23 | * 24 | * Cubature rule of degree 5 with 3*dim^2 + 3*dim + 1 points. 25 | * All points are inside the hypercube. 26 | * 27 | * This rule was published in 28 | * A. H. Stroud., Extensions of Symmetric Integration Formulas. 29 | * Math Comput, V 22 (1968), 271-274 30 | * 31 | * It is also presented in 32 | * A. H. Stoud. Approximate Calculation of Multiple Integrals (1971) 33 | * as formula Cn: 5-3 34 | */ 35 | 36 | #ifndef HINTLIB_RULE_5_STROUD_H 37 | #define HINTLIB_RULE_5_STROUD_H 1 38 | 39 | #include 40 | 41 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 42 | #pragma interface 43 | #endif 44 | 45 | #include 46 | #include 47 | 48 | 49 | namespace HIntLib 50 | { 51 | class CubatureRuleFactory; 52 | 53 | class Rule5Stroud : public CubatureRule, private OrbitRule 54 | { 55 | public: 56 | Rule5Stroud (int dim); 57 | 58 | virtual real eval (Integrand &, const Hypercube &); 59 | 60 | virtual int getDimension() const { return dim; } 61 | virtual Index getNumPoints() const; 62 | virtual int getDegree() const { return 5; } 63 | virtual bool isAllPointsInside() const { return true; } 64 | virtual real getSumAbsWeight() const; 65 | 66 | static CubatureRuleFactory* getFactory(); 67 | 68 | private: 69 | // Arrays for temporary data 70 | 71 | Point aR; 72 | Point aMinusR; 73 | Point aS; 74 | Point aMinusS; 75 | Point aT; 76 | Point aMinusT; 77 | 78 | // Dimension dependent constants 79 | 80 | const real b0; 81 | const real b2; 82 | const real b4; 83 | }; 84 | 85 | } // namespace HIntLib 86 | 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /src/create_bitop.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | 22 | #include 23 | #include 24 | 25 | // This is not really a library object. However, since library files are 26 | // linked static, we do not require DLL-export names. 27 | #define HINTLIB_LIBRARY_OBJECT 28 | 29 | #include 30 | 31 | using std::cout; 32 | using std::setw; 33 | 34 | using namespace HIntLib::NormalBitOp; 35 | 36 | void create_data (int f (unsigned)) 37 | { 38 | cout << "{\n"; 39 | 40 | for (unsigned i = 0; i < 256; ++i) 41 | { 42 | if (i % 16 == 0) cout << " "; 43 | 44 | unsigned char c = i; 45 | 46 | cout << setw (2) << f (c) << ","; 47 | 48 | if (i % 16 == 15) cout << '\n'; 49 | } 50 | 51 | cout << "};\n\n"; 52 | } 53 | 54 | int main() 55 | { 56 | cout << "/*******************************************************/\n" 57 | "/*** This file is program-generated! ***/\n" 58 | "/*** ***/\n" 59 | "/*** Do not change!!! ***/\n" 60 | "/*** ***/\n" 61 | "/*** Update " __FILE__ " to update this file. ***/\n" 62 | "/*******************************************************/\n" 63 | "\n" 64 | "#include \n" 65 | "\n" 66 | "#ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION\n" 67 | "#pragma implementation\n" 68 | "#endif\n" 69 | "\n" 70 | "namespace L = HIntLib;\n" 71 | "\n" 72 | "const int L::Private::ms1_data [] =\n"; 73 | 74 | create_data (ms1); 75 | 76 | cout << "const int L::Private::ls0_data [] =\n"; 77 | 78 | create_data (ls0); 79 | 80 | return 0; 81 | } 82 | 83 | -------------------------------------------------------------------------------- /src/HIntLib/adaptintegratorlocallist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HIntLib - Library for High-dimensional Numerical Integration 3 | * 4 | * Copyright (C) 2002,03,04,05 Rudolf Schuerer 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 | */ 20 | 21 | /** 22 | * AdaptIntegratorLocalList 23 | * 24 | * Parallel Adaptive Integration with local region collections 25 | */ 26 | 27 | #ifndef HINTLIB_ADAPT_INTEGRATOR_LOCAL_LIST_H 28 | #define HINTLIB_ADAPT_INTEGRATOR_LOCAL_LIST_H 1 29 | 30 | #include 31 | 32 | #ifndef HINTLIB_PARALLEL 33 | #error AdaptIntegratorLocalList can only be used in PARALLEL mode 34 | #endif 35 | 36 | #ifdef HINTLIB_USE_INTERFACE_IMPLEMENTATION 37 | #pragma interface 38 | #endif 39 | 40 | #include 41 | 42 | namespace HIntLib 43 | { 44 | class EmbeddedRuleFactory; 45 | class RegionCollection; 46 | 47 | class AdaptIntegratorLocalList : public EmbeddedRuleBasedIntegrator 48 | { 49 | public: 50 | AdaptIntegratorLocalList ( 51 | const EmbeddedRuleFactory *, 52 | MPI_Comm = MPI_COMM_WORLD, 53 | unsigned frequency = 5000, unsigned maxDimension = 0); 54 | 55 | virtual 56 | Status integrate ( 57 | Integrand &f, const Hypercube &h, Index maxEval, 58 | real reqAbsError, real reqRelError, EstErr &ee); 59 | 60 | private: 61 | MPI_Comm comm; 62 | enum TAGS {ERROR_CMP, REGIONS}; 63 | 64 | unsigned frequency; 65 | 66 | unsigned dimension; 67 | int rank; 68 | int nodes; 69 | 70 | int size [8]; // Size of mesh in a given direction 71 | int coord [8]; // position of itself in the mesh 72 | int succ [8]; 73 | int pred [8]; 74 | 75 | void doExchange2 (RegionCollection &rc, unsigned dir, unsigned dim); 76 | void doExchange (RegionCollection &rc, unsigned dir, unsigned dim); 77 | void doExchangeOld (RegionCollection &rc, unsigned dir, unsigned dim); 78 | }; 79 | } // namespace HIntLib 80 | 81 | #endif 82 | 83 | --------------------------------------------------------------------------------