Source Listing for Project Pala
Total Page:16
File Type:pdf, Size:1020Kb
Source Listing for project pala Ulrich Mutze www.ulrichmutze.de July 1, 2020 Contents 1 Introduction, Draft 1 1.1 Addition for usage of multiple precision arithmetic . 2 1.2 Code Structure . 2 1.3 The First Steps in the Program . 4 2 Legal Matters 5 3 alloca.h 7 4 cpmactionprinciple.h 8 5 cpmactionprinciple.cpp 9 6 cpmalgorithms.h 17 7 cpmalgorithms.cpp 39 8 cpmangle.h 62 9 cpmangle.cpp 68 10 cpmapplication.h 76 11 cpmapplication.cpp 82 12 cpmbasicinterfaces.h 98 13 cpmbasictypes.h 100 14 cpmbody.h 102 Contents 15 cpmbody.cpp 104 16 cpmbodycpp.h 106 17 cpmbodyx.h 126 18 cpmc.h 148 19 cpmc.cpp 156 20 cpmcamera.h 163 21 cpmcamera.cpp 165 22 cpmcamera2.h 166 23 cpmcamera2cpp.h 171 24 cpmcamera3.h 178 25 cpmcamera3cpp.h 185 26 cpmcamerax.h 198 27 cpmcameraxcpp.h 205 28 cpmclinalg.h 215 29 cpmcompar.h 234 30 cpmcompar.cpp 236 31 cpmcomparcpp.h 238 32 cpmcomparx.h 295 33 cpmcompdef.h 333 34 cpmconstphys.h 336 35 cpmconstphys.cpp 339 36 cpmdefinitions.h 340 37 cpmdigraph.h 341 2 Contents 38 cpmdigraph.cpp 356 39 cpmdim.h 358 40 cpmdim.cpp 361 41 cpmdim2.h 362 42 cpmdim2cpp.h 382 43 cpmdim3.h 394 44 cpmdim3cpp.h 423 45 cpmdimdef.h 445 46 cpmdimx.h 446 47 cpmdimxcpp.h 473 48 cpmdiscretespace.h 524 49 cpmdistribution.h 527 50 cpmdistribution.cpp 532 51 cpmdynaux.h 537 52 cpmdynaux.cpp 540 53 cpmextractor.h 542 54 cpmextractorx.h 544 55 cpmf.h 554 56 cpmfa.h 564 57 cpmfft.h 574 58 cpmfftmore.h 578 59 cpmfield.h 583 60 cpmfile.h 590 3 Contents 61 cpmfl.h 594 62 cpmfo.h 617 63 cpmfontgeneration.h 621 64 cpmfontgeneration.cpp 628 65 cpmforces.h 645 66 cpmforces.cpp 647 67 cpmforcescpp.h 649 68 cpmforcesx.h 687 69 cpmfr.h 720 70 cpmframe.h 728 71 cpmframe.cpp 751 72 cpmframes.h 775 73 cpmframes.cpp 778 74 cpmgraph.h 783 75 cpmgraph.cpp 806 76 cpmgreg.h 849 77 cpmgreg.cpp 855 78 cpmgroupgraph.h 863 79 cpmhistogr.h 866 80 cpmhistogr.cpp 870 81 cpmhomunitvecxcpp.h 877 82 cpmimage.h 880 83 cpmimagingtools.h 919 4 Contents 84 cpmimagingtools.cpp 934 85 cpmimg24.h 952 86 cpmimg24.cpp 968 87 cpminifilebasapp.h 995 88 cpminifilebasapp.cpp 1008 89 cpminterfaces.h 1026 90 cpminterval.h 1036 91 cpminterval.cpp 1047 92 cpmlinalg.h 1060 93 cpmlinalg.cpp 1079 94 cpmm.h 1101 95 cpmmacros.h 1112 96 cpmmini.h 1115 97 cpmmini.cpp 1119 98 cpmmpi.h 1129 99 cpmmultiimage.h 1136 100cpmnumbers.h 1177 101cpmnumbers.cpp 1213 102cpmp.h 1221 103cpmpardef.h 1229 104cpmpardynsys.h 1230 105cpmpardynsys.cpp 1287 106cpmparens.h 1288 5 Contents 107cpmparensx.h 1290 108cpmparofspc.h 1296 109cpmparofspcx.h 1298 110cpmparticleviewer.h 1336 111cpmperm.h 1343 112cpmperm.cpp 1346 113cpmproperties.h 1350 114cpmproperties.cpp 1359 115cpmr2func.h 1374 116cpmr2func.cpp 1378 117cpmrecord.h 1388 118cpmrecord.cpp 1402 119cpmrecordhandler.h 1429 120cpmrecordhandler.cpp 1434 121cpmrfunc.h 1443 122cpmrfunc.cpp 1458 123cpmrigbodydyn.h 1499 124cpmrigbodydyn.cpp 1505 125cpmrmateig.h 1521 126cpmrmateig.cpp 1525 127cpmrmatrix.h 1536 128cpmrmatrix.cpp 1547 129cpmroot.h 1568 6 Contents 130cpmroot.cpp 1571 131cpmrvector.h 1576 132cpmrvector.cpp 1586 133cpms.h 1596 134cpmshapes.h 1611 135cpmshapes.cpp 1612 136cpmshapesx.h 1613 137cpmshapesxcpp.h 1619 138cpmsmoothlocalinterpol.h 1627 139cpmsmoothlocalinterpol.cpp 1630 140cpmsys2.h 1643 141cpmsys2.cpp 1645 142cpmsys2aps.h 1647 143cpmsys2aps.cpp 1649 144cpmsys2apscpp.h 1650 145cpmsys2cpp.h 1659 146cpmsys2dat.h 1696 147cpmsys2dat.cpp 1698 148cpmsys2datcpp.h 1699 149cpmsys2datx.h 1702 150cpmsys2x.h 1705 151cpmsystem.h 1713 152cpmsystem.cpp 1728 7 Contents 153cpmsystemdependencies.h 1744 154cpmsysviewer.h 1746 155cpmsysviewer.cpp 1748 156cpmsysviewercpp.h 1752 157cpmtypes.h 1754 158cpmtypes.cpp 1764 159cpmuc.h 1774 160cpmuc.cpp 1779 161cpmunits.h 1780 162cpmv.h 1783 163cpmv.cpp 1838 164cpmva.h 1840 165cpmvectorgraphics.h 1853 166cpmvectorgraphics.cpp 1859 167cpmvectormore.h 1866 168cpmvectormore.cpp 1877 169cpmviewport.h 1900 170cpmviewport.cpp 1911 171cpmvo.h 1924 172cpmvr.h 1939 173cpmword.h 1943 174cpmword.cpp 1958 175cpmx.h 1969 8 1 Introduction, Draft 176cpmzinterval.h 1991 177cpmzinterval.cpp 2000 178features.h 2006 179mpfr.h 2016 180pala.cpp 2039 181stdio.h 2043 182stdlib.h 2061 183time.h 2082 184survey.txt 2089 185headerdependencies.txt 2112 1 Introduction, Draft This is a listing of the source files of the program PaLa (Particle Lab). The whole file system that upon compiling and linking makes up the program can be downloaded from www.ulrichmutze.de/sourcecode/pala.zip. Here, after unpacking, one has all *.cpp and *.h files in a single directory which allows the corresponding make file to have a simple structure. Further, all *.cpp and *.h files which make up the C+− file system can be downloaded from www.ulrichmutze.de/sourcecode/cpmsource.zip. Here they are distributed over several directories which reflect the file type and, roughly, the problem field they deal with. During the development I worked under Windows, Cygwin, and Linux in parallel. Here is a list of the compilers that I worked with: Microsoft C/C++ Optimizing Compiler Version 13.10.3052 g++(GCC) 3.3.4 (cygwin special) g++(GCC) 3.3.5 20050117 (prerelease) (SUSE Linux) g++ (ubuntu/Linario 4.6.3-1ubuntu5) 4.6.3 Recently I restricted development and testing to a Ubuntu/Linux system and request getting 0 warnings with the following setting for compilation and linking defines = -D_CONSOLE options = -O1 -pedantic-errors linkoptions = -lglut -lGL -lGLU -lgmp -lmpfr 9 1 Introduction, Draft The present listed form of the code may help to become familiar with the program since it brings the whole code under the control of the text search function of the any PDF- Reader. This should not only be helpful to get an overview but also for getting the final answer to any question why the program behaves the way it does. For a short description of the scope of the program and the way to use it, see the file pala_readme.txt in the doc directory in pala.zip. 1.1 Addition for usage of multiple precision arithmetic One has to set CPM_MP in file cpmdefinitions.h, e. g. #define CPM_MP 32 and to add -lmpfr and -lgmp to the linkoptions. A much faster but less far reaching boost of computational accuracy can be invoked by using long double instead of double to represent real numbers. One has to define CPM_LONG in file cpmdefinitions.h. 1.2 Code Structure The PaLa program is defined in file pala.cpp. All other files are part of my class system Classes for Physics and Mathematics which I have been using in creating many programs in the past. Only the files really needed for PaLa are incorporated here. There are, however, functions defined in these files which are not needed for PaLa. In this class system all file names begin with the prefix cpm and all storable entities declared in these files reside in namespaces the names of which all begin with Cpm. Finally, all macros introduced here have names beginning with CPM . So provisions are in place for a peaceful coexistence with tools from other libraries. In the present compilation the cpm-files appear in alphabetic order. All geometric and physical concepts are given for a world of two space dimensions (’flatland’) and the real world of three space dimensions. For instance, the declarations using namespace CpmDim2; using namespace CpmRigidBody2; ComPar cp; introduce a composite (polyspherical particle) cp having a tensor of inertia which is representable by a single number, wheras using the namespaces CpmDim3 and Cpm- RigidBody3 would make the tensor of inertia represented by a triplet of vectors. In order to implement this double structure with a minimum of doublicated code, a straightfor- ward file inclusion scheme is employed. Using templates for this purpose did not work with the compiler which I used at the time of introducing this scheme. Also with the improved template capability of today it would be hard to come up with a solution as easy to work with as the present one. The inner working of this treatment of space dimension can be seen from the file cpmdim.h 10 1 Introduction, Draft which includes cpmdimx.h cpmdim2.h cpmdim3.h and the file cpmdim.cpp which includes cpmdimxcpp.h cpmdim2cpp.h cpmdim3cpp.h Here, the files with an x in their name contain code that is identical text for 2D and 3D. It is only by action of the pre-processor that it becomes adapted to the space dimension. Files with a 2 or 3 in their name contain code that contains explicit reference to the dimension. With the cpmdim files in place, all other dimension-dependent concepts (except those in defining class Camera) are coded without explicit reference to the space dimension. This implies that the usual habit of expecting declarations in files *.h and implementations in *.cpp has to be modified: Also files *cpp.h are implementation files, as could be expected from this mixed kind of name. All this code adheres to a simplifying programming style which I refer to as C+− . Elements of this style are explained in many places but particularly in files cpmv.h and cpmfl.h. Especially the template class F (defined in cpmfl.h) and the way it is used to define geometrical and physical entities such as shapes and fields seem to be programming innovations. The same seems to be true for the template class Vp ('polymorphic vector') which allows to loop over objects derived from a common base without having to provide pointers to these objects. Generally, the most important single aspect of the present class system is that pointers are never a part of the public interface (of course, the internal workings rely heavily on pointers) so that it is impossible to make memory management mistakes.