GNU Octave
   HOME

TheInfoList



OR:

GNU Octave is a
high-level programming language In computer science, a high-level programming language is a programming language with strong abstraction from the details of the computer. In contrast to low-level programming languages, it may use natural language ''elements'', be easier to us ...
primarily intended for
scientific computing Computational science, also known as scientific computing or scientific computation (SC), is a field in mathematics that uses advanced computing capabilities to understand and solve complex problems. It is an area of science that spans many disc ...
and
numerical computation Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). It is the study of numerical methods th ...
. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with
MATLAB MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation ...
. It may also be used as a
batch-oriented Computerized batch processing is a method of running software programs called jobs in batches automatically. While users are required to submit the jobs, no other interaction by the user is required to process the batch. Batches may automatically ...
language. As part of the
GNU Project The GNU Project () is a free software, mass collaboration project announced by Richard Stallman on September 27, 1983. Its goal is to give computer users freedom and control in their use of their computers and computing devices by collaborat ...
, it is
free software Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, no ...
under the terms of the
GNU General Public License The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the Four Freedoms (Free software), four freedoms to run, study, share, and modify the software. The license was th ...
.


History

The project was conceived around 1988. At first it was intended to be a companion to a chemical reactor design course. Full development was started by John W. Eaton in 1992. The first alpha release dates back to 4 January 1993 and on 17 February 1994 version 1.0 was released. Version 7.1.0 was released on Apr 6, 2022. The program is named after
Octave Levenspiel Octave Levenspiel (January 1, 1926 – March 5, 2017) was a professor of chemical engineering at Oregon State University (OSU). His principal interest was chemical reaction engineering, and he was the author of a major textbook ''Chemical Reaction ...
, a former professor of the principal author. Levenspiel was known for his ability to perform quick
back-of-the-envelope calculation A back-of-the-envelope calculation is a rough calculation, typically jotted down on any available scrap of paper such as an envelope. It is more than a guess but less than an accurate calculation or mathematical proof. The defining characteristic o ...
s.


Development history


Developments

In addition to use on desktops for personal scientific computing, Octave is used in academia and industry. For example, Octave was used on a massive
parallel Parallel is a geometric term of location which may refer to: Computing * Parallel algorithm * Parallel computing * Parallel metaheuristic * Parallel (software), a UNIX utility for running programs in parallel * Parallel Sysplex, a cluster of ...
computer at
Pittsburgh Supercomputing Center The Pittsburgh Supercomputing Center (PSC) is a high performance computing and networking center founded in 1986 and one of the original five NSF Supercomputing Centers.
to find vulnerabilities related to guessing social security numbers. Acceleration with
OpenCL OpenCL (Open Computing Language) is a framework for writing programs that execute across heterogeneous platforms consisting of central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), field-progra ...
or
CUDA CUDA (or Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) that allows software to use certain types of graphics processing units (GPUs) for general purpose processing, an approach ...
is also possible with use of GPUs.


Technical details

* Octave is written in
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
using the
C++ standard library The C standard library or libc is the standard library for the C programming language, as specified in the ISO C standard. ISO/IEC (2018). '' ISO/IEC 9899:2018(E): Programming Languages - C §7'' Starting from the original ANSI C standard, it was ...
. * Octave uses an interpreter to execute the Octave scripting language. * Octave is extensible using dynamically loadable modules. * Octave interpreter has an OpenGL-based graphics engine to create plots, graphs and charts and to save or print them. Alternatively,
gnuplot gnuplot is a command-line and GUI program that can generate two- and three-dimensional plots of functions, data, and data fits. The program runs on all major computers and operating systems (Linux, Unix, Microsoft Windows, macOS, FreeDOS, ...
can be used for the same purpose. * Octave includes a
Graphical User Interface The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inste ...
(GUI) in addition to the traditional Command Line Interface (CLI); see #User interfaces for details.


Octave, the language

The Octave language is an interpreted programming language. It is a structured programming language (similar to C) and supports many common C standard library functions, and also certain
UNIX Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
system calls and functions. However, it does not support passing arguments by reference although function arguments are
copy-on-write Copy-on-write (COW), sometimes referred to as implicit sharing or shadowing, is a resource-management technique used in computer programming to efficiently implement a "duplicate" or "copy" operation on modifiable resources. If a resource is dupl ...
to avoid unnecessary duplication. Octave programs consist of a list of function calls or a
script Script may refer to: Writing systems * Script, a distinctive writing system, based on a repertoire of specific elements or symbols, or that repertoire * Script (styles of handwriting) ** Script typeface, a typeface with characteristics of handw ...
. The syntax is
matrix Matrix most commonly refers to: * ''The Matrix'' (franchise), an American media franchise ** ''The Matrix'', a 1999 science-fiction action film ** "The Matrix", a fictional setting, a virtual reality environment, within ''The Matrix'' (franchis ...
-based and provides various functions for matrix operations. It supports various
data structure In computer science, a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, a ...
s and allows
object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of pr ...
. Its syntax is very similar to MATLAB, and careful programming of a script will allow it to run on both Octave and MATLAB. Because Octave is made available under the
GNU General Public License The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the Four Freedoms (Free software), four freedoms to run, study, share, and modify the software. The license was th ...
, it may be freely changed, copied and used. The program runs on
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
and most
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
and
Unix-like A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
s, including
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
, Android, and
macOS macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
.


Notable features


Command and variable name completion

Typing a TAB character on the command line causes Octave to attempt to complete variable, function, and file names (similar to
Bash Bash or BASH may refer to: Arts and entertainment * ''Bash!'' (Rockapella album), 1992 * ''Bash!'' (Dave Bailey album), 1961 * '' Bash: Latter-Day Plays'', a dramatic triptych * ''BASH!'' (role-playing game), a 2005 superhero game * "Bash" ('' ...
's
tab completion Command-line completion (also tab completion) is a common feature of command-line interpreters, in which the program automatically fills in partially typed commands. Command line interpreters are programs that allow a user to interact with the u ...
). Octave uses the text before the cursor as the initial portion of the name to complete.


Command history

When running interactively, Octave saves the commands typed in an internal buffer so that they can be recalled and edited.


Data structures

Octave includes a limited amount of support for organizing data in structures. In this example, we see a structure with elements , , and , (an integer, an array, and a string, respectively): octave:1> x.a = 1; x.b = , 2; 3, 4 x.c = "string"; octave:2> x.a ans = 1 octave:3> x.b ans = 1 2 3 4 octave:4> x.c ans = string octave:5> x x =


Short-circuit Boolean operators

Octave's && and , , logical
operators Operator may refer to: Mathematics * A symbol indicating a mathematical operation * Logical operator or logical connective in mathematical logic * Operator (mathematics), mapping that acts on elements of a space to produce elements of another sp ...
are evaluated in a
short-circuit A short circuit (sometimes abbreviated to short or s/c) is an electrical circuit that allows a current to travel along an unintended path with no or very low electrical impedance. This results in an excessive current flowing through the circuit. ...
fashion (like the corresponding operators in the C language), in contrast to the element-by-element operators & and , .


Increment and decrement operators

Octave includes the C-like increment and decrement operators ++ and -- in both their prefix and postfix forms. Octave also does
augmented assignment Augmented assignment (or compound assignment) is the name given to certain assignment operators in certain programming languages (especially those derived from C). An augmented assignment is generally used to replace a statement where an operat ...
, e.g. x += 5.


Unwind-protect

Octave supports a limited form of
exception handling In computing and computer programming, exception handling is the process of responding to the occurrence of ''exceptions'' – anomalous or exceptional conditions requiring special processing – during the execution of a program. In general, an ...
modelled after th
unwind_protect
of Lisp. The general form of an unwind_protect block looks like this: unwind_protect body unwind_protect_cleanup cleanup end_unwind_protect As a general rule, GNU Octave recognizes as termination of a given ''block'' either the keyword end (which is compatible with the MATLAB language) or a more specific keyword end_''block''. As a consequence, an unwind_protect block can be terminated either with the keyword end_unwind_protect as in the example, or with the more portable keyword end. The ''cleanup'' part of the block is always executed. In case an exception is raised by the ''body'' part, ''cleanup'' is executed immediately before propagating the exception outside the block unwind_protect. GNU Octave also supports another form of exception handling (compatible with the MATLAB language): try body catch exception_handling end This latter form differs from an unwind_protect block in two ways. First, ''exception_handling'' is only executed when an exception is raised by ''body''. Second, after the execution of ''exception_handling'' the exception is not propagated outside the block (unless a rethrow( lasterror ) statement is explicitly inserted within the ''exception_handling'' code).


Variable-length argument lists

Octave has a mechanism for handling functions that take an unspecified number of arguments without explicit upper limit. To specify a list of zero or more arguments, use the special argument varargin as the last (or only) argument in the list. function s = plus (varargin) if (nargin

0) s = 0; else s = varargin + plus (varargin); end end


Variable-length return lists

A function can be set up to return any number of values by using the special return value varargout. For example: function varargout = multiassign (data) for k=1:nargout varargout = data(:,k); end end


C++ integration

It is also possible to execute Octave code directly in a C++ program. For example, here is a code snippet for calling rand( 0,1: #include ... ColumnVector NumRands(2); NumRands(0) = 10; NumRands(1) = 1; octave_value_list f_arg, f_ret; f_arg(0) = octave_value(NumRands); f_ret = feval("rand", f_arg, 1); Matrix unis(f_ret(0).matrix_value()); C and C++ code can be integrated into GNU Octave by creating oct files, or using the MATLAB compatible
MEX file A MEX file is a type of computer file that provides an interface between MATLAB or Octave and functions written in C, C++ or Fortran. It stands for "MATLAB executable". When compiled, MEX files are dynamically loaded and allow external functions ...
s.


MATLAB compatibility

Octave has been built with MATLAB compatibility in mind, and shares many features with MATLAB: # Matrices as fundamental data type. # Built-in support for complex numbers. # Powerful built-in math functions and extensive function libraries. # Extensibility in the form of user-defined functions. Octave treats incompatibility with MATLAB as a bug; therefore, it could be considered a software clone, which does not infringe
software copyright Software copyright is the application of copyright in law to machine-readable software. While many of the legal principles and policy debates concerning software copyright have close parallels in other domains of copyright law, there are a number o ...
as per ''
Lotus v. Borland ''Lotus Dev. Corp. v. Borland Int'l, Inc.'', 516 U.S. 233 (1996), is a United States Supreme Court case that tested the extent of software copyright.. The lower court had held that copyright does not extend to the user interface of a computer progr ...
'' court case. MATLAB scripts from the
MathWorks MathWorks is an American privately held corporation that specializes in mathematical computing software. Its major products include MATLAB and Simulink, which support data analysis and simulation. History The company's key product, MATLAB, was ...
' FileExchange repository in principle are compatible with Octave. However, while they are often provided and uploaded by users under an Octave
compatible Compatibility may refer to: Computing * Backward compatibility, in which newer devices can understand data generated by older devices * Compatibility card, an expansion card for hardware emulation of another device * Compatibility layer, compo ...
and proper open source
BSD license BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD lice ...
, the FileExchange Terms of use prohibit any usage beside MathWorks'
proprietary {{Short pages monitor