Using and Porting the GNU Compiler Collection (GCC) Iii

Total Page:16

File Type:pdf, Size:1020Kb

Using and Porting the GNU Compiler Collection (GCC) Iii Using and Porting the GNU Compiler Collection Richard M. Stallman Last updated 22 June 2001 for GCC 3.1 Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. For GCC Version 3.1 Published by the Free Software Foundation 59 Temple Place—Suite 330 Boston, MA 02111-1307, USA Last printed April, 1998. Printed copies are available for $50 each. ISBN 1-882114-37-X Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License”, the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled “GNU Free Documentation License”. (a) The FSF’s Front-Cover Text is: A GNU Manual (b) The FSF’s Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ...................................... 1 1 Compile C, C++, Objective-C, Fortran, Java or CHILL ..... 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .......................... 7 4 Installing GNU CC ............................ 137 5 Extensions to the C Language Family................ 149 6 Extensions to the C++ Language ................... 199 7 GNU Objective-C runtime features ................. 211 8 gcov: a Test Coverage Program ................... 217 9 Known Causes of Trouble with GCC ................ 223 10 Reporting Bugs ............................... 243 11 How To Get Help with GCC ...................... 251 12 Contributing to GCC Development ................. 253 13 Using GCC on VMS ........................... 255 14 Additional Makefile and configure information. ......... 261 15 GCC and Portability ........................... 265 16 Interfacing to GCC Output ....................... 267 17 Passes and Files of the Compiler ................... 269 18 Trees: The intermediate representation used by the C and C++ front ends ................................... 277 19 RTL Representation............................ 309 20 Machine Descriptions ........................... 351 21 Target Description Macros and Functions ............. 417 22 The Configuration File .......................... 541 23 Makefile Fragments ............................ 545 Funding Free Software ............................. 549 Linux and the GNU Project ......................... 551 GNU GENERAL PUBLIC LICENSE ................... 553 GNU Free Documentation License ..................... 561 Contributors to GCC .............................. 569 Option Index.................................... 577 Index ......................................... 587 ii Using and Porting the GNU Compiler Collection (GCC) iii Table of Contents Introduction .................................. 1 1 Compile C, C++, Objective-C, Fortran, Java or CHILL ................................... 3 2 Language Standards Supported by GCC .... 5 3 GCC Command Options ................... 7 3.1 Option Summary........................................ 7 3.2 Options Controlling the Kind of Output ................. 15 3.3 Compiling C++ Programs ............................... 18 3.4 Options Controlling C Dialect ........................... 18 3.5 Options Controlling C++ Dialect......................... 23 3.6 Options Controlling Objective-C Dialect ................. 28 3.7 Options to Control Diagnostic Messages Formatting ...... 29 3.8 Options to Request or Suppress Warnings ................ 30 3.9 Options for Debugging Your Program or GCC............ 41 3.10 Options That Control Optimization .................... 49 3.11 Options Controlling the Preprocessor ................... 59 3.12 Passing Options to the Assembler ...................... 63 3.13 Options for Linking ................................... 63 3.14 Options for Directory Search ........................... 66 3.15 Specifying subprocesses and the switches to pass to them ....................................................... 68 3.16 Specifying Target Machine and Compiler Version ........ 74 3.17 Hardware Models and Configurations ................... 75 3.17.1 M680x0 Options .............................. 75 3.17.2 M68hc1x Options............................. 77 3.17.3 VAX Options ................................ 78 3.17.4 SPARC Options .............................. 78 3.17.5 Convex Options .............................. 82 3.17.6 AMD29K Options ............................ 83 3.17.7 ARM Options ................................ 84 3.17.8 MN10200 Options ............................ 88 3.17.9 MN10300 Options ............................ 89 3.17.10 M32R/D Options............................ 89 3.17.11 M88K Options .............................. 90 3.17.12 IBM RS/6000 and PowerPC Options.......... 93 3.17.13 IBM RT Options ........................... 100 3.17.14 MIPS Options.............................. 101 3.17.15 Intel 386 Options ........................... 105 3.17.16 HPPA Options ............................. 108 iv Using and Porting the GNU Compiler Collection (GCC) 3.17.17 Intel 960 Options ........................... 110 3.17.18 DEC Alpha Options ........................ 111 3.17.19 Clipper Options ............................ 115 3.17.20 H8/300 Options ............................ 115 3.17.21 SH Options ................................ 115 3.17.22 Options for System V ....................... 117 3.17.23 TMS320C3x/C4x Options................... 117 3.17.24 V850 Options .............................. 119 3.17.25 ARC Options .............................. 120 3.17.26 NS32K Options ............................ 120 3.17.27 AVR Options .............................. 122 3.17.28 MCore Options............................. 123 3.17.29 IA-64 Options .............................. 123 3.17.30 D30V Options.............................. 125 3.17.31 S/390 and zSeries Options .................. 125 3.18 Options for Code Generation Conventions.............. 126 3.19 Environment Variables Affecting GCC ................. 132 3.20 Running Protoize .................................... 134 4 Installing GNU CC ...................... 137 4.1 Files Created by configure............................ 138 4.2 Configurations Supported by GNU CC.................. 138 4.3 Building and Installing a Cross-Compiler................ 139 4.3.1 Steps of Cross-Compilation .................... 140 4.3.2 Configuring a Cross-Compiler ................. 140 4.3.3 Tools and Libraries for a Cross-Compiler ....... 140 4.3.4 Cross-Compilers and Header Files.............. 141 4.3.5 Actually Building the Cross-Compiler .......... 142 4.4 Installing GNU CC on VMS ........................... 142 4.5 collect2 ............................................. 146 4.6 Standard Header File Directories ....................... 146 5 Extensions to the C Language Family ..... 149 5.1 Statements and Declarations in Expressions ............. 149 5.2 Locally Declared Labels ............................... 150 5.3 Labels as Values ...................................... 151 5.4 Nested Functions...................................... 152 5.5 Constructing Function Calls ........................... 153 5.6 Naming an Expression’s Type .......................... 154 5.7 Referring to a Type with typeof ....................... 155 5.8 Generalized Lvalues ................................... 155 5.9 Conditionals with Omitted Operands ................... 156 5.10 Double-Word Integers ................................ 157 5.11 Complex Numbers ................................... 157 5.12 Hex Floats .......................................... 158 5.13 Arrays of Length Zero ................................ 158 5.14 Arrays of Variable Length ............................ 159 5.15 Macros with a Variable Number of Arguments. ......... 160 v 5.16 Slightly Looser Rules for Escaped Newlines ............ 161 5.17 String Literals with Embedded Newlines ............... 161 5.18 Non-Lvalue Arrays May Have Subscripts ............... 162 5.19 Arithmetic on void- and Function-Pointers............. 162 5.20 Non-Constant Initializers ............................. 162 5.21 Compound Literals ................................... 162 5.22 Designated Initializers ................................ 163 5.23 Case Ranges ......................................... 165 5.24 Cast to a Union Type ................................ 165 5.25 Mixed Declarations and Code ......................... 165 5.26 Declaring Attributes of Functions ..................... 166 5.27 Attribute Syntax ..................................... 173 5.28 Prototypes and Old-Style Function Definitions ......... 175 5.29 C++ Style Comments ................................. 176 5.30 Dollar Signs in Identifier Names ....................... 176 5.31 The Character hESCi in Constants...................... 177 5.32 Inquiring on Alignment of Types or Variables .......... 177 5.33 Specifying Attributes of Variables ..................... 177 5.34 Specifying Attributes of Types ........................ 181 5.35 An Inline Function is As Fast As a Macro .............. 183 5.36 Assembler Instructions with C Expression Operands .... 185 5.36.1 i386 floating point asm operands.............. 189 5.37 Controlling Names Used in Assembler Code ............ 190 5.38 Variables in Specified Registers........................ 190 5.38.1 Defining Global Register Variables
Recommended publications
  • Red Hat Enterprise Linux 6 Developer Guide
    Red Hat Enterprise Linux 6 Developer Guide An introduction to application development tools in Red Hat Enterprise Linux 6 Dave Brolley William Cohen Roland Grunberg Aldy Hernandez Karsten Hopp Jakub Jelinek Developer Guide Jeff Johnston Benjamin Kosnik Aleksander Kurtakov Chris Moller Phil Muldoon Andrew Overholt Charley Wang Kent Sebastian Red Hat Enterprise Linux 6 Developer Guide An introduction to application development tools in Red Hat Enterprise Linux 6 Edition 0 Author Dave Brolley [email protected] Author William Cohen [email protected] Author Roland Grunberg [email protected] Author Aldy Hernandez [email protected] Author Karsten Hopp [email protected] Author Jakub Jelinek [email protected] Author Jeff Johnston [email protected] Author Benjamin Kosnik [email protected] Author Aleksander Kurtakov [email protected] Author Chris Moller [email protected] Author Phil Muldoon [email protected] Author Andrew Overholt [email protected] Author Charley Wang [email protected] Author Kent Sebastian [email protected] Editor Don Domingo [email protected] Editor Jacquelynn East [email protected] Copyright © 2010 Red Hat, Inc. and others. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
    [Show full text]
  • Using Restricted Transactional Memory to Build a Scalable In-Memory Database
    Using Restricted Transactional Memory to Build a Scalable In-Memory Database Zhaoguo Wang†, Hao Qian‡, Jinyang Li§, Haibo Chen‡ † School of Computer Science, Fudan University ‡ Institute of Parallel and Distributed Systems, Shanghai Jiao Tong University § Department of Computer Science, New York University Abstract However, the correctness of the resulting code is complex to reason about and relies on the processor’s (increasingly The recent availability of Intel Haswell processors marks the complex) memory model. transition of hardware transactional memory from research Recently, Intel has shipped its 4th-generation Haswell toys to mainstream reality. DBX is an in-memory database processor with support for Hardware Transactional Mem- that uses Intel’s restricted transactional memory (RTM) to ory [16]. This opens up a third possibility to scaling multi- achieve high performance and good scalability across multi- core software. Instead of relying on fine-grained locking core machines. The main limitation (and also key to practi- and atomic operations, one can synchronize using hardware cality) of RTM is its constrained working set size: an RTM transactions, which offer a programming model that is ar- region that reads or writes too much data will always be guably even more straightforward than mutual exclusion. aborted. The design of DBX addresses this challenge in sev- The promise is that the resulting implementation is much eral ways. First, DBX builds a database transaction layer on simpler and easier-to-understand while still retaining the top of an underlying shared-memory store. The two layers performance benefits of fine-grained locking. use separate RTM regions to synchronize shared memory Does hardware transactional memory actually deliver its access.
    [Show full text]
  • Studying the Real World Today's Topics
    Studying the real world Today's topics Free and open source software (FOSS) What is it, who uses it, history Making the most of other people's software Learning from, using, and contributing Learning about your own system Using tools to understand software without source Free and open source software Access to source code Free = freedom to use, modify, copy Some potential benefits Can build for different platforms and needs Development driven by community Different perspectives and ideas More people looking at the code for bugs/security issues Structure Volunteers, sponsored by companies Generally anyone can propose ideas and submit code Different structures in charge of what features/code gets in Free and open source software Tons of FOSS out there Nearly everything on myth Desktop applications (Firefox, Chromium, LibreOffice) Programming tools (compilers, libraries, IDEs) Servers (Apache web server, MySQL) Many companies contribute to FOSS Android core Apple Darwin Microsoft .NET A brief history of FOSS 1960s: Software distributed with hardware Source included, users could fix bugs 1970s: Start of software licensing 1974: Software is copyrightable 1975: First license for UNIX sold 1980s: Popularity of closed-source software Software valued independent of hardware Richard Stallman Started the free software movement (1983) The GNU project GNU = GNU's Not Unix An operating system with unix-like interface GNU General Public License Free software: users have access to source, can modify and redistribute Must share modifications under same
    [Show full text]
  • Using the GNU Compiler Collection (GCC)
    Using the GNU Compiler Collection (GCC) Using the GNU Compiler Collection by Richard M. Stallman and the GCC Developer Community Last updated 23 May 2004 for GCC 3.4.6 For GCC Version 3.4.6 Published by: GNU Press Website: www.gnupress.org a division of the General: [email protected] Free Software Foundation Orders: [email protected] 59 Temple Place Suite 330 Tel 617-542-5942 Boston, MA 02111-1307 USA Fax 617-542-2652 Last printed October 2003 for GCC 3.3.1. Printed copies are available for $45 each. Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being \GNU General Public License" and \Funding Free Software", the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled \GNU Free Documentation License". (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ...................................... 1 1 Programming Languages Supported by GCC ............ 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .........................
    [Show full text]
  • Extending the UHC LLVM Backend: Adding Support for Accurate Garbage Collection
    Extending the UHC LLVM backend: Adding support for accurate garbage collection Paul van der Ende MSc Thesis October 18, 2010 INF/SCR-09-59 Daily Supervisors: Center for Software Technology dr. A. Dijkstra Dept. of Information and Computing Sciences drs. J.D. Fokker Utrecht University Utrecht, the Netherlands Second Supervisor: prof. dr. S.D. Swierstra Abstract The Utrecht Haskell Compiler has an LLVM backend for whole program analyse mode. This backend pre- viously used the Boehm-Weiser library for heap allocation and conservative garbage collection. Recently an accurate garbage collector for the UHC compiler has been developed. We wanted this new garbage collection library to work with the LLVM backend. But since this new collector is accurate, it needs cooperation with the LLVM backend. Functionality needs to be added to find the set of root references and traversing all live references. To find the root set, the bytecode interpreter backend currently uses static stack maps. This is where the problem arises. The LLVM compiler is known to do various aggressive transformations. These optimizations might change the stack layout described by the static stack map. So to avoid this problem we wanted to use the shadow-stack provided by the LLVM framework. This is a dynamic structure maintained on the stack to safely find the garbage collection roots. We expect that the shadow-stack approach comes with a runtime overhead for maintaining this information dynamically on the stack. So we did measure the impact of this method. We also measured the performance improvement of the new garbage collection method used and compare it with the other UHC backends.
    [Show full text]
  • Bash Shell Scripts
    Bash Shell Scripts Writing Bash shell scripts Bash shell scripts are text files Text files most efficiently built with programming editors (emacs or vi) File must be executable and in search path chmod 700 my_script PATH environment variable may not include .! An example shell script: #!/bin/bash #My first script echo "Hello World!" Bash Shell Scripts Writing Bash shell scripts Compile a Verilog file with vlog #!/bin/bash if [ ! d work ] ; then echo work does not exist, making it vlib work fi if [ ! s adder.v ] ; then vlog adder.v fi work directory must exist before compilation Get scripts via wget, eg: wget http://web.engr.oregonstate.edu/~traylor/ece474/script --- Bash Shell Scripts Writing Bash shell scripts File attribute checking #!/bin/bash if [ ! s junk_dir ] ; then mkdir junk_dir fi Spaces around brackets are needed! File attribute checking d exists and is a directory e, a file exists f exists and is a regular file s file exists and is not empty --- Bash Shell Scripts Writing Bash shell scripts Compile Verilog then run a simultion #!/bin/bash if [ ! -d "work" ] ; then vlib work fi if [ -s "adder.v" ] ; then vlog adder.v #runs simulation with a do file and no GUI vsim adder -do do.do quiet c else echo verilog file missing fi --- Bash Shell Scripts Writing Bash shell scripts vsim command and arguments vsim entity_name do dofile.do quiet -c -quiet (do not report loading file messages) -c (console mode, no GUI) -do (run vsim from a TCL do file) +nowarnTFMPC (don’t warn about mismatched ports, scary) +nowarnTSCALE (don’t warn about timing mismatches) Try vsim help for command line arguements --- Bash Shell Scripts Writing Bash Shell Scripts (TCL Script) In another text file, we create a TCL script with commands for the simulator.
    [Show full text]
  • Introduction to Linux by Lars Eklund Based on Work by Marcus Lundberg
    Introduction to Linux By Lars Eklund Based on work by Marcus Lundberg ● What is Linux ● Logging in to UPPMAX ● Navigate the file system ● “Basic toolkit” What is Linux ● The Linux Operating system is a UNIX like UNIX compatible Operating system. ● Linux is a Kernel on which many different programs can run. The shell(bash, sh, ksh, csh, tcsh and many more) is one such program ● Linux has a multiuser platform at its base which means permissions and security comes easy. Many Flavours Connect to UPPMAX ● (Download XQuartz or other X11 server for Mac OS ) ● Linux and MacOS: – start Terminal – $ ssh -X [email protected] Connect to UPPMAX for windows users ● Download a X-server such as GWSL or X-ming or VcXsrv or an other of your choosing ● Install WSL and a Distribution such as ubuntu or a ssh program such as MobaXTerm ● Connect to $ ssh -X [email protected] Windows links ● https://sourceforge.net/projects/vcxsrv/ ● https://mobaxterm.mobatek.net/ ● https://opticos.github.io/gwsl/ ● https://sourceforge.net/projects/xming/ ● https://docs.microsoft.com/en-us/windows/wsl/install-wi n10 ● Don’t forget to update to wsl2 X11-forwarding graphics from the command line ● Graphics can be sent through the SSH connection you’re using to connect - Use ssh -Y or ssh -X ● MacOS users will need to install XQuartz. ● When starting a graphical program, a new window will open, but your terminal will be “locked”. - Run using & at the end to run it as a background proccess e.g. “gedit &” - Alternatively, use ctrl-z to put gedit to sleep and
    [Show full text]
  • Bringing GNU Emacs to Native Code
    Bringing GNU Emacs to Native Code Andrea Corallo Luca Nassi Nicola Manca [email protected] [email protected] [email protected] CNR-SPIN Genoa, Italy ABSTRACT such a long-standing project. Although this makes it didactic, some Emacs Lisp (Elisp) is the Lisp dialect used by the Emacs text editor limitations prevent the current implementation of Emacs Lisp to family. GNU Emacs can currently execute Elisp code either inter- be appealing for broader use. In this context, performance issues preted or byte-interpreted after it has been compiled to byte-code. represent the main bottleneck, which can be broken down in three In this work we discuss the implementation of an optimizing com- main sub-problems: piler approach for Elisp targeting native code. The native compiler • lack of true multi-threading support, employs the byte-compiler’s internal representation as input and • garbage collection speed, exploits libgccjit to achieve code generation using the GNU Com- • code execution speed. piler Collection (GCC) infrastructure. Generated executables are From now on we will focus on the last of these issues, which con- stored as binary files and can be loaded and unloaded dynamically. stitutes the topic of this work. Most of the functionality of the compiler is written in Elisp itself, The current implementation traditionally approaches the prob- including several optimization passes, paired with a C back-end lem of code execution speed in two ways: to interface with the GNU Emacs core and libgccjit. Though still a work in progress, our implementation is able to bootstrap a func- • Implementing a large number of performance-sensitive prim- tional Emacs and compile all lexically scoped Elisp files, including itive functions (also known as subr) in C.
    [Show full text]
  • Improving Memory Management Security for C and C++
    Improving memory management security for C and C++ Yves Younan, Wouter Joosen, Frank Piessens, Hans Van den Eynden DistriNet, Katholieke Universiteit Leuven, Belgium Abstract Memory managers are an important part of any modern language: they are used to dynamically allocate memory for use in the program. Many managers exist and depending on the operating system and language. However, two major types of managers can be identified: manual memory allocators and garbage collectors. In the case of manual memory allocators, the programmer must manually release memory back to the system when it is no longer needed. Problems can occur when a programmer forgets to release it (memory leaks), releases it twice or keeps using freed memory. These problems are solved in garbage collectors. However, both manual memory allocators and garbage collectors store management information for the memory they manage. Often, this management information is stored where a buffer overflow could allow an attacker to overwrite this information, providing a reliable way to achieve code execution when exploiting these vulnerabilities. In this paper we describe several vulnerabilities for C and C++ and how these could be exploited by modifying the management information of a representative manual memory allocator and a garbage collector. Afterwards, we present an approach that, when applied to memory managers, will protect against these attack vectors. We implemented our approach by modifying an existing widely used memory allocator. Benchmarks show that this implementation has a negligible, sometimes even beneficial, impact on performance. 1 Introduction Security has become an important concern for all computer users. Worms and hackers are a part of every day internet life.
    [Show full text]
  • Ethereal Developer's Guide Draft 0.0.2 (15684) for Ethereal 0.10.11
    Ethereal Developer's Guide Draft 0.0.2 (15684) for Ethereal 0.10.11 Ulf Lamping, Ethereal Developer's Guide: Draft 0.0.2 (15684) for Ethere- al 0.10.11 by Ulf Lamping Copyright © 2004-2005 Ulf Lamping Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. All logos and trademarks in this document are property of their respective owner. Table of Contents Preface .............................................................................................................................. vii 1. Foreword ............................................................................................................... vii 2. Who should read this document? ............................................................................... viii 3. Acknowledgements ................................................................................................... ix 4. About this document .................................................................................................. x 5. Where to get the latest copy of this document? ............................................................... xi 6. Providing feedback about this document ...................................................................... xii I. Ethereal Build Environment ................................................................................................14 1. Introduction .............................................................................................................15
    [Show full text]
  • GNU Emacs Manual
    GNU Emacs Manual GNU Emacs Manual Sixteenth Edition, Updated for Emacs Version 22.1. Richard Stallman This is the Sixteenth edition of the GNU Emacs Manual, updated for Emacs version 22.1. Copyright c 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being \The GNU Manifesto," \Distribution" and \GNU GENERAL PUBLIC LICENSE," with the Front-Cover texts being \A GNU Manual," and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled \GNU Free Documentation License." (a) The FSF's Back-Cover Text is: \You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development." Published by the Free Software Foundation 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA ISBN 1-882114-86-8 Cover art by Etienne Suvasa. i Short Contents Preface ::::::::::::::::::::::::::::::::::::::::::::::::: 1 Distribution ::::::::::::::::::::::::::::::::::::::::::::: 2 Introduction ::::::::::::::::::::::::::::::::::::::::::::: 5 1 The Organization of the Screen :::::::::::::::::::::::::: 6 2 Characters, Keys and Commands ::::::::::::::::::::::: 11 3 Entering and Exiting Emacs ::::::::::::::::::::::::::: 15 4 Basic Editing
    [Show full text]
  • Introduction to GNU Octave
    Introduction to GNU Octave Hubert Selhofer, revised by Marcel Oliver updated to current Octave version by Thomas L. Scofield 2008/08/16 line 1 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 8 6 4 2 -8 -6 0 -4 -2 -2 0 -4 2 4 -6 6 8 -8 Contents 1 Basics 2 1.1 What is Octave? ........................... 2 1.2 Help! . 2 1.3 Input conventions . 3 1.4 Variables and standard operations . 3 2 Vector and matrix operations 4 2.1 Vectors . 4 2.2 Matrices . 4 1 2.3 Basic matrix arithmetic . 5 2.4 Element-wise operations . 5 2.5 Indexing and slicing . 6 2.6 Solving linear systems of equations . 7 2.7 Inverses, decompositions, eigenvalues . 7 2.8 Testing for zero elements . 8 3 Control structures 8 3.1 Functions . 8 3.2 Global variables . 9 3.3 Loops . 9 3.4 Branching . 9 3.5 Functions of functions . 10 3.6 Efficiency considerations . 10 3.7 Input and output . 11 4 Graphics 11 4.1 2D graphics . 11 4.2 3D graphics: . 12 4.3 Commands for 2D and 3D graphics . 13 5 Exercises 13 5.1 Linear algebra . 13 5.2 Timing . 14 5.3 Stability functions of BDF-integrators . 14 5.4 3D plot . 15 5.5 Hilbert matrix . 15 5.6 Least square fit of a straight line . 16 5.7 Trapezoidal rule . 16 1 Basics 1.1 What is Octave? Octave is an interactive programming language specifically suited for vectoriz- able numerical calculations.
    [Show full text]