GNU Octave
Encyclopedia
GNU Octave is a high-level language, primarily intended for numerical computations
Numerical analysis
Numerical analysis is the study of algorithms that use numerical approximation for the problems of mathematical analysis ....

. It provides a convenient command-line interface
Command-line interface
A command-line interface is a mechanism for interacting with a computer operating system or software by typing commands to perform specific tasks...

 (CLI) for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with MATLAB
MATLAB
MATLAB is a numerical computing environment and fourth-generation programming language. Developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages,...

. It may also be used as a batch-oriented
Batch processing
Batch processing is execution of a series of programs on a computer without manual intervention.Batch jobs are set up so they can be run to completion without manual intervention, so all input data is preselected through scripts or command-line parameters...

 language.
As part of the GNU Project
GNU Project
The GNU Project is a free software, mass collaboration project, announced on September 27, 1983, by Richard Stallman at MIT. It initiated GNU operating system development in January, 1984...

, it is free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 under the terms of the GNU General Public License
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

 (GPL).

History

The project was conceived around 1988. At first it was intended to be a companion to a chemical reactor design course. Real development was started by John W. Eaton
John W. Eaton
For other people named John Eaton, see John Eaton .John W. Eaton is the initial and main author of Octave, a system for numerical computations with a language that is mostly compatible with MATLAB, but is free software....

 in 1992. The first alpha release dates back to January 4, 1993 and on February 17, 1994 version 1.0 was released. Version 3.0 was released on December 21, 2007.

The program is named after Octave Levenspiel
Octave Levenspiel
Octave Levenspiel is an Emeritus professor of chemical engineering at Oregon State University. His principal interest has been chemical reaction engineering, a branch of chemical engineering studying the application of chemical reaction kinetics and physics to the design of chemical reactors.He...

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

s.

Deployments

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 computing
Parallel computing is a form of computation in which many calculations are carried out simultaneously, operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently . There are several different forms of parallel computing: bit-level,...

 computer at Pittsburgh supercomputing center to find vulnerability related to guessing social security numbers.

Technical details

  • Octave is written in C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

     using the Standard Template Library
    Standard Template Library
    The Standard Template Library is a C++ software library which later evolved into the C++ Standard Library. It provides four components called algorithms, containers, functors, and iterators. More specifically, the C++ Standard Library is based on the STL published by SGI. Both include some...

     (STL).
  • Octave uses an interpreter
    Interpreter (computing)
    In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language...

     to execute the Octave scripting language.
  • Octave is extensible using dynamically loadable modules.
  • Octave interpreter works with gnuplot
    Gnuplot
    - License :Despite gnuplot's name, it is not part of or related to the GNU system and it is not distributed under the GNU General Public License .However, some GNU packages do use gnuplot....

     and Grace
    Grace (plotting tool)
    Grace is a free WYSIWYG 2D graph plotting tool, for Unix-like operating systems. The package name stands for "GRaphing, Advanced Computation and Exploration of data." Grace uses the X Window System and Motif for its GUI. It has been ported to VMS, OS/2, and Windows 9*/NT/2000/XP...

     software to create plots, graphs, and charts, and to save or print them.

Octave, the language

The Octave language is an interpreted programming language. It is a structured programming language (similar to C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

) and supports many common C standard library
C standard library
The C Standard Library is the standard library for the programming language C, as specified in the ANSI C standard.. It was developed at the same time as the C POSIX library, which is basically a superset of it...

 functions, and also certain UNIX
POSIX
POSIX , an acronym for "Portable Operating System Interface", is a family of standards specified by the IEEE for maintaining compatibility between operating systems...

 system calls and functions. However, it does not support passing arguments by reference.

Octave programs consist of a list of function calls or a script.
The syntax is matrix
Array programming
In computer science, array programming languages generalize operations on scalars to apply transparently to vectors, matrices, and higher dimensional arrays....

-based and provides various functions for matrix operations. It is not object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

, but it does support various data structure
Data structure
In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks...

s.

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
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

, it may be freely changed, copied and used. The program runs under most Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 and Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s including Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, and Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

.

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. For instance:

octave:1> x.a = 1; x.b = [1, 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 =
{
a = 1
b =

1 2
3 4

c = string
}

Short-circuit boolean operators

Octave's '&&' and '||' logical operators
Operator (programming)
Programming languages typically support a set of operators: operations which differ from the language's functions in calling syntax and/or argument passing mode. Common examples that differ by syntax are mathematical arithmetic operations, e.g...

 are evaluated in a short-circuit fashion (like the corresponding operators in the C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 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
Increment and decrement operators are unary operators that add or subtract one from their operand, respectively. They are commonly implemented in imperative programming languages...

 '++' and '--' in both their prefix and postfix forms.
Also augmented assignment
Augmented assignment
Augmented assignment is the name given to certain operators in certain programming languages...

.

Unwind-protect

Octave supports a limited form of exception handling
Exception handling
Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....

 modelled after the '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 purposely inserted within the exception_handling code).

Variable-length argument lists

Octave has a real 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 (nargin0)
s = 0;
else
s = varargin{1} + plus (varargin{2:nargin});
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{k} = 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([10,1]):
  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);

MATLAB compatibility
Octave has been built with MATLAB
MATLAB
MATLAB is a numerical computing environment and fourth-generation programming language. Developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages,...

 compatibility in mind, and shares many features with MATLAB:
  1. Matrices as fundamental data type.
  2. Built-in support for complex numbers.
  3. Powerful built-in math functions and extensive function libraries.
  4. Extensibility in the form of user-defined functions.


There are a few purposeful, albeit minor, differences:
  1. Comment lines can be prefixed with the # character as well as the % character
  2. Various C-based operators ++, --, +=, *=, /= are supported
  3. Elements can be referenced without creating a new variable, e.g. [1:10](3)
  4. Strings can be defined with the " character as well as the ' character

See also



External links


Documentation


Numerical packages and libraries interfacing with GNU Octave

GNU Octave is also powered by third-party tools and libraries, mostly providing general or domain-specific abstractions for scientific computing. Those tools may be categorized according whether their contributions are more oriented toward computational modelling or toward enhancing visual analysis.

Numerical tools

  • Octave-forge community development page – Free software toolboxes for various problems from independent developers. A Windows installer for both GNU Octave and the toolboxes is also available.
  • Mastrave project – Cross-language library (GNU GPLv3+ covered) compatible with GNU Octave and Matlab, to ease environmental modelling
    Scientific modelling
    Scientific modelling is the process of generating abstract, conceptual, graphical and/or mathematical models. Science offers a growing collection of methods, techniques and theory about all kinds of specialized scientific modelling...

     with general purpose semantic array programming
    Array programming
    In computer science, array programming languages generalize operations on scalars to apply transparently to vectors, matrices, and higher dimensional arrays....

     utilities.
  • Neuroimaging Analysis Kit – Library (MIT License
    MIT License
    The MIT License is a free software license originating at the Massachusetts Institute of Technology . It is a permissive license, meaning that it permits reuse within proprietary software provided all copies of the licensed software include a copy of the MIT License terms...

     covered) to process neuroimaging
    Neuroimaging
    Neuroimaging includes the use of various techniques to either directly or indirectly image the structure, function/pharmacology of the brain...

     data within GNU Octave or Matlab, particularly functional magnetic resonance images. It also offers a Pipeline system to handle multi-stage processing.
  • Parallel Matlab Toolbox – Matlab language data structures and functions which implement distributed Matlab arrays. It is released under MIT license.
  • MPI Toolbox for Octave (MPITB) – Parallel Computing for Octave using MPI.

Plotting tools

  • PLPlot
    PLplot
    PLplot is a library of functions that are often used to make scientific plots in compiled languages such as C, C++, D, Fortran, Ada, OCaml and Java. PLplot can also be used interactively by interpreted languages such as Octave, Python, Perl and Tcl. The current version was written primarily by...

     – A replacement of the traditional gnuplot
    Gnuplot
    - License :Despite gnuplot's name, it is not part of or related to the GNU system and it is not distributed under the GNU General Public License .However, some GNU packages do use gnuplot....

     in GNU Octave, licensed under the GNU LGPL.
  • OctPlot – High quality 2D graphics (postscript and screen graphics). Released under GNU GPL.
  • Octave graphics add-on – 3D visualization system for Octave.
  • Octaviz – 3D visualization system for GNU Octave (wrapper that makes VTK classes accessible from within GNU Octave). It also provides high-level functions for 2D visualization. (Note: Their site says, "Unfortunately, Octaviz is no longer in development. The latest release (0.4.7) was quite usable and stable when built against vtk-5.0.")

User interfaces

Current versions of Octave do not come with a graphical user interface (GUI)/integrated development environment (IDE) by default. However, an official graphical interface based on Qt has now been migrated to the main source repository and will likely be released with Octave 4.0. Several 3rd-party graphical front-ends have been developed:
Matlab-like IDEs
  • GUIOctave (Windows; closed source) Under active development as of 2011.
  • Xoctave (Windows, Linux; GPL3) Under active development as of 2011.
  • QtOctave Graphical User Interface (Windows, Linux; GPL2) Official development ceased June 2011.
  • Kalculus (Linux) Matlab like UI for GNU Octave and Yacas
    Yacas
    Yacas is a general-purpose computer algebra system. The name is an acronym for Yet Another Computer Algebra System.Released under the GNU General Public License, Yacas is free software....

     written in Qt4
    Qt (toolkit)
    Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface , and also used for developing non-GUI programs such as command-line tools and consoles for servers...

     with Ruby
    Ruby (programming language)
    Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

     bindings. Last updated Jun 2008.

Other GUIs
  • Cantor
    Cantor (software)
    Cantor is a free software mathematics application for scientific statistics and analysis. It is part of the KDE Software Compilation 4, and was introduced with the 4.4 release as part of the KDE Education Project's kdeedu package.- Features :...

     (Linux, Windows; GPL2) A KDE mathematics application, with backends for R, Maxima, Octave, Scilab, Sage, KAlgebra, and Qalculate. Under active development as of 2011.
  • OctaveNB (Linux, Windows, OS X; GPL2) NetBeans IDE integration for GNU Octave. Last updated Apr 2009.

Web-based user interfaces (WUI)

Further reading
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK