CSL - C++ Symbolic Computation Library User Manual

CSL - C++ Symbolic Computation Library User Manual

CSL - C++ Symbolic Computation Library User Manual Grégoire Uhlrich December 2, 2020 CSL Manual 2 Contents 1 Introduction 15 2 C++ basics 17 2.1 C++ 101.......................................... 17 2.1.1 History, philosophy................................. 17 2.1.2 Compile-time vs. run-time............................. 18 2.1.3 Type system..................................... 18 2.2 Constness in C++..................................... 19 2.3 References, pointers..................................... 20 2.4 Namespaces......................................... 23 2.5 Enumerations........................................ 24 2.6 The auto keyword...................................... 25 2.7 Lambda functions...................................... 26 2.8 The standard library.................................... 28 2.8.1 I/O streams..................................... 28 2.8.2 Strings........................................ 29 2.8.3 Containers, C++ vector.............................. 30 2.8.4 Smart pointers................................... 33 2.8.5 Optional variables.................................. 35 2.9 Lists in C++........................................ 36 2.10 Polymorphism........................................ 37 3 CSL basics 41 3.1 Philosophy.......................................... 41 3.2 Symbolic computation................................... 41 3.2.1 Principle....................................... 41 3.2.2 Internal representation of an expression...................... 42 3.2.3 The Expr type................................... 42 3.2.4 Limitations..................................... 46 3.3 Using CSL .......................................... 47 3.4 CSL type system...................................... 47 3.4.1 Type system..................................... 47 3.4.2 Primary type system................................ 48 3.4.3 When CSL type system is not enough....................... 50 3.5 CSL builder functions.................................... 50 3.6 CSL error system...................................... 51 3.7 Loops with CSL expressions................................ 51 3.8 Canonical forms of expressions............................... 51 3.9 Automatic ordering of expressions............................. 53 3 CSL Manual CONTENTS 3.10 How to learn CSL ...................................... 55 3.10.1 The manual..................................... 55 3.10.2 The documentation................................. 55 3.10.3 The code, for the brave............................... 55 4 CSL good manners 57 4.1 Resource safety....................................... 57 4.2 Memory allocation..................................... 58 4.3 C++ good manners..................................... 59 4.3.1 Strings........................................ 59 4.3.2 C++ vectors.................................... 59 4.4 CSL good manners..................................... 63 4.4.1 The Expr type................................... 63 4.4.2 Avoidable allocations................................ 63 4.4.3 Heavy interface functions.............................. 64 5 Numbers 65 5.1 Integer............................................ 65 5.2 Float............................................. 66 5.3 IntFraction......................................... 67 5.4 Complex........................................... 68 5.5 NumericalEval........................................ 68 6 Scalar literals 71 6.1 Complex literals....................................... 71 6.2 Constant........................................... 71 6.3 Variable........................................... 72 6.4 Imaginary.......................................... 74 6.5 IntFactorial......................................... 75 6.6 Arbitrary.......................................... 76 6.7 CSL global variables.................................... 77 7 Mathematical operations 81 7.1 Sum............................................. 81 7.2 Prod............................................. 84 7.3 Pow............................................. 85 7.4 Subtraction and division.................................. 86 8 Mathematical functions 87 8.1 Common mathematical functions............................. 88 8.2 Other functions....................................... 90 8.2.1 Angle........................................ 90 8.2.2 Factorial....................................... 91 8.2.3 DiracDelta...................................... 92 9 Operators 95 9.1 Principle........................................... 95 9.2 RealPart, ImaginaryPart.................................. 95 9.3 Derivative.......................................... 96 9.4 Integrals........................................... 98 4 CSL Manual CONTENTS 9.4.1 ScalarIntegral.................................... 98 9.4.2 VectorIntegral.................................... 101 10 Vectorial expressions 103 10.1 Principle........................................... 103 10.2 Vector............................................ 103 10.3 Matrix............................................ 106 10.4 HighDTensor........................................ 108 11 Indicial expressions 111 11.1 Principle of indicial computations............................. 111 11.1.1 Motivation...................................... 111 11.1.2 Parents and elements................................ 111 11.1.3 Knowing if an expression is indexed........................ 112 11.2 Space and Index....................................... 113 11.2.1 Space........................................ 113 11.2.2 Index......................................... 115 11.2.3 Basics on indices.................................. 116 11.3 Indicial tensors (Tensor).................................. 117 11.3.1 Principle....................................... 117 11.3.2 Building....................................... 117 11.3.3 Manipulating parents................................ 118 11.3.4 Setting properties to tensors............................ 119 11.3.5 Complex, Transposed, Hermitian properties................... 121 11.3.6 Contraction properties............................... 122 11.3.7 Tensor values.................................... 123 11.4 Indicial tensor fields (TensorField)............................. 124 11.5 Tensorial derivative (TDerivative)............................. 125 11.6 ISum............................................. 125 11.7 IProd............................................ 126 12 Abbreviations 129 12.1 Principle........................................... 129 12.2 Creating and printing.................................... 129 12.3 Evaluating.......................................... 131 13 Expression modifiers 133 13.1 General principle...................................... 133 13.2 Copy, Refresh........................................ 134 13.2.1 Copy......................................... 134 13.2.2 Refresh....................................... 137 13.3 Expansion.......................................... 138 13.3.1 Standard expansion................................. 138 13.3.2 Conditional expansion............................... 139 13.4 Factorization........................................ 140 13.5 Deriving........................................... 141 13.6 Evaluation.......................................... 142 13.6.1 Principle....................................... 142 13.6.2 CSL evaluation flags................................ 142 5 CSL Manual CONTENTS 13.6.3 Example....................................... 143 13.7 Replacement......................................... 144 13.7.1 CSL replacement.................................. 144 13.7.2 CSL swapping.................................... 148 14 Interface functions 151 14.1 Principle........................................... 151 14.2 Expression dependencies.................................. 151 14.3 Complex numbers...................................... 152 14.4 Interface for indicial objects................................ 153 14.4.1 Space and indices.................................. 153 14.4.2 Tensor involution properties............................ 153 14.4.3 Contraction properties............................... 155 14.5 Other interface functions.................................. 155 15 Algorithms 157 15.1 Read-only algorithms.................................... 158 15.1.1 Find......................................... 159 15.1.2 FindIf........................................ 160 15.1.3 VisitEach algorithm................................ 162 15.1.4 Other read-only algorithms............................. 163 15.2 Read and write algorithms................................. 163 15.2.1 Transform algorithm................................ 164 15.2.2 ForEach algorithm................................. 164 15.2.3 Other read and write algorithms.......................... 166 16 Tools and options 167 16.1 Tools............................................. 167 16.1.1 Timer........................................ 167 16.1.2 ScopedProperty................................... 168 16.2 Options........................................... 169 16.2.1 errorStopsProgram (boolean)........................... 169 16.2.2 checkCommutations (boolean)........................... 169 16.2.3 freezeMerge (boolean)............................... 169 16.2.4 applySelfContractions (boolean).......................... 169 16.2.5 applyChainContractions (boolean)........................ 169 16.2.6 fullComparison (boolean)............................. 169 16.2.7 printIndexIds (boolean).............................. 170 17 Tutorials 171 17.1 Tutorial: basic manipulations..............................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    186 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us