CSL - C++ Symbolic Computation Library User Manual

Total Page:16

File Type:pdf, Size:1020Kb

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..............................
Recommended publications
  • Rapid Research with Computer Algebra Systems
    doi: 10.21495/71-0-109 25th International Conference ENGINEERING MECHANICS 2019 Svratka, Czech Republic, 13 – 16 May 2019 RAPID RESEARCH WITH COMPUTER ALGEBRA SYSTEMS C. Fischer* Abstract: Computer algebra systems (CAS) are gaining popularity not only among young students and schol- ars but also as a tool for serious work. These highly complicated software systems, which used to just be regarded as toys for computer enthusiasts, have reached maturity. Nowadays such systems are available on a variety of computer platforms, starting from freely-available on-line services up to complex and expensive software packages. The aim of this review paper is to show some selected capabilities of CAS and point out some problems with their usage from the point of view of 25 years of experience. Keywords: Computer algebra system, Methodology, Wolfram Mathematica 1. Introduction The Wikipedia page (Wikipedia contributors, 2019a) defines CAS as a package comprising a set of algo- rithms for performing symbolic manipulations on algebraic objects, a language to implement them, and an environment in which to use the language. There are 35 different systems listed on the page, four of them discontinued. The oldest one, Reduce, was publicly released in 1968 (Hearn, 2005) and is still available as an open-source project. Maple (2019a) is among the most popular CAS. It was first publicly released in 1984 (Maple, 2019b) and is still popular, also among users in the Czech Republic. PTC Mathcad (2019) was published in 1986 in DOS as an engineering calculation solution, and gained popularity for its ability to work with typeset mathematical notation in combination with automatic computations.
    [Show full text]
  • The World of Scripting Languages Pdf, Epub, Ebook
    THE WORLD OF SCRIPTING LANGUAGES PDF, EPUB, EBOOK David Barron | 506 pages | 02 Aug 2000 | John Wiley & Sons Inc | 9780471998860 | English | New York, United States The World of Scripting Languages PDF Book How to get value of selected radio button using JavaScript? She wrote an algorithm for the Analytical Engine that was the first of its kind. There is no specific rule on what is, or is not, a scripting language. Most computer programming languages were inspired by or built upon concepts from previous computer programming languages. Anyhow, that led to me singing the praises of Python the same way that someone would sing the praises of a lover who ditched them unceremoniously. Find the best bootcamp for you Our matching algorithm will connect you to job training programs that match your schedule, finances, and skill level. Java is not the same as JavaScript. Found on all windows and Linux servers. All content from Kiddle encyclopedia articles including the article images and facts can be freely used under Attribution-ShareAlike license, unless stated otherwise. Looking for more information like this? Timur Meyster in Applying to Bootcamps. Primarily, JavaScript is light weighed, interpreted and plays a major role in front-end development. These can be used to control jobs on mainframes and servers. Recover your password. It accounts for garbage allocation, memory distribution, etc. It is easy to learn and was originally created as a tool for teaching computer programming. Kyle Guercio - January 21, 0. Data Science. Java is everywhere, from computers to smartphones to parking meters. Requires less code than modern programming languages.
    [Show full text]
  • Csc 311 Survey of Programming of Programming Languages Overview of Programing Languages
    CSC 311 SURVEY OF PROGRAMMING OF PROGRAMMING LANGUAGES OVERVIEW OF PROGRAMING LANGUAGES LECTURE ONE Lesson objectives By the end of this lesson, students should be able to: Understand programming and programming language Describe flow of programming language Describe the structure of programming language Describe different classification of programming language Identify why are there so many programming languages Identify what makes a language successful Describe importance of programming language What is Programming? A program is a set of instructions use in performing specific task. Therefore, Programming is an act of writing programs. Meaning of Programming Language Programming Languages are important for software technologies. It is a basic one, without it programming could not do a thing about software. It is a key factor to every software. There are different types of programming languages that are currently trendy. Such as: • C • C++ • Java • C# • Python • Ruby. etc Normal Language is a communication between two people. We are using English, Tamil, Hindi and so on using communication between two people. Flow of programming Languages Compiler Compiler is an intermediary to understand each language. Compiler converts High level languages to low level languages as well as low level languages convert to high level languages. Each language needs at least one compiler. Without compiler we could not understand low level language. Input Output Structure of Programming Languages Each programming Language has separate structure but a little bit changes in each programming change. Syntax wise we only have changes of each programming language otherwise it's the same structure. Header file is some supporting files. It is located at the top of program.
    [Show full text]
  • Linguistic Modeling Based on Symbolic Calculations
    UDC 81`32 A.G. Sinyutich LINGUISTIC MODELING BASED ON SYMBOLIC CALCULATIONS Brest State University named after A.S. Pushkin Анотація Дана стаття містить інформацію про символьних обчисленнях і системах комп'ютерної алгебри, за допомогою яких символьні обчислення виконуються. Про системи символьних обчислень, як ефективні інструменти в моделюванні лінгвістичних феноменів. Ключові слова: лінгвістичне моделювання, символьні обчислення, лінгвістика, комп'ютерна алгебра, комп'ютерне моделювання Abstract This article contains information about symbol calculations and computer algebra systems, through which the symbolic computations are performed. About systems of symbolic calculations, as effective tools in modeling of linguistic phenomena. Key words: linguistic modeling, symbolic calculations, linguistics, computer algebra, computer modeling Symbolic computation involves the processing of mathematical expressions and their elements as sequences of symbols (as opposed to numerical calculations that operate with numeric values behind mathematical expressions). Modern symbolic calculations are represented as dynamically developing field of mathematical modeling. The development of symbolic methods of modeling carried out through computer algebra. Practical implementation of symbolic modeling is made on the basis of the use of computer algebra system (CAS): Maple, Sage, Maxima, Reduce, etc. Most of the cases solved by computer algebra systems are purely mathematical in their essence: the mathematical nature (the disclosure of products and degrees, factorization, differentiation, integration, calculation of the limits of functions and sequences, the solution of equations, operating with series, etc.). However, the universality of symbolic calculations and their potential in modeling linguistic phenomena has never been questioned. And the MATHLAB, one of the first systems of computer algebra, was created within the framework of the project of research of artificial intelligence (MITRE) on the basis of language LISP.
    [Show full text]
  • Scientific & Engineering Programming
    Scientific & Engineering Programming Lecture I Introduction. Tools. Mathematica overview Mariusz Janiak, Robert Muszyński Copyright c 2017-2020 MJ & RM Some facts course home page: https://kcir.pwr.edu.pl/~mucha/SciEng instructors: Mariusz Janiak, Robert Muszyński office: room 331, building C-3 office hours: refer to the lecturers’ home pages final tests: will be, for details refer to the CHP credit: pass the final tests and complete the laboratory classes contents – soon 1/ 11 Scientific & Engineering Programming Scientific – related to science science – knowledge about or study of the natural world based on facts learned through experiments and observation (Merriam-Webster Dict.) scientist – some of you (if not now, in near future, hopefully:) Engineering – a function of an engineer but also: the application of science and mathematics by which the properties of matter and the sources of energy in nature are made useful to people (Merriam-Webster Dict.) engineer – some of you, again (let’s hope:) – a designer of engines (Merriam-Webster Dict.) – a person who designs, builds, or maintains engines, machines, or structures (Oxford Dict.) 2/ 11 Scientific & Engineering Programming Scientific – related to science science – knowledge about the natural world Engineering – related to design engineering – application of science and mathematics in nature Programming – related to programs programming – the act of creating computer programs 3/ 11 Scientist & Engineer Needs acquire knowledge describe nature predict behaviors invent machines design machines analyze
    [Show full text]
  • Comparative Programming Languages CM20253
    We have briefly covered many aspects of language design And there are many more factors we could talk about in making choices of language The End There are many languages out there, both general purpose and specialist And there are many more factors we could talk about in making choices of language The End There are many languages out there, both general purpose and specialist We have briefly covered many aspects of language design The End There are many languages out there, both general purpose and specialist We have briefly covered many aspects of language design And there are many more factors we could talk about in making choices of language Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important For example, can you easily join together code written in Java and C? The End Or languages And then the interopability of languages becomes important For example, can you easily join together code written in Java and C? The End Or languages Often a single project can use several languages, each suited to its part of the project For example, can you easily join together code written in Java and C? The End Or languages Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important The End Or languages Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important For example, can you easily
    [Show full text]
  • Numerically Simulating the Solar System in Mathematica
    Journal of Advances in Information Technology Vol. 10, No. 4, November 2019 Numerically Simulating the Solar System in Mathematica Charles Chen Northwood High School, Irvine, USA Email: [email protected] Abstract—The planetary motion within our solar system is a variables is global across all notebooks. This works by topic that has been studied for hundreds of years and has assigning a serial number $푠푛푛푛 to the end of all variable given rise to the science of astronomy. It is very important names, making them unique. to know the positions of the planets in our solar system, as Due to its user-friendly notebook format, Mathematica many of our current scientific research depends on it. Space is commonly used as an elaborate graphing calculator and exploration, for example, is a perfect example of when we need to know the exact positions of the planets in our solar sometimes overlooked as a programming language for system. Since it takes many years to send a rover or satellite numerical simulations. Furthermore, Mathematica’s to a planet, we will need to be able to predict the position of selection of helpful built-in functions such as “Animate”, that planet many years into the future. Therefore, I present “Manipulate”, and “Dynamic”, which allow the user to a second order Runge-Kutta simulation to predict the control input parameters (via a slide bar) for graphical future position and velocity of the planets in our solar plots of analytic functions, often cause users to overlook system based on Newtonian laws of motion. The equations Mathematica’s ability to animate numerical solutions in of motion are implemented into a Mathematia script which real time.
    [Show full text]
  • CUDA Programming with the Wolfram Language
    WOLFRAM WHITE PAPER CUDA Programming with the Wolfram Language Introduction CUDA, short for Common Unified Device Architecture, is a C-like programming language devel- oped by NVIDIA to facilitate general computation on the Graphical Processing Unit (GPU). CUDA allows users to design programs around the many-core hardware architecture of the GPU. By using many cores, carefully designed CUDA programs can achieve speedups (1000x in some cases) over a similar CPU implementation. Coupled with the investment price and power required to GFLOP (billion floating-point operations per second), the GPU has quickly become an ideal platform for both high-performance clusters and scientists wishing for a supercomputer at their disposal. Yet while the user can achieve speedups, CUDA does have a steep learning curve—including learning the CUDA programming API and understanding how to set up CUDA and compile CUDA programs. This learning curve has, in many cases, alienated many potential CUDA programmers. Wolfram’s CUDALink simplified the use of the GPU within the Wolfram Language by introducing dozens of functions to tackle areas ranging from image processing to linear algebra. CUDALink also allows the user to load their own CUDA functions into the Wolfram System kernel. By utilizing the Wolfram Language and integrating with existing programs and development tools, CUDALink offers an easy way to use CUDA. In this document we describe the benefits of CUDA integration in the Wolfram Language and provide some applications for which it is suitable. Motivations for CUDALink CUDA is a C-like language designed to write general programs around the NVIDIA GPU hardware.
    [Show full text]
  • Mathematica 12 Installing Mathematica 12
    Mathematica 12 Installing Mathematica 12 Access to Mathematica Desktop, Mathematica Online and Wolfram|Alpha Pro Computer clusters - The Mathematica license for Millersville allows for parallel computing, both on dedicated research clusters and in ad-hoc, or distributed, grid environments. For more details, please contact Andy Dorsett at [email protected] To request Mathematica Desktop, Mathematica Online, and Wolfram|Alpha Pro, follow the directions below: Faculty 1. Create an account (New users only): a. Go to user.wolfram.com and click "Create Account" b. Fill out form using a @millersville.edu email, and click "Create Wolfram ID" c. Check your email and click the link to validate your Wolfram ID 2. Request access to the product: Mathematica Desktop For school-owned machines: a. Fill out this form to request an Activation Key b. Click the "Product Summary page" link to access your license c. Click "Get Downloads" and select "Download" next to your platform d. Run the installer on your machine, and enter Activation Key at prompt For a personally owned machine: a. Fill out this form to request a home-use license from Wolfram. Mathematica Online a. Fill out this form to request access b. Go to Mathematica Online and sign in to access Mathematica Online Wolfram|Alpha Pro a. Fill out this form to request access b. Go to Wolfram|Alpha and click "Sign in" to access Wolfram|Alpha Pro Wolfram Programming Lab a. Fill out this form to request access b. Go to Wolfram Programming Lab and sign in to access Wolfram Programming Lab Students 1. Create an account (New users only): a.
    [Show full text]
  • El Camino College How to Get Mathematica
    5/15/2017 Wolfram Technology at El Camino College How to Get Mathematica Mathematica Desktop (the traditional Wolfram Mathematica) Mathematica Online Wolfram|Alpha Pro Students: 1. Create an account (New users only): a. Go to user.wolfram.com and click "Create Account" b. Fill out form using a @elcamino.edu email, and click "Create Wolfram ID" c. Check your email and click the link to validate your Wolfram ID 2. Request access to the product. Choose Mathematica Desktop, Mathematica Online, Wolfram Alpha Pro, or all three: Mathematica Desktop For a personally owned machine: a. Fill out this form to request an Activation Key b. Click the "Product Summary page" link to access your license c. Click "Get Downloads" and select "Download" next to your platform d. Run the installer on your machine, and enter Activation Key at prompt Mathematica Online e. Fill out this form to request access f. Go to Mathematica Online and sign in to access Mathematica Online Wolfram|Alpha Pro g. Fill out this form to request access h. Go to Wolfram|Alpha and click "Sign in" to access Wolfram|Alpha Pro 5/15/2017 Faculty: 1. Create an account (New users only): a. Go to user.wolfram.com and click "Create Account" b. Fill out form using a @elcamino.edu email, and click "Create Wolfram ID" c. Check your email and click the link to validate your Wolfram ID 2. Request access to the product. Choose Mathematica Desktop, Mathematica Online, Wolfram Alpha Pro, or all three: Mathematica Desktop For school-owned machines: a) Fill out this form to request an Activation Key b) Click the "Product Summary page" link to access your license c) Click "Get Downloads" and select "Download" next to your platform d) Run the installer on your machine, and enter Activation Key at prompt For a personally owned machine: • Fill out this form to request a home-use license from Wolfram.
    [Show full text]
  • Programming: Concepts for New Programmers
    Programming: Concepts for new programmers How to Use this User Guide This handbook accompanies the taught sessions for the course. Each section contains a brief overview of a topic for your reference and then one or more exercises. Exercises are arranged as follows: A title and brief overview of the tasks to be carried out; A numbered set of tasks, together with a brief description of each; Some exercises, particularly those within the same section, assume that you have completed earlier exercises. If you have any problems with the text or the exercises, please ask the teacher or one of the demonstrators for help. Many of the exercises used here are designed to be worked through in pairs or small groups of students, to encourage discussion about the topics covered. Software Used None Files Used None Revision Information Version Date Author Changes made 1.0 Sept 2006 Dave Baker Created 1.1 May 2007 Dave Baker Minor typo corrections Rename of Chapter 6, with change of focus 1.1a Nov 2007 Dave Baker Correction of typos in Ex 6 1.2 Dec 2007 Dave Baker Revision of some exercises 1.3 April 2011 Dave Baker Revision/removal of some exercises 1.3a Oct 2011 Dave Baker Minor corrections 1.4 Oct 2012 Dave Baker Minor updates 1.5 Sep 2013 Dave Baker Revision of some exercises 1.6 Feb 2014 Dave Baker Added section on code re- use 1.7 Jun 2014 Dave Baker Added section on lists 1.8 Oct 2016 Duncan Young Updates to University names and language descriptions in Section 7 Acknowledgements Many of the ideas in this module have been talked through with colleagues and friends, in particular Jonathan Gregory formally of Abingdon College of Further Education.
    [Show full text]
  • New Scientific Programming Language
    New Scientific Programming Language Taha BEN SALAH (NOCCS, ENISo, Sousse University) Taoufik AGUILI (Sys’Com, ENIT, UTM University) Agenda ● Introduction ● Existing Scientific Programming Languages ● Presenting the new Scientific Programming Language ● Comparisons and results ● Conclusion 2 What is a scientific language A scientific language is a programming language optimized for the use of mathematical formulas and matrices. 3 Existing Scientific Languages: DSL : Domain Specific Languages MATLAB, Maple, FORTRAN, ALGOL, APL,J, Julia, Wolfram Language/Mathematica, and R. Non Scientific Languages used by scientists GPL: General Purpose Languages C/C++, Python, Scala, Java 4 Why a new Programming Language ● Limits of the existing Programming Languages ● Simpler syntax or More Powerful syntax ● Better portability ● Better integration ● Better performance 5 Existing Languages Python Java/Scala/Kotlin Julia Matlab R Type GPL GPL DSL DSL DSL Paradigm Prototyping, Server, Big Data, Computation Scientific Statistics, Data Web, Data Distributed computation, Science Science Systems Matrices, ... Price Free & Open Free & Open Free & Open Commercial Free & Open Source Source Source Source Advantages Community, Community, Tools, Simplicity, Simplicity, Toolboxes Simplicity, Libraries Performance Toolboxes Libraries (Simulink) Limitations Performance, Steep learning Small Commercial, not not appropriate tools, curve popularity, appropriate for for complex compatibility few libraries big projects, projects 6 performance Existing Languages Python Java/Scala/Kotlin
    [Show full text]