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 ...
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. 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, implementa ...
. It may also be used as a batch-oriented 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 Computer hardware, computing devi ...
, 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, ...
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 user In product development, an end user (sometimes end-user) is a person who ultimately uses or is intended to ulti ...
.


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, a former professor of the principal author. Levenspiel was known for his ability to perform quick back-of-the-envelope calculations.


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 computer at Pittsburgh Supercomputing Center 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-prog ...
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++ using the C++ standard library. * Octave uses an interpreter to execute the Octave scripting language. * Octave is extensible using dynamically loadable modules. * Octave interpreter has an
OpenGL OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve ha ...
-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 User (computing), users to Human–computer interaction, interact with electronic devices through graphical icon (comp ...
(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 Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs of selection ( if/then/else) and repetition (w ...
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, a ...
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 ha ...
. 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'' (franchi ...
-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 Efficiency, efficient Data access, access to data. More precisely, a data structure is a collection of data values, the rel ...
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 ...
. 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 user In product development, an end user (sometimes end-user) is a person who ultimately uses or is intended to ulti ...
, it may be freely changed, copied and used. The program runs on Microsoft Windows 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, a ...
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 daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
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 i ...
,
Android Android may refer to: Science and technology * Android (robot), a humanoid robot or synthetic organism designed to imitate a human * Android (operating system), Google's mobile operating system ** Bugdroid, a Google mascot sometimes referred to ...
, 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 (computer), Mac computers. Within the market of ...
.


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's tab completion). 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 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
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 are evaluated in a short-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 Increment and decrement operators are unary operators that ''add'' or ''subtract'' one, to or from their operand, respectively. They are commonly implemented in imperative programming languages. C-like languages feature two versions (pre- and ...
++ and -- in both their prefix and postfix forms. Octave also does augmented assignment, 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, a ...
modelled after th
unwind_protect
of
Lisp A lisp is a speech impairment in which a person misarticulates sibilants (, , , , , , , ). These misarticulations often result in unclear speech. Types * A frontal lisp occurs when the tongue is placed anterior to the target. Interdental lispi ...
. 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 This list contains selected positive numbers in increasing order, including counts of things, dimensionless quantities and probabilities. Each number is given a name in the short scale, which is used in English-speaking countries, as well as a ...
: #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 files.


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 In computing, a clone is hardware or software that is designed to function in exactly the same way as another system. A specific subset of clones are remakes (or remades), which are revivals of old, obsolete, or discontinued products. Motivati ...
, which does not infringe software copyright 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 prog ...
'' court case. MATLAB scripts from the MathWorks' FileExchange repository in principle are compatible with Octave. However, while they are often provided and uploaded by users under an Octave compatible and proper
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
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 li ...
, the FileExchange Terms of use prohibit any usage beside MathWorks' proprietary MATLAB.


Syntax compatibility

There are a few purposeful, albeit minor
syntax additions
# Comment lines can be prefixed with the # character as well as the % character; # Various C-based operators ++, --, +=, *=, /= are supported; # Elements can be referenced without creating a new variable by cascaded indexing, e.g. :103); #
String String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian anim ...
s can be defined with the double-quote " character as well as the single-quote ' character; # When the variable type is single (a single-precision floating-point number), Octave calculates the "
mean There are several kinds of mean in mathematics, especially in statistics. Each mean serves to summarize a given group of data, often to better understand the overall value ( magnitude and sign) of a given data set. For a data set, the '' ari ...
" in the single-domain (MATLAB in double-domain) which is faster but gives less accurate results; # Blocks can also be terminated with more specific Control structure keywords, i.e., endif, endfor, endwhile, etc.; # Functions can be defined within scripts and at the Octave prompt; # Presence of a do-until loop (similar to do-while in C).


Function compatibility

Many, but not all, of the numerous MATLAB functions are available in GNU Octave, some of them accessible through packages i
Octave Forge
The functions available as part of either core Octave or Forge packages are liste
online
A list of unavailable functions is included in the Octave function
__unimplemented.m__
Unimplemented functions are also listed under many Octave Forge packages in th
Octave Wiki
When an unimplemented function is called the following error message is shown: octave:1> guide warning: the 'guide' function is not yet implemented in Octave Please read to learn how you can contribute missing functionality. error: 'guide' undefined near line 1 column 1


User interfaces

Octave comes with an official
graphical user interface The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows User (computing), users to Human–computer interaction, interact with electronic devices through graphical icon (comp ...
(GUI) and an
integrated development environment An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools a ...
(IDE) based on Qt. It has been available since Octave 3.8, and has become the default interface (over the command line interface) with the release of Octave 4.0. It was well-received by an EDN contributor, who wrote " ctavenow has a very workable GUI" in reviewing the then-new GUI in 2014. Several 3rd-party graphical front-ends have also been developed, like ToolboX for coding education.


GUI applications

With Octave code, the user can create GUI applications. Se
GUI Development (GNU Octave (version 7.1.0))
Below are some examples: Button, edit control, checkbox # create figure and panel on it f = figure; # create a button (default style) b1 = uicontrol (f, "string", "A Button", "position", 0 10 150 40; # create an edit control e1 = uicontrol (f, "style", "edit", "string", "editable text", "position", 0 60 300 40; # create a checkbox c1 = uicontrol (f, "style", "checkbox", "string", "a checkbox", "position", 0 120 150 40; Textbox prompt = ; defaults = ; rowscols = ,10; 2,20; 3,30 dims = inputdlg (prompt, "Enter Box Dimensions", rowscols, defaults); Listbox with message boxes. my_options = ; el, ok= listdlg ("ListString", my_options, "SelectionMode", "Multiple"); if (ok

1) msgbox ("You selected:"); for i = 1:numel (sel) msgbox (sprintf ("\t%s", my_options)); endfor else msgbox ("You cancelled."); endif
Radiobuttons # create figure and panel on it f = figure; # create a button group gp = uibuttongroup (f, "Position", 0 0.5 1 1 # create a buttons in the group b1 = uicontrol (gp, "style", "radiobutton", "string", "Choice 1", "Position", 10 150 100 50 ; b2 = uicontrol (gp, "style", "radiobutton", "string", "Choice 2", "Position", 10 50 100 30 ; # create a button not in the group b3 = uicontrol (f, "style", "radiobutton","string", "Not in the group","Position", 10 50 100 50 ;


Packages

Octave also has many packages available. Those packages are located at Octave-Forg
Octave Forge - Packages
o
Github Octave Packages
It is also possible for anyone to create and maintain packages.


Comparison with other similar software

Other
free Free may refer to: Concept * Freedom, having the ability to do something, without having to obey anyone/anything * Freethought, a position that beliefs should be formed only on the basis of logic, reason, and empiricism * Emancipate, to procur ...
alternatives to MATLAB include Scilab and FreeMat. Octave is more compatible with MATLAB than Scilab is, and FreeMat has not been updated since June 2013.


See also

* List of numerical-analysis software * Comparison of numerical-analysis software * List of statistical packages * List of numerical libraries * MATLAB


Notes


References


Further reading

*


External links

* {{DEFAULTSORT:Gnu Octave Array programming languages Articles with example MATLAB/Octave code Cross-platform free software Data analysis software Data mining and machine learning software Free educational software Free mathematics software Free software programmed in C++
Octave In music, an octave ( la, octavus: eighth) or perfect octave (sometimes called the diapason) is the interval between one musical pitch and another with double its frequency. The octave relationship is a natural phenomenon that has been refer ...
High-priority free software projects Numerical analysis software for Linux Numerical analysis software for macOS Numerical analysis software for Windows Numerical programming languages Science software that uses Qt Software that uses Qt