™ GAUSS User Guide
Information in this document is subject to change without notice and does not represent a commitment on the part of Aptech Systems, Inc. The software described in thisdocument is furnished under a license agreement or nondisclosure agreement. The software may be used or copied only in accordance with the terms of the agreement.The purchaser may make one copy of the software for backup purposes.
Tektronix is a trademark of Tektronix, Inc. Windows is a registered trademark of Microsoft Corporation. Other trademarks are the property of their respective owners. The Java API for the GAUSS Engine uses the JNA library. The JNA library is covered under the LGPL license version 3.0 or later at the discretion of the user. A full copy of this license and the JNA source code have been included with the distribution.
Contents Contents 1 Introduction 1-1 1.1 Product Overview 1-1 1.2 Documentation Conventions 1-1 2 Getting Started 2-1 2.1 Installation Under Linux 2-1 2.2 Installation Under Windows 2-2 2.2.1 Machine Requirements 2-2 2.2.2 Installation from Download 2-3 2.2.3 Installation from CD 2-3 3 Introduction to the GAUSS Graphical User Interface 3-1 3.1 Page Organization Concept 3-1 3.2 Command Page 3-3 3.2.1 Menus and Toolbars 3-4 3.2.2 Command Page Toolbar 3-6 3.2.
GAUSS User Guide 3.4 Command Line History and Command Line Editing 3.4.1 Error Output Window 3.5 Source Page: Editing Programs 3-12 3-13 3.5.1 Menus and Toolbars 3-13 3.5.2 Layout and Usage 3-14 3.5.3 Find and Replace 3-22 3.5.4 Changing Editor Properties 3-24 3.5.5 Error Output Window 3-26 3.5.6 The Source Browser: Advanced Search and Replace 3-26 3.6 Data Page 3-29 3.6.1 Menu Bar 3-30 3.6.2 Layout 3-32 3.6.3 Symbol Editor 3-35 3.7 Debug Page 3-37 3.7.1 Menus and Toolbars 3-37 3.
Contents 4.2 Navigating Between Pages 4-2 4.3 Focus Program Output on I/O 4-3 4.4 F1 Help 4-3 4.5 CTRL+F1 Source Browsing 4-4 5 Using the GAUSS Debugger 5-1 5.1 Starting the Debugger 5-1 5.2 Examining Variables 5-3 5.3 The Call Stack Window 5-5 5.4 Ending Your Debug Session 5-6 6 GAUSS Graphics 6-1 6.1 Overview 6-1 6.2 Basic Plotting 6-2 6.2.1 Plotting multiple curves 6.3 Plot Customization 6.3.1 Using the Graphics Preferences Settings Window 6.
GAUSS User Guide Understanding the dstart parameter 6-20 6.7.1 Quarterly Example 6-21 6.7.2 Controlling Tic Label Locations 6-22 6.7.3 Tic Label Formatting 6-24 6.8 Interacting with Plots in GAUSS 6-27 6.8.1 Interacting with 2-D Plots 6-28 Hide/Restore Curves 6-28 Relocating Graphic Items 6-29 6.8.2 3-D Plots Zoom 6-31 Panning and Scrolling 6-31 Rotate/Viewpoint Change 6-31 6.8.3 File Export 6-32 6.8.4 Saving Graphs 6-34 7 Graphics Editing 7-1 7.1 Changing Appearance 7-1 7.
Contents 8.1 Viewing Graphics 8-2 8.2 Command Line History and Command Line Editing 8-2 8.2.1 Movement 8-3 8.2.2 Editing 8-4 8.2.3 History Retrieval 8-5 8.3 Interactive Commands 8-6 8.3.1 quit 8-7 8.3.2 ed 8-8 8.3.3 browse 8-9 8.3.4 config 8-10 8.4 Debugging 8-11 8.4.1 General Functions 8-12 8.4.2 Listing Functions 8-13 8.4.3 Execution Functions 8-14 8.4.4 View Commands 8-16 8.4.5 Breakpoint Commands 8-17 8.
GAUSS User Guide 9.2.2 Nonexecutable Statements 9.3 Programs viii 9-3 9-4 9.3.1 Main Section 9-4 9.3.2 Secondary Sections 9-4 9.4 Compiler Directives 9-5 9.5 Procedures 9-8 9.6 Data Types 9-8 9.6.1 Constants 9-8 9.6.2 Matrices 9-9 9.6.3 Sparse Matrices 9-17 9.6.4 N-dimensional Arrays 9-17 9.6.5 Strings 9-18 9.6.6 String Arrays 9-23 9.6.7 Character Matrices 9-25 9.6.8 Date and Time Formats 9-26 9.6.9 Special Data Types 9-27 9.7 Operator Precedence 9-29 9.
Contents 9.9 Functions 9-36 9.10 Rules of Syntax 9-37 9.10.1 Statements 9-38 9.10.2 Case 9-39 9.10.3 Comments 9-40 9.10.4 Extraneous Spaces 9-41 9.10.5 Symbol Names 9-42 9.10.6 Labels 9-43 9.10.7 Assignment Statements 9-44 9.10.8 Function Arguments 9-45 9.10.9 Indexing Matrices 9-46 9.10.10 Arrays of Matrices and Strings 9-48 9.10.11 Arrays of Procedures 9-49 10 Operators 10-1 10.1 Element-by-Element Operators 10-1 10.2 Matrix Operators 10-3 10.2.
GAUSS User Guide 10.6 Using Dot Operators with Constants 10-19 10.7 Operator Precedence 10-20 11 Procedures and Keywords 11.1 Defining a Procedure 11-2 11.1.1 Procedure Declaration 11-3 11.1.2 Local Variable Declarations 11-4 11.1.3 Body of Procedure 11-6 11.1.4 Returning from the Procedure 11-7 11.1.5 End of Procedure Definition 11-8 11.2 Calling a Procedure 11-8 11.3 Keywords 11-9 11.3.1 Defining a Keyword 11-10 11.3.2 Calling a Keyword 11-12 11.
Contents 12.3 Parallel Random Number Generation 12-5 12.3.1 Multiple Stream Generators 12-6 12.3.2 Block-skipping 12-7 13 Sparse Matrices 13-1 13.1 Defining Sparse Matrices 13-1 13.2 Creating and Using Sparse Matrices 13-2 13.3 Sparse Support in Matrix Functions and Operators 13-4 13.3.1 Return Types for Dyadic Operators 13-5 14 N-Dimensional Arrays 14-1 14.1 Bracketed Indexing 14-3 14.2 ExE Conformability 14-4 14.3 Glossary of Terms 14-5 15 Working with Arrays 15-1 15.
GAUSS User Guide 15.2.2 getarray 15-10 15.2.3 getmatrix 15-11 15.2.4 getmatrix4D 15-11 15.2.5 getscalar3D, getscalar4D 15-12 15.2.6 putarray 15-14 15.2.7 setarray 15-14 15.3 Looping with Arrays 15-15 15.3.1 loopnextindex 15-17 15.4 Miscellaneous Array Functions 15.4.1 atranspose 15-19 15.4.2 amult 15-21 15.4.3 amean, amin, amax 15-22 15.4.4 getdims 15-24 15.4.5 getorders 15-24 15.4.6 arraytomat 15-25 15.4.7 mattoarray 15-25 15.5 Using Arrays with GAUSS functions 15-26 15.
Contents 16.1.1 Structure Definition 16-1 16.1.2 Declaring an Instance 16-3 16.1.3 Initializing an Instance 16-3 16.1.4 Arrays of Structures 16-5 16.1.5 Structure Indexing 16-5 16.1.6 Saving an Instance to the Disk 16-8 16.1.7 Loading an Instance from the Disk 16-8 16.1.8 Passing Structures to Procedures 16-9 16.2 Structure Pointers 16-10 16.2.1 Creating and Assigning Structure Pointers 16-10 16.2.2 Structure Pointer References 16-11 16.2.
GAUSS User Guide 16.4.4 The Command File 16-29 17 Run-Time Library Structures 17-1 17.1 The PV Parameter Structure 17-1 17.2 Fast Pack Functions 17-5 17.3 The DS Data Structure 17-6 18 Multi-Threaded Programming in GAUSS 18.1 The Functions 18-1 18.2 GAUSS Threading Concepts 18-3 18.3 Coding With Threads 18-4 18.4 Coding Restrictions 18-6 19 Libraries 19.1 Autoloader 19-1 19-1 19.1.1 Forward References 19-1 19.1.2 The Autoloader Search Path 19-2 19.2 Global Declaration Files 19.
Contents 20.4 Refreshing a Library 21 Compiler 20-5 21-1 21.1 Compiling Programs 21-1 21.1.1 Compiling a File 21-2 21.2 Saving the Current Workspace 21-2 21.3 Debugging 21-3 22 File I/O 22.1 ASCII Files 22-1 22-3 22.1.1 Matrix Data 22-3 22.1.2 General File I/O 22-6 22.2 Data Sets 22-7 22.2.1 Layout 22-7 22.2.2 Creating Data Sets 22-8 22.2.3 Reading and Writing 22-8 22.2.4 Distinguishing Character and Numeric Data 22.3 GAUSS Data Archives 22-10 22-11 22.3.
GAUSS User Guide 22.5.1 Small Matrix v89 (Obsolete) 22-16 22.5.2 Extended Matrix v89 (Obsolete) 22-17 22.5.3 Small String v89 (Obsolete) 22-18 22.5.4 Extended String v89 (Obsolete) 22-19 22.5.5 Small Data Set v89 (Obsolete) 22-19 22.5.6 Extended Data Set v89 (Obsolete) 22-21 22.5.7 Matrix v92 (Obsolete) 22-22 22.5.8 String v92 (Obsolete) 22-23 22.5.9 Data Set v92 (Obsolete) 22-24 22.5.10 Matrix v96 22-25 22.5.11 Data Set v96 22-27 22.5.
Contents 24.3.3 Execution Phase 24.4 Reserved Variables 25 The GAUSS Profiler 25.1 Using the GAUSSProfiler 24-4 24-4 25-1 25-1 25.1.1 Collection 25-1 25.1.2 Analysis 25-2 26 Time and Date 26-1 26.1 Time and Date Formats 26-2 26.2 Time and Date Functions 26-4 26.2.1 Timed Iterations 27 ATOG 26-7 27-1 27.1 Command Summary 27-1 27.2 Commands 27-3 27.3 Examples 27-13 27.4 Error Messages 27-16 28 Error Messages 28-1 29 Maximizing Performance 29-1 29.1 Library System 29-1 29.
GAUSS User Guide 29.3.2 CPU Cache 29-4 30 GAUSS Graphics Colors 30-1 31 Reserved Words 31-1 32 Singularity Tolerance 32-1 32.1 Reading and Setting the Tolerance 32-2 32.2 Determining Singularity 32-2 33 Publication Quality Graphics 33-1 33.1 General Design 33-1 33.2 Using Publication Quality Graphics 33-2 33.2.1 Getting Started 33-3 33.2.2 Graphics Coordinate System 33-7 33.3 Graphic Panels 33.3.1 Tiled Graphic Panels 33-8 33.3.2 Overlapping Graphic Panels 33-9 33.3.
Contents 33.4.2 Greek and Mathematical Symbols 33-18 33.5 Colors 33-19 33.6 Global Control Variables 33-19 34 PQG Fonts 34-1 34.1 Simplex 34-1 34.2 Simgrma 34-2 34.3 Microb 34-3 34.
1 Introduction 1.1 Product Overview GAUSSTM is a complete analysis environment suitable for performing quick calculations, complex analysis of millions of data points, or anything in between. Whether you are new to computerized analysis or a seasoned programmer, the GAUSS family of products combine to offer you an easy to learn environment that is powerful and versatile enough for virtually any numerical task.
GAUSS User Guide used ..." 1-2 bold text emphasis "...not supported under UNIX." italics variables "... If vnames is a string or has fewer elements than x has columns, it will be ..." monospace code example if scalerr(cm); cm = inv(x); endif; monospace filename, path, etc. "...is located in the examples subdirectory..." monospace bold reference to a GAUSS command or other programming element within a narrative paragraph "...as explained under plotScatter...
2 Getting Started 2.1 Installation Under Linux 1. Make a directory to install GAUSS in. NOTE: If you choose to install GAUSS in a directory which does not have write permissions for normal user accounts such as /opt or /usr/local, then you must choose the Advanced Installation and Multi-User Installation options during installation. 2. cd to that directory. 3. Gunzip the .gz file. 4. Untar the .tar file. 5. Run the executable script ginstall.
GAUSS User Guide user (a user that has never started GAUSS on this machine ) starts GAUSS on this machine, GAUSS will create a local working directory for that user under the user's home directory. This local working directory will contain the files and folders that which may be customized by the user. This allows the admin to install GAUSS in a location without universal write privileges. No files will be placed under the home directory of any user who does not start GAUSS. 6.
Getting Started l l l l Windows 8 32-bit, 1 GB minimum, 2 GB or more recommended. l Windows 8 64-bit, 2 GB minimum, 4 GB or more recommended. Minimum of 200 MB free hard disk space, more may be needed depending on the size of matrices and the complexity of the program. Minimum of 128 MB of RAM for video is required to run 3-D graphics. A dedicated graphics card is not required. Monthly defragmenting is recommended for traditional hard drives. Solid-state drives should not be defragmented. 2.2.
3 Introduction to the GAUSS Graphical User Interface 3.1 Page Organization Concept The GAUSS graphical user interface is organized into separate ''pages.'' Pages are separate, customizable, main windows with their own set of widgets. Each page is designed to facilitate the performance of one of the common tasks performed in GAUSS: entering commands interactively, editing a program, examining data, viewing graphs, debugging a program, and accessing the help system.
GAUSS User Guide Figure 3.1: GAUSS page organization 3-2 Command Page For executing interactive commands. Source Page For editing program files. Data Page For examining and editing GAUSS matrices and other data. Debug Page For interactively debugging your programs. Graphics Page For viewing and interacting with graphs. Help Page For accessing the GAUSS help system.
Introduction to the GAUSS GUI Each page may be undocked from the main application and redocked by toggling the Dock button on the right side of the status bar. Navigation between an undocked page and the main application may be accomplished with ALT+TAB and ALT+SHIFT+TAB. To navigate between pages, use CTRL+TAB to cycle forward and CTRL+SHIFT+TAB to cycle backwards between pages. Each page has its own toolbars and menus.
GAUSS User Guide Figure 3.2: Command Page 3.2.1 Menus and Toolbars Command Page File Menu 3-4 New Creates a new, untitled file in a programming editor on the Source Page. Open File Opens an existing file in a programming editor on the Source Page.
Introduction to the GAUSS GUI Open Graph Opens a previously created GAUSS graph (.plot file). Print Prints selected text. Recent Files Holds a selectable dropdown list of recently edited files. Exit Exits a GAUSS session. Edit Menu Undo Restores your last unsaved change. Redo Re-inserts changes removed with undo. Cut Removes selected text and copies it to the clipboard. Copy Copies selected text to the clipboard. Paste Copies the clipboard contents to the cursor position.
GAUSS User Guide Directory Clear Working Directory History Deletes the contents of your working directory history. Recent Working Directories Contains a dropdown list of your most recent working directories. View Menu The View menu lets you toggle on or off the windows on the current page. Help Menu Goto Help Takes you to the Help Page. About GAUSS Provides information regarding your version of GAUSS . 3.2.2 Command Page Toolbar Figure 3.
Introduction to the GAUSS GUI Copy Copies selected text to the clipboard. Paste Copies the clipboard contents to the cursor position. Print Prints selected text. Run Runs the file at the top of the Action List. Debug Debugs the file at the top of the Action List. Edit Opens the file at the top of the Action List. Stop Program Stops a running GAUSS program. 3.2.
GAUSS User Guide Figure 3.5: Command History Toolbar Run Executes the highlighted command from the command history. Paste Pastes the highlighted command to the Program Input/Output Window for further editing. Search Previous Searches the Command Output Window for previous executions of a command and its output. Search Next Searches the Command Output Window for the next execution of a command and its output. 3.2.
Introduction to the GAUSS GUI Figure 3.6: Action List Toolbar 3.3 Layout The Command Page contains three main widgets: the Program Input/Output Window, the Command History Window, and the Error Output Window, which appears when GAUSS encounters an error. Figure 3.
GAUSS User Guide The Program Input/Output Window allows the user to enter interactive commands as well as displaying any output from a program run. It is also the location for user input requested by the GAUSS functions keyw and cons. 3.3.1 Command History Window The Command History Window contains a list of recently executed commands. Commands in the command history can be executed by double clicking them or highlighting a command and clicking the Run button from the Command History toolbar. Figure 3.
Introduction to the GAUSS GUI Figure 3.9: Command History Right-click in the Command History Window to bring up the context menu with the following options: Copy Copies the highlighted entry to the clipboard. Delete Deletes the highlighted entry. Clear Window Deletes all Command History entries. Send to File Creates a new source file containing the highlighted commands. Toggle View Mode Toggles between session mode and date mode.
GAUSS User Guide 3.4 Command Line History and Command Line Editing When you run a command at the GAUSS prompt, it is added to your command line history. The last 1,000 commands executed at the GAUSS command line are stored. The following keystrokes are supported for movement and editing at the command line and for retrieving the command line history: Left Arrow Moves cursor left one character. Right Arrow Moves cursor right one character. HOME Moves cursor to beginning of line.
Introduction to the GAUSS GUI Double-clicking on the first line of the error will bring you to the file and line on which the error occurred. Figure 3.10: Error Window 3.5 Source Page: Editing Programs The Source Page is for creating and editing programs and procedures. 3.5.1 Menus and Toolbars Section 3.2 provides details of the main menus and toolbars. The Source Page contains the following additional menu options. File Menu Save Saves the active file.
GAUSS User Guide Split File Buffer Horizontally Horizontally splits the active file into two views. Split File Buffer Vertically Vertically splits the active file into two views. Split Tab Stack Horizontally Tiles any open programming editors horizontally. Split Tab Stack Vertically Tiles any open programming editors vertically. Remove Tab Split Removes any editor window tiling. Remove Buffer Split Removes a buffer split in the active file. 3.5.
Introduction to the GAUSS GUI Figure 3.11: Source Page Programming Editor Individual programming editors are opened in the editor docking area. The editor docking area allows tabbing of multiple open files, with the option to tile editors with a horizontal or vertical split. Select Window->Split Horizontally or Window->Split Vertically to tile open editor windows.
GAUSS User Guide Figure 3.12: Programming Editor Programming editor features: 1. Syntax highlighting:The GAUSS programming editor will provide syntax highlighting for GAUSS, C/C++, Java, Fortran, R and many other languages. 2. Autocompletion:Autocompletion is available in the GAUSS programming editor for GAUSS functions and for structure members of any structure in an active GAUSS library.
Introduction to the GAUSS GUI Figure 3.13: Autocomplete Using autocomplete: if the characters you enter match items in the autocomplete list, a dropdown box will appear containing those functions. To navigate the dropdown list, press the down arrow or continue typing until only one selection remains. Once the desired command is highlighted, press the ENTER key to insert the remainder of the word.
GAUSS User Guide Figure 3.15: Function Browser 5. Code folding:At the start of code blocks (e.g., procedure definitions, do and for loops, and if statements), the left margin of the programming editor will contain a +. Clicking the + will hide the block of code from view and place a horizontal line across the editor indicating folded code and changing the + to a -. Clicking on the - will reveal the hidden code. Figure 3.
Introduction to the GAUSS GUI 6. Autoindenting: The GAUSS programming editor provides automatic code indenting and deindenting. Autoindenting not only simplifies the process of writing code but also encourages the creation of readable code. 7. Variable highlighting:Click on a variable name and all instances of that variable will be highlighted. Figure 3.17: Variable highlighting 8.
GAUSS User Guide Figure 3.18: Find usages 9. Bookmarks:Bookmarks allow quick navigation to often visited lines of code. To insert a bookmark, hold down the SHIFT key and left click in the left margin of the file on the line where you would like to set the bookmark. If a file contains more than one bookmark, you may use F2 to navigate to the next bookmark in the file. To navigate between bookmarks in multiple files, use the bookmark window. The bookmark window contains a list of all of your bookmarks.
Introduction to the GAUSS GUI key CTRL+I. Programming Editor Hot Keys CTRL+A Select All. CTRL+C Copy. CTRL+D Debug current file. CTRL+F Find and replace. CTRL+G Go to line. CTRL+I Formats the current file. CTRL+L Delete line. CTRL+N Open new file. CTRL+O Open existing file. CTRL+P Print file. CTRL+/ Used for block commenting. CTRL+R Run current file. CTRL+S Save current file. CTRL+T Switches current line with the line above. CTRL+V Paste. CTRL+W Closes the current file.
GAUSS User Guide CTRL+Z Undo. CTRL+Y Redo. CTRL+~ Cycles through open editor windows. CTRL+F1 Go to definition of function under cursor. F1 Go to Help Page for function under cursor. SHIFT+F1 Open inline help for function under cursor. 3.5.3 Find and Replace From the Edit Menu, selecting Find and Replace or pressing CTRL+F will bring up the find and replace widget at the bottom of your open programming editor.
Introduction to the GAUSS GUI Figure 3.19: Find and Replace The Replace Box has three buttons: > means replace the highlighted expression and search forwards, < means replace the highlighted expression and search backwards and replace means replace the highlighted text and do not change the cursor position. Regular Expressions Find and Replace in GAUSS supports regular expression searching.
GAUSS User Guide Regular expressions allow you to perform very specific find and replace commands. Suppose that we want to find all usages of rndu and rndn and replace them with rndKMu. Figure 3.20: Find and Replace Regular Expression To open Find and Replace, we enter CTRL+F in out open text editor. In the Find and Replace widget, select the check box next to Regex to enable regular expression searching. One of the most simple regular expression options is to add a '.'. The '.' means any character.
Introduction to the GAUSS GUI left. Here you can customize the programming editor's behavior. Figure 3.21: Editor Preferences The editor preferences has three main sections: General Settings The general settings are located on the top left. Colors This section is located along the bottom half of the preferences dialog window. Click one of the color buttons to change an element in the color scheme used in the editor.
GAUSS User Guide GAUSS Library Provides autocomplete suggestions for GAUSS intrinsic functions. Current Document Provides autocomplete suggestions for all variables, procedures, GAUSS functions and keywords that are used in the file. Both Provides autocomplete suggestions for both above. None Turns off autocomplete suggestions in the editor. 3.5.5 Error Output Window The Error Output Window can be accessed by toggling the Error Output button on the right side of the status bar.
Introduction to the GAUSS GUI Figure 3.23: Source Browser The source browser is made up of two main sections. On the left are the control tabs and on the right is the results display. The first of the control tabs is the Search tab. In this tab you enter your search query. You can specify a specific file pattern or filename to search and also the directory within which to search. The button with three dots [...
GAUSS User Guide The Advanced tab allows you to refine your search criteria. Checking the References check box will limit your search to only locations where a variable is referenced. Alternatively, checking the Assignments box would limit your search to only those places where the variable was assigned to. For example, if you were searching for the variable 'nobs', this is an assignment: nobs = 300; whereas this is a reference: myVar = nobs - 1; Figure 3.
Introduction to the GAUSS GUI Figure 3.26: Executing a search Expand the node of a file to examine its list of matches, or right-click and select 'Expand All' from the context menu. Once you expand the node for a file, you will see the line number of the match followed by a colon and then the line of code with the match highlighted in yellow. Double-click on a line to edit that file.
GAUSS User Guide Figure 3.27: Data Page l l l Menu Bar Layout Symbol Editor 3.6.1 Menu Bar Symbol Editor Menu 3-30 Edit Symbol Opens an active symbol from your current GAUSS workspace in a symbol editor. Save Symbol Saves changes to the symbol in the active symbol editor.
Introduction to the GAUSS GUI Reload Symbol Reloads a symbol that is out-of-sync with the GAUSS symbol table. Note: This only applies if auto-reload mode is turned off. Toggle Auto-reload Turns on/off autoreload for the active symbol editor. Preferences Brings up preference dialog for changing the settings of open symbol editors. Window Menu Split Horizontally Tiles open symbol editors horizontally. Split Vertically Tiles open symbol editors vertically. Toolbar Figure 3.
GAUSS User Guide 3.6.2 Layout The Data Page has two main widgets: the symbol tree and the source editor docking area. The Program Input/Output and Error Windows are also accessible from the toggle buttons on the right side of the status bar. The Symbol Tree window lists all of your active symbols, organized by type. To view your active symbols, click on the node expander or right click and select Symbol View from the context menu.
Introduction to the GAUSS GUI Figure 3.29: Symbol View Double-clicking an already open symbol will bring that symbol to the top of the stack of open symbol editors. If you would like to open a second copy of a symbol, right-click on the symbol in the symbol tree and select Edit Another Copy. GAUSS allows you to open more than one copy of each symbol so that you can examine different portions of a large matrix at the same time.
GAUSS User Guide To view a structure in the GAUSS Symbol Editor, expand the Structures node on the Symbol Tree. From here you will see a full list of all structures in your current GAUSS workspace. Expanding the node of a structure will reveal its members. To view the contents of any member of a GAUSS structure, first open the structure in a Struct Viewer, by either double-clicking or right-clicking and selecting Edit over the name of the structure in the Symbol Tree.
Introduction to the GAUSS GUI Figure 3.30: The Struct Editor Individual structure members can be opened for editing or viewing from the Struct Tree Widget in the same manner as other data types, such as matrices, are opened from the Symbol Tree. Structure members will be opened in a Symbol Editor to the right of the Struct Tree Widget. Multi-dimensional Arrays Expand the Arrays node and double-click on an array to open it in a symbol editor.
GAUSS User Guide Figure 3.31: Changing a value inside a symbol editor To highlight multiple cells, click on the corresponding row or column header. To highlight the entire contents of a symbol editory, click in the empty header box that connects the first row header to the first column header. Autoreload By default, open symbol editors will automatically update when the symbol has been changed programmatically. This behavior is referred to as autoreload.
Introduction to the GAUSS GUI may disable autoreload for that symbol. If the value of a symbol with autoreload disabled is changed in the GAUSS symbol table, the symbol editor will display the message outof-sync. This indicates that the values in the symbol editor are not current. 3.7 Debug Page 3.7.1 Menus and Toolbars Figure 3.32: Debug Toolbar Go Runs the program to the next breakpoint. Toggle Breakpoint Sets/Clears a breakpoint at the cursor. Clear Breakpoints Clears all breakpoints in a file.
GAUSS User Guide Run to Cursor Runs the program until it reaches the cursor position. Stop Terminates a debugging session. Components and Usage The Debug Page is composed of five main widgets: Breakpoint List An interactive list of all breakpoints. Call Stack Window An interactive display of the chain of procedure calls. Local Variable Window An interactive display of all variables that are in scope. Variable Dump Window Displays the full contents of a variable.
Introduction to the GAUSS GUI Figure 3.33: Debug Window Starting and Stopping the Debugger You can start debugging of a file you are in by pressing CTRL+D. Click the Debug button to debug the file in the top of the Action List. Placing your mouse over the Debug button will reveal a tooltip with the name of this file, or click the downward pointing triangle next to the debug button and select a file from the list.
GAUSS User Guide Figure 3.34: Debug Button When the debugger is started, it will highlight the first line of code to be run. Any breakpoints are shown in the left margin of the window. You can stop debugging at any time by clicking the Stop button on the debug toolbar. 3.7.2 Using Breakpoints Breakpoints stop code execution where you have inserted them.
Introduction to the GAUSS GUI Figure 3.35: Setting Breakpoints To clear a breakpoint in the file, click on the breakpoint you would like to remove or click a line of code that has a breakpoint set and then click Set/Clear Breakpoint. You can clear all breakpoints from the active file by clicking Clear All Breakpoints. 3.7.3 Stepping Through a Program GAUSS's debugger includes the ability to step into, step out of, and step over code during debugging.
GAUSS User Guide Use Step Out to execute to the end of the current function without pause and return to the calling function. Figure 3.37: Step Out (F10) Use Step Over to execute the line of code currently highlighted by the debugger without entering the functions that are called. Figure 3.38: Step Over (F9) Use Stop to stop the debugger.
Introduction to the GAUSS GUI Figure 3.39: Stop 3.7.4 Viewing Variables GAUSS allows you several ways to view the values of variables during debugging. Hover Tool-tip View Once the debugger is started, hovering your mouse over a variable name will open tooltip with a preview of the values in the variable. These tooltip views are only intended to give a quick view of the data, so they may not show all data held by the variable.
GAUSS User Guide You can make the Matrix Editor a Watch Window, allowing you to watch the changing value of a variable as the lines of the program are executed. You can activate the Watch Window by clicking Set Watch on the Debug toolbar or by highlighting a variable name in the Debugger Window and pressing CTRL+E. Figure 3.40: Watch Window You use a Watch Window to see how variables change in value during debugging.
Introduction to the GAUSS GUI A watch variable can be the name of a matrix, a scalar, a string array, or a string. For a matrix or a string array, the first element is displayed. If a matrix element is clicked, the Matrix Editor is loaded with the matrix. The matrix elements can be changed during the debugging session. 3.8 Help Page The Help Page gives you access to the entire GAUSS help system in HTML format. The table of contents tree is on the left.
GAUSS User Guide Hot Keys 3-46 F1 Opens the Command Reference section for the highlighted command. CTRL+F1 Opens a programming editor with the function definition of a highlighted procedure. SHIFT+F1 Opens a floating Help Window for the highlighted command.
4 Navigating the GAUSS Graphical User Interface Navigation of the GAUSS Graphical User Interface is designed to naturally follow your actions. For example, if the action you would like to perform is debugging the file that you are editing, you can either enter CTRL+D to debug or select the file from the Debug Toolbar Button's drop down Action List. Both of these options will begin your debugging session and take you to the Debug Page.
GAUSS User Guide F6 Debug file at top of Action List. Inside a debug session, F6 will cause the debugger to run to the next breakpoint, or the end of the file if no breakpoint is set. F7 Edit file at top of Action List. F8 Step in (During a debug session). F9 Step over (During a debug session). F10 Step out (During a debug session). The Control Keys operate on a file that is being edited or is open in a Programming Editor and has focus. This file is referred to as the Active File.
Navigating the GAUSS GUI from the Command Page will bring up the Source Page. CTRL+TAB from the Help Page will wrap and bring up the Command Page. ALT+TAB Cycles between any pages that are undocked as well as other open programs. WINDOW+TAB Windows only: Cycles between any pages that are undocked as well as other open programs. Mouse Scroll Wheel When floating over any set of tabs, the mouse scroll wheel will cycle through the open tabs.
GAUSS User Guide Figure 4.1: Inline help window opened with SHIFT+F1 4.5 CTRL+F1 Source Browsing For procedures that reside in a GAUSS Library (.lcg file), you can browse to the procedure definition and to the initiation of any global variables with CTRL+F1. Like F1 help, set your cursor on the procedure or global variable name and enter CTRL+F1. If it resides in an active library, the source file will be immediately opened in a Programming Editor.
5 Using the GAUSS Debugger The GAUSS debugger is a powerful tool to speed up and simplify your program development. Debugging takes place on the Debug Page, which is a full-featured dashboard providing you a wealth of information about the status of your variables and your program every step of the way. 5.1 Starting the Debugger Figure 5.
GAUSS User Guide Figure 5.2: Debug Window From here you can step through your program line-by-line, or run to a line of interest. To tell the debugger to run to a particular line, you must first set a breakpoint. Setting a breakpoint on a line in your program tells the debugger to pause when it gets to that line. You may set a breakpoint in any source file by simply clicking in the margin to the left of the line numbers.
Using the GAUSS Debugger Figure 5.3: Debug Toolbar Debug Run Runs to the next breakpoint. Debug Stop Stops the debug session. Toggle Breakpoint Toggles a breakpoint on the current line. Clear Breakpoints Removes all breakpoints from all files. Examine Variable Opens a user-specified variable in a floating Symbol Editor window. Step in Steps to the next line. If the next line is a procedure, it will step inside this procedure.
GAUSS User Guide Figure 5.4: >Local Variable Window A single-click to one of these variables will display its full contents in the symbol dump window. The symbol dump window is a GAUSS symbol editor, similar in appearance to a spreadsheet. Double-clicking on a variable in the Local Variable window opens that variable in a floating symbol editor. Located just below the Local Variable window is the Watch window.
Using the GAUSS Debugger Figure 5.5: Symbol Dump Window You may see a tooltip preview of any variable in your file by floating your cursor over the variable name. Placing your cursor on a variable and pressing CTRL-E will open that variable in a floating symbol editor. 5.3 The Call Stack Window The Call Stack window is like a map into your program. The top entry in the Call Stack window is always your current location.
GAUSS User Guide Figure 5.6: Call Stack Window This list is interactive. Single-clicking on any of the items in the Call Stack window will bring you to that particular line and file. For example, if you would like to examine the line from which your current procedure was called, click on the second item in the call stack list.
6 GAUSS Graphics 6.1 Overview The plotting functionality available in GAUSS is designed to provide intuitive methods for visualizing data using a variety of plot types. The main plot drawing functions are: plotBar Creates a bar plot. plotBox Creates a box plot using the box graph percentile method. plotContour Creates a contour plot. plotHist Calculates and creates a frequency histogram plot. plotHistF Creates a histogram plot from a vector of frequencies.
GAUSS User Guide plotScatter Creates a 2-dimensional scatter plot. plotSurface Creates a 3-dimensional surface plot. plotTS Creates a graph of time series data. plotXY Creates a 2-dimensional line plot. 6.2 Basic Plotting The simplest way to plot data in GAUSS is to use default values for the plot settings, such as line color, line size, legend text, etc. These settings may be changed by the user from the main menu bar: Tools-> Preferences-> Graphics.
GAUSS Graphics Figure 6.1: One Curve Plot 6.2.1 Plotting multiple curves Each column of the input matrices is treated as a separate curve or line on the graph. Below is an example that uses the variables created from the example above and adds an additional line: x = seqa(-5, 0.
GAUSS User Guide Figure 6.2: Two Curve Plot 6.3 Plot Customization GAUSS offers two ways to customize your graphs. The first is through the graphics preferences dialog window. The second method for plot customization is using a plotControl structure. 6.3.1 Using the Graphics Preferences Settings Window Main Graph Settings The default settings for graphics can be opened from the main application menu bar Tools-> Preferences. Then select Graphics from the list on the top left of the preferences window.
GAUSS Graphics Figure 6.3: The Graph Settings Tab 2-D Curve Settings The second section is the Group tabs. These specify the settings for each curve, set of bars, or set of points. Here you may specify line color, thickness, symbol type, bar fill type and the corresponding legend description. Note that you may specify separate preferences for each plot type: xy, scatter, polar, etc.
GAUSS User Guide Figure 6.4: The Group Tab Click the 'Apply' and 'OK' buttons after making your desired changes. GAUSS will use these preferences for all future graphs that are made without passing in a plotControl structure. As we will see in the next section, these settings will also be the starting point when you create a plotControl structure. These settings may be changed at any time.
GAUSS Graphics 6.4 PlotControl Structures The GAUSSplotControl structure provides a powerful and flexible method for programmatic control of your graphs in GAUSS. This structure is a convenient package that stores all of the information about how you would like a specific graph to be displayed. These structures may be saved to disk and reloaded during a future session or passed on to colleagues. Using a plotControl structure requires just two easy steps: 1. Declare the structure. 2.
GAUSS User Guide Figure 6.5: Plot Using plotControl Structure The available plotControl setting functions include: 6-8 plotGetDefaults Applies the user defined default settings for a specified graph type to a plotControl structure. plotSetBar Sets the fill style and format of bars in a histogram or bar graph. plotSetBkdColor Sets background color of a graph. plotSetGrid Controls the settings for the background grid of a plot.
GAUSS Graphics plotSetNewWindow Sets whether new graphs should be drawn in the same window or in a newly created window. plotSetTitle Controls the settings for the title for a graph. plotSetXLabel Controls the settings for the X-axis label on a graph. plotSetXTicInterval Controls the interval between X-axis tic labels and optionally at which X-value to place the first tic label. plotSetXTicLabel Controls the formatting and angle of Xaxis tic labels for 2-D graphs.
GAUSS User Guide myPlot = plotGetDefaults("bar"); //Create data to plot x = seqa(1, 1, 10); y = abs(rndn( 10, 1 )); //Change plot settings //Turn off the grid plotSetGrid(&myPlot, "off"); // Make the background light-gray plotSetBkdColor(&myPlot, "light gray"); //Set the title, title font and font size plotSetTitle(&myPlot, "Example Bar Plot", "verdana", 16); //Draw graph plotBar(myPlot, x, y); Figure 6.
GAUSS Graphics Notice in the previous example that the first input to the plotSetTitle function is &myPlot and not just the variable name, myPlot. This is because all of the plotControl setting functions take a structure pointer. The ampersand (&) in front of the variable name makes the input argument a pointer to that structure. Passing structure pointers as arguments is much faster and more efficient than passing an entire structure.
GAUSS User Guide Any 2-D plot type may be added to any other 2-D plot type, with the exception of contour plots, polar plots and time series plots. You may add a polar plot to a previous polar plot or a time series plot to a time series plot. Example //Create and plot multivariate random normal data rndseed 19823434; cov = { 1 0.9, 0.9 1 }; mu = { 2, 2 }; y = rndMVn(300, mu, cov); plotScatter(y[.,1], y[.,2]); //Create line coordinates and add to scatter plot x = { -0.3, 4.8 }; y2 = { 0, 4.
GAUSS Graphics The plotAdd functions will not make any styling changes to the existing plot. They may, however, increase the scale of the view if needed to accommodate the new curve. Use the plotAdd functions only to add data to an existing graph. Do not attempt to use them to create a new graph. 6.6 Creating Subplots GAUSS allows you to create two types of graphs within graphs. The first is called a subplot. In GAUSS a subplot divides the canvas up into tiles of equal size and shape.
GAUSS User Guide This next graph, after a call to plotClearLayout, will either draw over any existing graphs or be drawn in a new window depending on your graphics preferences. This setting can be controlled from the "On graph load" setting, located under Tools-> Preferences-> Graphics. It may also be set with the plotSetNewWindow function.
GAUSS Graphics Figure 6.
GAUSS Graphics GAUSS User Guide 6.6.1 Creating Mixed Layouts In GAUSS, plotLayouts may not overlap. For this functionality use the plotCustomLayout function. However, you may divide the canvas into sections of different size as long as they do not overlap.
6.6.2 Creating Custom Regions Custom regions in GAUSS are graphs inside of graphs. They may be placed in any location on the canvas and may be any size. This functionality is controlled by the plotCustomLayout function. It takes the location and size parameters for the custom region as a percentage of the entire canvas. As with plotLayout, these settings will be applied to the next drawn graph.
GAUSS Graphics GAUSS User Guide //Create plot in custom region defined above plotBox(myPlot, 0, y); //Clear the layout, so future graphs will not be //drawn in this custom region plotClearLayout(); Figure 6.11: Example Custom Layout 6.7 Time Series Plots in GAUSS GAUSS provides the following functions to simplify the process of creating time series graphics: plotTS Creates a graph of time series data. plotSetXTicLabel Controls the formatting and angle of X-axis tic labels for 2-D time series graphs.
be labeled for 2-D time series graphs. To create a basic time series plot in GAUSS, you will use the plotTS function. In addition to the y data to plot, this function requires the following inputs: dstart Scalar, the starting date of the time series in DT scalar format. frequency Scalar, the frequency of the data per year.
GAUSS Graphics GAUSS User Guide Figure 6.12: Close-up of monthly data plot Understanding the dstart parameter The dstart parameter is specified to be a scalar value in DT scalar format. In DT scalar format the leading four digits are the year and the next two digits, if present, represent the month. If the month information is not present, as in the example above, GAUSS will assume the first month of the year.
200807 200810 6.7.1 Quarterly Example Using what we have just learned, we will create a quarterly graph that starts at 2007 Q4 and runs for 16 quarters.
GAUSS Graphics GAUSS User Guide Figure 6.13: Close-up of quarterly data plot 6.7.2 Controlling Tic Label Locations The first tic label on the X-axis of the graph that ended the last section is located on the first data point, 2007 Q4. Let us suppose that we would prefer the graph to have tic labels only on the first quarter of each year. We can accomplish this by using the function plotSetXTicInterval.
Labeled to be the first full year in our series, 2008.
GAUSS Graphics GAUSS User Guide Figure 6.14: Quarterly data graph We can see that the X-tics are in the correct location. However since we are only labeling each year, we may not want Q1 printed next to the year on each of the X-tic labels. 6.7.3 Tic Label Formatting We can change the formatting of these labels and optionally the angle at which they are printed with the function plotSetXTicLabel.
QQ print the quarter as Q1, Q2, Q3 or Q4. MO print the month as a two digit number. These format specifiers can be placed in any order. You may place any characters in between them and they will be printed literally.
GAUSS Graphics GAUSS User Guide dstart = 200710; freq = 4; //Start x-tic labels at 2008 and label every 4th //data point interval = 4; firstLabeled = 2008; plotSetXTicInterval(&myPlot, interval, firstLabeled); //Label X-tics with only the 4 digit year plotSetXTicLabel(&myPlot, “YYYY”); //Plot the data plotTS(myPlot, dstart, freq, y); This final program should yield a graph that looks similar to: Figure 6.
6.8 Interacting with Plots in GAUSS Once a graph has been created, GAUSS provides interactive zooming, panning, and the moving of legends and subplots as well as the ability to hide and restore individual curves on the graph. Plot rotation is also available for 3-dimensional plots.
GAUSS Graphics GAUSS User Guide 6.8.1 Interacting with 2-D Plots To interact with plots in GAUSS, first select the "Zoom/Pan Plot" button from the toolbar. With this button selected, you will be able to perform actions on the view of a particular plot. Zooming is controlled by the mouse scroll wheel. Scroll the mouse wheel forward to zoom in. Pan and scroll is accomplished by drag-and-drop with the mouse. Note that upon zooming or panning, the axes will be automatically updated to reflect the new view.
Figure 6.17: The legend acts as a button to hide curves Relocating Graphic Items To relocate subplots or legends first select the "Revise Layout" button. You may then drag and drop the item to its desired location. Initially, legends will be grouped with their respective graph. This means that when you select and move a graph, its legend will also be selected and maintain its position relative to the graph. You may ungroup a legend from its parent graph by right-clicking the legend and selecting "Ungroup.
GAUSS Graphics GAUSS User Guide Figure 6.
6.8.2 3-D Plots Zoom Zooming in and out on a 3-dimensional graph may be accomplished by use of the mouse scroll wheel. Panning and Scrolling To move a 3-D image without rotating it, hold down the CTRL key and drag the image to its desired location with your mouse. Rotate/Viewpoint Change To rotate 3-dimensional plots and examine the graph from different viewpoints, click and drag with the mouse.
GAUSS Graphics GAUSS User Guide 6.8.3 File Export GAUSS graphs may be exported to many popular file formats, including BMP, PNG, PS, SVG and PDF. Graphics may be exported programmatically or using the graphical controls. To export a graph programmatically, use the plotSave function, passing in the filename with extension and the dimensions in centimeters for the second argument: //Save the graph just created as mygraph.pdf with a width of //30 cm and a height of 18 cm size = { 30, 18 }; plotSave("mygraph.
Figure 6.
GAUSS Graphics GAUSS User Guide 6.8.4 Saving Graphs Graphs may be saved and then reloaded later. To save a graph, select the graph you would like to save and then select File-> Save Graph from the main menu. GAUSS graphs are saved in an XML format with a .plot extension. Figure 6.21: Save Graph menu Graphs may also be saved programmatically with the plotSave function.
7 Graphics Editing GAUSS allows you to interactively change most all attributes of a created graph. First create a graph. For demonstration purposes you may run the example program randomwalk.e to create a graph. Next open the Graph Settings window if it is not open already, by selecting View->Graph Settings from the menu bar. 7.1 Changing Appearance Figure 7.
GAUSS User Guide Click on the graph to populate the Graph Settings Window. To change one of the colors, single-click on the color button to bring up a color palette window. Figure 7.2: Color Palette To change text for a label or title, double-click the current text and edit the text. Figure 7.3: Text Options Double-click font names in the graph settings window to open a font dialog window.
Graphics Editing Figure 7.4: Font Options 7.2 Adding Items The Graphics Page toolbar has buttons for adding l l l l Lines and arrows Rectangles Ellipses Text boxes To add an item, click the appropriate toolbar button and then click and drag to create the object in your graphic window.
GAUSS User Guide Figure 7.5: Select the item to add Figure 7.6: Click and drag to add the object 7.3 Adding Text to a Text Box To add text to a text box, double-click in the text box. When you see a text cursor (which looks similar to a capital i), you may begin entering text. 7.4 Which Object Will Be Edited? If a graph or graphics object is actively selected, its border will be highlighted red. Changes made in the Graph Settings window will apply to this selected object.
Graphics Editing Figure 7.7: Highlighted Object When you place your mouse in the Graph Settings window, if no object is actively selected, the last selected object will be given a blue edge highlight to indicate to which object your changes will be made. Figure 7.
GAUSS User Guide 7.5 Moving and Resizing Objects To move an object, hover your mouse over it. When your mouse pointer is a hand icon and the object you would like to move has a blue highlight around its edges, click and drag to move the object to its desired location. Figure 7.9: Moving a graphic object Hover over the corner of an object until your mouse pointer is two opposing arrows and the object has a blue edge highlight. Then click and drag to resize the object. Figure 7.
8 Using the Command Line Interface TGAUSS is the command line version of GAUSS. The executable file, tgauss, is located in the GAUSS installation directory. The format for using TGAUSS is: tgauss flag(s) program program... -b Execute file in batch mode and then exit. You can execute multiple files by separating file names with spaces. -l logfile Set the name of the batch mode log file when using the -b argument. The default is tmp/gauss.log###, where ### is the process ID.
GAUSS User Guide 8.1 Viewing Graphics NOTE: Graphics using plot* functions are only available from the graphical user interface. The deprecated Publication Quality Graphics graphics generated .tkf files for graphical output. The default output for these graphics is graphic.tkf. On Windows, you can use vwr.exe to view the graphics file; on UNIX/Linux/Mac, you can use vwrmp. Two functions are available to convert .
8.2.
Using the Command Line Interface GAUSS User Guide 8.2.
8.2.
Using the Command Line Interface GAUSS User Guide tiple keystroke mappings have been supported to maximize the availability of these commandson any given machine. 8.3 Interactive Commands This section discusses interactive commands available in TGAUSS.
8.3.1 quit The quit command will exit TGAUSS. The format for quit is: quit You can also use the system command to exit TGAUSS from either the command line or a program (see system in the GAUSS LANGUAGE REFERENCE).
Using the Command Line Interface GAUSS User Guide 8.3.2 ed The ed command will open an input file in an external text editor (see ed in the GAUSS LANGUAGE REFERENCE).
8.3.3 browse The browse command allows you to search for specific symbols in a file and open the file in the default editor. You can use wildcards to extend search capabilities of the browse command.
Using the Command Line Interface GAUSS User Guide 8.3.4 config The config command gives you access to the configuration menu allowing you to change the way GAUSS runs and compiles files. The format for config is: config Run Menu Translator Toggles on/off the translation of a file using dataloop. The translator is not necessary for GAUSS program files not using dataloop. Translator line number tracking Toggles on/off execution time line number tracking of the original file before translation.
Compiler Trace Includes the following options: Off Turns off the compiler trace function. File Traces program file openings and closings. Line Traces compilation by line. Symbol Creates a report of procedures and the local and global symbols they reference. 8.4 Debugging The debug command runs a program under the source level debugger.
Using the Command Line Interface GAUSS User Guide 8.4.1 General Functions 8-12 ? Displays a list of available commands. q/Esc Exits the debugger and returns to the GAUSS command line. +/- Disables the last command repeat function.
8.4.2 Listing Functions l number Displays a specified number of lines of source code in the current file. lc Displays source code in the current file starting with the current line. ll file line Displays source code in the named file starting with the specified line. ll file Displays source code in the named file starting with the first line. ll line Displays source code starting with the specified line. File does not change. ll Displays the next page of source code.
Using the Command Line Interface GAUSS User Guide 8.4.3 Execution Functions 8-14 s number Executes the specified number of lines, stepping into procedures. n number Executes the specified number of lines, stepping over procedures. x number Executes code from the beginning of the program to the specified line count, or until a breakpoint is hit. g Executes from the current line to the end of the program, stopping at breakpoints. The optional arguments specify other stopping points.
filename The debugger will stop at every line in the named file. line The debugger will stop when it reaches the specified line in the current file. procedure period The debugger will stop every period times it reaches the first line in a called procedure. procedure The debugger will stop every time it reaches the first line in a called procedure. j Executes code to a specified line, procedure, or period in the file without stopping at breakpoints.
Using the Command Line Interface GAUSS User Guide 8.4.4 View Commands v [[vars]] Searches for (a local variable, then a global variable) and displays the value of a specified variable. v$[[vars]] Searches for (a local variable, then a global variable) and displays the specified character matrix. The display properties of matrices and string arrays can be set using the following commands. 8-16 r Specifies the number of rows to be shown. c Specifies the number of columns to be shown.
8.4.5 Breakpoint Commands lb Shows all the breakpoints currently defined. b Sets a breakpoint in the code. The syntax for each optional argument is: filename line period The debugger will stop every period times it reaches the specified line in the named file. filename line The debugger will stop when it reaches the specified line in the named file. filename ,, period The debugger will stop every period times it reaches any line in the named file.
Using the Command Line Interface GAUSS User Guide procedure d The debugger will stop every time it reaches the first line in a called procedure. Removes a previously specified breakpoint. The optional arguments are the same arguments as b, listed above. 8.5 Using the Source Browser in TGAUSS To start the Source Browser in TGAUSS, type BROWSE followed by a symbol name. When the Source Browser is active, the prompt displays Browse:.
9 Language Fundamentals GAUSS is a compiled language. GAUSS is also an interpreter. A compiled language, because GAUSS scans the entire program once and translates it into a binary code before it starts to execute the program. An interpreter, because the binary code is not the native code of the CPU. When GAUSS executes the binary pseudocode it must "interpret" each instruction for the computer. How can GAUSS be so fast if it is an interpreter? Two reasons.
GAUSS User Guide y = x*3; If an expression has no assignment operator (=), it will be assumed to be an implicit print statement: print x*3; or x*3; Here is an example of a statement that is a command rather than an expression: output on; Commands cannot be used as a part of an expression. There can be multiple statements on the same line as long as each statement is terminated with a semicolon. 9.2.
Language Fundamentals x = 1 3 7 2 9 4 0 3 ; 9.2.2 Nonexecutable Statements Nonexecutable statements are statements that have an effect only when the program is compiled (compile time). They generate no executable code at the current location of the instruction pointer. Here are two examples: declare matrix x = 1 2 3 4 ; external matrix ybar; Procedure definitions are nonexecutable. They do not generate executable code at the current location of the instruction pointer.
GAUSS User Guide There is code generated in the procedure definition, but it is isolated from the rest of the program. It is executable only within the scope of the procedure and can be reached only by calling the procedure. 9.3 Programs A program is any set of statements that are run together at one time. There are two sections within a program. 9.3.1 Main Section The main section of the program is all of the code that is compiled together WITHOUT relying on the autoloader.
Language Fundamentals retp(abs(a-b) <= tol); endp; 9.4 Compiler Directives Compiler directives are commands that tell GAUSS how to process a program during compilation. Directives determine what the final compiled form of a program will be. They can affect part or all of the source code for a program. Directives are not executable statements and have no effect at run-time. They do not take a semicolon at the end of the line. The #include statement mentioned earlier is actually a compiler directive.
GAUSS User Guide #endif End of #if-#else-#endif code block. #include Include code from another file in program. #lineson Compile program with line number and file name records. #linesoff Compile program without line number and file name records. #srcfile Insert source file name record at this point (currently used when doing data loop translation). #srcline Insert source file line number record at this point (currently used when doing data loop translation).
Language Fundamentals This allows the same program to calculate answers using different base logarithms, depending on whether or not the program has a #define log_10 statement at the top. #undef allows you to undefine text-replacement or flag variables so they no longer affect a program, or so you can #define them again with a different value for a different section of the program. If you use #definecs to define a case-sensitive variable, you must use the right case when #undef'ing it.
GAUSS User Guide #srcfile(/gauss/test.e) 9.5 Procedures A procedure allows you to define a new function which you can then use as if it were an intrinsic function. It is called in the same way as an intrinsic function. y = myproc(a,b,c); Procedures are isolated from the rest of your program and cannot be entered except by calling them. Some or all of the variables inside a procedure can be local variables. local variables exist only when the procedure is actually executing and then disappear.
Language Fundamentals Decimal constants can be either integer or floating point values: 1.34e-10 1.34e123 -1.34e+10 -1.34d-10 1.34d10 1.34d+10 123.456789345 Up to 18 consecutive digits before and after the decimal point(depending on the platform) are significant, but the final result will be rounded to double precision if necessary. The range is the same as for matrices (For details, see Matrices, Section 9.6.2 String String constants are enclosed in quotation marks: "This is a string.
GAUSS User Guide space. Matrices are stored in row major order.
Language Fundamentals | Vertical concatenation. ~ Horizontal concatenation. con Numeric input from keyboard. cons Character input from keyboard. declare Compile-time matrix or string initialization. let Matrix definition statement. load Load matrix (same as loadm). readr Read from a GAUSS matrix or data set file. save Save matrices, procedures and strings to disk. saved Convert a matrix to a GAUSS data set. stof Convert string to matrix. submat Extract a submatrix.
GAUSS User Guide 1 2 3 x = 4 5 6 7 8 9 The statement let x[3,3] = 1 2 3 4 5 6 7 8 9; will result in 1 2 3 x = 4 5 6 7 8 9 The statement let x[3,3] = 1; will result in 1 1 1 x = 1 1 1 1 1 1 The statement let x[3,3]; will result in 0 0 0 x = 0 0 0 0 0 0 The statement let x = 1 2 3 4 5 6 7 8 9; 9-12
Language Fundamentals will result in 1 2 3 4 x = 5 6 7 8 9 Complex constants can be entered in a let statement. In the following example, the + or - is not a mathematical operator, but connects the two parts of a complex number. There should be no spaces between the + or - and the parts of the number. If a number has both real and imaginary parts, the trailing 'i' is not necessary. If a number has no real part, you can indicate that it is imaginary by appending the 'i'.
GAUSS User Guide x = x ~ data_in(hsec-hsec0); endo; You can test whether a matrix is empty by entering rows(x), cols(x) and scalerr (x). If the matrix is empty rows and cols will return a 0, and scalerr will return 65535. The ~ is the horizontal concatenation operator and the | is the vertical concatenation operator.
Language Fundamentals The let command is used to initialize matrices with constant values: let x[2,2] = 1 2 3 4; Unlike the concatenation operators, it cannot be used to define matrices in terms of expressions such as: y = x1-x2~x2|x3*3~x4; The statement y = x[1:3,5:8]; will put the intersection of the first three rows and the fifth through eighth columns of x into the matrix y.
GAUSS User Guide will set the 2,4 element of the existing matrix y to 3. This statement is illegal if y does not have at least 2 rows and 4 columns. The statement x = con(3,2); will cause the following prompt to be printed in the window: - (1,1) indicating that the user should enter the [1,1] element of the matrix. Entering a number and then pressing ENTER will cause a prompt for the next element of the matrix to appear. Pressing ? will display a help screen, and pressing x will exit.
Language Fundamentals 9.6.3 Sparse Matrices Many GAUSS operators and commands support the sparse matrix data type. You may use any of the following commands to create a sparse matrix: denseToSp Converts a dense matrix to a sparse matrix. denseToSpRE Converts a dense matrix to a sparse matrix, using a relative epsilon. packedToSp Creates a sparse matrix from a packed matrix of nonzero values and row and column indices.
GAUSS User Guide described by the two trailing dimensions of the array are equal to the identity. areshape Reshape a scalar, matrix, or array into an array of user-specified size. arrayalloc Create an N-dimensional array with unspecified contents. arrayinit Create an N-dimensional array with a specified fill value. mattoarray Convert a matrix to a type array. See N-DIMENSIONAL ARRAYS , CHAPTER 14 , for a more detailed explanation. 9.6.
Language Fundamentals matrix. ftos Character representation of numbers in 1x1 matrix. ftostrC Convert a matrix to a string array using a C language format specification. getf Load ASCII or binary file into string. indcv Find index of element in character vector. lower Convert to lowercase. stof Convert string to floating point. strindx Find index of a string within a second string. strlen Length of a string. strsect Extract substring of string.
GAUSS User Guide vals Convert from string to numeric vector of ASCII codes. Strings can be created like this: x = "example string"; or x = cons; // keyboard input or x = getf("myfile",0); // read a file into a string They can be printed like this: print x; A character matrix must have a '$' prefixed to it in a print statement: print $x; A string can be saved to disk with the save command in a file with a .fst extension and then loaded with the load command: save x; loads x; or loads x=x.
Language Fundamentals "\b" backspace (ASCII 8) "\e" escape (ASCII 27) "\f" formfeed (ASCII 12) "\g" beep (ASCII 7) "\l" line feed (ASCII 10) "\r" carriage return (ASCII 13) "\t" tab (ASCII 9) "\\" a backslash "\###" the ASCII character whose decimal value is ''###''. When entering DOS pathnames in double quotes, two backslashes must be used to insert one backslash: st = "c:\\gauss\\myprog.
GAUSS User Guide If you want to get the data set name from a string variable and the variable names from a character vector, use dataset="olsdat"; let vnames=age pay sex; create f1=^dataset with ^vnames,0,2; The substitution operator (^) works with load and save also: lpath="/gauss/procs"; name="mydata"; load path=^lpath x=^name; command="dir *.fmt"; The general syntax is: ^variable_name Expressions are not allowed.
Language Fundamentals 9.6.6 String Arrays String arrays are NxK matrices of strings. Here is a partial list of the functions for manipulating string arrays: $| Vertical string array concatenation operator. $~ Horizontal string array concatenation operator. [ ] Extract subarrays or individual strings from their corresponding array, or assign their values. ' Transpose operator. .' Bookkeeping transpose operator. declare Initialize variables at compile time.
GAUSS User Guide lshow Print global symbol table to the printer. print Print expressions on window and/or auxiliary output. reshape Reshape a matrix or string array to new dimensions. save Save matrix, string array, string, procedure, function or keyword to disk and gives the disk file either a .fmt , .fst or .fcg extension. show Display global symbol table. sortcc Quick-sort rows of matrix or string array based on character column.
Language Fundamentals x = "age"; y = "pay"; n = "sex"; s = x$+y$+n; sa = x$~y$~n; assign the values: s = agepaysex s = age pay sex 9.6.7 Character Matrices Matrices can have either numeric or character elements. For convenience, a matrix containing character elements is referred to as a character matrix. A character matrix is not a separate data type, but gives you the ability to store and manipulate data elements that are composed of ASCII characters as well as floating point numbers.
GAUSS User Guide vector of ones and zeros can be used by printfm when printing your data. Since GAUSS does not know whether a matrix has character or numeric information, it is up to you to specify which type of data it contains when printing the contents of the matrix. (For details, see print and printfm in the GAUSS LANGUAGE REFERENCE.) Most functions that take a string argument will take an element of a character matrix also, interpreting it as a string of up to 8 characters. 9.6.
Language Fundamentals DTV Vector Format The DTV vector is a 1x8 vector. The format for the DTV vector is: [1] Year [2] Month, 1-12 [3] Day of month, 1-31 [4] Hour of day, 0-23 [5] Minute of hour, 0-59 [6] Second of minute, 0-59 [7] Day of week, 0-6 where 0 is Sunday [8] Day since beginning of year, 0-365 UTC Scalar Format The UTC scalar format is the number of seconds since January 1, 1970, Greenwich Mean Time. 9.6.
GAUSS User Guide Certain numerical errors will cause the math coprocessor to create a NaN called an "indefinite." This will be printed as a -NaN when using the print command. These values are created by the following operations: l +∞ plus -∞ l +∞ minus +∞ l -∞ minus -∞ l 0*∞ l ∞/∞ l 0/0 l Operations where one or both operands is a NaN l Trigonometric functions involving ∞ INF When the math coprocessor overflows, the result will be a properly signed infinity.
Language Fundamentals The procedure isindef will return 1 (true) if the matrix passed to it contains any NaN's that are the indefinite mentioned earlier. The GAUSS missing value code as well as GAUSS scalar error codes are NaN's, but this procedure tests only for indefinite: proc isindef(x); retp(not x $/= __INDEFn); endp; Be sure to call gausset before calling isindef. gausset will initialize the value of the global __INDEFn to a platform-specific encoding.
GAUSS User Guide these operators, the operand pairs associated with the * or / operator are evaluated first. Whether * or / is evaluated first depends on which comes first in the particular expression. For a listing of the precedence of all operators, see Operator Precedence, Section 10.7 . The expression -5+3/4+6*3 is evaluated as (-5)+(3/4)+(6*3) Within a term, operators of equal precedence are evaluated from left to right.
Language Fundamentals 3.14^5*6/(2+sqrt(3)/4) ((3.145) * 6)/(2 + (sqrt(3) / 4)) -a+b*c^2 (-a) + (b * (c2)) a+b-c+d-e (((a + b) - c) + d) - e a^b^c*d ((ab)c) * d a*b/d*c ((a * b) / d) * c a^b+c*d (ab) + (c * d) 2^4! 2(4!) 2*3! 2 * (3!) 9.8 Flow Control A computer language needs facilities for decision making and looping to control the order in which computations are done. GAUSS has several kinds of flow control statements. 9.8.
GAUSS User Guide . . endo; also do until scalar_expression; // loop if expression is false . . statements . . endo; The scalar_expression is any expression that returns a scalar result. The expression will be evaluated as TRUE if its real part is nonzero and FALSE if it is zero. There is no counter variable that is automatically incremented in a do loop. If one is used, it must be set to its initial value before the loop is entered and explicitly incremented or decremented inside the loop.
Language Fundamentals 1,1 2,1 3,1 4,1 1,2 2,2 3,2 4,2 1,3 2,3 3,3 4,3 Use the relational and logical operators without the dot '.' in the expression that controls a do loop. These operators always return a scalar result. break and continue are used within do loops to control execution flow. When break is encountered, the program will jump to the statement following the endo. This terminates the loop.
GAUSS User Guide . endfor; counter is the literal name of the counter variable. start, stop and step are scalar expressions. start is the initial value, stop is the final value and step is the increment. break and continue are also supported by for loops. (For more information, see for in the GAUSS LANGUAGE REFERENCE.) 9.8.2 Conditional Branching The if statement controls conditional branching: if scalar_expression; . . statements . . elseif scalar_expression; . . statements . . else; . . statements . .
Language Fundamentals The scalar_expression is any expression that returns a scalar result. The expression will be evaluated as TRUE if its real part is nonzero and FALSE if it is zero. GAUSS will test the expression after the if statement. If it is TRUE, then the first list of statements is executed. If it is FALSE, then GAUSS will move to the expression after the first elseif statement, if there is one, and test it.
GAUSS User Guide . . goto errout("Matrix singular"); . . goto errout("File not found"); . . errout: pop errmsg; errorlog errmsg; end; gosub With a gosub, the address of the gosub statement is remembered and when a return statement is encountered, the program will resume executing at the statement following the gosub. Parameters can be passed with a gosub in the same way as a goto. With a gosub it is also possible to return parameters with the return statement.
Language Fundamentals These functions can be called in the same way as intrinsic functions. The above function could be used in the following program sequence. diameter = 3; radius = 3 / 2; a = area(radius); 9.10 Rules of Syntax This section lists the general rules of syntax for GAUSS programs.
Language Fundamentals GAUSS User Guide 9.10.1 Statements A GAUSS program consists of a series of statements. A statement is a complete expression or command. Statements in GAUSS end with a semicolon with one exception: from the GAUSS command line, the final semicolon in an interactive program is implicit if it is not explicitly given: (gauss) x=5; z=rndn(3,3); y=x+z Column position is not significant. Blank lines are allowed.
9.10.2 Case GAUSS does not distinguish between uppercase and lowercase except inside double quotes.
Language Fundamentals GAUSS User Guide 9.10.3 Comments // This comments out all text between the '//' and the end // of the line /* This kind of comment can be nested */ @ We consider this kind of comment to be obsolete, but it is supported for backwards compatibility.
9.10.
Language Fundamentals GAUSS User Guide 9.10.5 Symbol Names The names of matrices, strings, procedures, and functions can be up to 32 characters long. The characters must be alphanumeric or an underscore. The first character must be alphabetic or an underscore.
9.10.6 Labels A label is used as the target of a goto or a gosub. The rules for naming labels are the same as for matrices, strings, procedures, and functions.
Language Fundamentals GAUSS User Guide 9.10.7 Assignment Statements The assignment operator is the equal sign '=': y = x + z; Multiple assignments must be enclosed in braces '{ }'. The statement: mant,pow = base10(x); is incorrect.
9.10.
Language Fundamentals GAUSS User Guide 9.10.9 Indexing Matrices Brackets '[ ]' are used to index matrices: x = { 1 2 3, 3 7 5, 3 7 4, 8 9 5, 6 1 8 }; y = x[3,3]; z = x[1 2:4,1 3]; Vectors can be indexed with either one or two indices: v = 1 2 3 4 5 6 7 8 9 ; k = v[3]; j = v[1,6:9]; x[2,3] returns the element in the second row and the third column of x. x[1 3 5,4 7] returns the submatrix that is the intersection of rows 1, 3, and 5 and columns 4 and 7. x[.,3] returns the third column of x. x[3:5,.
indices. If rv is a scalar 0, all rows will be used; if cv is a scalar 0, all columns will be used. If a vector is used in an index expression, it is illegal to use the space operator or the colon operator on the same side of the comma as the vector.
Language Fundamentals GAUSS User Guide 9.10.10 Arrays of Matrices and Strings It is possible to index sets of matrices or strings using the varget function. In this example, a set of matrix names is assigned to mvec. The name y is indexed from mvec and passed to varget which will return the global matrix y.
9.10.11 Arrays of Procedures It is also possible to index procedures. The ampersand operator (&) is used to return a pointer to a procedure. Assume that f1, f2, and f3 are procedures that take a single argument. The following code defines a procedure fi that will return the value of the ith procedure, evaluated at x. nms = &f1 | &f2 | &f3; proc fi(x,i); local f; f = nms[i]; local f:proc; retp(f(x)); endp; fi(x,2) will return f2(x). The ampersand is used to return the pointers to the procedures.
10 Operators 10.1 Element-by-Element Operators Element-by-element operators share common rules of conformability. Some functions that have two arguments also operate according to the same rules. Element-by-element operators handle those situations in which matrices are not conformable according to standard rules of matrix algebra. When a matrix is said to be ExE conformable, it refers to this element-by-element conformability.
GAUSS User Guide 1 3 2 x = 4 5 1 3 7 4 2 4 3 y = 3 1 4 6 1 2 3 7 6 z = 7 6 5 9 8 6 l If x is a matrix and y is a scalar, or vice versa, then the scalar is operated on with respect to every element in the matrix.
Operators vector matrix result l 2 4 3 ↓ ↓ ↓ 7 3 5 2 0 3 4 1 2 ↓ ↓ ↓ 9 5 7 6 4 7 7 4 5 When one argument is a row vector and the other is a column vector, the result of an element-by-element operation will be the "table" of the two: row vector 3 → column vector 2 → 5 → 2 ↓ 5 4 7 4 ↓ 7 6 9 3 ↓ 6 5 8 1 ↓ 4 3 6 If x and y are such that none of these conditions apply, the matrices are not conformable to these operations and an error message will be generated. 10.
Operators GAUSS User Guide 10.2.1 Numeric Operators For details on how matrix conformability is defined for element-by-element operators, see Element-by-Element Operators, Section 10.1 . + Addition: y = x + z; Performs element-by-element addition. - Subtraction or negation: y = x - z; y = - k; Performs element-by-element subtraction or the negation of all elements, depending on context.
Ax = b Linear equation solution is performed in the following cases: l l If A is a square matrix and has the same number of rows as b, this statement will solve the system of linear equations using an LU decomposition. If A is rectangular with the same number of rows as b, this statement will produce the least squares solutions by forming the normal equations and using the Cholesky decomposition to get the solution: x= A′b A′A If trap 2 is set, missing values will be handled with pairwise deletion.
Operators GAUSS User Guide If x is a column vector, and z is a row vector (or vice versa), the ''outer product'' or ''table'' of the two will be computed. (For comformability rules, see Element-by-Element Operators, Section 10.1 .) ./ Element-by-element division y = x ./ z; ^ Element-by-element exponentiation y = x^z; If x is negative, z must be an integer. .^ Same as ^ .*.Kronecker (tensor) product: y = x .*.
x = 1 3 2 4 y = 5 7 6 8 z = x *~ y; z = 5 6 10 12 21 24 28 32 The input matrices x and y must have the same number of rows. The result will have cols(x) * cols(y) columns.
Operators GAUSS User Guide 10.2.2 Other Matrix Operators ' Transpose operator: y = x'; The columns of y will contain the same values as the rows of x and the rows of y will contain the same values as the columns of x. For complex matrices this computes the complex conjugate transpose. If an operand immediately follows the transpose operator, the ' will be interpreted as '*. Thus y = x'x is equivalent to y = x'*x. .'Bookkeeping transpose operator: y = x.
z = 1 4 7 2 5 8 3 6 9 10.3 Relational Operators For details on how matrix conformability is defined for element-by-element operators, see Element-by-Element Operators, Section 10.1 . Each of these operators has two equivalent representations. Either can be used (for example, < or lt), depending only upon preference. The alphabetic form should be surrounded by spaces.
Operators GAUSS User Guide is interpreted as: "if every element of x is not equal to the corresponding element of y". To check if two matrices are not identical, use if not x == y; For complex matrices, the ==, /=, .== and ./= operators compare both the real and imaginary parts of the matrices; all other relational operators compare only the real parts.
l Greater than or equal to z = x >= y; z = x ge y; z = x $>= y; l Greater than z = x > y; z = x gt y; z = x $> y; If the relational operator IS preceded by a dot '.', then the result will be a matrix of 1's and 0's, based upon an element-by-element comparison of x and y. l Element-by-element less than z = x .< y; z = x .lt y; z = x .$< y; l Element-by-element less than or equal to z = x .<= y; z = x .le y; z = x .$<= y; l Element-by-element equal to z = x .== y; z = x .eq y; z = x .
Operators GAUSS User Guide z = x .!= y; z = x .$/= y; z = x .$!= y; l Element-by-element greater than or equal to z = x .>= y; z = x .ge y; z = x .$>= y; l Element-by-element greater than z = x .> y; z = x .gt y; z = x .$> y; 10.4 Logical Operators The logical operators perform logical or Boolean operations on numeric values. On input a nonzero value is considered TRUE and a zero value is considered FALSE. The logical operators return a 1 if TRUE and a 0 if FALSE.
Disjunction x y x or y T T T T F T F T T F F F Exclusive Or x y x xor y T T F T F T F T T F F F Equivalence x y x eqv y T T T T F F F T F F F T For complex matrices, the logical operators consider only the real part of the matrices. The following operators require scalar arguments.
Operators GAUSS User Guide l Disjunction z = x or y; l Exclusive or z = x xor y; l Equivalence z = x eqv y; If the logical operator is preceded by a dot '.', the result will be a matrix of 1's and 0's based upon an element-by-element logical comparison of x and y: l Element-by-element logical complement z = .not x; l Element-by-element conjunction z = x .and y; l Element-by-element disjunction z = x .or y; l Element-by-element exclusive or z = x .
y = 3; Comma Commas are used to delimit lists: clear x,y,z; to separate row indices from column indices within brackets: y = x[3,5]; and to separate arguments of functions within parentheses: y = momentd(x,d); Period Dots are used in brackets to signify ''all rows'' or ''all columns'': y = x[.
Operators GAUSS User Guide No extraneous spaces are allowed within expressions in print or lprint statements unless the expression is enclosed in parentheses: print (x / 2) (2 * sqrt(x)); Colon A colon is used within brackets to create a continuous range of indices: y = x[1:5,.]; Ampersand The (&) ampersand operator will return a pointer to a procedure (proc), function (fn), or structure (struct).
k = y $+ "fish"; The result will be a 3x1 matrix with each element containing 'catfish'. If we then use k created above: t = "" $+ k[1,1]; The result will be a string containing 'catfish'. If we used the same k to create z as follows: z = "dog" $+ k[1,1]; The resulting z will be a string containing 'dogcatfish'.
Operators GAUSS User Guide create f1 = olsdat with x,4,2; by default GAUSS will interpret olsdat as the literal name of the GAUSS data file you want to create. It will also interpret x as the literal prefix string for the variable names x1 x2 x3 x4.
run ^prog; msym ^mstring; 10.6 Using Dot Operators with Constants When you use those operators preceded by a '.' (dot operators) with a scalar integer constant, insert a space between the constant and any following dot operator. Otherwise, the dot will be interpreted as part of the scalar; that is, the decimal point. For example: let y = 1 2 3; x = 2.
Operators GAUSS User Guide y =(x ./ 2.) / x; not y =(x ./ 2) ./ x; The second division, then, is handled as a matrix division rather than an element-by-element division. 10.7 Operator Precedence The order in which an expression is evaluated is determined by the precedence of the operators involved and the order in which they are used. For example, the * and / operators have a higher precedence than the + and - operators.
For a compound statement such as: Z = (X'X)/(Y'X); the parentheses are required. Operator Precedence Operator Precedence Operator Precedence 90 .$>= 65 $>= 55 90 ./= 65 /= 55 89 .< 65 < 55 .^ 85 .<= 65 <= 55 ^ 85 .== 65 == 55 (unary -) 83 .> 65 > 55 * 80 .>= 65 >= 55 * .* 80 .eq 65 eq 55 80 .ge 65 ge 55 .*. 80 .gt 65 gt 55 ./ 80 .le 65 le 55 / 80 .lt 65 lt 55 % 75 .ne 65 ne 55 $+ 70 .not 64 not 49 + 70 .
Operators GAUSS User Guide 10-22 .$< 65 $< 55 : 35 .$<= 65 $<= 55 = 10 .$== 65 $== 55 .
11 Procedures and Keywords Procedures are multiple-line, recursive functions that can have either local or global variables. Procedures allow a large computing task to be written as a collection of smaller tasks. These smaller tasks are easier to work with and keep the details of their operation from the other parts of the program that do not need to know them. This makes programs easier to understand and easier to maintain.
GAUSS User Guide 11.1 Defining a Procedure A procedure definition consists of five parts, four of which are denoted by explicit GAUSS commands: 1. Procedure declaration proc statement 2. Local variable declaration local statement 3. Body of procedure 4. Return from procedure retp statement 5. End of procedure definition endp statement There is always one proc statement and one endp statement in a procedure definition. Any statements that come between these two statements are part of the procedure.
11.1.1 Procedure Declaration The proc statement is the procedure declaration statement. The format is: proc (rets) = name(arg1, arg2,...argn); rets Optional constant, number of values returned by the procedure. Acceptable values here are 0-1023; the default is 1. name Name of the procedure, up to 32 alphanumeric characters or an underscore, beginning with an alpha or an underscore. arg# Names that will be used inside the procedure for the arguments that are passed to the procedure when it is called.
Procedures and Keywords GAUSS User Guide 11.1.2 Local Variable Declarations The local statement is used to declare local variables. Local variables are variables known only to the procedure being defined. The names used in the argument list of the proc statement are always local. The format of the local statement is: local x, y, f:proc, g:fn, z, h:keyword; Local variables can be matrices or strings.
The maximum number of locals is limited by stack space and the size of workspace memory. The limiting factor applies to the total number of active local symbols at any one time during execution. If cat has 10 locals and it calls dog which has 20 locals, there are 30 active locals whenever cat is called. There can be multiple local statements in a procedure. They will affect only the code in the procedure that follows.
Procedures and Keywords GAUSS User Guide 11.1.3 Body of Procedure The body of the procedure can have any GAUSS statements necessary to perform the task the procedure is being written for. Other user-defined functions and other procedures can be referenced as well as any global matrices and strings. GAUSS procedures are recursive, so the procedure can call itself as long as there is logic in the procedure to prevent an infinite recursion.
11.1.4 Returning from the Procedure The return from the procedure is accomplished with the retp statement: retp; retp(expression1, expression2, arg1, arg2, argN, expressionN); The retp statement can have multiple arguments. The number of items returned must coincide with the number of rets in the proc statement. If the procedure was defined with no items returned, the retp statement is optional. The endp statement that ends the procedure will generate an implicit retp with no objects returned.
Procedures and Keywords GAUSS User Guide 11.1.5 End of Procedure Definition The endp statement marks the end of the procedure definition: endp; An implicit retp statement that returns nothing is always generated here so it is impossible to run off the end of a procedure without returning. If the procedure was defined to return one or more objects, executing this implicit return will result in a Wrong number of returns error message and the program will terminate. 11.
call dog(ak, 4, 3); when calling it. The arguments passed to procedures can be complicated expressions involving calls to other functions and procedures. This calling mechanism is completely general. For example, y = dog(cat(3*x, bird(x, y))-2, 2, 1); is legal. 11.3 Keywords A keyword, like a procedure, is a subroutine that can be called interactively or from within a GAUSS program. A keyword differs from a procedure in that a keyword accepts exactly one string argument, and returns nothing.
Procedures and Keywords GAUSS User Guide 11.3.1 Defining a Keyword A keyword definition is much like a procedure definition. Keywords always are defined with 0 returns and 1 argument. The beginning of a keyword definition is the keyword statement: keyword name(strarg); name Name of the keyword, up to 32 alphanumeric characters or an underscore, beginning with an alpha or an underscore. strarg Name that will be used inside of the keyword for the argument that is passed to the keyword when it is called.
sum = sum + stof(tok); endo; format /rd 1,2; print "The sum is: " sum; endp; The keyword defined above will print the string argument passed to it. The argument will be printed enclosed in single quotes.
Procedures and Keywords GAUSS User Guide 11.3.2 Calling a Keyword When a keyword is called, every character up to the end of the statement, excluding the leading spaces, is passed to the keyword as one string argument. For example, if you type add 1 2 3 4 5; the keyword will respond The sum is: 15.00 Here is another example: add; the keyword will respond The argument is a null string 11.
retp(x); else; retp(y); endif; endp; fn lgsqrt(x) = ln(sqrt(x)); /* function to return log of square root */ proc myproc(&f1, &f2, x, y); local f1:proc, f2:fn, z; z = f1(x, y); retp(f2(z)); endp; The procedure myproc takes four arguments. The first is a procedure f1 that has two arguments. The second is a function f2 that has one argument. It also has two other arguments that must be matrices or scalars. In the local statement, f1 is declared to be a procedure and f2 is declared to be a function.
Procedures and Keywords GAUSS User Guide 11.5 Indexing Procedures This example assumes there are a set of procedures named f1-f5 that are already defined. A 1x5 vector procvec is defined by horizontally concatenating pointers to these procedures. A new procedure, g(x, i) is then defined to return the value of the ith procedure evaluated at x: procVec = &f1 ~ &f2 ~ &f3 ~ &f4 ~ &f5; proc g(x, i); local f; f = procVec[i]; local f:proc; retp( f(x)); endp; The local statement is used twice.
To make the assignment, the list of targets must be enclosed in braces.
Procedures and Keywords GAUSS User Guide local ixy, zr, zi; ixy = inv(xr)*xi; zr = inv(xr+xi*ixy); zi = -ixy*zr; retp(zr,zi); endp; //real part of inverse //imaginary part of inverse proc (2) = cmmult(xr, xi, yr, yi); local zr, zi; zr = xr*yr-xi*yi; zi = xr*yi+xi*yr; retp(zr, zi); endp; { xr, xi { yr, yi { zr, zi { qr, qi { wr, wi yi))); } } } } } = = = = = cmcplx(rndn(3,3)); cmcplx(rndn(3,3)); cmmult(cminv(xr, xi), cminv(yr, yi)); cmmult(yr, yi, cminv(yr, yi)); cmmult(yr, yi, cminv(cmmult(cminv(xr, x
save path = c:\gauss\cp proc1,proc2,proc3; loadp path = c:\gauss\cp proc1,proc2,proc3; The name of the file will be the same as the name of the procedure, with a .fcg extension. (For details, see loadp and save in the GAUSS LANGUAGE REFERENCE.) All compiled procedures should be saved in the same subdirectory, so there is no question where they are located when it is necessary to reload them. The loadp path can be set in your startup file to reflect this.
12 Random Number Generation in GAUSS GAUSS provides a powerful suite of functionality for random number generation. The key features include: 1. Availability of several modern random number generators 2. Sampling of many distributions 3. Thread-safe random number generators 4. Parallel random number generation 12.1 Available Random Number Generators 1. KISS-Monster 2. MRG32k3a 3. MT19937: Mersenne-Twister 19937 4.
GAUSS User Guide 5. SFMT19937: Optimized Mersenne-Twister 19937 6.
12.1.1 Choosing a Random Number Generator Quality What is a high quality random number generator? Pierre L'Ecuyer stated that "The difference between the good and bad random number generators, in a nutshell, is that the bad ones fail very simple tests whereas the good ones fail only very complicated tests that are hard to figure out or impractical to run.
Random Number Generation GAUSS User Guide 3. MRG32K3A 4. Wichmann-Hill 5. Kiss-Monster Beyond simply choosing the fastest available generators, two coding techniques can also cause your programs to run faster. The first is creating larger numbers of random deviates at a time. For example, creating one million random numbers in one call will be much faster than creating the same one million numbers through 100,000 calls that each create 10 numbers.
The problem with the above example is that implicit in each call to rndn is a write to the same global state. Note that rndn, rndGam and rndu all share the same global state. So replacing one of the above calls to rndn with a call to rndu would still result in an illegal program.
Random Number Generation GAUSS User Guide 12.3.1 Multiple Stream Generators Some of the RNGs in GAUSS are a collection of more than one independent stream of random numbers. A stream is an independent series of numbers with a length that is the period length of the generator. Each of these sequences or streams has the same statistical properties. However, not all of the RNGs in GAUSS offer this ability. The MT2203 and the Wichman-Hill are examples of RNGs with multiple streams.
12.3.2 Block-skipping Creating random numbers from multiple streams provides multiple sets of independent random numbers with similar statistical properties that can be used in different threads. However, these separate streams do not form a contiguous set of random numbers. If you would like to process a contiguous stream of random numbers in multiple threads, you can use block-splitting.
Random Number Generation GAUSS User Guide Each successive thread in the above program will process a different chunk of the sequence of random numbers.
1. (MRG32k3a) L'Ecuyer, P. "Good Parameter Sets for Combined Multiple Recursive Random Number Generators." Operations Research, 47, 1, 159-164, 1999. 2. (TestU01) L'Ecuyer, P. and Simard, R. "TestU01: A C Library for Empirical Testing of Random Number Generators." ACM Trans. Math. Softw. 33, 4, Article 22 , 2007. 3. (Wichmann-Hill) MacLaren, N.M. "The Generation of Multiple Independent Sequences of Pseudorandom Numbers." Applied Statistics, 38, 351-359, 1989.
13 Sparse Matrices The sparse matrix data type stores only the non-zero values of a 2-dimensional sparse matrix, which makes working with sparse matrices use less memory. Sparse matrix calculations may be faster or slower than those on an equivalent dense matrix, depending upon several factors. Sparse matrix computations require extra complexity. This makes them slower than the same operation on an equivalent dense matrix.
GAUSS User Guide declare sparse matrix sm1; let sparse matrix sm1; or the following implicit let statement: sparse matrix sm1; declare may be used to define multiple sparse matrices in a single statement: declare sparse matrix sm1, sm2, sm3; To define a local sparse matrix inside of a procedure, use an implicit let statement: sparse matrix lsm1; As neither let nor declare support the initialization of a sparse matrix at this time, you must initialize a sparse matrix with an assignment after defining it.
Sparse Matrices method. spCreate Creates a sparse matrix from vectors of non-zero values, row indices, and column indices. spDenseSubmat Returns a dense submatrix of sparse matrix. spDiagRvMat Inserts submatrices along the diagonal of a sparse matrix. spEigv Computes a specified number of eigenvalues and eigenvectors of a square, sparse matrix. spEye Creates a sparse identity matrix. spGetNZE Returns the non-zero values in a sparse matrix, as well as their corresponding row and column indices.
GAUSS User Guide spTScalar Multiplies a sparse matrix by a scalar. spZeros Creates a sparse matrix containing no non-zero values. See COMMAND REFERENCE for detailed information on each command. 13.3 Sparse Support in Matrix Functions and Operators Support for the sparse matrix data type has also been added to many matrix functions and operators. The following is a complete list of the matrix functions and operators that currently support the new sparse matrix type: ... /= .
Sparse Matrices Note that printing a sparse matrix results in a table of the non-zero values contained in the sparse matrix, followed by their corresponding row and column indices, respectively. 13.3.1 Return Types for Dyadic Operators The types of the returns for the dyadic operators were decided on a case-by-case basis, using the following general principles: 1. The return type for dyadic operations on two dense arguments is always dense. 2.
GAUSS User Guide dense = sparse - dense dense = dense - dense sparse = sparse - sparse dense = dense - sparse Element-by-Element Multiplication Result = Left Operator Right sparse = sparse .* dense dense = dense .* dense sparse = sparse .* sparse sparse = dense .* sparse Element-by-Element Division Result = Left Operator Right sparse = sparse ./ dense dense = dense ./ dense dense = sparse ./ sparse dense = dense .
Sparse Matrices dense = dense / dense dense = dense / sparse Note that at this time, the dense = dense / sparse case is defined only for real data. When either of its arguments are sparse, the / operator uses a tolerance to determine the result, which may be read or set using the sysstate function, case 39. The default tolerance is 1e-14.
GAUSS User Guide Horizontal Concatenation Result = Left Operator Right dense = dense dense sparse = sparse sparse Vertical Concatenation 13-8 Result = Left Operator Right dense = dense dense sparse = sparse sparse
14 N-Dimensional Arrays In GAUSS, internally, matrices and arrays are separate data types. Matrices, which are 2-dimensional objects, are stored in memory in row major order. Therefore, a 3x2 matrix is stored as follows: [1,1] [1,2] [2,1] [2,2] [3,1] [3,2] The slowest moving dimension in memory is indexed on the right, and the fastest moving dimension is indexed on the left. This is true of N-dimensional arrays as well.
GAUSS User Guide terms). The vector of orders for a 6x5x4x3x2 array, which has 5 dimensions, is the following 5x1 vector: 6 5 4 3 2 Two terms that are important in working with N-dimensional arrays are "dimension index" and "dimension number." A dimension index specifies a dimension based on indexing the vector of orders.
N-Dimensional Arrays 3 2 1 indexes the [3,2,1] element of x. A 2x1 vector of indices for this 3-dimensional example, references the 1-dimensional array whose starting location is given by the indices. Because the elements of the vector of indices are always in the same order (the first element of the vector of indices corresponds to the slowest moving dimension of the array, the second element to the second slowest moving dimension, and so on), each unique vector of indices locates a unique subarray.
GAUSS User Guide [1,1,1] through [1,3,4] = 1 2 3 4 5 6 7 8 9 10 11 12 [2,1,1] through [2,3,4] = 13 14 15 16 17 18 19 20 21 22 23 24 x[1,2,3] returns a 1x1x1 array containing the [1,2,3] element of x. 7 x[.,3,2] returns a 2x1x1 array containing: 10 22 x[2,.,1 4] returns a 1x3x2 array containing 13 17 21 16 20 24 x[.,2,1:3] returns a 2x1x3 array containing 5 6 7 17 18 19 14.
N-Dimensional Arrays l l l Any N-dimensional array is conformable to a scalar. An array is conformable to a matrix only if the array has fewer than 3 dimensions, and the array and matrix follow the standard rules of ExE conformability. Two arrays are ExE conformable if they comply with one of the following requirements: l The two arrays have the same number of dimensions, and each dimension has the same size.
GAUSS User Guide 14-6 dimension index Scalar [1-to-N], where 1 corresponds to the first element of the vector of orders or vector of indices. locator [1-to-N]x1 vector of indices into an array used by array functions to locate a contiguous block of the array.
15 Working with Arrays 15.1 Initializing Arrays The use of N-dimensional arrays in GAUSS is an additional tool for reducing development time and increasing execution speed of programs. There are multiple ways of handling N-dimensional arrays and using them to solve problems, and these ways sometimes have implications for a trade-off between speed of execution and development time. We will try to make this clear in this chapter.
GAUSS User Guide 15.1.1 areshape areshape is a method for creating an array with specified contents. arrayinit creates an array filled with a selected scalar value: areshape will do the same, but with a matrix. For example, given a matrix, areshape will create an array containing multiple copies of that matrix: x = reshape(seqa(1, 1, 4), 2, 2); ord = 3 | 2 | 2; a = areshape(x, ord); print a; Plane [1,.,.] 1.0000 2.0000 3.0000 4.0000 Plane [2,.,.] 1.0000 2.0000 3.0000 4.0000 Plane [3,.,.] 1.0000 2.0000 3.
Working with Arrays vc = mm / 100 - amult(atranspose(mn, 1|3|2), mn); panel is a 5x100x10 array, and in this context is 5 panels of 100 cases measured on 10 variables. Inserting Random Numbers into Arrays A random array of any dimension or size can be quickly created using areshape.
GAUSS User Guide 1.0000 0.3000 0.2000 0.3000 1.0000 0.1000 0.2000 0.1000 1.0000 15.1.2 aconcat aconcat creates arrays from conformable sets of matrices or arrays. With this function, contents are completely specified by the user. This example tries three concatenations, one along each dimension: rndseed 345678; x1 = rndn(2,2); x2 = arrayinit(2|2,1); /* ** along the first dimension or rows */ a = aconcat(x1,x2,1); print a; -0.4300 -0.2878 1.0000 1.0000 -0.1327 -0.0573 1.0000 1.
Working with Arrays /* ** along the third dimension */ a = aconcat(x1,x2,3); print a; Plane [1,.,.] -0.4300 -0.2878 -0.1327 -0.0573 Plane [2,.,.] 1.0000 1.0000 1.0000 1.0000 15.1.3 aeye aeye creates an array in which the principal diagonal of the two trailing dimensions is set to one. For example: ord = 2 | 3 | 3; a = aeye(ord); print a; Plane [1,.,.] 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000 1.00000 Plane [2,.,.] 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 0.00000 1.
GAUSS User Guide 15.1.4 arrayinit arrayinit creates an array with all elements set to a specified value. For example: ord = 3 | 2 | 3; a = arrayinit(ord,1); print a; Plane [1,.,.] 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Plane [2,.,.] 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Plane [3,.,.] 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 15.1.5 arrayalloc arrayalloc creates an array with specified number and size of dimensions without setting elements to any values.
Working with Arrays a[i,.,.] = rndn(2, 3); endfor; print a; Plane [1,.,.] -0.4300 -0.2878 -0.1327 -0.0573 -1.2900 0.2467 Plane [2,.,.] -1.4249 -0.0796 1.2693 -0.7530 -1.7906 -0.6103 Plane [3,.,.] 1.2586 -0.4773 0.7044 -1.2544 0.5002 0.3559 The second argument in the call to arrayalloc specifies whether the created array is real or complex. arrayinit creates only real arrays. 15.
GAUSS User Guide getmatrix Get a matrix from an array. getmatrix4D Get a matrix from a 4-dimensional array. getscalar4D Get a scalar from a 4-dimensional array. The index operator is the slowest way to extract parts of arrays. The specialized functions are the fastest when the circumstances are appropriate for their use. 15.2.
Working with Arrays a[1,.,.] = rndn(2, 2); print a; Plane [1,.,.] -1.7906502 -0.61038103 1.2586160 -0.47736360 Plane [2,.,.] 0.00000 0.00000 1.00000 1.00000 Plane [3,.,.] 0.00000 0.00000 1.00000 1.00000 The index operator will extract an array from a subarray in a manner analogous to the use of index operators on matrices: a = areshape(seqa(1,1,12), 3|2|2); b = a[.,1,.]; print a; Plane [1,.,.] 1.0000 2.0000 3.0000 4.0000 Plane [2,.,.] 5.0000 6.0000 7.0000 8.0000 Plane [3,.,.] 9.0000 10.000 11.000 12.
GAUSS User Guide Plane [1,.,.] 1.0000 2.0000 Plane [2,.,.] 5.0000 6.0000 Plane [3,.,.] 9.0000 10.000 It is important to note that the result is always an array even if it's a scalar value: c = a[1,1,1]; print c; Plane [1,.,.] 1.0000 If you require a matrix result, and if the result has one or two dimensions, use arraytomat to convert to a matrix, or use getmatrix, or getmatrix4D. Or, if the result is a scalar, use getscalar3D or getscalar4D. 15.2.
Working with Arrays Plane [3,.,.] 9.0000 10.000 11.000 12.000 print b; 5.0000 6.0000 getarray can only extract a contiguous part of an array. To get non-contiguous parts you must use the index operator. 15.2.3 getmatrix If the result is one or two dimensions, getmatrix returns a portion of an array converted to a matrix. getmatrix is about 20 percent faster than the index operator: a = areshape(seqa(1,1,12), 3|2|2); b = getmatrix(a, 2); print b; 5.0000 6.0000 7.0000 8.0000 15.2.
GAUSS User Guide for j(1, 100, 1); b = a[i,j,.,.]; endfor; endfor; t1 = date; e1 = ethsec(t0, t1); print e1; print; t2 = date; for i(1,100,1); for j(1,100,1); b = getmatrix4d(a, i, j); endfor; endfor; t3 = date; e2 = ethsec(t2, t3); print e2; print; print ftostrC(100*((e1-e2)/e1), "percent difference %6.2lf%%"); 13.000000 5.0000000 percent difference - 61.54% 15.2.
Working with Arrays a = arrayinit(100|10|10, 1); t0 = date; for i(1,100,1); for j(1,10,1); for k(1,10,1); b = a[i,j,k]; endfor; endfor; endfor; t1 = date; e1 = ethsec(t0, t1); print e1; print; t2=date; for i(1,100,1); for j(1,10,1); for k(1,10,1); b = getscalar3d(a, i, j, k); endfor; endfor; endfor; t3 = date; e2 = ethsec(t2, t3); print e2; print; print ftostrC(100*((e1-e2)/e1), "percent difference %6.2lf%%"); 7.0000000 2.0000000 percent difference - 71.
GAUSS User Guide 15.2.6 putarray putarray enters a subarray, matrix, or scalar into an N-dimensional array and returns the result in an array. This function is much faster than the index operator, but it requires the part of the array being assigned to be contiguous: a = arrayinit(3|2|2, 3); b = putarray(a, 2, eye(2)); print b; Plane [1,.,.] 3.0000 3.0000 3.0000 3.0000 Plane [2,.,.] 1.0000 0.00000 0.00000 1.0000 Plane [3,.,.] 3.0000 3.0000 3.0000 3.0000 15.2.
Working with Arrays 1.0000 0.0000 0.0000 1.0000 Plane [3,.,.] 3.0000 3.0000 3.0000 3.0000 15.3 Looping with Arrays When working with arrays, for loops and do loops may be used in the usual way. In the following, let Y be an Nx1xL array of L time series, X an Nx1xK array of K independent variables, b a KxL matrix of regression coefficients, phi a PxLxL array of garch coefficients, theta a QxLxL array of arch coefficients, and omega a LxL symmetric matrix of constants.
GAUSS User Guide sigma[i,.,.] = sigma[i,.,.] + amult(W, atranspose(W, 1|3|2)); endfor; for j(1, P, 1); sigma[i,.,.] = sigma[i,.,.] + amult(amult(phi[j,.,.], sigma[i-j,.,.]),phi[j,.,.]); endfor; endfor; sigmai = invpd(sigma); lndet = ln(det(sigma)); lnl = -0.
Working with Arrays amult(W, atranspose(W, 2|1)); endfor; for j(1, P, 1); setarray sigma,i, getarray(sigma,i)+ areshape(amult(amult(getarray(phi, j), getarray(sigma, i-j)), getarray(phi, j)), 3|3); endfor; endfor; sigmai = invpd(sigma); lndet = ln(det(sigma)); lnl = -0.
GAUSS User Guide sig0ind = sig0ind - 1; W = amult(getarray(theta,thetaind), atranspose(getarray(E, sig0ind), 2|1)); setarray sigma,sigind, getarray(sigma, sigind)+ amult(W, atranspose(W, 2|1)); loopnextindex thetaloop,thetaind,aord; sig0ind = sigind; phiind = 1; philoop: sig0ind[1] = sig0ind[1] - 1; setarray sigma,sigind, getarray(sigma, sigind)+ areshape(amult(amult(getarray(phi, phiind), getArray(sigma, sig0ind)), getArray(phi, phiind)), 3|3); loopnextindex philoop,phiind,gord; loopnextindex sigloop,sigi
Working with Arrays for j(1, 3, 1); for k(1, 3, 1); setarray a,i|j|k,b; endfor; endfor; endfor; ind = { 1,1,1 }; loopi: setarray a,ind,b; loopnextindex loopi,ind,ord; Calling each loop 10,000 times and measuring the time each takes, we get for loop: 1.171 seconds loopnextindex: .321 seconds In other words, loopnextindex is about four times faster, a very significant difference. 15.4 Miscellaneous Array Functions This section discusses miscellaneous array functions. 15.4.
GAUSS User Guide 3.0000 4.0000 5.0000 6.0000 Plane [2,.,.] 7.0000 8.0000 9.0000 10.000 11.000 12.000 /* ** swap 2nd and 3rd dimension */ print atranspose(a,1|3|2); Plane [1,.,.] 1.0000 3.0000 5.0000 2.0000 4.0000 6.0000 Plane [2,.,.] 7.0000 9.0000 11.000 8.0000 10.000 12.000 /* ** swap 1st and 3rd dimension */ print atranspose(a,3|2|1); Plane [1,.,.] 1.0000 7.0000 3.0000 9.0000 5.0000 11.000 Plane [2,.,.] 2.0000 8.0000 4.0000 10.000 6.0000 12.
Working with Arrays ** move 3rd into the front */ print atranspose(a,3|1|2); Plane [1,.,.] 1.0000 3.0000 5.0000 7.0000 9.0000 11.000 Plane [2,.,.] 2.0000 4.0000 6.0000 8.0000 10.000 12.000 15.4.2 amult This function performs a matrix multiplication on the last two trailing dimensions of an array. The leading dimensions must be strictly conformable, and the last two trailing dimensions must be conformable in the matrix product sense.
GAUSS User Guide Plane [1,.,.] 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 Plane [2,.,.] 9.0000 10.000 11.000 12.000 13.000 14.000 15.000 16.000 print c; Plane [1,.,.] 11.000 14.000 17.000 20.000 23.000 30.000 37.000 44.000 35.000 46.000 57.000 68.000 Plane [2,.,.] 167.00 182.00 197.00 212.00 211.00 230.00 249.00 268.00 255.00 278.00 301.00 324.00 Suppose we have a matrix of data sets, a 2x2 matrix of 100x5 data sets that we've stored in a 2x2x100x5 array called x.
Working with Arrays Plane [1,.,.] 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 Plane [2,.,.] 7.0000 8.0000 9.0000 10.000 11.000 12.000 /* ** compute means along third dimension */ print amean(a, 3); Plane [1,.,.] 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 /* ** print means along the second dimension, i.e., ** down the columns */ print amean(a, 2); Plane [1,.,.] 3.0000 4.0000 Plane [2,.,.] 9.0000 10.
GAUSS User Guide print amin(a, 2); Plane [1,.,.] 1.0000 2.0000 Plane [2,.,.] 7.0000 8.0000 /* ** print the maximums along the third dimension */ print amax(a, 3); Plane [1,.,.] 7.0000 8.0000 9.0000 10.000 11.000 12.000 15.4.4 getdims This function returns the number of dimensions of an array: a = arrayinit(4|4|5|2, 0); print getdims(a); 4.00 15.4.5 getorders This function returns the sizes of each dimension of an array.
Working with Arrays 4.00 4.00 5.00 2.00 15.4.6 arraytomat This function converts an array with two or fewer dimensions to a matrix: a = arrayinit(2|2, 0); b = arraytomat(a); type(a); 21.000 type(b); 6.0000 15.4.7 mattoarray This function converts a matrix to an array: b = rndn(2,2); a = mattoarray(b); type(b); 6.0000 type(a); 21.
GAUSS User Guide 15.5 Using Arrays with GAUSS functions Many of the GAUSS functions have been re-designed to work with arrays. There are two general approaches to this implementation. There are exceptions, however, and you are urged to refer to the documention if you are not sure how a particular GAUSS function handles array input. In the first approach, the function returns an element-by-element result that is strictly conformable to the input.
Working with Arrays a = areshape(seqa(1,1,108), 2|3|6|3); b=svds(a); print b; Plane [1,1,.,.] 45.894532 1.6407053 1.2063156e-015 Plane [1,2,.,.] 118.72909 0.63421188 5.8652600e-015 Plane [1,3,.,.] 194.29063 0.38756064 1.7162751e-014 Plane [2,1,.,.] 270.30524 0.27857175 1.9012118e-014 Plane [2,2,.,.] 346.47504 0.21732995 1.4501098e-014 Plane [2,3,.,.] 422.71618 0.17813229 1.
GAUSS User Guide GAUSS function's behavior on a matrix. This may be true with some of the functions, but not all. For example, the GAUSSmeanc function returns a column result for matrix input. However, the behavior for the GAUSSamean function is not analogous. This function takes a second argument that specifies on which dimension the mean is to be taken. That dimension is then collapsed to a size of 1. Thus: a = areshape(seqa(1, 1, 24), 2|3|4); print a; Plane 1.000 5.000 9.000 [1,.,.] 2.000 3.000 4.000 6.
Working with Arrays ** means computed down columns */ c = amean(a,2); print c; Plane [1,.,.] 5.000 6.000 7.000 8.000 Plane [2,.,.] 17.000 18.000 19.000 20.000 /* ** means computed along 3rd dimension */ d = amean(a,3); print d; Plane [1,.,.] 7.000 8.000 9.000 10.000 11.000 12.000 13.000 14.000 15.000 16.000 17.000 18.000 15.6 A Panel Data Model Suppose we have N cases observed at T times.
GAUSS User Guide The log-likelihood for this model is lnL = -0.5(NT(ln(2π)) - ln|Ω| + (Y - ΧΒ)'Ω-1(Y - ΧΒ)) where Ω is the block-diagonal moment matrix of the residuals. Computing the Log-likelihood Using GAUSS arrays, we can compute the log-likelihood of this model without resorting to do loops. Let Y be a 100x3x1 array of observations on the dependent variable, and X a 100x3x5 array of observations on the independent variables.
Working with Arrays All of this can be made more efficient by nesting statements, which eliminates copying of temporary intervening arrays to local arrays. It is also useful to add a check for the positive definiteness of sigma: N = 100; T = 3; K = 5; const = -0.5*N*T*ln(2*pi); oldt = trapchk(1); trap 1,1; sigmai = invpd(sigu*ones(T, T)+sige*eye(T)); trap oldt,1; if not scalmiss(sigmai); E = Y - amult(X, areshape(B,N|K|1)); lnl = const + 0.5*N*ln(detl)0.
GAUSS User Guide of an array. amean Compute the mean along one dimension of an array. amin Compute the minimum elements across a dimension of an array. amult Perform a matrix multiplication on the last two trailing dimensions of an array. areshape Reshape a scalar, matrix, or array into an array of user-specified size. arrayalloc Create an N-dimensional array with unspecified contents. arrayinit Create an N-dimensional array with a specified fill value.
Working with Arrays getscalar4D Get a scalar form a 4-dimensional array. loopnextindex Increment an index vector to the next logical index and jump to the specified label if the index did not wrap to the beginning. mattoarray Change a matrix to a type array. nextindex Return the index of the next element or subarray in an array. previousindex Return the index of the previous element or subarray in an array.
16 Structures 16.1 Basic Structures 16.1.1 Structure Definition The syntax for a structure definition is struct A { /* list of members */ }; The list of members can include scalars, arrays, matrices, strings, and string arrays, as well as other structures. As a type, scalars are unique to structures and don't otherwise exist.
GAUSS User Guide make the structure definition available for your program. This may be accomplished by either executing the structure definition file or by adding the structure definition to a library. Executing a structure definition file You can execute a structure definition just like any other GAUSS program file. However, any time that the new command is entered, the structure definition will be cleared from your workspace.
Structures 16.1.2 Declaring an Instance To use a structure, it is necessary to declare an instance. The syntax for this is struct structure_type structure_name; For example: #include example.sdf struct generic_example p0; 16.1.3 Initializing an Instance Members of structures are referenced using a "dot" syntax: p0.x = rndn(20,3); The same syntax applies when referred to on the right-hand side: mn = meanc(p0.x); Initialization of Global Structures Global structures are initialized at compile time.
GAUSS User Guide string array "", a 1x1 string array set to null sparse matrix {}, an empty sparse matrix with zero rows and zero columns If a global already exists in memory, it will not be reinitialized. It may be the case in your program that when it is rerun, the global variables may need to be reset to default values. That is, your program may depend on certain members of a structure being set to default values that are set to some other value later in the program.
Structures unused structures. They will be initialized to default values only when the first assignment is made to one of its members. 16.1.4 Arrays of Structures To create a matrix of instances, use the reshape command: #include ds.sdf struct DS p0; p0 = reshape(dsCreate,5,1); This creates a 5x1 vector of instances of DS structures, with all of the members initialized to default values.
GAUSS User Guide matrix x; matrix y; string str; }; you could create an array of example1 structures and index it as follows: struct example1 e1a; struct example1 e1b; e1a = e1a | e1b; e1a[2,1].y = rndn(25,10); In this example, e1a and e1b are concatenated to create a 2x1 array of example1 structures that is assigned back to e1a. Then the y member of the [2,1] element of e1a is set to a random matrix. Indexing of structure arrays can occur on multiple levels.
Structures struct example2 e2; }; Figure 16.1: Structure tree for e1 Let's assume that we have an example1 structure e1 like the one displayed in the figure above. We could then index the structure as follows: r = e1.e2[3,1].e3[2,1].w You can also use indexing to reference the structure itself, rather than a member of that structure: struct example3 e3tmp; e3tmp = e1.e2[3,1].
GAUSS User Guide e3tmp = e1.e2[3,1].e3[.,1]; In this case, e3tmp would be an array of 3x1 example3 structures, since the [3,1] member of e1.e2 contains a 3x1 array of example3 structures. It is important to remember, however, that when indexing a structure array on multiple levels, only the final index may resolve to an array of structures. For example: e3tmp = e1.e2[.,1].e3[2,1]; would be invalid, since e1.e2 [.,1] resolves to a 3x1 array of example2 structures. 16.1.
Structures { instance, retc } = loadstruct(file_name, structure_name); For example: #include ds.sdf; struct DS p3; { p3, retc } = loadstruct("p2", "ds"); 16.1.8 Passing Structures to Procedures Structures or members of structures can be passed to procedures. When a structure is passed as an argument to a procedure, it is passed by value. The structure becomes a local copy of the structure that was passed.
GAUSS User Guide cent.lry = -cent.uly; retp(cent); endp; 16.2 Structure Pointers A structure pointer is a separate data type that contains the address of a structure and is used to reference that structure. 16.2.
Structures struct example_struct es2; es2 = *esp; copies the contents of the structure that esp is pointing at (i.e., the contents of es) to es2. It is the same as struct example_struct es2; es2 = es; 16.2.2 Structure Pointer References To reference a member of a structure, we use a "dot" syntax. For example, we might use the following code to set the x member of es. es.x = rndn(3,3); To reference a member of a structure using a pointer to that structure, we use an "arrow" syntax.
GAUSS User Guide s.sp1->x; will ever be valid (sp1 and sp2 are assumed to be structure pointers, s a structure instance, and x a matrix). The "arrow" (->) will only be valid if it is used for the first (or furthest left) dereference, as in: sp1->st.x; At this point we do not support indexing of structure pointers. Thus, a structure pointer should point at a scalar structure instance, not a matrix of structures. However, you may index members of that scalar structure instance.
Structures members of that structure, then it makes a local copy of the entire structure before modifying it. Thus if you want to have the modified copy of the structure after running the procedure, you need to pass the structure out of the procedure as one of its return arguments. For example: struct example_struct { matrix x; matrix y; matrix z; }; proc product(struct example_struct es); es.z = (es.x).*(es.y); retp(es); endp; struct example_struct es1; es1.x = rndn(1000,100); es1.
GAUSS User Guide proc(0) = product(struct example_struct *esp); esp->z = (esp->x).*(esp->y); endp; struct example_struct es1; struct example_struct *es1p; es1p = &es1; es1.x = rndn(1000,100); es1.y = rndn(1000,1); product(es1p); In this case, the procedure modifies the structure es1, which es1p is pointing at, instead of a local copy of the structure. 16.3 Special Structures There are three common types of structures that will be found in the GAUSS Run-Time Library and applications.
Structures struct DS { scalar type; matrix dataMatrix; array dataArray; string dname; string array vnames; }; This structure was designed for use by the various optimization functions in GAUSS, in particular, sqpSolvemt, as well as a set of gradient procedures, gradmt, hessmt, et al. These procedures all require that the user provide a procedure computing a function (to be optimized or take the derivative of, etc.), which takes the DS structure as an argument.
GAUSS User Guide The various procedures in the Run-Time Library and applications for optimization, modelling, derivatives, etc., all require a parameter vector. Parameters in complex models, however, often come in matrices of various types, and it has been the responsibility of the programmer to generate the parameter vector from the matrices and vice versa. The PV procedures make this problem much more convenient to solve.
Structures garch = pvUnpack(p0, "garch"); arch = pvUnpack(p0, "arch"); omega = pvUnpack(p0, "omega"); p = rows(garch); q = rows(arch); u = d0.dataMatrix - b0; vc = moment(u,0)/rows(u); w = omega + (zeros(q,q) | shiftr((u.*ones(1,q))', seqa(q-1,-1,q))) * arch; h = recserar(w,vc*ones(p,1),garch); logl = -0.5 * ((u.*u)./h + ln(2*pi) + ln(h)); retp(logl); endp; Masked Matrices The pvUnpack function unpacks parameters into matrices or arrays for use in computations.
GAUSS User Guide Symmetric matrices are a special case because even if the entire matrix is to be estimated, only the nonredundant portion is to be put into the parameter vector. Thus, for them there are special procedures. For example: vc = { 1 .6 .4, .6 1 .2, .4 .2 1 }; p0 = pvPacks(p0,vc, "vc"); There is also a procedure for masking in case only a subset of the nonredundant elements are to be included in the parameter vector: vc = { 1 .6 .4, .6 1 .2, .4 .
Structures 16.3.3 Miscellaneous PV Procedures pvList This procedure generates a list of the matrices or arrays packed into the structure: p0 = pvPack(p0,b0, "b0"); p0 = pvPack(p0,garch, "garch"); p0 = pvPack(p0,arch, "arch"); p0 = pvPack(p0,omega, "omega"); print pvList(p0); b0 garch arch omega pvLength This procedure returns the length of the parameter vector: print pvLength(p0); 6.
GAUSS User Guide print pvGetParVector(p0); 1.0000 0.1000 0.1000 0.1000 0.1000 1.0000 pvPutParVector This procedure replaces the parameter vector with the one in the argument: newp = { 1.5, .2, .2, .3, .3, .8 }; p0 = pvPutParVector(newp,p0); print pvGetParVector(p0); 1.5000 0.2000 0.2000 0.3000 0.3000 0.8000 pvGetIndex This procedure returns the indices in the parameter vector of the parameters in a matrix. These indices are useful when setting linear constraints or bounds in sqpSolvemt.
Structures c0.bounds = ones(pvLength(par0),1).*(-1e250~1e250); // set bounds for lambda parameters to be positive c0.bounds[lind,1] = zeros(rows(lind),1); 16.3.4 Control Structures Another important class of structures is the "control" structure. Applications developed before structures were introduced into GAUSS typically handled some program specifications by the use of global variables which had some disadvantages, in particular, preventing the nesting of calls to procedures.
GAUSS User Guide matrix weights; }; The members of this structure determine optional behaviors of sqpSolvemt. 16.
Structures proc fct(struct PV p0, struct DS d0); local y, x, b0, b, e, s; y = d0[1].dataMatrix; x = d0[2].dataMatrix; b0 = pvUnpack(p0, "constant"); b = pvUnpack(p0, "coefficients"); e = y - b0 - x * b; s = sqrt(e'e/rows(e)); retp(-pdfn(e/s); endp; Note that this procedure returns a vector rather than a scalar. When the objective function is a properly defined log-likelihood, returning a vector of minus log-probabilities permits the calculation of a QML covariance matrix of the parameters.
GAUSS User Guide = Β, where p is a vector of the parameters. C MxK matrix, linear inequality constraint coefficients: CΘ = D, where p is a vector of the parameters. D Mx1 vector, linear inequality constraint constants: CΘ = D, where p is a vector of the parameters. eqProc scalar, pointer to a procedure that computes the nonlinear equality constraints.
Structures and DS structures, and one output argument, the derivatives. If the function procedure returns a scalar, the gradient procedure returns a 1xK row vector of derivatives. If function procedure turns an Nx1 vector, the gradient procedure returns an NxK matrix of derivatives. This procedure may compute a subset of the derivatives. sqpSolvemt will compute numerical derivatives for all those elements set to missing values in the return vector or matrix. Default = .; i.e.
GAUSS User Guide DirTol scalar, convergence tolerance for gradient of estimated coefficients. Default = 1e-5. When this criterion has been satisifed, sqpSolvemt exits the iterations. CovType scalar, if 2, QML covariance matrix, else if 0, no covariance matrix is computed, else ML covariance matrix is computed. For a QML covariance matrix, the objective function procedure must return an Nx1 vector of minus log-probabilities.
Structures PrintIters scalar, if nonzero, prints iteration information. Default = 0. weights vector, weights for objective function returning a vector. Default = 1. 16.4.2 Output Argument The single output argument is an sqpSolvemtOut structure.
GAUSS User Guide equality constraints lagr.nlineq Nx1 vector, Lagrangeans of nonlinear equality constraints lagr.linineq Px1 vector, Lagrangeans of linear inequality constraints lagr.nlinineq Qx1 vector, Lagrangeans of nonlinear inequality constraints lagr.bounds Kx2 matrix, Lagrangeans of bounds Whenever a constraint is active, its associated Lagrangean will be nonzero.
Structures 8 function complex 9 feasible direction couldn't be found 16.4.3 Example Define Y = Λη + Θ where Λ is a KxL matrix of loadings, η an Lx1 vector of unobserved "latent" variables, and Θ a Kx1 vector of unobserved errors. Then Σ = ΛΦΛ'Ψ where Φ is the LxL covariance matrix of the latent variables, and Ψ is the KxK covariance matrix of the errors. The log-likelihood of the ith observation is logP(i) = -½[Kln(2π) + ln| π | + Y(i)ΣY(i)'] Not all elements of Λ, Φ, and Ψ can be estimated.
GAUSS User Guide #include sqpsolvemt.sdf lambda = { 1.0 0.0, 0.5 0.0, 0.0 1.0, 0.0 0.5 }; lmask = { 0 0, 1 0, 0 0, 0 1 }; phi = { 1.0 0.3, 0.3 1.0 }; psi = { 0.6 0.0 0.0 0.0, 0.0 0.6 0.0 0.0, 0.0 0.0 0.6 0.0, 0.0 0.0 0.0 0.
Structures c0.bounds[lind,2] = 10*ones(rows(lind),1); c0.bounds[tind,1] = .001*ones(rows(tind),1); c0.bounds[tind,2] = 100*ones(rows(tind),1); c0.output = 1; c0.printIters = 1; c0.trustRadius = 1; c0.ineqProc = &ineq; c0.covType = 1; struct DS d0; d0 = dsCreate; d0.dataMatrix = loadd("maxfact"); output file = sqpfact.out reset; struct SQPsolveMTOut out0; out0 = SQPsolveMT(&lpr,par0,d0,c0); lambdahat = pvUnpack(out0.par, "lambda"); phihat = pvUnpack(out0.par, "phi"); psihat = pvUnpack(out0.
GAUSS User Guide psise = pvUnpack(stderr, "psi"); print "standard errors"; print; print "lambda" lambdase; print; print "phi" phise; print; print "psi" psise; endif; output off; proc lpr(struct PV par1, struct DS data1); local lambda,phi,psi,sigma,logl; lambda = pvUnpack(par1, "lambda"); phi = pvUnpack(par1, "phi"); psi = pvUnpack(par1, "psi"); sigma = lambda*phi*lambda' + psi; logl = -lnpdfmvn(data1.
17 Run-Time Library Structures Two structures are used by several GAUSSRun-Time Library functions for handling parameter vectors and data: the PV parameter structure and the DS data structure. 17.1 The PV Parameter Structure The members of an instance of structure of type PV are all "private," that is, not accessible directly to the user. It is designed to handle parameter vectors for thread-safe optimization functions.
GAUSS User Guide The pvCreate function initializes p1 to default values. pvPack enters the 4x3 matrix stored row-wise as a 12x1 parameter vector for the optimization function. The optimization program will pass the instance of the structure of type PV to your objective function. By calling pvUnpack your 4x3 coefficient matrix is retrieved from the parameter vector.
Run-Time Library Structures 1 0 }; p1 = pvPacksm(p1,cov, "correlation",mask); Here only the one element in the lower left of cov is stored in the parameter vector. Suppose the optimization program sends a trial value for that parameter of, say, .45. When the matrix is unpacked in your procedure it will contain the fixed values associated with the zeros in the mask as well as the trial value in that part of the matrix associated with the ones. Thus, print unpack(p1, "correlation"); 1.0000 .4500 .4500 1.
GAUSS User Guide 0 1 }; phi = { 1.0 0.3, 0.3 1.0 }; theta = { 0.6 0.0 0.0 0.0, 0.0 0.6 0.0 0.0, 0.0 0.0 0.6 0.0, 0.0 0.0 0.0 0.6 }; tmask = { 1 0 0 0, 0 1 0 0, 0 0 1 0, 0 0 0 1 }; struct PV par0; par0 = pvCreate; par0 = pvPackm(par0,lambda, "lambda",lmask); par0 = pvPacks(par0,phi, "phi"); par0 = pvPacksm(par0,theta, "theta",tmask); It isn't necessary to know where in the parameter vector the parameters are located in order to use them in your procedure calculating the objective function.
Run-Time Library Structures 1 0 }; p1 = pvPacksm(p1,cov, "correlation",mask); print pvGetParVector(p1); 0.5000 p1 = pvPutParVector(p1,.8); print pvGetParVector(p1); 0.8000 print pvUnpack(p1, "correlation"); 1.0000 .8000 0.8000 1.0000 print pvGetParNames(p1); correlation[2,1] print pvLength(p1); 1.0000 Also, pvTest tests an instance to make sure it is properly constructed.
GAUSS User Guide x = rndn(4,4); p1 = pvPacki(p1,y, "Y",1); p1 = pvPacki(p1,x, "X",2); print pvUnpack(p1,1); .3422 .0407 .5611 .0953 print pvUnpack(p1, "Y"); .3422 .0407 .5611 .0953 The call to pvPacki puts an entry in the table associating the matrix in its second argument with the index 1. As indicated above the matrix can be unpacked either by index or by name. Unpacking by index, however, is much faster than by name. Note that the matrix can be unpacked using either the index or the matrix name.
Run-Time Library Structures d0.type scalar d0.dname string d0.vnames string array The definition and use of the elements of d0 are determined by the particular application and are mostly up to the user. A typical use might use a vector of structures. For example, suppose the objective function requires a vector of observations on a dependent variable as well as on K independent variables. Then: struct DS d0; d0 = dsCreate; y = rndn(20,1); x = rndn(20,5); d0 = reshape(d0,2,1); d0[1].
GAUSS User Guide umns of the data stored in d0.dataMatrix, or d0.type could be an indicator variable for the elements of a vector of DS instances. The following are complete examples of the use of the PV and DS structures. The first example fits a set of data to the Micherlitz model. It illustrates packing and unpacking by index. #include sqpsolvemt.sdf struct DS Y; Y = dsCreate; Y.dataMatrix = 3.183| 3.059| 2.871| 2.622| 2.541| 2.184| 2.110| 2.075| 2.018| 1.903| 1.770| 1.762| 1.
Run-Time Library Structures c1.bounds = 0~100; positive c1.CovType = 1; c1.output = 1; c1.printIters = 0; c1.gradProc = &grad; // constrains parameters to be struct PV par1; par1 = pvCreate; start = { 2, 4, 2 }; par1 = pvPacki(par1,start, "Parameters",1); struct SQPsolveMTout out1; out1 = SQPsolveMT(&Micherlitz,par1,Z,c1); estimates = pvGetParVector(out1.par); print " parameter estimates "; print estimates; print; print " standard errors "; print sqrt(diag(out1.
GAUSS User Guide s2 = moment(e,0) / rows(e); e1 = -ones(rows(e),1); e2 = -w; e3 = p0[2]*Z[2].dataMatrix.*w; w =(1 - e.*e / s2) / rows(e); g = e.*e1 + w*(e'e1); g = g ~ (e.*e2 + w*(e'e2)); g = g ~ (e.*e3 + w*(e'e3)); retp(4*g/(rows(e)*s2)); endp; This example estimates parameters of a "confirmatory factor analysis" model. #include sqpsolvemt.sdf lambda = { 1.0 0.0, 0.5 0.0, 0.0 1.0, 0.0 0.5 }; lmask = { 0 0, 1 0, 0 0, 0 1 }; phi = { 1.0 0.3, 0.3 1.0 }; theta = { 0.6 0.0 0.0 0.0, 0.0 0.6 0.0 0.0, 0.0 0.0 0.
Run-Time Library Structures par0 = pvPacks(par0,phi, "phi"); par0 = pvPacksm(par0,theta, "theta",tmask); struct SQPsolveMTControl c0; c0 = sqpSolveMTcontrolCreate; lind = pvGetIndex(par0, "lambda"); // get indices of lambda parameters // in parameter vector tind = pvGetIndex(par0, "theta"); // get indices of theta parameters // in parameter vector c0.bounds = ones(pvLength(par0),1).*(-1e250~1e250); c0.bounds[lind,1] = zeros(rows(lind),1); c0.bounds[lind,2] = 10*ones(rows(lind),1); c0.bounds[tind,1] = .
GAUSS User Guide print "theta" thetahat; struct PV stderr; stderr = out0.par; if not scalmiss(out0.moment); stderr = pvPutParVector(stderr,sqrt(diag(out0.
Run-Time Library Structures e = e | eigh(phi) - .
18 Multi-Threaded Programming in GAUSS The term thread comes from the phrase "thread of execution"--simply, it denotes a section of code that you want to execute. A single-threaded program has only one thread of execution, i.e., the program itself. A multi-threaded program is one that can have multiple threads--sections of code--executing simultaneously. Since these threads are part of the same program, they share the same workspace, and see and operate on the same symbols.
GAUSS User Guide ThreadEnd Marks the end of a block of code to be executed as a thread. ThreadJoin Completes the definition of a set of threads, waits until they are done.
Multi-Threaded Programming ThreadBegin; y = x'x; z = y'y; ThreadEnd; ThreadBegin; q = r'r; r = q'q; ThreadEnd; ThreadStat n = m'm; ThreadStat p = o'o; ThreadJoin; b = z + r + n'p; // Thread 1 // Thread 2 // // // // Thread 3 Thread 4 waits for Threads 1-4 to finish Using the results 18.2 GAUSS Threading Concepts This is really the one and only thing you need to know about threads: threads are separate sections of the same program, executing simultaneously, operating on the same data.
GAUSS User Guide thread. No other thread in the set can reference that symbol. They cannot assign to it, nor can they read from it. They cannot refer to it at all. Note: the writer-must-isolate rule only applies to the threads within a given set (including any child thread sets they may create). It does not apply between thread sets that have no chance of running simultaneously. For threads defined in the main code, the writer-must-isolate rule applies to the global symbols.
Multi-Threaded Programming ThreadEnd; ThreadJoin; q = m'c; ThreadEnd; ThreadBegin; ThreadStat r = m'm; ThreadStat s = m + inv(b); ThreadJoin; t = r's; ThreadEnd; ThreadJoin; x = r+s+q+z-t; More importantly, you can do things like this: proc bef(x); local y,t; ThreadStat y = nof(x); ThreadStat t = dof(x'x); ThreadJoin; t = t+y; retp(t); endp; proc abr(m); local x,y,z,a,b; a = m'm; ThreadStat x = inv(m); ThreadStat y = bef(m); ThreadStat z = dne(a); ThreadJoin; b = chut(x,y,z,a); retp(inv(b)); endp; s = rndn
GAUSS User Guide ThreadStat q = abr(s^2); ThreadStat r = che(s); ThreadJoin; w = del(t,q,r); print w[1:10,1:10]; This means you can multi-thread anything you want, and call it from anywhere. You can multi-thread all the proc's and keyword's in your libraries, and call them freely anywhere in your multi-threaded programs. 18.4 Coding Restrictions A few points on coding restrictions. First, you can't interlace thread definition statements and regular statements.
Multi-Threaded Programming Each set of threads is defined as a group, and always completed by a ThreadJoin, like this: n = q; ThreadStat a = b'b; ThreadStat c = d'd; ThreadJoin; And this: ThreadBegin; if k == 1; a = b'b; elseif k == 2; a = c'c; endif; ThreadEnd; ThreadBegin; if j == 1; d = e'e; elseif j == 2; d = f'f; endif; ThreadEnd; ThreadJoin; Second--as stated above, you can reference read-only symbols in as many threads within a set as you like, but any symbols that are assigned to must be wholly o
GAUSS User Guide ThreadJoin; You cannot do this: ThreadStat x = y'y; Threadstat z = x'x; ThreadStat a = b-y; ThreadJoin; This is because the threads within a set run simultaneously. Thus, there is no way of knowing when an assignment to a symbol has taken place, no way of knowing in one thread the "state" of a symbol in another.
Multi-Threaded Programming ThreadJoin; x = r+s+q+z-t; // Joins Th1, Th2 The main point here is that any symbols a thread or its children assign to must be isolated from all the other threads (and their children) of the same nesting level in that set. On the other hand, the children of a thread can freely read/write symbols that are read/written by their parent, because there is no risk of simultaneity; they must only isolate written symbols from their siblings and siblings' offspring.
GAUSS User Guide ThreadJoin; z = fnc(x,y); save z; end; badidea: errorlog "Error computing fna(q)"; q = fnd(q); goto retry; Basically, don't do anything that will keep a thread from reaching its ThreadEnd command. That's the only way it knows its work is done. end and stop are okay to call, though--they will bring the program to an end as usual, and terminate all running threads in the process.
19 Libraries The GAUSS library system allows for the creation and maintenance of modular programs. The user can create "libraries" of frequently used functions that the GAUSS system will automatically find and compile whenever they are referenced in a program. 19.1 Autoloader The autoloader resolves references to procedures, keywords, matrices, and strings that are not defined in the program from which they are referenced.
GAUSS User Guide A left-hand side reference is usually a reference to a symbol on the left-hand side of the equal sign in an expression. x = 5; Left-hand side references, since they are assignments, are assumed to be matrices. In the statement above, x is assumed to be a matrix and the code is compiled accordingly. If, at execution time, the expression actually returns a string, the assignment is made and the type of the symbol x is forced to string. Some commands are implicit left-hand side assignments.
Libraries definition of the symbol must be in the main file or in one of the files that are #include'd. No global symbols are deleted automatically. If the autoloader is ON, GAUSS searches for unresolved symbol references during compilation using a specific search path as outlined below. If the autoloader is OFF, an Undefined symbol error message will result for right-hand side references to unknown symbols. When autoload is ON, the autodelete state controls the handling of references to unknown symbols.
GAUSS User Guide x = rndn(10,10); y = sym(x); // Forward reference to sym proc sym(x); retp(x+x'); endp; Use an external statement for anything referenced above its definition if autodelete is OFF: external proc sym; x = rndn(10,10); y = sym(x); proc sym(x); retp(x+x'); endp; When autodelete is OFF, symbols not found in an active library will not be added to the symbol table. This prevents the creation of uninitialized procedures in the global symbol table.
Libraries First, create the file that is to contain your desired procedure definitions. By convention, this file is usually named with a .src extension, but you may use any name and any file extension. In this file, put all the definitions of related procedures you wish to use. Here is an example of such a file. It is called norm.src: /* ** ** ** ** ** ** */ norm.src This is a file containing the definitions of three procedures which return the norm of a matrix x.
GAUSS User Guide fn user-defined single line function. keyword keyword. proc procedure. matrix matrix, numeric or character. array N-dimensional array. string string. sparse matrix sparse matrix. struct structure. A structure is always denoted by struct followed by the structure type name. If the symbol type is missing, the colon must not be present and the symbol type is assumed to be proc.
Libraries /* ** math ** ** This library lists files and procedures for mathematical routines. */ c:\gauss\src\norm.src onenorm : proc infnorm : proc Enorm : proc c:\gauss\src\complex.src cmmult : proc cmdiv : proc cmadd : proc cmsoln : proc c:\gauss\src\fcomp.src feq : proc fne : proc flt : proc fgt : proc fle : proc fge : proc c:\gauss\src\fcomp.dec _fcmptol : matrix Once the autoloader finds, via the library, the file containing your procedure definition, everything in that file will be compiled.
GAUSS User Guide lib user myfile.src This will update the user library by adding a reference to myfile.src. No user library is shipped with GAUSS. It will be created the first time you use the lib command to update it. For details on the parameters available with the lib command, see the GAUSS LANGUAGE REFERENCE. .g Files If autoload and autodelete are ON and a symbol is not found in a library, the autoloader will assume it is a procedure and look for a file that has the same name as the symbol and a .
Libraries sparse matrix empty sparse matrix structure 1x1 structure containing empty and/or zeroed out members In order to declare structures in a .dec file, you must #include the file(s) containing the definitions of the types of structures that you wish to declare at the top of your .dec file. For example, if you have the following structure type definition in a file called mystruct.
GAUSS User Guide /* ** fcomp.src ** ** These functions use _fcmptol to fuzz the comparison operations ** to allow for roundoff error. ** ** The statement: y = feq(a,b); ** ** is equivalent to: y = a eq b; ** ** Returns a scalar result, 1 (true) or 0 (false) ** ** y = feq(a,b); ** y = fne(a,b); */ #include fcomp.ext proc feq(a,b); retp(abs(a-b) <= _fcmptol); endp; proc fne(a,b); retp(abs(a-b) > _fcmptol); endp; .dec File: /* ** fcomp.dec - global declaration file for fuzzy comparisons.
Libraries */ external matrix _fcmptol; .lcg File: /* ** fcomp.lcg - fuzzy compare library */ fcomp.dec _fcmptol:matrix fcomp.src feq:proc fne:proc With the exception of the library (.lcg) files, these files must be located along your src_path. The library files must be on your lib_path. With these files in place, the autoloader will be able to find everything needed to run the following programs: library fcomp; x = rndn(3,3); xi = inv(x); xix = xi*x; if feq(xix, eye(3)); print "Inverse within tolerance.
GAUSS User Guide print "Inverse within tolerance."; else; print "Inverse not within tolerance."; endif; 19.3 Troubleshooting Below is a partial list of errors you may encounter in using the library system, followed by the most probable cause. (4) : error G0290 : '/gauss/lib/prt.lcg' : Library not found The autoloader is looking for a library file called prt.lcg, because it has been activated in a library statement.
Libraries /gauss/lib/prt.lcg(5) : error G0301 : 'prt.dec' : Syntax error in library Undefined symbols: __VNAMES /gauss/src/prt.src(6) Check your library to see that all filenames are flush left and that all the symbols defined in that file are indented by at least one space. 19.3.1 Using .dec Files Below is some advice you are encouraged to follow when constructing your own library system: l l Whenever possible, declare variables in a file that contains only declare statements.
GAUSS User Guide By following these guidelines, any declare warnings and redefinition errors you get will be meaningful. By knowing that such warnings and errors are significant, you will be able to debug your programs more efficiently.
20 The Library Tool Libraries are collections of GAUSS procedures that are grouped together. The GAUSS Library Tool makes it easy for users to create and manage GAUSS libraries. The Library Tool is available on the Source Page and may be opened from the application menu View->Library Tool. 20.
GAUSS User Guide Figure 20.1: Create new library At the top right corner of the Library Tool is a plus icon (+). Click this icon to create a new library. A file system window will open and ask you to enter a name for the library. Do not add a file extension as GAUSS will automatically add the correct file extension (.lcg).
The Library Tool Figure 20.2: File browser Once you have create a new empty library, you need to add some files. Click the wrench icon next to the library to which you would like to add a file and select 'Add Files' from the menu. This will open up a file browser window. Locate and select the file or files that you would like to add to the library.
GAUSS User Guide Figure 20.3: Add Files 20.2 Loading a Library Loading a library makes all of its procedures available in GAUSS. It also allows you to navigate to the definition of a procedure by clicking on the name of a procedure and using the hotkey CTRL+F1, or selecting 'Open function definition' from the source editor's context menu. To load the library, click the wrench icon and select 'Load Library' from the menu.
The Library Tool 20.3 Viewing Procedures Expanding the node of any library in the tree will reveal a list of the included files. Double-clicking on one of the file names will open that file a source editor. Loaded libraries have an additional expandable node for each file. Expand this node to view each procedure stored in that file. Double-click the procedure name to open the file at the location of that procedure. Figure 20.4: Library Tool Tree 20.
GAUSS User Guide requires a library refresh. To perform this action, click on the corresponding wrench icon and select 'Refresh'.
21 Compiler GAUSS allows you to compile your large, frequently used programs to a file that can be run over and over with no compile time. The compiled image is usually smaller than the uncompiled source. GAUSS is not a native code compiler; rather, it compiles to a form of pseudocode. The file will have a .gcg extension. The compile command will compile an entire program to a compiled file.
GAUSS User Guide 21.1.1 Compiling a File Source code program files that can be run with the run command can be compiled to .gcg files with the compile command: compile qxy.e; All procedures, global matrices, arrays, strings and string arrays, and the main program segment will be saved in the compiled file. The compiled file can be run later using the run command. Any libraries used in the program must be present and active during the compile, but not when the program is run.
Compiler 21.3 Debugging If you are using compiled code in a development situation in which debugging is important, compile the file with line number records. After the development is over, you can recompile without line number records if the maximum possible execution speed is important. If you want to guarantee that all procedures contain line number records, put a new statement at the top of your program and turn line number tracking on.
22 File I/O The following is a partial list of the I/O commands in the GAUSS programming language: close Close a file. closeall Close all open files. colsf Number of columns in a file. create Create GAUSS data set. eof Test for end of file. fcheckerr Check error status of a file. fclearerr Check error status of a file and clear error flag. fflush Flush a file's output buffer. fgets Read a line of text from a file. fgetsa Read multiple lines of text from a file.
GAUSS User Guide 22-2 fgetst Read a line of text from a file, discarding newline. fileinfo Return names and information of files matching a specification. files Return a directory listing as a character matrix. filesa Return a list of files matching a specification. fopen Open a file. fputs Write strings to a file. fputst Write strings to a file, appending newlines. fseek Reposition file pointer. fstrerror Get explanation of last file I/O error. ftell Get position of file pointer.
File I/O readr Read a specified number of rows from a file. rowsf Number of rows in file. save Save matrices, strings, procedures. saved Save a matrix in a GAUSS data set. seekr Reset read/write pointer in a data set. sortd Sort a data set. typef Return type of data set (bytes per element). writer Write data to a data set. 22.1 ASCII Files GAUSS has facilities for reading and writing ASCII files.
GAUSS User Guide load x[] = dat1.asc; will load the data in the file dat1.asc into an Nx1 matrix x. This method is preferred because rows(x) can be used to determine how many elements were actually loaded, and the matrix can be reshape'd to the desired form: load x[] = dat1.asc; if rows(x) eq 500; x = reshape(x,100,5); else; errorlog "Read Error"; end; endif; For quick interactive loading without error checking, use load x[100,5] = dat1.asc; This will load the data into a 100x5 matrix.
File I/O It is easy to forget to turn the window on again. Use the end statement to terminate your programs; end will automatically perform screen on and output off. The following commands can be used to control printing to the auxiliary output: format Specify format for printing a matrix. output Open, close, rename auxiliary output file or device. outwidth Set auxiliary output width. printfm Formatted matrix print. print Print matrix or string. screen Turn printing to the window on and off.
GAUSS User Guide open fp = mydata; do until eof(fp); print readr(fp,200);; endo; fp = close(fp); end; The output ... reset command will create an auxiliary output file called mydata.asc to receive the output. The window is turned off to speed up the process. The GAUSS data file mydata.dat is opened for reading and 200 rows are read per iteration until the end of the file is reached. The data read are printed to the auxiliary output mydata.asc only, because the window is off. 22.1.
File I/O endif; do until eof(fin); str = fgets(fin, 1024); if fputs(fout, str) /= 1; call close(fin); call close(fout); retp(3); endif; endo; call close(fin); call close(fout); retp(0); endp; 22.2 Data Sets GAUSS data sets are the preferred method of storing data contained in a single matrix for use within GAUSS. Use of these data sets allows extremely fast reading and writing of data. Many library functions are designed to read data from these data sets.
GAUSS User Guide Bytes Type Significant Digits 2 integer 4 4 single 6-7 8 double 15-16 Range −32768 <= X <= 32767 8.43E − 37 <= X <= 3.37E + 38 4.193E − 307 <= X <= 1.67E + 308 22.2.2 Creating Data Sets Data sets can be created with the create or datacreate command. The names of the columns, the type of data, etc., can be specified. (For details, see create in the GAUSS LANGUAGE REFERENCE.) Data sets, unlike matrices, cannot change from real to complex, or vice-versa.
File I/O The following example illustrates the creation of a GAUSS data file by merging (horizontally concatenating) two existing data sets: file1 = "dat1"; file2 = "dat2"; outfile = "daty"; open fin1 = ^file1 for read; open fin2 = ^file2 for read; varnames = getname(file1)|getname(file2); otyp = maxc(typef(fin1)|typef(fin2)); create fout = ^outfile with ^varnames,0,otyp; nr = 400; do until eof(fin1) or eof(fin2); y1 = readr(fin1,nr); y2 = readr(fin2,nr); r = maxc(rows(y1)|rows(y2)); y = y1[1:r,.
GAUSS User Guide 22.2.4 Distinguishing Character and Numeric Data Although GAUSS itself does not distinguish between numeric and character columns in a matrix or data set, some of the GAUSS Application programs do. When creating a data set, it is important to indicate the type of data in the various columns. The following discusses two ways of doing this.
File I/O Sex Age Pay 0 1 1 The call to getnamef in this example returns a string array rather than a character vector, so you can print it without the '$' prefix. Using the Uppercase/Lowercase Convention (v89 Data Sets) Historically, some GAUSS Application programs recognized an "uppercase/lowercase" convention: if the variable name was uppercase, the variable was assumed to be numeric, and if it was lowercase, the variable was assumed to be character.
GAUSS User Guide To write variables to the GDA, you must call gdaWrite. A single call to gdaWrite writes only one variable to the GDA. Writing multiple variables requires multiple calls to gdaWrite. For example, the following code: ret ret ret ret = = = = gdaCreate("myfile.gda",1); gdaWrite("myfile.gda",rndn(100,50), "x1"); gdaWrite("myfile.gda", "This is a string", "str1"); gdaWrite("myfile.
File I/O sparse matrix gdaReadSparse structure gdaReadStruct gdaRead, gdaReadSparse, and gdaReadStruct take a variable name and return the variable data. gdaReadByIndex returns the variable data for a specified variable index. For example, to get the variable x1 out of myfile.gda, you could call: y = gdaRead("myfile.gda", "x1"); or y = gdaReadByIndex("myfile.gda",1); If you want to read only a part of a matrix, array, string, or string array from a GDA, call gdaReadSome.
GAUSS User Guide On the other hand, gdaUpdateAndPack uses disk space efficiently, but it may be slow for large files (especially if the variable to be updated is one of the first variables in the file). If speed and disk space are both concerns and you are going to update several variables, it will be most efficient to use gdaUpdate to update the variables and then call gdaPack once at the end to pack the file. The syntax is the same for both gdaUpdate and gdaUpdateAndPack: ret = gdaUpdate("myfile.
File I/O memory. seekr and readr can be used to jump to particular rows and to read them into memory. This is useful when only a subset of rows is needed at any time. This procedure will save memory and be much faster than load'ing the entire matrix into memory. 22.5 File Formats This section discusses the GAUSS binary file formats. There are four currently supported matrix file formats: Version Extension Support Small Matrix v89 .fmt Obsolete, use v96. Extended Matrix v89 .fmt Obsolete, use v96.
GAUSS User Guide Version Extension Support Small Data Set v89 .dat, .dht Obsolete, use v96. Extended Data Set v89 .dat, .dht Obsolete, use v96. Data Set v92 .dat Obsolete, use v96. Universal Data Set v96 .dat Supported for read/write. 22.5.1 Small Matrix v89 (Obsolete) Matrix files are binary files, and cannot be read with a text editor. They are created with save. Matrix files with up to 8190 elements have a .
File I/O The body of the file starts at offset 16 and consists of IEEE format double precision floating point numbers or character elements of up to 8 characters. Character elements take up 8 bytes and are padded on the right with zeros. The size of the body of the file is 8*rows*cols rounded up to the next 16-byte paragraph boundary. Numbers are stored row by row.
GAUSS User Guide 8-11 columns, unsigned 4-byte integer 12-15 size of file minus 16-byte header, unsigned 4-byte integer The size of the body of an extended matrix file is 8*rows*cols (not rounded up to a paragraph boundary). Aside from this, the body is the same as the small matrix v89 file. 22.5.3 Small String v89 (Obsolete) String files are created with save.
File I/O 22.5.4 Extended String v89 (Obsolete) Strings with more than 65519 characters are saved in an extended format. These files have a 16-byte header formatted as follows: Offset Description 0-1 EEDF hex, identification flag 2-3 001D hex, type of file 4-7 1, unsigned 4-byte integer 8-11 length of string plus null byte, unsigned 4-byte integer 12-15 size of file minus 16-byte header, unsigned 4-byte integer The body of the file starts at offset 16.
GAUSS User Guide The .dht file is used in conjunction with the .dat file as a descriptor file and as a place to store names for the columns in the .dat file. Data sets with up to 8175 columns have a .dht file formatted as follows: Offset Description 0-1 DADA hex, identification flag 2-5 reserved, all 0's 6-7 columns, unsigned 2-byte integer 8-9 row size in bytes, unsigned 2-byte integer 10-11 header size in bytes, unsigned 2-byte integer 12-13 data type in .
File I/O GAUSS currently examines only the 4's bit of the control flags. This bit is set to 0 for real data sets, 1 for complex data sets. All other bits are 0. Data sets are always stored a row at a time. A real data set with 2 rows and 3 columns will be stored on disk in the following way, from the lowest addressed element to the highest addressed element: [1, 1] [1, 2] [1, 3] [2, 1] [2, 2] [2, 3] The rows of a complex data set are stored with the real and imaginary parts interleaved, element by element.
GAUSS User Guide 12-15 row size in bytes, unsigned 4-byte integer 16-19 header size in bytes, unsigned 4-byte integer 20-23 reserved, all 0's 24-27 reserved, all 0's 28-29 control flags, unsigned 2-byte integer 30-127 reserved, all 0's Aside from the differences in the descriptor file and the number of columns allowed in the data file, extended data sets conform to the v89 data set description specified above. 22.5.
File I/O 0 - scalar 1 - row vector 2 - column vector, matrix 28-31 header size, 128 + number of dimensions * 4, padded to 8-byte boundary 32-127 reserved If the data is a scalar, the data will directly follow the header. If the data is a row vector, an unsigned integer equaling the number of columns in the vector will precede the data, along with 4 padding bytes. If the data is a column vector or a matrix, there will be two unsigned integers preceding the data.
GAUSS User Guide 16-19 reserved 20-23 size of string in units of 8 bytes 24-27 length of string plus null terminator in bytes 28-127 reserved The size of the data area is always divisible by 8, and is padded with nulls if the length of the string is not evenly divisible by 8. If the length of the string is evenly divisible by 8, the data area will be the length of the string plus 8. The data area follows immediately after the 128-byte header. 22.5.
File I/O 32-35 type of data in data set, 2, 4, or 8 36-39 header size in bytes is 128 + columns * 9 40-127 reserved The variable names begin at offset 128 and are stored 8 bytes each in ASCII format. Each name corresponds to one column of data. Names less than 8 characters are padded on the right with bytes of zero. The variable type flags immediately follow the variable names. They are 1-byte binary integers, one per column, padded to an even 8-byte boundary.
GAUSS User Guide 24-27 0xFFFFFFFF for forward bit order, 0 for backward bit order 28-31 always 0xABCDEF01 32-35 currently 1 36-39 reserved 40-43 floating point type, 1 for IEEE 754 44-47 1008 (double precision data) 48-51 8, the size in bytes of a double matrix 52-55 0 - real matrix, 1 - complex matrix 56-59 1 - imaginary part of matrix follows real part (standard GAUSS style) 2 - imaginary part of each element immediately follows real part (FORTRAN style) 60-63 number of dimensions 0 -
File I/O If the data is a scalar, the data will directly follow the header. If the data is a row vector, an unsigned integer equaling the number of columns in the vector will precede the data, along with 4 padding bytes. If the data is a column vector or a matrix, there will be two unsigned integers preceding the data. The first will represent the number of rows in the matrix and the second will represent the number of columns. The data area always begins on an even 8-byte boundary.
GAUSS User Guide 36-39 reserved 40-43 floating point type, 1 for IEEE 754 44-47 12 - signed 2-byte integer 1004 - single precision floating point 1008 - double precision float 48-51 2, 4, or 8, the size of an element in bytes 52-55 0 - real matrix, 1 - complex matrix 56-59 1 - imaginary part of matrix follows real part (standard GAUSS style) 2 - imaginary part of each element immediately follows real part (FORTRAN style) 60-63 always 2 64-67 1 for row major ordering of elements, 2 for column
File I/O The variable names begin at offset 128 and are stored 32 bytes each in ASCII format. Each name corresponds to one column of data. Names less than 32 characters are padded on the right with bytes of zero. The variable type flags immediately follow the variable names. They are 1-byte binary integers, one per column, padded to an even 8-byte boundary. A 1 indicates a numeric variable and a 0 indicates a character variable. Contents of the data set follow the header and start on an 8-byte boundary.
GAUSS User Guide 24-27 32-bit unsigned integer always 0 28-31 32-bit unsigned integer always 0xABCDEF08 32-35 32-bit unsigned integer version, currently 1 36-39 32-bit unsigned integer reserved 40-43 32-bit unsigned integer floating point type, 1 for IEEE 754 44-55 32-bit unsigned integers reserved 56-63 64-bit unsigned integer number of variables 64-67 32-bit unsigned integer header size, 128 68-95 32-bit unsigned integers reserved 96-103 64-bit unsigned integer offset of vari
File I/O data len size_t length of element data, including null-terminating byte On a 32-bit machine, a size_t is 4 bytes. On a 64-bit machine, it is 8 bytes. Arrays are written with the orders (sizes) of each dimension followed by the array data.
GAUSS User Guide Offset Type Description 0-3 32-bit unsigned integer variable type 4-7 32-bit unsigned integer data type, 10 for 8 byte floating point 8-11 32-bit unsigned integer dimensions, used only for arrays 12-15 32-bit unsigned integer complex flag, 1 for real data, 0 for complex 16-19 32-bit unsigned integer size of pointer, indicates whether the variable was written on a 32-bit or 64-bit platform 20-23 32-bit unsigned integer huge flag, indicates whether the variable is larger
File I/O The variable type (bytes 0-3) may be any of the following: 20 array 30 matrix 40 string 50 string array The size of pointer element (bytes 16-19) is the size of a pointer on the machine on which the variable was written to the GDA. It will be set to 4 on 32-bit machines and 8 on 64-bit machines. This element is used only for string array variables.
23 Foreign Language Interface The Foreign Language Interface (FLI) allows users to create functions written in C, FORTRAN, or other languages, and call them from a GAUSS program. The functions are placed in dynamic libraries (DLLs, also known as shared libraries or shared objects) and linked in at run-time as needed. The FLI functions are: dlibrary Link and unlink dynamic libraries at run-time. dllcall Call functions located in dynamic libraries.
GAUSS User Guide the double pointer to a char pointer inside the function. 2. Take those arguments either in a list or a vector. 3. Return an integer. In C syntax, then, your functions would take one of the following forms: 1. int func(void); 2. int func(double *arg1 [, double *arg2,...]); 3. int func(double *arg[]); Functions can be written to take a list of up to 100 arguments, or a vector (in C terms, a 1-dimensional array) of up to 1000 arguments.
Foreign Language Interface static int hypo(double *x, double *y, double *h, int r, int c) { double *wx; double *wy; double *dp; double *sp1; double *sp2; int i, elems; elems = r*c; // malloc work arrays if ((wx =(double *)malloc(elems*sizeof(double))) == NULL) return 30; // out of memory if ((wy =(double *)malloc(elems*sizeof(double))) == NULL) { free(wx); return 30; // out of memory } dp = wx; sp1 = x; // square x into work area wx for (i=0; i
GAUSS User Guide sp2 = y; // square y into work area wy for (i=0; i
Foreign Language Interface return hypo( x, y, h, (int)*r, (int)*c); } The following Makefiles contain the compile and link commands you would use to build the dynamic library on various platforms. For explanations of the various flags used, see the documentation for your compiler and linker. Windows hyp.dll: hyp.obj link /dll /out:hyp.dll hyp.obj hyp.obj: hyp.c cl -c -MD -GX hyp.c Solaris $(CCOPTS) indicates any optional compilation flags you might add. CCOPTIONS = -g -xsb -xarch=v9 -KPIC CC = cc libhyp.
24 Data Transformations GAUSS allows expressions that directly reference variables (columns) of a data set. This is done within the context of a data loop: dataloop infile outfile; drop wagefac wqlec shordelt foobly; csed = ln(sqrt(csed)); select csed > 0.
GAUSS User Guide code Create variable based on a set of logical expressions. delete Delete rows (observations) based on a logical expression. drop Specify variables NOT to be written to data set. extern Allow access to matrices and strings in memory. keep Specify variables to be written to output data set. lag Lag variables a number of periods. listwise Control deletion of missing values. make Create new variable. outtyp Specify output file precision.
Data Transformations preceded by a '#' are passed through to the temporary file without modification. The user familiar with the code generated in the temporary file can use this to do out-of-the-ordinary operations inside the data loop. 24.3 Debugging Data Loops The translator that processes data loops can be turned on and off. When the translator is on, there are three distinct phases in running a program: Translation Translation of main program file to temporary file.
GAUSS User Guide 24.3.3 Execution Phase In the execution phase, the compiled program is executed. Depending on the status of line number tracking, error messages will include line number references from both the main file and the temporary file. 24.
25 The GAUSS Profiler GAUSS includes a profiler, which enables you to determine exactly how much time your programs are spending on each line and in each called procedure, thereby providing you with the information you need to increase the efficiency of your programs. The GAUSS Profiler (gaussprof)and tcollect are both run from a command prompt window, not at a GAUSS prompt. 25.1 Using the GAUSSProfiler There are two steps to using the GAUSS Profiler: collection and analysis. 25.1.
GAUSS User Guide Note that running tcollect on long programs may generate a very large .gco output file. Thus you may want to delete the .gco files on your machine regularly. 25.1.2 Analysis To analyze the information stored in the tcollect output file, you must run the gaussprof executable, which is also shipped with GAUSS, on that file. gaussprof produces an organized report, displaying the time usage by procedure and by line. Assuming that running myfile.
The GAUSS Profiler a ascending order d descending order (default) Columns are sorted all ascending or all descending. -sl order line number sort order where order contains one or more of the following: t time spent on line c number of times line was executed f file name l line number a ascending order d descending order (default) Columns are sorted all ascending or all descending. The default, with no flags, is: -pl -sp dep -sl dtf.
26 Time and Date GAUSS offers a comprehensive set of time and date functions. These functions afford the user the ability to return the current time and date, to carry out most related calculations and format the results for output. GAUSS also allows the user to perform timed iterations. In the year 1 AD the calendar in general use was the Julian calendar. The Gregorian calendar that we use today was not invented until the late 1500's.
GAUSS User Guide 26.1 Time and Date Formats The Time and Date formats in GAUSS fall into one of two major categories, matrix/vector and string. The matrix/vector formats can be used for either calculations or if desired for output. The string formats are, however, mostly for use as ouput. Some manipulation of strings is possible with the use of the stof function. A 4x1 vector is returned by both the date and time functions. d = date; d; 1997.00 5.00000 29.0000 56.4700 t = time; t; 10.00 // 17.00 // 33.
Time and Date A list and brief description of these, and other related functions is provided in the table in Section 24.2 . Another major matrix/vector format is the dtv, or date and time vector. The dtv vector is a 1x8 vector used with the dtvnormal and utctodtv functions. The format for the dtv vector is: Year Month Day Hour Min Sec DoW DiY 1955 4 21 4 16 0 4 110 Where: Year Year, four digit integer. Month 1-12, Month in year. Day 1-31, Day of month. Hour 0-23, Hours since midnight.
GAUSS User Guide 1954 3 17 4 16 0 3 75 dtv[3] = dtv[3] + 400; print dtv; 1954 3 417 4 16 0 3 75 dtv = dtvnormal(dtv); print dtv; 1955 4 21 4 16 0 4 110 26.2 Time and Date Functions Following is a partial listing of the time and date functions available in GAUSS. 26-4 datestr Formats a Date vector to a string (mo/dy/yr). datestrymd Formats a Date vector to an eight character string of the type yyyymmdd. dayinyr Returns day number in the year of a given date.
Time and Date ethsec Computes the difference between two times in hundredths of a second. etstr Formats a time difference measured in hundreths of a second to a string. _isleap Returns a vector of ones and zeros, 1 if leap year 0 if not. timestr Formats a Time vector to a string hr:mn:sc. timeutc Universal time coordinate, number of seconds since January 1, 1970 Greenwich Mean Time. utctodtv Converts a scalar, number of seconds since, or before, Jan 1 1970 Greenwich mean time, to a dtv vector.
GAUSS User Guide d2 = { 1997, 4, 28, 4248879.3 }; dif = etdays(d1,d2); dif = 130.00000 The last element of d1 is optional when used as an input for etdays. _isleap returns a matrix of ones and zeros, ones when the corresponding year is a leap year. x = seqa(1970,1,20); y = _isleap(x); delif(x,abs(y-1)); 1972.0000 // Vector containing all leap years 1976.0000 // between 1970 - 1989 1980.0000 1984.0000 1988.
Time and Date 26.2.1 Timed Iterations Iterations of a program can be timed with the use of the hsec function in the following manner. et = hsec; // Start timer /* Segment of code to be timed */ et =(hsec-et)/100; // Stop timer, convert to seconds In the case of a program running from one day into the next you would need to replace the hsec function with the date function.
27 ATOG ATOG is a stand-alone conversion utility that converts ASCII files into GAUSS data sets. ATOG can convert delimited and packed ASCII files into GAUSS data sets. ATOG can be run from a batch file or the command line; it is not run from a GAUSS prompt but rather from a command prompt window. The syntax is: atog cmdfile where cmdfile is the name of the command file. If no extension is given, .cmd will be assumed. If no command file is specified, a command summary will be displayed. 27.
GAUSS User Guide msym Specify missing value character. nocheck Don't check data type or record length. output The name of the GAUSS data set to be created. outtyp Output data type. outvar List of variables to be included in output file. preservecase Preserve case of variable names in output file. The principle commands for converting an ASCII file that is delimited with spaces or commas are given in the following example: input agex.
ATOG The output file will have four columns since the first column of the input file (race) is not included in the output variables. The columns of the output file are: column name data type 1 region character 2 AGE numeric 3 sex character 4 PAY numeric The variable names are saved in the file header. Unless preservecase has been specified, the names of character variables will be saved in lowercase, and the names of numeric variables will be saved in uppercase.
GAUSS User Guide complex; Complex GAUSS data sets are stored by rows, with the real and imaginary parts interleaved, element by element. ATOG assumes the same structure for the ASCII input file, and will thus read TWO numbers out for EACH variable specified. complex cannot be used with packed ASCII files. input Specifies the file name of the ASCII file to be converted. The full path name can be used in the file specification. For example, the command: input data.
ATOG column name data type 1 AGE numeric 2 name character 3 sex character 4 PAY numeric 5 VAR01 numeric 6 VAR02 numeric 7 VAR03 numeric 8 VAR04 numeric 9 VAR05 numeric 10 VAR06 numeric 11 VAR07 numeric 12 VAR08 numeric 13 VAR09 numeric 14 VAR10 numeric 15 X001 numeric 16 X002 numeric 27-5
GAUSS User Guide 17 X003 numeric 18 X004 numeric 19 X005 numeric As the input file is translated, the first 19 elements will be interpreted as the first row (observation), the next 19 will be interpreted as the second row, and so on. If the number of elements in the file is not evenly divisible by 19, the final incomplete row will be dropped and a warning message will be given. Hard Delimited ASCII Files Hard delimited files have a printable character as a delimiter between elements.
ATOG invar delimit(,) $ name # var[5]; or invar delimit $ name # var[5]; will expect a file like this: BILL , 222.3, 123.2, 456.4, 345.2, 533.2, STEVE, 624.3, 340.3, , 624.3, 639.5, TOM , 244.2, 834.3, 602.3, 333.4, 822.5 The difference between specifying N or N-1 delimiters can be seen here: 456.4, 345.2, 533.2, , 624.3, 639.5, 602.3, 333.
GAUSS User Guide BILL,222.3,123.2,456.4,345.2,533.2, STEVE,624.3,340.3,,624.3,639.5, TOM,244.2,834.3,602.3,333.4,822.5 would work just as well. Linefeeds are significant only if \n is specified as the delimiter, or when using \r. This example: invar delimit(\r) $ name # var[5]; will expect a file with no comma after the final element in each row: BILL , 222.3, 123.2, 456.4, 345.2, 533.2 STEVE, 624.3, 340.3, 245.3, 624.3, 639.5 TOM , 244.2, 834.3, 602.3, 333.4, 822.
ATOG start starting position of the field in the record, 1 is the first position. The default is 1. length the length of the field in bytes. The default is 8. precoptional; a decimal point will be inserted automatically prec places in from the RIGHT edge of the field. If several variables are listed after a format definition, each succeeding field will be assumed to start immediately after the preceding field.
GAUSS User Guide variable value type group ABC character dept DEF character X1 12.34 numeric X2 56.78 numeric X3 90.12 numeric Y 34567 numeric This example: invar record=32 $ dept (*,2) id # (*,5) wage (*,2) area will result in: variable value type dept ABCDEFGH character id IJ character WAGE 12345 numeric AREA 67 numeric msym Specifies the character in the input file that is to be interpreted as a missing value.
ATOG msym &; defines the character '&' as the missing value character. The default '.' (dot) will always be interpreted as a missing value unless it is part of a numeric value. nocheck Optional; suppresses automatic checking of packed ASCII record length and output data type.
GAUSS User Guide Bytes Type Significant Digits Range −32768 <= X <= 32767 2 integer 4 4 single 6-7 8 double 15-16 8.43E − 37 <= X <= 3.37E + 38 4.193E − 307 <= X <= 1.67E + 308 If the output type is integer, the input numbers will be truncated to integers. If your data has more than 6 or 7 significant digits, specify outtyp as double. Character data require outtyp d.
ATOG 4 X003 numeric 5 VAR01 numeric 6 VAR02 numeric 7 VAR03 numeric 8 VAR04 numeric 9 VAR05 numeric 10 VAR06 numeric 11 VAR07 numeric 12 VAR08 numeric outvar is not used with packed ASCII files. preservecase Optional; preserves the case of variable names. The default is nopreservcase, which will force variable names for numeric variables to upper case and character variables to lower case. 27.3 Examples Example 1 The first example is a soft delimited ASCII file called agex1.asc.
GAUSS User Guide input /gauss/agex1.asc; output agex1; invar $month #temp pres vol $true var[02]; outvar month true temp pres vol; The output data set will contain the following information: name case 1 case 2 case 3 type month Jan Feb Mar char true yes no yes char TEMP 167.3 165.8 165.3 numeric PRES 822.4 987.3 842.3 numeric VOL 6.34e+6 5.63e+6 7.34e+6 numeric The data set is double precision since character data is explicitly specified. Example 2 The second example is a packed ASCII file xlod.
ATOG case 3 GWD NAD MST y 59725 type char char char char numeric The data set is double precision since character data is explicitly specified. Example 3 The third example is a hard delimited ASCII file called cplx.asc. The file contains six columns of ASCII data: 456.4, 345.2, 533.2, -345.5, 524.5, 935.3, -257.6, 624.3, 639.5, 826.5, 331.4, 376.4, 602.3, -333.4, 342.1, 816.7, -452.6, -690.8 The ATOG command file is cplx.cmd: input /gauss/cplx.
GAUSS User Guide 27.4 Error Messages atog - Can't find input file The ASCII input file could not be opened. atog - Can't open output file The output file could not be opened. atog - Can't open temporary file Notify Aptech Systems. atog - Can't read temporary file Notify Aptech Systems. atog - Character data in output file Setting output file to double precision The output file contains character data. The type was set to double precision automatically.
ATOG atog - Illegal command An unrecognizable command was found in a command file. atog - Internal error Notify Aptech Systems. atog - Invalid delimiter The delimiter following the backslash is not supported. atog - Invalid output type Output type must be I, F, or D. atog - Missing value symbol not found No missing value was specified in an msym statement. atog - No Input file No ASCII input file was specified. The input command may be missing.
GAUSS User Guide The command file has a comment that is not closed. Comments must be enclosed in @'s: @ comment @ atog - Out of memory Notify Aptech Systems. atog - read error A read error has occurred while converting a packed ASCII file. atog - Record length must be 1-16384 bytes The record subcommand has an out of range record length. atog - Statement too long Command file statements must be less than 16384 bytes. atog - Syntax error at: There is unrecognizable syntax in a command file.
ATOG A variable requested in an outvar statement was not listed in an invar statement. atog WARNING: missing ')' at: The parentheses in the delimit subcommand were not closed. atog WARNING: some records begin with cr/lf A packed ASCII file has some records that begin with a carriage return/linefeed. The record length may be wrong. atog - complex illegal for packed ASCII file. A complex command was encountered following an invar command with record specified. atog - Cannot read packed ASCII.
28 Error Messages The following is a list of error messages intrinsic to the GAUSS programming language. Error messages generated by library functions are not included here. G0002 File too large G0003 Indexing a matrix as a vector A single index can be used only on vectors. Vectors have only one row or only one column. G0004 Compiler stack overflow - too complex An expression is too complex. Break it into smaller pieces. Notify Aptech Systems.
GAUSS User Guide missing on previous statement. create Unrecognizable statement in command file, or numvar or outvar statement error. G0009 Compiler pass out of memory Compiler pass has run out of memory. Notify Aptech Systems. G0010 Can't open output file G0011 Compiled file must have correct extension GAUSS requires a .gcg extension. G0012 Invalid drive specifier G0013 Invalid filename G0014 File not found G0015 Directory full G0016 Too many #include's #include'd files are nested too deep.
Error Messages G0021 use must be at the beginning of a program G0022 User keyword cannot be used in expression G0023 Illegal attempt to redefine symbol to an index variable G0024 Invalid use of ->, probably should be . G0025 Undefined symbol A symbol has been referenced that has not been given a definition. G0026 Too many symbols The global symbol table is full. (To set the limit, see new in the GAUSS LANGUAGE REFERENCE.
GAUSS User Guide G0034 Missing arguments G0035 Argument too large G0036 Matrices are not conformable For a description of the function or operator being used and conformability rules, see Matrix Operators, Section 10.2 , or the GAUSS LANGUAGE REFERENCE MANUAL. G0037 Result too large The size of the result of an expression is greater than the limit for a single matrix.
Error Messages G0048 Matrix singular The matrix is singular using the current tolerance. G0049 Target matrix not complex G0050 Out of memory for program The main program area is full. (To increase the main program space, see new in the GAUSS LANGUAGE REFERENCE.) G0051 Program too large The main program area is full. (To increase the main program space, see new in the GAUSS LANGUAGE REFERENCE.
GAUSS User Guide You have referenced a matrix element that is out of bounds for the matrix being referenced. G0059 exec command string too long G0060 Nonscalar index G0061 Cholesky downdate failed G0062 Zero pivot encountered crout The Crout algorithm has encountered a diagonal element equal to 0. Use croutp instead. G0063 Operator missing An expression contains two consecutive operands with no intervening operator.
Error Messages You are using an argument of the wrong data type (e.g., inputting a matrix when a string is called for). G0072 Too many files open The limit on simultaneously open files is 10. G0073 Redefinition of declare An attempt has been made to initialize a variable that is already initialized. This is an error when declare := is used. declare != or declare ?= may be a better choice for your application. declare An attempt has been made to redefine a string as a matrix or procedure, or vice versa.
GAUSS User Guide G0078 vargetl outside of procedure G0079 varputl outside of procedure G0080 File handle must be an integer G0081 Error renaming file G0082 Error reading file G0083 Error creating temporary file G0084 Too many locals A procedure has too many local variables. G0085 Invalid file type You cannot use this kind of file in this way. G0086 Error deleting file G0087 Couldn't open The auxiliary output file could not be opened. Check the file name and make sure there is room on the disk.
Error Messages G0093 Locate off screen G0094 Argument out of range G0095 Seed out of range G0096 Error parsing string parse encountered a token that was too long. G0097 String not closed A string must have double quotes at both ends. G0098 Invalid character for imaginary part of complex number G0099 Illegal redefinition of user keyword G0100 Internal E R R O R ### Notify Aptech Systems. G0101 Argument cannot be zero The argument to ln or log cannot be zero.
GAUSS User Guide G0106 Factorial overflow G0107 Nesting too deep Break the expression into smaller statements. G0108 Missing left bracket [ G0109 Not enough data items You omitted data in a let statement. G0110 Found ) expected ] G0111 Found ] expected ) G0112 Matrix multiplication overflow G0113 Unclosed ( G0114 Unclosed [ G0115 Illegal redefinition of function You are attempting to turn a function into a matrix or string. If this is a name conflict, delete the function.
Error Messages G0122 Bad file handle The file handle does not refer to an open file or is not in the valid range for file handles. G0123 File handle not open The file handle does not refer to an open file. G0124 readr call too large You are attempting to read too much in one call. G0125 Read past end of file You have already reached the end of the file.
GAUSS User Guide You have an assignment operator (=) where you want a comparison operator (==), or you have too many arguments. G0137 Negative argument - erf or erfc G0138 User keyword must have one argument G0139 Negative parameter - Incomplete Beta G0140 Invalid second parameter - Incomplete Beta G0141 Invalid third parameter - Incomplete Beta G0142 Nonpositive parameter - gamma G0143 NaN or missing value - cdfchic G0144 Negative parameter - cdfchic G0145 Second parameter < 1.
Error Messages G0153 Unsuccessful close on auxiliary output The disk may be full. G0154 Illegal redefinition of string G0155 Nested procedure definition A proc statement was encountered inside a procedure definition. G0156 Illegal redefinition of procedure You are attempting to turn a procedure into a matrix or string. If this is a name conflict, delete the procedure. G0157 Illegal redefinition of matrix G0158 endp without proc You are attempting to end a procedure that you never started.
GAUSS User Guide The maximum length for character elements is 8 characters. G0167 Argument must be column vector G0168 Wrong number of returns The procedure was defined to return a different number of items. G0169 Invalid pointer You are attempting to call a local procedure using an invalid procedure pointer. G0170 Invalid use of ampersand G0171 Called symbol is wrong type You are attempting to call a local procedure using a pointer to something else.
Error Messages G0181 Illegal assignment - type mismatch G0182 2nd and 3rd arguments different order G0274 Invalid parameter for conv G0275 Parameter is NaN (Not A Number) The argument is a NaN (see Special Data Types, Section 9.6.9 ). G0276 Illegal use of reserved word G0277 Null string illegal here G0278 proc without endp You must terminate a procedure definition with an endp statement.
GAUSS User Guide G0293 Procedure has no definition The procedure was not initialized. Define it. G0294 Error opening temporary file One of the temporary files could not be opened. The directory may be full. G0295 Error writing temporary file One of the temporary files could not be written to. The disk may be full.
Error Messages G0352 Warning: Reinitializing : declare != The symbol is already initialized. It will be reset. G0355 Wrong size line matrix G0360 Write error G0364 Paging error G0365 Unsupported executable file type G0368 Unable to allocate translation space G0369 Unable to allocate buffer G0370 Syntax Error in code statement G0371 Syntax Error in recode statement G0372 Token verify error Notify Aptech Systems.
GAUSS User Guide G0381 vector Variable is a Number G0382 vector Variable is Procedure G0383 Cannot vector Existing Variable G0384 Cannot vector External Variable G0385 Cannot vector String Constant G0386 Invalid extern statement G0387 Cannot extern number G0388 Procedures always external A procedure name has been declared in an extern statement. This is a warning only. G0389 extern variable already local A variable declared in an extern statement has already been assigned local status.
Error Messages G0398 recode Variable is a Number G0399 recode Variable is Procedure G0400 Cannot recode External Variable G0401 Cannot recode String Constant G0402 Invalid keep statement G0403 Invalid drop statement G0404 Cannot define Number G0405 Cannot define String G0406 Invalid select statement G0407 Invalid delete statement G0408 Invalid outtyp statement G0409 outtyp already defaulted to 8 Character data has been found in the output data set before an outtyp 2 or outtyp 4 statement.
GAUSS User Guide G0414 Invalid listwise statement G0415 Invalid lag statement G0416 lag variable is a number G0417 lag variable is a procedure G0418 Cannot lag External Variable G0419 Cannot lag String Constant G0421 Command not supported in Run-Time Module G0428 Cannot use debug command inside program G0429 Invalid number of subdiagonals G0431 Error closing dynamic library G0432 Error opening dynamic library G0433 Cannot find DLL function G0434 Error opening default dynamic library G0435 Invalid mode G043
Error Messages G0442 No type vector in gfblock G0445 Illegal left-hand side reference in procedure G0446 Argument is the wrong size G0447 vfor called with illegal loop level G0454 Failure opening printer for output G0456 Failure buffering output for printer G0457 Cannot take log of a negative number G0458 Attempt to index proc/fn/keyword as a matrix G0459 Missing right brace G0460 Unexpected end of statement G0461 Too many data items G0462 Negative trim value G0463 Failure generating graph G0465 Redefiniti
GAUSS User Guide G0473 String not terminated with null byte G0477 FOR loops nested too deep G0486 Character argument too long G0487 License expired G0490 License manager initialization error G0491 License manager error G0492 Licensing failure G0497 Missing right parenthesis G0500 Cannot create temporary filename G0503 Cannot assign matrix to scalar member G0504 Invalid structure member G0505 Invalid structure redefinition G0506 Structure assignment mismatch G0507 Undefined structure G0508 Structure argumen
Error Messages G0517 Too many dimensions in argument G0518 Not implemented for complex G0519 Illegal dereference of structure array G0520 Arguments not conformable G0521 Argument must be real G0522 Illegal indexing of dereferenced structure G0523 Numeric argument must be integer G0524 Found comma, expecting index G0525 Argument contains NaNs G0526 Argument must be compact format G0529 Array orders must be >= 1 G0531 Two trailing dimensions of argument must be the same size G0532 Both dimensions of argument
GAUSS User Guide G0548 Array not conformable for boolean operation G0549 Global structure pointer cannot point to local structure G0550 Invalid use of * G0551 Feature not authorized G0553 Path too long G0554 Unable to create sparse matrix G0555 Cannot index uninitialized structure G0556 #IF nesting limit exceeded G0557 #ELSE without #IF G0558 #ENDIF without #IF G0559 Symbol not #DEFINE'd G0560 Too many #DEFINE's G0561 Duplicate #DEFINE G0562 Open /* */comment G0563 Open @ @ comment G0564 Illegal redefiniti
Error Messages G0568 Operation not defined for triangular, symmetric, or Hermitian sparse matrix G0569 Argument must be complex G0570 Diagonal must be real G0571 Diagonal must not contain zeros G0572 Argument must be triangular G0573 Argument must be symmetric G0574 Sparse type mismatch G0575 Unable to load variable G0576 Threading error G0577 Expected THREADSTAT, THREADBEGIN, or THREADJOIN G0578 A THREADJOIN failed G0579 Cannot call RUN from inside thread G0580 Unable to converge in allowed number of iter
GAUSS User Guide G0584 Invalid Input: 'which' must be 'LM' 'SM' 'LR' 'LI' 'SR' or 'SI' and type string G0585 Error Return from LAPACK eigenvalue calculation G0586 dneupd error 1: contact Aptech Systems G0587 Input matrix must be sparse G0588 Incorrect Input: Number of eigenvalues must be scalar G0589 Incorrect Input: Tolerance must be scalar G0590 No eigenvalues found to specified tolerance in allowed iterations G0591 Incorrect Input: Max iterations must be scalar G0592 Incorrect Input: Number of column ve
Error Messages G0599 Incorrect Input: Input 2 may not have more columns that input 1 has rows G0600 Incorrect Input: Input 1 must be square G0601 Incorrect Input: Input 2 must be square G0602 Incorrect Input: 1 <= il < iu and iu <= rows of x G0603 Failure to converge 28-27
29 Maximizing Performance These hints will help you maximize the performance of your new GAUSS System. 29.1 Library System Some temporary files are created during the autoloading process. If you have a tmp_ path configuration variable or a tmp environment string that defines a path on a RAM disk, the temporary files will be placed on the RAM disk. For example: set tmp=f:\tmp tmp_path takes precedence over the tmp environment variable.
GAUSS User Guide 29.2 Loops The use of the built-in matrix operators and functions rather than do loops will ensure that you are utilizing the potential of GAUSS. Here is an example: Given the vector x with 8000 normal random numbers, x = rndn(8000,1); you could get a count of the elements with an absolute value greater than 1 with a do loop, like this: c = 0; i = 1; do while i <= rows(x); if abs(x[i]) > 1; c = c+1; endif; i = i+1; endo; print c; Or, you could use: c = sumc(abs(x) .
Maximizing Performance advantage of this feature. The speed-ups using this feature can be significant. For example, ols is called using a data set stored in a matrix versus stored on the disk in a GAUSS data set. The computer is a 2.8 Megahertz computer with Windows XP.
GAUSS User Guide maxbytes is a GAUSS procedure that returns the value of a scalar global __maxbytes that sets the amount of available RAM. This value can be modified for a particular run by setting __maxbytes in your command file to some other value. The value returned by a call to maxbytes can be permanently modified by editing system.dec and changing the value of __maxbytes.
30 GAUSS Graphics Colors The following is a chart and list of colors available for use in GAUSS graphics with both the name and RGB value listed.
GAUSS User Guide 30-2
GAUSS Graphics Colors 30-3
31 Reserved Words The following words are used for GAUSS functions.
GAUSS User Guide AmericanBinomPut_ImpVol AmericanBSCall AmericanBSCall_Greeks AmericanBSCall_ImpVol AmericanBSPut AmericanBSPut_Greeks AmericanBSPut_ImpVol amin amult and annualTradingDays arccos arcsin arctan arctan2 areshape arrayalloc arrayindex arrayinit arraytomat asclabel asin 31-2
Reserved Words asum atan atan2 atranspose axmargin B balance band bandchol bandcholsol bandltsol bandrv bandsolpd bar base10 begwind besselj bessely box boxcox break C 31-3
GAUSS User Guide calcbox call callexe cdfbeta cdfbvn cdfbvn2 cdfbvn2e cdfchic cdfchii cdfchinc cdffc cdffnc cdfgam cdfmvn cdfn cdfn2 cdfnc cdfni cdftc cdftci cdftnc cdftvn 31-4
Reserved Words cdir ceil cfft cffti changedir chdir checkinterrupt chol choldn cholsol cholup chrs cint clear clearg close closeall cls cmsplit cmsplit2 code color 31-5
GAUSS User Guide cols colsf combinate combinated comlog commandeerm commandeersa compile complex con cond conformed conj cons continue contour conv convertsatostr convertstrtosa coreleft corrm corrms 31-6
Reserved Words corrvc corrx corrxs cos cosh counts countwts create crossprd crout croutp csrcol csrlin csrtype cumprodc cumsumc curve cvtos cvtosa D datacreate datacreatecomplex 31-7
GAUSS User Guide datalist dataload dataopen datasave date datestr datestring datestrymd dayinyr dayOfWeek debug declare delete deletefile delif denseSubmat design det detl dfft dffti dfree 31-8
Reserved Words diag diagrv digamma disable dlibrary dllcall do dos doswincloseall doswinopen dotfeq dotfeqmt dotfge dotfgemt dotfgt dotfgtmt dotfle dotflemt dotflt dotfltmt dotfne dotfnemt 31-9
GAUSS User Guide draw dsCreate dstat dstatmt dstatmtControlCreate dtdate dtday dttime dttodtv dttostr dttoutc dtvnormal dtvtodt dtvtoutc dummy dummybr dummydn E ed edit editm eig 31-10
Reserved Words eigcg eigcg2 eigch eigch2 eigh eighv eigrg eigrg2 eigrs eigrs2 eigv elapsedTradingDays else elseif enable end endfor endif endo endp endwind envget 31-11
GAUSS User Guide eof eq eqSolve eqSolvemt eqSolvemtControlCreate eqSolvemtOutCreate eqSolveSet eqv erf erfc error errorlog etdays ethsec etstr EuropeanBinomCall EuropeanBinomCall_Greeks EuropeanBinomCall_ImpVol EuropeanBinomPut EuropeanBinomPut_Greeks EuropeanBinomPut_ImpVol EuropeanBSCall 31-12
Reserved Words EuropeanBSCall_Greeks EuropeanBSCall_ImpVol EuropeanBSPut EuropeanBSPut_Greeks EuropeanBSPut_ImpVol exctsmpl exec execbg exp expr external eye F fcheckerr fclearerr feq feqmt fflush fft ffti fftm fftmi 31-13
GAUSS User Guide fftn fge fgemt fgets fgetsa fgetsat fgetst fgt fgtmt fileinfo files filesa fix fle flemt floor flt fltmt fmod fn fne fnemt 31-14
Reserved Words font fontload fonts fontunload fontunloadall fopen for format formatcv formatnv fputs fputst fseek fstrerror ftell ftocv ftos ftostrc G gamma gammaii gausset 31-15
GAUSS User Guide gdaappend gdacreate gdadstat gdadstatmat gdagetindex gdagetname gdagetnames gdagetorders gdagettype gdagettypes gdagetvarinfo gdaiscplx gdapack gdaread gdareadbyindex gdareadsome gdareportvarinfo gdaupdate gdaupdateandpack gdawrite gdawritesome gdtfastcat 31-16
Reserved Words ge getarray getdims getf getmatrix getmatrix4d getname getnamef getNextTradingDay getNextWeekDay getnr getnrmt getorders getpath getPreviousTradingDay getPreviousWeekDay getscalar3d getscalar4d getwind gosub goto gradMT 31-17
GAUSS User Guide gradMTm gradp graph graphgpg graphinit graphprt graphset graphsev3 gt H hardcopy hasimag header headermt hess hessMT hessMTg hessMTgw hessMTm hessMTmw hessMTw hessp 31-18
Reserved Words hist histf histp hsec I if imag indcv indexcat indices indices2 indicesf indicesfn indnv indsav int intgrat2 intgrat3 inthp intHP1 intHP2 intHP3 31-19
GAUSS User Guide intHP4 inthpControlCreate intquad1 intquad2 intquad3 intrleav intrleavsa intrsect intrsectsa intsimp inv invpd invswp iscplx iscplxf isinfnanmiss scalmiss isSparse K key keyav keymatchmc 31-20
Reserved Words keyw keyword L lag lag1 lagn lapeighb lapeighi lapeighvb lapeighvi lapgeig lapgeigh lapgeighv lapgeigv lapgschur lapgsvdcst lapgsvds lapgsvdst lapsvdcusv lapsvds lapsvdusv le 31-21
GAUSS User Guide let lib library license_id line linsolve ln lncdfbvn lncdfbvn2 lncdfmvn lncdfn lncdfn2 lncdfnc lnfact lngamma lnpdfmvn lnpdfmvt lnpdfn lnpdft load loadarray loadd 31-22
Reserved Words loadexe loadf loadk loadm loadp loads loadstruct loadwind local locate loess loessmt loessmtControlCreate log loglog logx logy loopnextindex lower lowmat lowmat1 lpos 31-23
GAUSS User Guide lprint lpwidth lshow lt ltrisol lu lusol M machEpsilon makevars makewind margin matalloc matinit matrix mattoarray maxbytes maxc maxindc maxvec mbesselei mbesselei0 31-24
Reserved Words mbesselei1 mbesseli mbesseli0 mbesseli1 meanc median mergeby mergebysa mergevar minc minindc miss missex missrv moment momentd movingave movingaveExpwgt movingaveWgt msym N 31-25
GAUSS User Guide nametype ndpchk ndpclex ndpcntrl ne new nextindex nextn nextnevn nextwind not null null1 numCombinations O oldfft oldffti ols olsmt olsmtControlCreate olsqr olsqr2 31-26
Reserved Words olsqrmt ones open openpqg optn optnevn or orth output outwidth P pacf packr parse pause pdfn pi pinv pinvmt plot plotsym polar 31-27
GAUSS User Guide polychar polyeval polyint polymake polymat polymroot polymult polyroot pop pqgwin prcsn previousindex princomp print printdos printfm printfmt proc prodc push putarray putf 31-28
Reserved Words pvCreate pvgetindex pvgetparnames pvgetparvector pvLength pvList pvnumoffsets pvoffsets pvPack pvPacki pvPackm pvPackmi pvPacks pvPacksi pvPacksm pvPacksmi pvputparvector pvtest pvunpack Q QNewton QNewtonmt 31-29
GAUSS User Guide QNewtonmtControlCreate QNewtonmtOutCreate QNewtonSet QProg QProgmt QProgmtInCreate qqr qqre qqrep qr qre qrep qrsol qrtsol qtyr qtyre qtyrep quantile quantiled quantilem quantilemd qyr 31-30
Reserved Words qyre qyrep R rank rankindx readr real recode recserar recsercp recserrc register_off register_on register_reset register_show renamefile replay rerun reshape retp return rev 31-31
GAUSS User Guide rfft rffti rfftip rfftn rfftnp rfftp rndbeta rndcon rndgam rndi rndKMbeta rndKMgam rndkmi rndkmn rndKMnb rndKMp rndkmu rndKMvm rndLCbeta rndLCgam rndlci rndlcn 31-32
Reserved Words rndLCnb rndLCp rndlcu rndLCvm rndmod rndmult rndn rndnb rndns rndp rndseed rndu rndus rndvm rotater round rows rowsf rref run S 31-33
GAUSS User Guide satocv satostrC save saveall saved savestruct savewind scale scale3d scalerr scalinfnanmiss scalmiss schtoc schur screen scroll searchsourcepath seekr selif seqa seqm setarray 31-34
Reserved Words setcnvrt setdif setdifsa setvars setvmode setvwrmode setwind shell shiftr show showpqg sin singleindex sinh sleep solpd sortc sortcc sortd sorthc sorthcc sortind 31-35
GAUSS User Guide sortindc sortindmc sortmc sortr sortrc sparseCols sparseEye sparseFD sparseFP sparseHConcat sparseNZE sparseOnes sparseRows sparseScale sparseSet sparseSolve sparseSubmat sparseTD sparseTranspose sparseTrTD sparseTscalar sparseVConcat 31-36
Reserved Words spline spline1D spline2D sqpmt_feasible sqpmt_meritFunct sqpSolve SQPsolveMT sqpSolveMTcontrolCreate sqpSolveMTlagrangeCreate sqpSolveMToutCreate sqpSolveset sqrt stdc stocv stof stop strcombine strindx string strlen strput strrindx 31-37
GAUSS User Guide strsect strsplit strsplitpad strtodt strtodtd strtof strtofcplx strtriml strtrimr strtrunc strtruncl strtruncpad strtruncr struct submat subscat substute subvec sumc sumr surface svd 31-38
Reserved Words svd1 svd2 svdcusv svds svdusv sysstate system T tab tan tanh tempname ThreadBegin ThreadEnd ThreadJoin ThreadStat time timedt timestr timeutc title tkf2eps 31-39
GAUSS User Guide tkf2ps tkf2ps_margin tocart todaydt toeplitz token topolar trace trap trapchk trigamma trim trimr trunc type typecv typef U union unionsa uniqindmc uniqindx 31-40
Reserved Words uniqindxsa unique uniquemc uniquesa until upmat upmat1 upper use utctodt utctodtv utrisol V vals varget vargetl varmall varmares varput varputl vartype vartypef 31-41
GAUSS User Guide vcm vcms vcx vcxs vec vech vecr vfor vget view viewxyz vlist vnamecv volume vput vread vtypecv W wait waitc walkindex while 31-42
Reserved Words winclear wincleararea winclearttylog winclose wincloseall winconvertpqg window wingetactive wingetattributes wingetcolorcells wingetcursor winmove winopenpqg winopentext winopentty winpan winprint winprintpqg winrefresh winrefresharea winresize winsetactive 31-43
GAUSS User Guide winsetbackground winsetcolor winsetcolorcells winsetcolormap winsetcursor winsetforeground winsetrefresh winsettextwrap winwrite winzoompqg writer X x_indcv xlabel xor xpnd xtics xy xyz Y ylabel ytics 31-44
Reserved Words Z zeros zlabel ztics 31-45
32 Singularity Tolerance The tolerance used to determine whether or not a matrix is singular can be changed. The default value is 1.0e-14 for both the LU and the Cholesky decompositions. The tolerance for each decomposition can be changed separately. The following operators are affected by a change in the tolerance: Crout LU Decomposition crout(x) croutp(x) inv(x) det(x) y/x when neither x nor y is scalar and x is square.
GAUSS User Guide solpd(y, x) y/x when neither x nor y is scalar and x is not square. 32.1 Reading and Setting the Tolerance The tolerance value may be read or set using the sysstate function, cases 13 and 14. 32.2 Determining Singularity There is no perfect tolerance for determining singularity. The default is 1.0e-14. You can adjust this as necessary. A numerically better method of determining singularity is to use cond to determine the condition number of the matrix.
33 Publication Quality Graphics GAUSS Publication Quality Graphics (PQG) is a set of routines built on the graphics functions in GraphiC by Scientific Endeavors Corporation. These routines are deprecated but included for backward compatibility. The main graphics routines include xy, xyz, surface, polar and log plots, as well as histograms, bar, and box graphs. Users can enhance their graphs by adding legends, changing fonts, and adding extra lines, arrows, symbols and messages.
GAUSS User Guide histf Histogram from a vector of frequencies. loglog Log scaling on both axes. logx Log scaling on X axis. logy Log scaling on Y axis. polar Polar plots. surface 3-D surface with hidden line removal. xy Cartesian graph. xyz 3-D Cartesian graph. 33.
33.2.1 Getting Started There are four basic parts to a graphics program. These elements should be in any program that uses graphics routines. The four parts are the header, data setup, graphics format setup, and graphics call. Header In order to use the graphics procedures, the pgraph library must be activated. This is done in the library statement at the top of your program or command file.
Publication Quality Graphics GAUSS User Guide Following are three PQG examples. The first two programs are different versions of the same graph. The variables that begin with _p are the global control variables used by the graphics routines. (For a detailed description of these variables, see Global Control Variables, Section 33.6 .) Example 1 The routine being called here is a simple XY plot. The entire window will be used.
_pltype = { 1, 2, 6, 6 }; lines */ _pstype = { 1, 2, 0, 0 }; squares */ _plegctl= { 2, 3, 1.7, 4.5 }; tions */ _plegstr= "Sin wave 1.\0"\ "Sin wave .8\0"\ "Sin wave .6\0"\ "Sin wave .4"; ylabel("Amplitude"); xlabel("X Axis"); title("Example xy Graph"); xy(x,y); /* dashed, dotted, solid /* symbol types circles, /* legend size and loca/* 4 lines legend text */ /* /* /* /* Y axis label */ X axis label */ main title */ call to main routine */ Example 3 In this example, two graphics panels are drawn.
Publication Quality Graphics GAUSS User Guide */ _pzclr = { 1, 2, 3, 4 }; title("cos(5*sin(x) - y)"); xlabel("X Axis"); ylabel("Y Axis"); scale3d(miss(0,0),miss(0,0),-5|5); surface(x,y,z); nextwind; */ graphset; */ _pzclr = { 1, 2, 3, 4 }; _pbox = 15; contour(x,y,z); endwind; /* /* /* /* /* /* /* set Z level colors */ set main title */ set X axis label */ set Y axis label */ scale Z axis */ call surface routine */ activate second window.
33.2.2 Graphics Coordinate System PQG uses a 4190x3120 pixel resolution grid on a 9.0x6.855-inch printable area. There are three units of measure supported with most of the graphics global elements: Inch Coordinates Inch coordinates are based on the dimensions of the full-size 9.0x6.855-inch output page. The origin is (0,0) at the lower left corner of the page. If the picture is rotated, the origin is at the upper left. (For more information, see Inch Units in Graphic Panels, Section 33.3.6 .
Publication Quality Graphics GAUSS User Guide 33.3.1 Tiled Graphic Panels Tiled graphic panels do not overlap. The window can easily be divided into any number of tiled graphic panels with the window command. window takes three parameters: number of rows, number of columns, and graphic panel attribute (1=transparent, 0=nontransparent). This example will divide the window into six equally sized graphic panels.
33.3.2 Overlapping Graphic Panels Overlapping graphic panels are laid on top of one another as they are created, much as if you were using the cut and paste method to place several graphs together on one page. An overlapping graphic panel is created with the makewind command. In this example, makewind will create an overlapping graphic panel that is 4 inches wide by 2.5 inches tall, positioned 1 inch from the left edge of the page and 1.5 inches from the bottom of the page.
Publication Quality Graphics GAUSS User Guide 33.3.3 Nontransparent Graphic Panels A nontransparent graphic panel is one that is blanked before graphics information is written to it. Therefore, information in any previously drawn graphic panels that lie under it will not be visible.
33.3.4 Transparent Graphic Panels A transparent graphic panel is one that is not blanked, allowing the graphic panel beneath it to "show through". Lines, symbols, arrows, error bars, and other graphics objects may extend from one graphic panel to the next by using transparent graphic panels. First, create the desired graphic panel configuration. Then create a full-window, transparent graphic panel using the makewind or window command.
Publication Quality Graphics GAUSS User Guide 33.3.5 Using Graphic Panel Functions The following is a summary of the graphic panel functions: begwind Graphic panel initialization procedure. endwind End graphic panel manipulations, display graphs. window Partition window into tiled graphic panels. makewind Create graphic panel with specified size and position. setwind Set to specified graphic panel number. nextwind Set to next available graphic panel number.
x = seqa(1,1,1000); y =(sin(x) + 1) * 10.; setwind(1); xy(x,y); nextwind; logx(x,y); nextwind; logy(x,y); nextwind; loglog(x,y); nextwind; bar(x,y); endwind; /* Create X data */ /* Create Y data */ /* Graph 1, upper left corner */ /* Graph 2, upper rt. corner */ /* Graph 3, lower left corner */ /* Graph 4, lower rt.
Publication Quality Graphics GAUSS User Guide 33.3.6 Inch Units in Graphic Panels Some global variables allow coordinates to be input in inches. If a coordinate value is in inches and is being used in a graphic panel, that value will be scaled to "graphic panel inches" and positioned relative to the lower left corner of the graphic panel.
33.3.7 Saving Graphic Panel Configurations The functions savewind and loadwind allow the user to save graphic panel configurations. Once graphic panels are created (using makewind and window), savewind may be called. This will save to disk the global variables containing information about the current graphic panel configuration. To load this configuration again, call loadwind. (See loadwind in the GAUSS LANGUAGE REFERENCE. 33.
Publication Quality Graphics GAUSS User Guide title("This is the first line\lthis is the second line"); A null byte \000 is used to separate strings in _plegstr and _pmsgstr: _pmsgstr = "First string\000Second string\000Third string"; or _plegstr = "Curve 1\000Curve 2"; Use [..] to create the expression () ( ): M t = E e tz _pmsgstr = "M(t) = E(e[tx])"; Use @ to generate [ and ] in an X axis label: xlabel("Data used for x is: data@[.
33.4.1 Selecting Fonts Four fonts are supplied with the Publication Quality Graphics system. They are Simplex, Complex, Simgrma, and Microb. (For a list of the characters available in each font, see PQG FONTS , CHAPTER 34 .) Fonts are loaded by passing to the fonts procedure a string containing the names of all fonts to be loaded.
Publication Quality Graphics GAUSS User Guide 33.4.2 Greek and Mathematical Symbols The following examples illustrate the use of the Simgrma font; they assume that Simgrma was the fourth font loaded. (For the available Simgrma characters and their numbers, see PQG FONTS , CHAPTER 34 .) The Simgrma characters are specified by either: 1. The character number, preceeded by a "\". 2. The regular text character with the same number.
_pmsgstr = "\2041\2011/2\204p ,\201e[-\204m[\2012]\201/2] d\204m"; This produces: √ 1 / 2π ∫ e−µ 2 /2 dµ 33.5 Colors 0 Black 8 Dark Grey 1 Blue 9 Light Blue 2 Green 10 Light Green 3 Cyan 11 Light Cyan 4 Red 12 Light Red 5 Magenta 13 Light Magenta 6 Brown 14 Yellow 7 Grey 15 White 33.6 Global Control Variables The following global variables are used to control various graphics elements. Default values are provided.
Publication Quality Graphics GAUSS User Guide graphset can be called whenever the user wants to reset these variables to their default values. _pageshf 2x1 vector, the graph will be shifted to the right and up if this is not 0. If this is 0, the graph will be centered on the output page. Default is 0. Note: Used internally. (For the same functionality, see makewind in the GAUSS LANGUAGE REFERENCE.) This is used by the graphic panel routines.
[M, 4] y ending point. [M, 5] ratio of the length of the arrow head to half its width. [M, 6] size of arrow head in inches. [M, 7] type and location of arrow heads. This integer number will be interpreted as a decimal expansion mn, for example: if 10, then m = 1, n= 0. m, type of arrow head: 0 solid 1 empty 2 open 3 closed n, location of arrow head: 0 none 1 at the final end 2 at both ends [M, 8] color of arrow, see PQG GRAPHICS COLORS, CHAPTER 35 .
Publication Quality Graphics GAUSS User Guide [M, 10] [M, 11] 1 x,y starting and ending locations in plot coordinates 2 x,y starting and ending locations in inches 3 x,y starting and ending locations in pixels line type: 1 dashed 2 dotted 3 short dashes 4 closely spaced dots 5 dots and dashes 6 solid controls thickness of lines used to draw arrow. This value may be zero or greater. A value of zero is normal line width.
matrix (for a total of M arrows). If scalar zero, no arrows will be drawn. [M, 1] x starting point in 3-D plot coordinates. [M, 2] y starting point in 3-D plot coordinates. [M, 3] z starting point in 3-D plot coordinates. [M, 4] x ending point in 3-D plot coordinates. [M, 5] y ending point in 3-D plot coordinates. [M, 6] z ending point in 3-D plot coordinates. [M, 7] ratio of the length of the arrow head to half its width. [M, 8] size of arrow head in inches.
Publication Quality Graphics GAUSS User Guide 1 empty 2 open 3 closed n, location of arrow head: 0 none 1 at the final end 2 at both ends [M, 10] color of arrow, see PQG GRAPHICS COLORS, CHAPTER 35 . [M, 11] line type: [M, 12] 1 dashed 2 dotted 3 short dashes 4 closely spaced dots 5 dots and dashes 6 solid controls thickness of lines used to draw arrow. This value may be zero or greater. A value of zero is normal line width.
_parrow3 = { 1 1 1 2 2 2 3 0.2 11 10 6 0, 3 4 5 2 2 2 3 0.2 11 10 6 0 }; _paxes scalar, 2x1, or 3x1 vector for independent control for each axis. The first element controls the X axis, the second controls the Y axis, and the third (if set) controls the Z axis. If 0 the axis will not be drawn. Default is 1. If this is a scalar, it will be expanded to that value.
Publication Quality Graphics GAUSS User Guide 4 diagonal lines with negative slope 5 diagonal cross-hatch 6 solid The second column controls the bar color, see PQG GRAPHICS COLORS, CHAPTER 35 . _pbarwid scalar, width of bars in bar graphs and histograms. The valid range is 0-1. If 0, the bars will be a single pixel wide. If 1, the bars will touch each other. Default is 0.5, so the bars take up about half the space open to them. _pbox scalar, draws a box (border) around the entire graph.
Elements 4 and 5 are ignored. 2 statistical standard with the minimum and maximum calculated according to interquartile range as follows: intqrange = 75th - 25th min = 25th - 1.5 intqrange max = 75th + 1.5 intqrange Elements 4 and 5 are ignored. 3 _pboxlim minimum and maximum percentiles taken from elements 4 and 5. [4] minimum percentile value (0-100) if _ pboxctl[3] = 3. [5] maximum percentile value (0-100) if _ pboxctl[3] = 3.
Publication Quality Graphics GAUSS User Guide _pcolor [4, M] 75th percentile (top of box). [5, M] maximum whisker limit according to _ pboxctl[3]. scalar or Kx1 vector, colors for main curves in xy, xyz and log graphs. To use a single color set for all curves set this to a scalar color value. If 0, use default colors. Default is 0. The default colors come from a global vector called _ pcsel. This vector can be changed by editing pgraph.
drawn by _pline. _pcrop = { 1 1 0 1 0 }; _pcross scalar. If 1, the axes will intersect at the (0,0) X-Y location if it is visible. Default is 0, meaning the axes will be at the lowest end of the X-Y coordinates. _pdate date string. If this contains characters, the date will be appended and printed. The default is set as follows (the first character is a font selection escape code): _pdate = "\201GAUSS "; If this is set to a null string, no date will be printed.
Publication Quality Graphics GAUSS User Guide [M, 5] bottom of error bar. [M, 6] top of error bar. [M, 7] line type: 1 dashed 2 dotted 3 short dashes 4 closely spaced dots 5 dots and dashes 6 solid [M, 8] color, see PQG GRAPHICS COLORS, CHAPTER 35 . [M, 9] line thickness. This value may be 0 or greater. A value of 0 is normal line width. To create one error bar using solid lines, use _perrbar = { 1 0 2 2 1 3 6 2 0 }; _pframe 2x1 vector, controls frame around axes area.
1 frame on 0 frame off 1 tick marks on frame 0 no tick marks [2] The default is a frame with tick marks. _pgrid 2x1 vector to control grid. [1] [2] grid through tick marks: 0 no grid 1 dotted grid 2 fine dotted grid 3 solid grid grid subdivisions between major tick marks: 0 no subdivisions 1 dotted lines at subdivisions 2 tick marks only at subdivisions The default is no grid and tick marks at subdivisions.
Publication Quality Graphics GAUSS User Guide 0 draw line only. >0 draw line and symbols every _plctrl points. <0 draw symbols only every _plctrl points. -1 all of the data points will be plotted with no connecting lines. This example draws a line for the first curve, draws a line and plots a symbol every 10 data points for the second curve, and plots symbols only every 5 data points for the third curve: _plctrl = { 0, 10, -5 }; _plegctl scalar or 1x4 vector, legend control variable.
y coordinate of lower left corner of legend box. [4] This example puts a legend in the lower right corner: _plegctl = 1; This example creates a smaller legend and positions it 2.5 inches from the left and 1 inch from the bottom. _plegctl = { 2 3 2.5 1 }; _plegstr string, legend entry text. Text for multiple curves is separated by a null byte (''\000''). For example: _plegstr = "Curve 1\000Curve 2\000Curve 3"; _plev Mx1 vector, user-defined contour levels for contour. Default is 0.
Publication Quality Graphics GAUSS User Guide [M, 2] [M, 3-7] 33-34 4 circle in plot coordinates 5 circle in inch coordinates 6 radius in plot coordinates 7 radius in inch coordinates line type: 1 dashed 2 dotted 3 short dashes 4 closely spaced dots 5 dots and dashes 6 solid coordinates and dimensions: if item type is line (1<=_pline[M,1]<=3): [M, 3] x starting point. [M, 4] y starting point. [M, 5] x ending point. [M, 6] y ending point.
[M, 7] 0 if this is a continuation of a curve, 1 if this begins a new curve. if item type is circle (_pline[M,1] = 4 or _pline[M,1] = 5): [M, 3] x center of circle. [M, 4] y center of circle. [M, 5] radius. [M, 6] starting point of arc in radians. [M, 7] ending point of arc in radians. if item type is radius (_pline[M,1] = 6 or _pline [M,1] = 7): [M, 3] x center of circle. [M, 4] y center of circle. [M, 5] beginning point of radius, 0 is the center of the circle.
Publication Quality Graphics GAUSS User Guide _pline3d 33-36 [M, 7] angle in radians. [M, 8] color, see PQG GRAPHICS COLORS, CHAPTER 35 . [M, 9] controls line thickness. This value may be zero or greater. A value of zero is normal line width. Mx9 matrix. Allows extra lines to be added to an xyz or surface graph in 3-D plot coordinates. [M, 1] x starting point. [M, 2] y starting point. [M, 3] z starting point. [M, 4] x ending point. [M, 5] y ending point. [M, 6] z ending point.
_plotshf 1 dashed 2 dotted 3 short dashes 4 closely spaced dots 5 dots and dashes 6 solid [M, 9] line thickness, 0 = normal width. [M, 10] hidden line flag, 1 = obscured by surface, 0 = not obscured. 2x1 vector, distance of plot from lower left corner of output page in inches. [1] x distance. [2] y distance. If scalar 0, there will be no shift. Default is 0. Note: Used internally. (For the same functionality, see axmargin in the GAUSS LANGUAGE REFERENCE.
Publication Quality Graphics GAUSS User Guide when using the graphic panel procedures. _pltype scalar or Kx1 vector, line type for the main curves. If this is a nonzero scalar, all lines will be this type. If scalar 0, line types will be default styles. Default is 0. 1 dashed 2 dotted 3 short dashes 4 closely spaced dots 5 dots and dashes 6 solid The default line types come from a global vector called _ plsel. This vector can be changed by editing pgraph.
[5] Z axis label. [6] title. [7] box. [8] date. [9] background. If this is scalar, it will be expanded to a 9x1 vector. _pmsgctl Lx7 matrix of control information for printing the strings contained in _pmsgstr. [L, 1] horizontal location of lower left corner of string. [L, 2] vertical location of lower left corner of string. [L, 3] character height in inches. [L, 4] angle in degrees to print string. This may be 180 to 180 relative to the positive X axis.
Publication Quality Graphics GAUSS User Guide [L, 7] _pmsgstr font thickness, may be 0 or greater. If 0 use normal line width. string, contains a set of messages to be printed on the plot. Each message is separated from the next by a null byte (\000). The number of messages must correspond to the number of rows in the _pmsgctl control matrix. This can be created as follows: _pmsgstr = "Message one.\000Message two."; _pnotify _pnum scalar, controls window output during the creation of the graph.
For example: _pnum = { 0, 2 }; /* no X axis numbers, *//* horizontal on Y axis */ _pnumht scalar, size of axes numbers in inches. If 0, a size of .13 will be used. Default is 0. _protate scalar. If 0, no rotation, if 1, plot will be rotated 90 degrees. Default is 0. _pscreen scalar. If 1, display graph in window, if 0, do not display graph in window. Default is 1. _psilent scalar. If 0, a beep will sound when the graph is finished drawing to the window. Default is 1 (no beep).
Publication Quality Graphics GAUSS User Guide 8 solid circle 9 solid square 10 solid triangle 11 solid plus 12 solid diamond 13 solid inverted triangle 14 solid star If this is a vector, each line will have a different symbol. Symbols will repeat if there are more lines than symbol types. Default is 0 (no symbols are shown). _psurf _psym 2x1 vector, controls 3-D surface characteristics. [1] if 1, show hidden lines. Default is 0. [2] color for base, see PQG GRAPHICS COLORS, CHAPTER 35 .
[M, 2] y location. [M, 3] symbol type, see _pstype earlier. [M, 4] symbol height. If this is 0, a default height of 5.0 will be used. [M, 5] symbol color, see PQG GRAPHICS COLORS, CHAPTER 35 . [M, 6] type of coordinates: [M, 7] _psym3d 1 plot coordinates 2 inch coordinates line thickness. A value of zero is normal line width. Mx7 matrix for plotting extra symbols on a 3-D (surface or xyz) graph. [M, 1] x location in plot coordinates. [M, 2] y location in plot coordinates.
Publication Quality Graphics GAUSS User Guide [M, 5] symbol height. If this is 0, a default height of 5.0 will be used. [M, 6] symbol color, see PQG GRAPHICS COLORS, CHAPTER 35 . [M, 7] line thickness. A value of 0 is normal line width. Use _psym for plotting extra symbols in inch coordinates. _psymsiz scalar or Kx1 vector, symbol size for the symbols on the main curves. This is NOT related to _psym. If 0, a default size of 5.0 is used. _ptek string, name of Tektronix format graphics file.
_pypmax scalar, the maximum number of places to the right of the decimal point for the Y axis numbers. Default is 12. _pysci scalar, the threshold in digits above which the data for the Y axis will be scaled and a power of 10 scaling factor displayed. Default is 4. _pzclr scalar, row vector, or Kx2 matrix, Z level color control for procedures surface and contour. (See surface in the GAUSS LANGUAGE REFERENCE.
34 PQG Fonts There are four fonts available in the Publication Quality Graphics System: Simplex standard sans serif font Simgrma Simplex greek, math Microb bold and boxy complex standard font with serif The following tables show the characters available in each font and their ASCII values. (For details on selecting fonts for your graph, see Selecting Fonts, Section 33.4.1 .) 34.
GAUSS User Guide 34.
PQG Fonts 34.
GAUSS User Guide 34.
PQG Fonts 34-5
35 PQG Graphics Colors 0 Black 8 Dark Grey 1 Blue 9 Light Blue 2 Green 10 Light Green 3 Cyan 11 Light Cyan 4 Red 12 Light Red 5 Magenta 13 Light Magenta 6 Brown 14 Yellow 7 Grey 15 White 35-1
Index ' 10-8 - 10-4, 10-21, 10-21, 13-4 ! 10-5 != 10-9, 10-10, 13-4 # 27-3, 27-3, 27-9 $ 10-9, 10-9, 27-3, 27-3, 27-9 $!= 10-10 $/= 10-10, 10-21 $| 10-17 $~ 10-17 $+ 10-21 $< 10-10, 10-22 $<= 10-10, 10-22 $== 10-10, 10-22 $> 10-11, 10-22 $>= 10-11, 10-21 % 10-5, 10-21 & 10-16, 27-11 * 10-21, 10-21, 13-4 *~ 10-6, 10-21 , (comma) 10-15 . (dot) 10-9, 10-11, 10-14, 10-15, 27-6, 27-11 .' 10-8, 10-21 .!= 10-12, 13-4 .$!= 10-12 .$/= 10-12, 10-21 .$< 10-11, 10-22 .$<= 10-11, 10-22 .$== 10-11, 10-22 .
Index @ 27-3, 27-18 .
Index autoloader 19-1, 19-2, 19-2 change working directory 3-5 autoreload 3-36 Cholesky decomposition 10-5, 32-1 auxiliary output 22-4 circles 7-3, 33-33 background color 6-8 clear action list 3-5 backslash 10-4 clear breakpoints 3-37, 3-41 bar shading 6-8, 33-25 clear working directory history 3-6 bar width 33-26 close 3-13 basic plotting 6-2 close all 3-13 batch mode 8-1 code (dataloop) 24-2 binary files 22-16 code folding 3-18 blank lines 9-38 colon 10-16 block-skipping 12-7 (semic
Index command line history 3-12 control flow 9-31 command page 3-3, 3-4 control structures 16-21 command page layout 3-9 coordinates 33-7 command page toolbar 3-6 copy 3-5, 3-7 comments 9-40 create 22-8 comparison operator 9-44 cropping 33-28 compilation phase 24-3 Crout LU decomposition 32-1 compile time 9-3 custom regions 6-17 compiled language 9-1 cut 3-5, 3-6 compiler 21-1 data loop 24-1, 24-2, 24-3, 24-3, 24-4 compiler directives 9-5 data page 3-29, 3-32 compiling programs 21-1 d
Index debug page 3-37, 3-38, 5-1, 5-1 editor properties 3-24 debug stop 5-6 element-by-element conformability 10-1 debugger 3-39, 5-1, 5-1, 5-3, 5-6 element-by-element operators 10-1 delete (dataloop) 24-2 empty matrix 9-13 delimit, ATOG command 27-6, 27-6 endp 11-8 delimited 27-1 eq 10-10, 10-21 delimited files 22-3 .eq 10-11, 10-21 delimited, hard 27-6 eqv 10-14, 10-21 delimited, soft 27-4 .
Index extern (dataloop) 24-2, 24-2 functions 9-36 extraneous spaces 9-41, 10-15, 10-16 gauss colors 30-1 factorial 10-5 GAUSS Data Archives 22-11, 22-11, 22-12, 22-13, 22-29 FALSE 9-35 fgets 22-6 file export, graphics 6-32 file formats 22-15 file input/output 22-1 files 22-6 files, binary 22-16 files, matrix 22-3 files, string 22-18, 22-19, 22-23 find and replace 3-22 flow control 9-31 fopen 22-6 Foreign Language Interface 23-1, 23-1, 23-2 GAUSS Graphics Colors 30-1 gaussprof 25-2 gdaCreate 22-11 gda
Index global control variables 33-19 .
Index installation, Linux 2-1 libraries, creating new 20-1 installation, Windows 2-2 libraries, loading 20-4 instruction pointer 9-3 library 29-1 interactive commands 8-6 library tool 20-1 interpreter 9-1 library, user 19-7, 19-13 intrinsic function 9-8 line colors 6-8 invar, ATOG command 27-1, 27-3, 273, 27-4, 27-6, 27-7, 27-8, 27-8, 279 line styles 6-8 keep (dataloop) 24-2 line thickness 33-30, 33-36, 33-37, 3338, 33-43, 33-44 keyword, calling 11-12 keyword, defining 11-10 keywords 11-1, 1
Index looping with arrays 15-15, 15-17 menu, file 3-4, 3-13 loopnextindex 15-17 menu, help 3-6 lt 10-10, 10-21 menu, symbol editor 3-30 .
Index not 10-13, 10-21 .not 10-14, 10-21 numeric operators 10-4 open 3-6, 22-8, 22-14 open file 3-4 open graph 3-5 operator precedence 9-29, 10-20 operators 9-29, 10-1 operators, dyadic 13-5 operators, element-by-element 10-1 operators, logical 10-12 operators, matrix 10-3 operators, numeric 10-4 operators, relational 10-9 or 10-14, 10-21 .
Index _pcross 33-29 plotAddXY 6-11 _pctrl 33-31 plotBar 6-1 _pdate 33-29 plotBox 6-1 period 10-15 plotClearLayout 6-14 _perrbar 33-29 plotContour 6-1 _pframe 33-30 plotCustomLayout 6-16, 6-17 _pgrid 33-31 plotGetDefaults 6-8 pixel coordinates 33-7 plotHist 6-1 _plegctl 33-32 plotHistF 6-1 _plegstr 33-33 plotHistP 6-1 _plev 33-33 plotLayout 6-13 _pline 33-33 plotLogLog 6-1 _pline3d 33-36 plotLogX 6-1 plot control structures 6-7 plotLogY 6-1 plot coordinate 33-7 plotPolar 6-1 plo
Index plotSetLineColor 6-8 _pnum 33-40 plotSetLineStyle 6-8 _pnumht 33-41 plotSetLineSymbol 6-8 pointer 9-49, 11-13, 11-14 plotSetLineThickness 6-8 pointer, instruction 9-2, 9-3 plotSetNewWindow 6-9, 6-14 pointers, structure 16-10, 16-10, 16-11, 16-12 plotSetTitle 6-9 plotSetXLabel 6-9 plotSetXTicInterval 6-9, 6-18, 6-22 plotSetXTicLabel 6-9, 6-18 plotSetYLabel 6-9 plotSetZLabel 6-9 _plotshf 33-37 _plotsiz 33-37 plotSurface 6-2 plotTS 6-2, 6-18 plotXY 6-2 _pltype 33-38 PQG fonts 33-17, 34-1 PQG G
Index _protate 33-41 _pxsci 33-44 _pscreen 33-41 _pypmax 33-45 _psilent 33-41 _pysci 33-45 _pstype 33-41 _pzclr 33-45 _psurf 33-42 _pzoom 33-45 _psym 33-42 _pzpmax 33-45 _psym3d 33-43 _pzsci 33-45 _psymsiz 33-44 radii 33-33 _ptek 33-44 random number generation, parallel 125 _pticout 33-44 _ptitlht 33-44 Publication Quality Graphics 33-1, 33-1, 33-2 random number generators 12-1, 12-4 random numbers 12-1, 12-3 readr 22-8, 22-14 putarray 15-7, 15-14 real 22-8 PV structure 16-15, 17-1 re
Index reload 3-31 scalerr 13-4 reload symbol 3-31 screen 22-5 remove buffer split 3-14 scrolling, 3-D plots 6-31 remove tab split 3-14 search and replace, advanced 3-26 reserved words 31-1 search next 3-8 restore curves 6-28 search previous 3-8 retp 11-7 secondary section 9-4 right-hand side 19-2 seekr 22-15 rotate, 3-D plots 6-31 select (dataloop) 24-2 rows 13-4 semicolon 9-1 rowsf 22-14 set watch 3-37 rules of syntax 9-37 setarray 15-7, 15-14 run 3-8 shortcuts 4-1 Run-Time Librar
Index spaces, extraneous 9-41, 10-15, 10-16 string concatenation 10-16 sparse matrices 9-17, 13-1, 13-2 string files 22-18, 22-19, 22-23 split file buffer horizontally 3-14 string variable substitution 10-17 split file buffer vertically 3-14 string, long 9-18 split horizontally 3-31 strings 9-18 split tab stack horizontally 3-14 strings, graphics 33-39 split tab stack vertically 3-14 struct editor 3-34 split vertically 3-31 structure definition 16-1 sqpSolveMT 16-22 structure indexing 16-5
Index syntax highlighting 3-16 transpose, bookkeeping 10-8 table 10-6 troubleshooting, libraries 19-12 tcollect 25-1, 25-2 TRUE 9-35 tensor 10-6 type 13-4 text boxes 7-3 unconditional branching 9-35 TGAUSS 8-1, 8-6 undo 3-5 thickness, line 33-30, 33-36, 33-37, 3338, 33-43, 33-44 UNN 9-28 threads 18-1, 18-4 tick marks 33-44 tilde 10-21, 13-4 time and date formats 26-2 time and date functions 26-1, 26-4 time series 6-18 time series plots 6-18 timed iterations 26-7 toggle auto-reload 3-31 toggle
Index zoom, 3-D plots 6-31 zooming graphs 33-45 Index-17