This is Info file octave.info, produced by Makeinfo-1.64 from the input
file octave.texi.

   Copyright (C) 1993, 1994, 1995 John W. Eaton.

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions.


File: octave.info,  Node: Rearranging Matrices,  Prev: Finding Elements and Checking Conditions,  Up: Matrix Manipulation

Rearranging Matrices
====================

   The function `fliplr' reverses the order of the columns in a matrix,
and `flipud' reverses the order of the rows.  For example,

     octave:13> fliplr ([1, 2; 3, 4])
     ans =
     
       2  1
       4  3
     
     octave:13> flipud ([1, 2; 3, 4])
     ans =
     
       3  4
       1  2

   The function `rot90 (A, N)' rotates a matrix counterclockwise in
90-degree increments.  The second argument is optional, and specifies
how many 90-degree rotations are to be applied (the default value is
1).  Negative values of N rotate the matrix in a clockwise direction.
For example,

     rot90 ([1, 2; 3, 4], -1)
     ans =
     
       3  1
       4  2

rotates the given matrix clockwise by 90 degrees.  The following are all
equivalent statements:

     rot90 ([1, 2; 3, 4], -1)
     rot90 ([1, 2; 3, 4], 3)
     rot90 ([1, 2; 3, 4], 7)

   The function `reshape (A, M, N)' returns a matrix with M rows and N
columns whose elements are taken from the matrix A.  To decide how to
order the elements, Octave pretends that the elements of a matrix are
stored in column-major order (like Fortran arrays are stored).

   For example,

     octave:13> reshape ([1, 2, 3, 4], 2, 2)
     ans =
     
       1  3
       2  4

   If the variable `do_fortran_indexing' is `"true"', the `reshape'
function is equivalent to

     retval = zeros (m, n);
     retval (:) = a;

but it is somewhat less cryptic to use `reshape' instead of the colon
operator.  Note that the total number of elements in the original
matrix must match the total number of elements in the new matrix.

   The function `sort' can be used to arrange the elements of a vector
in increasing order.  For matrices, `sort' orders the elements in each
column.

   For example,

     octave:13> sort (rand (4))
     ans =
     
       0.065359  0.039391  0.376076  0.384298
       0.111486  0.140872  0.418035  0.824459
       0.269991  0.274446  0.421374  0.938918
       0.580030  0.975784  0.562145  0.954964

   The `sort' function may also be used to produce a matrix containing
the original row indices of the elements in the sorted matrix.  For
example,

     s =
     
       0.051724  0.485904  0.253614  0.348008
       0.391608  0.526686  0.536952  0.600317
       0.733534  0.545522  0.691719  0.636974
       0.986353  0.976130  0.868598  0.713884
     
     i =
     
       2  4  2  3
       4  1  3  4
       1  2  4  1
       3  3  1  2

These values may be used to recover the original matrix from the sorted
version.  For example,


   The `sort' function does not allow sort keys to be specified, so it
can't be used to order the rows of a matrix according to the values of
the elements in various columns(1) in a single call.  Using the second
output, however, it is possible to sort all rows based on the values in
a given column.  Here's an example that sorts the rows of a matrix
based on the values in the third column.

     octave:13> a = rand (4)
     a =
     
       0.080606  0.453558  0.835597  0.437013
       0.277233  0.625541  0.447317  0.952203
       0.569785  0.528797  0.319433  0.747698
       0.385467  0.124427  0.883673  0.226632
     
     octave:14> [s, i] = sort (a (:, 3));
     octave:15> a (i, :)
     ans =
     
       0.569785  0.528797  0.319433  0.747698
       0.277233  0.625541  0.447317  0.952203
       0.080606  0.453558  0.835597  0.437013
       0.385467  0.124427  0.883673  0.226632

   The functions `triu (A, K)' and `tril (A, K)' extract the upper or
lower triangular part of the matrix A, and set all other elements to
zero.  The second argument is optional, and specifies how many
diagonals above or below the main diagonal should also be set to zero.

   The default value of K is zero, so that `triu' and `tril' normally
include the main diagonal as part of the result matrix.

   If the value of K is negative, additional elements above (for
`tril') or below (for `triu') the main diagonal are also selected.

   The absolute value of K must not be greater than the number of sub-
or super-diagonals.

   For example,
     octave:13> tril (rand (4), 1)
     ans =
     
       0.00000  0.00000  0.00000  0.00000
       0.09012  0.00000  0.00000  0.00000
       0.01215  0.34768  0.00000  0.00000
       0.00302  0.69518  0.91940  0.00000

forms a lower triangular matrix from a random 4 by 4 matrix, omitting
the main diagonal, and

     octave:13> tril (rand (4), -1)
     ans =
     
       0.06170  0.51396  0.00000  0.00000
       0.96199  0.11986  0.35714  0.00000
       0.16185  0.61442  0.79343  0.52029
       0.68016  0.48835  0.63609  0.72113

forms a lower triangular matrix from a random 4 by 4 matrix, including
the main diagonal and the first super-diagonal.

   ---------- Footnotes ----------

   (1)  For example, to first sort based on the values in column 1, and
then, for any values that are repeated in column 1, sort based on the
values found in column 2, etc.


File: octave.info,  Node: String Functions,  Next: System Utilities,  Prev: Matrix Manipulation,  Up: Top

String Functions
****************

   Octave currently has a limited ability to work with strings.

   The function `strcmp (S1, S2)' compares two strings, returning 1 if
they are the same, and 0 otherwise.

   *Note: For compatibility with MATLAB, Octave's strcmp function
returns 1 if the strings are equal, and 0 otherwise.  This is just the
opposite of the corresponding C library function.*

   The functions `int2str' and `num2str' convert a numeric argument to
a string.  These functions are not very flexible, but are provided for
compatibility with MATLAB.  For better control over the results, use
`sprintf' (*note Formatted Output::.).

   The function `setstr' can be used to convert a vector to a string.
Each element of the vector is converted to the corresponding ASCII
character.  For example,

     setstr ([97, 98, 99])

creates the string

     abc

   The function `undo_string_escapes (STRING)' converts special
characters in strings back to their escaped forms.  For example, the
expression

     bell = "\a";

assigns the value of the alert character (control-g, ASCII code 7) to
the string variable BELL.  If this string is printed, the system will
ring the terminal bell (if it is possible).  This is normally the
desired outcome.  However, sometimes it is useful to be able to print
the original representation of the string, with the special characters
replaced by their escape sequences.  For example,

     octave:13> undo_string_escapes (bell)
     ans = \a

replaces the unprintable alert character with its printable
representation.  *Note String Constants::, for a description of string
escapes.


File: octave.info,  Node: System Utilities,  Next: Command History Functions,  Prev: String Functions,  Up: Top

System Utilities
****************

   This chapter describes the functions that are available to allow you
to get information about what is happening outside of Octave, while it
is still running, and use this information in your program.  For
example, you can get information about environment variables, the
current time, and even start other programs from the Octave prompt.

* Menu:

* Timing Utilities::
* Interacting with the OS::
* System Information::
* Other Functions::


File: octave.info,  Node: Timing Utilities,  Next: Interacting with the OS,  Prev: System Utilities,  Up: System Utilities

Timing Utilities
================

   The function `clock' returns a vector containing the current year,
month (1-12), day (1-31), hour (0-23), minute (0-59) and second (0-60).
For example,

     octave:13> clock
     ans =
     
       1993     8    20     4    56     1

   The function clock is more accurate on systems that have the
`gettimeofday' function.

   To get the date as a character string in the form DD-MMM-YY, use the
command `date'.  For example,

     octave:13> date
     ans = 20-Aug-93

   Octave also has functions for computing time intervals and CPU time
used.  The functions `tic' and `toc' can be used to set and check a
wall-clock timer.  For example,

     tic ();
     # many computations later...
     elapsed_time = toc ();

will set the variable `elapsed_time' to the number of seconds since the
most recent call to the function `tic'.

   The function `etime' provides another way to get elapsed wall-clock
time by returning the difference (in seconds) between two time values
returned from `clock'.  For example:

     t0 = clock ();
     # many computations later...
     elapsed_time = etime (clock (), t0);

will set the variable `elapsed_time' to the number of seconds since the
variable `t0' was set.

   The function `cputime' allows you to obtain information about the
amount of CPU time your Octave session is using.  For example,

     [total, user, system] = cputime ();

returns the CPU time used by your Octave session.  The first output is
the total time spent executing your process and is equal to the sum of
second and third outputs, which are the number of CPU seconds spent
executing in user mode and the number of CPU seconds spent executing in
system mode, respectively.

   Finally, Octave's function `is_leap_year' returns 1 if the given
year is a leap year and 0 otherwise.  If no arguments are provided,
`is_leap_year' will use the current year.  For example,

     octave:13> is_leap_year (2000)
     ans = 1

Contrary to what many people who post misinformation to Usenet
apparently believe, Octave knows that the year 2000 will be a leap year.


File: octave.info,  Node: Interacting with the OS,  Next: System Information,  Prev: Timing Utilities,  Up: System Utilities

Interacting with the OS
=======================

   You can execute any shell command using the function `system (CMD,
FLAG)'.  The second argument is optional.  If it is present, the output
of the command is returned by `system' as a string.  If it is not
supplied, any output from the command is printed, with the standard
output filtered through the pager.  For example,

     users = system ("finger", 1)

places the output of the command `finger' in the variable `users'.

   If you want to execute a shell command and have it behave as if it
were typed directly from the shell prompt, you may need to specify extra
arguments for the command.  For example, to get `bash' to behave as an
interactive shell, you can type

     system ("bash -i >/dev/tty");

   The first argument, `-i', tells `bash' to behave as an interactive
shell, and the redirection of the standard output stream prevents any
output produced by `bash' from being sent back to Octave, where it
would be buffered until Octave displays another prompt.

   The `system' function can return two values.  The first is any
output from the command that was written to the standard output stream,
and the second is the output status of the command.  For example,

     [output, status] = system ("echo foo; exit 2");

will set the variable `output' to the string `foo', and the variable
`status' to the integer `2'.

   The name `shell_cmd' exists for compatibility with earlier versions
of Octave.

   You can find the values of environment variables using the function
`getenv'.  For example,

     getenv ("PATH")

returns a string containing the value of your path.

   The functions `clc', and `home' clear your terminal screen and move
the cursor to the upper left corner.

   You can change the current working directory using the `cd' command.
Tilde expansion is performed on the path.  For example,

     cd ~/octave

Changes the current working directory to `~/octave'.  If the directory
does not exist, an error message is printed and the working directory
is not changed.

   The name `chdir' is an alias for `cd'.

   The command `pwd' prints the current working directory.

   The functions `dir' and `ls' list directory contents.  For example,

     octave:13> ls -l
     total 12
     -rw-r--r--   1 jwe      users        4488 Aug 19 04:02 foo.m
     -rw-r--r--   1 jwe      users        1315 Aug 17 23:14 bar.m

   The `dir' and `ls' commands are implemented by calling your system's
directory listing command, so the available options may vary from
system to system.


File: octave.info,  Node: System Information,  Next: Other Functions,  Prev: Interacting with the OS,  Up: System Utilities

System Information
==================

   If possible, `computer' prints a string of the form CPU-VENDOR-OS
that identifies the kind of computer Octave is running on.  For example,

     octave:13> computer
     sparc-sun-sunos4.1.2

   The function `isieee' returns 1 if your computer claims to conform
to the IEEE standard for floating point calculations.

   The function `version' returns Octave's version number as a string.
This is also the value of the built-in variable `OCTAVE_VERSION'.
*Note Built-in Variables::.


File: octave.info,  Node: Other Functions,  Prev: System Information,  Up: System Utilities

Other Functions
===============

   The function `pause' allows you to suspend the execution of a
program.  If invoked without any arguments, Octave waits until you type
a character.  With a numeric argument, it pauses for the given number of
seconds.  For example, the following statement prints a message and then
waits 5 seconds before clearing the screen.

     fprintf (stderr, "wait please...\n"), pause (5), clc


File: octave.info,  Node: Command History Functions,  Next: Help,  Prev: System Utilities,  Up: Top

Command History Functions
*************************

   Octave provides three functions for viewing, editing, and re-running
chunks of commands from the history list.

   The function `history' displays a list of commands that you have
executed.  It also allows you to write the current history to a file for
safe keeping, and to replace the history list with the commands stored
in a named file.  Valid arguments are:

`-w file'
     Write the current history to the named file.  If the name is
     omitted, use the default history file (normally `~/.octave_hist').

`-r file'
     Read the named file, replacing the current history list with its
     contents.  If the name is omitted, use the default history file
     (normally `~/.octave_hist').

`N'
     Only display the most recent `N' lines of history.

`-q'
     Don't number the displayed lines of history.  This is useful for
     cutting and pasting commands if you are using the X Window System.

   For example, to display the five most recent commands that you have
typed without displaying line numbers, use the command `history -q 5'.

   The function `edit_history' allows you to edit a block of commands
from the history list using the editor named by the environment
variable `EDITOR', or the default editor (normally `vi').  It is often
more convenient to use `edit_history' to define functions rather than
attempting to enter them directly on the command line.  By default, the
block of commands is executed as soon as you exit the editor.  To avoid
executing any commands, simply delete all the lines from the buffer
before exiting the editor.

   The `edit_history' command takes two optional arguments specifying
the history numbers of first and last commands to edit.  For example,
the command

     edit_history 13

extracts all the commands from the 13th through the last in the history
list.  The command

     edit_history 13 169

only extracts commands 13 through 169.  Specifying a larger number for
the first command than the last command reverses the list of commands
before placing them in the buffer to be edited.  If both arguments are
omitted, the previous command in the history list is used.

   The command `run_history' is like `edit_history', except that the
editor is not invoked, and the commands are simply executed as they
appear in the history list.

   The `diary' command allows you to create a list of all commands
*and* the output they produce, mixed together just as you see them on
your terminal.

   For example, the command

     diary on

tells Octave to start recording your session in a file called `diary'
in your current working directory.  To give Octave the name of the file
write to, use the a command like

     diary my-diary.txt

Then Octave will write all of your commands to the file `my-diary.txt'.

   To stop recording your session, use the command

     diary off

Without any arguments, `diary' toggles the current diary state.


File: octave.info,  Node: Help,  Next: Programming Utilities,  Prev: Command History Functions,  Up: Top

Help
****

   Octave's `help' command can be used to print brief usage-style
messages, or to display information directly from an on-line version of
the printed manual, using the GNU Info browser.  If invoked without any
arguments, `help' prints a list of all the available operators,
functions, and built-in variables.  If the first argument is `-i', the
`help' command searches the index of the on-line version of this manual
for the given topics.

   For example, the command

     help help

prints a short message describing the `help' command, and

     help -i help

starts the GNU Info browser at this node in the on-line version of the
manual.

   *Note Using Info::, for complete details about how to use the GNU
Info browser to read the on-line version of the manual.


File: octave.info,  Node: Programming Utilities,  Next: Amusements,  Prev: Help,  Up: Top

Programming Utilities
*********************

* Menu:

* Evaluating Strings as Commands::
* Miscellaneous Utilities::


File: octave.info,  Node: Evaluating Strings as Commands,  Next: Miscellaneous Utilities,  Prev: Programming Utilities,  Up: Programming Utilities

Evaluating Strings as Commands
==============================

   It is often useful to evaluate a string as if it were an Octave
program, or use a string as the name of a function to call.  These
functions are necessary in order to evaluate commands that are not
known until run time, or to write functions that will need to call
user-supplied functions.

   The function `eval (COMMAND)' parses COMMAND and evaluates it as if
it were an Octave program, returning the last value computed.  The
COMMAND is evaluated in the current context, so any results remain
available after `eval' returns.  For example,

     octave:13> a
     error: `a' undefined
     octave:14> eval ("a = 13")
     a = 13
     ans = 13
     octave:15> a
     a = 13

   In this case, two values are printed:  one for the expression that
was evaluated, and one for the value returned from `eval'.  Just as
with any other expression, you can turn printing off by ending the
expression in a semicolon.  For example,

     octave:13> a
     error: `a' undefined
     octave:14> eval ("a = 13;")
     ans = 13
     octave:15> a
     a = 13

   The function `feval (NAME, ...)' can be used to evaluate the
function named NAME.  Any arguments after the first are passed on to
the named function.  For example,

     octave:12> feval ("acos", -1)
     ans = 3.1416

calls the function `acos' with the argument `-1'.

   The function `feval' is necessary in order to be able to write
functions that call user-supplied functions, because Octave does not
have a way to declare a pointer to a function (like C) or to declare a
special kind of variable that can be used to hold the name of a function
(like `EXTERNAL' in Fortran).  Instead, you must refer to functions by
name, and use `feval' to call them.

   For example, here is a simple-minded function for finding the root
of a function of one variable:

     function result = newtroot (fname, x)
     
     # usage: newtroot (fname, x)
     #
     #   fname : a string naming a function f(x).
     #   x     : initial guess
     
       delta = tol = sqrt (eps);
       maxit = 200;
       fx = feval (fname, x);
       for i = 1:maxit
         if (abs (fx) < tol)
           result = x;
           return;
         else
           fx_new = feval (fname, x + delta);
           deriv = (fx_new - fx) / delta;
           x = x - fx / deriv;
           fx = fx_new;
         endif
       endfor
     
       result = x;
     
     endfunction

   Note that this is only meant to be an example of calling
user-supplied functions and should not be taken too seriously.  In
addition to using a more robust algorithm, any serious code would check
the number and type of all the arguments, ensure that the supplied
function really was a function, etc.


File: octave.info,  Node: Miscellaneous Utilities,  Prev: Evaluating Strings as Commands,  Up: Programming Utilities

Miscellaneous Utilities
=======================

   The following functions allow you to determine the size of a
variable or expression, find out whether a variable exists, print error
messages, or delete variable names from the symbol table.

`columns (A)'
     Return the number of columns of A.

`rows (A)'
     Return the number of rows of A.

`length (A)'
     Return the number of rows of A or the number of columns of A,
     whichever is larger.

`size (A [, N])'
     Return the number rows and columns of A.

     With one input argument and one output argument, the result is
     returned in a 2 element row vector.  If there are two output
     arguments, the number of rows is assigned to the first, and the
     number of columns to the second.  For example,

          octave:13> size ([1, 2; 3, 4; 5, 6])
          ans =
          
            3  2
          
          octave:14> [nr, nc] = size ([1, 2; 3, 4; 5, 6])
          nr = 3
          
          nc = 2

     If given a second argument of either 1 or 2, `size' will return
     only the row or column dimension.  For example

          octave:15> size ([1, 2; 3, 4; 5, 6], 2)
          ans = 2

     returns the number of columns in the given matrix.

`is_global (A)'
     Return 1 if A is globally visible.  Otherwise, return 0.

`is_matrix (A)'
     Return 1 if A is a matrix.  Otherwise, return 0.

`is_vector (A)'
     Return 1 if A is a vector.  Otherwise, return 0.

`is_scalar (A)'
     Return 1 if A is a scalar.  Otherwise, return 0.

`is_square (X)'
     If X is a square matrix, then return the dimension of X.
     Otherwise, return 0.

`is_symmetric (X, TOL)'
     If X is symmetric within the tolerance specified by TOL, then
     return the dimension of X.  Otherwise, return 0.  If TOL is
     omitted, use a tolerance equal to the machine precision.

`isstr (A)'
     Return 1 if A is a string.  Otherwise, return 0.

`isempty (A)'
     Return 1 if A is an empty matrix (either the number of rows, or
     the number of columns, or both are zero).  Otherwise, return 0.

`clear PATTERN ...'
     Delete the names matching the given patterns from the symbol
     table.  The pattern may contain the following special characters:
    `?'
          Match any single character.

    `*'
          Match zero or more characters.

    `[ LIST ]'
          Match the list of characters specified by LIST.  If the first
          character is `!' or `^', match all characters except those
          specified by LIST.  For example, the pattern `[a-zA-Z]' will
          match all lower and upper case alphabetic characters.

     For example, the command

          clear foo b*r

     clears the name `foo' and all names that begin with the letter `b'
     and end with the letter `r'.

     If `clear' is called without any arguments, all user-defined
     variables (local and global) are cleared from the symbol table.  If
     `clear' is called with at least one argument, only the visible
     names matching the arguments are cleared.  For example, suppose
     you have defined a function `foo', and then hidden it by
     performing the assignment `foo = 2'.  Executing the command `clear
     foo' once will clear the variable definition and restore the
     definition of `foo' as a function.  Executing `clear foo' a second
     time will clear the function definition.

     This command may not be used within a function body.

`who OPTIONS PATTERN ...'
     List currently defined symbols matching the given patterns.  The
     following are valid options.  They may be shortened to one
     character but may not be combined.

    `-all'
          List all currently defined symbols.

    `-builtins'
          List built-in variables and functions.  This includes all
          currently compiled function files, but does not include all
          function files that are in the `LOADPATH'.

    `-functions'
          List user-defined functions.

    `-long'
          Print a long listing including the type and dimensions of any
          symbols.  The symbols in the first column of output indicate
          whether it is possible to redefine the symbol, and whether it
          is possible for it to be cleared.

    `-variables'
          List user-defined variables.

     Valid patterns are the same as described for the `clear' command
     above.  If no patterns are supplied, all symbols from the given
     category are listed.  By default, only user defined functions and
     variables visible in the local scope are displayed.

     The command `whos' is equivalent to `who -long'.

`exist (NAME)'
     Return 1 if the name exists as a variable, and 2 if the name (after
     appending `.m') is a function file in the path.  Otherwise, return
     0.

`error (MSG)'
     Print the message MSG, prefixed by the string `error: ', and set
     Octave's internal error state such that control will return to the
     top level without evaluating any more commands.  This is useful for
     aborting from functions.

     If MSG does not end with a new line character, Octave will print a
     traceback of all the function calls leading to the error.  For
     example,

          function f () g () end
          function g () h () end
          function h () nargin == 1 || error ("nargin != 1"); end
          f ()
          error: nargin != 1
          error: evaluating index expression near line 1, column 30
          error: evaluating binary operator `||' near line 1, column 27
          error: called from `h'
          error: called from `g'
          error: called from `f'

     produces a list of messages that can help you to quickly locate the
     exact location of the error.

     If MSG ends in a new line character, Octave will only print MSG
     and will not display any traceback messages as it returns control
     to the top level.  For example, modifying the error message in the
     previous example to end in a new line causes Octave to only print
     a single message:

          function h () nargin == 1 || error ("nargin != 1\n"); end
          f ()
          error: nargin != 1

`warning (MSG)'
     Print the message MSG prefixed by the string `warning: '.

`usage (MSG)'
     Print the message MSG, prefixed by the string `usage: ', and set
     Octave's internal error state such that control will return to the
     top level without evaluating any more commands.  This is useful for
     aborting from functions.

     After `usage' is evaluated, Octave will print a traceback of all
     the function calls leading to the usage message.

`perror (NAME, NUM)'
     Print the error message for function NAME corresponding to the
     error number NUM.  This function is intended to be used to print
     useful error messages for those functions that return numeric error
     codes.

`menu (TITLE, OPT1, ...)'
     Print a title string followed by a series of options.  Each option
     will be printed along with a number.  The return value is the
     number of the option selected by the user.  This function is
     useful for interactive programs.  There is no limit to the number
     of options that may be passed in, but it may be confusing to
     present more than will fit easily on one screen.

`document SYMBOL TEXT'
     Set the documentation string for SYMBOL to TEXT.

`file_in_path (PATH, FILE)'
     Return the absolute name name of FILE if it can be found in PATH.
     The value of PATH should be a colon-separated list of directories
     in the format described for the built-in variable `LOADPATH'.

     If the file cannot be found in the path, an empty matrix is
     returned.  For example,

          octave:13> file_in_path (LOADPATH, "nargchk.m")
          ans = /usr/local/lib/octave/1.1.0/m/general/nargchk.m

`nargchk (NARGIN_MIN, NARGIN_MAX, N)'
     If N is in the range NARGIN_MIN through NARGIN_MAX inclusive,
     return the empty matrix.  Otherwise, return a message indicating
     whether N is too large or too small.

     This is useful for checking to see that the number of arguments
     supplied to a function is within an acceptable range.

`octave_tmp_file_name'
     Return a unique temporary file name.

     Since the named file is not opened, by `octave_tmp_file_name', it
     is possible (though relatively unlikely) that it will not be
     available by the time your program attempts to open it.

`type NAME ...'
     Display the definition of each NAME that refers to a function.

     Currently, Octave can only display functions that can be compiled
     cleanly, because it uses its internal representation of the
     function to recreate the program text.

     Comments are not displayed because Octave's currently discards
     them as it converts the text of a function file to its internal
     representation.  This problem may be fixed in a future release.

`which NAME ...'
     Display the type of each NAME.  If NAME is defined from a function
     file, the full name of the file is also displayed.


File: octave.info,  Node: Amusements,  Next: Installation,  Prev: Programming Utilities,  Up: Top

Amusements
**********

   Octave cannot promise that you will actually win the lotto, but it
can pick your numbers for you.  The function `texas_lotto' will select
six numbers between 1 and 50.

   The function `list_primes (N)' uses a brute-force algorithm to
compute the first N primes.

   Other amusing functions include `casesen', `flops', `sombrero',
`exit', and `quit'.


File: octave.info,  Node: Installation,  Next: Trouble,  Prev: Amusements,  Up: Top

Installing Octave
*****************

   Here is the procedure for installing Octave from scratch on a Unix
system.  For instructions on how to install the binary distributions of
Octave, see *Note Binary Distributions::.

   * Run the shell script `configure'.  This will determine the features
     your system has (or doesn't have) and create a file named Makefile
     from each of the files named Makefile.in.

     Here is a summary of the configure options that are most
     frequently used when building Octave:

    `--prefix=PREFIX'
          Install Octave in subdirectories below PREFIX.  The default
          value of PREFIX is `/usr/local'.

    `--srcdir=DIR'
          Look for Octave sources in the directory DIR.

    `--with-f2c'
          Use f2c even if Fortran compiler is available.

    `--enable-dld'
          Use DLD to make Octave capable of dynamically linking
          externally compiled functions.  This only works on systems
          that have a working port of DLD.

    `--enable-lite-kernel'
          Compile smaller kernel.  This currently requires DLD so that
          Octave can load functions at run time that are not loaded at
          compile time.

    `--help'
          Print a summary of the options recognized by the configure
          script.

     See the file INSTALL for more information about the command line
     options used by configure.  That file also contains instructions
     for compiling in a directory other than where the source is
     located.

   * Run make.

     You will need a recent version of GNU make.  Modifying Octave's
     Makefiles to work with other make programs is probably not worth
     your time.  We recommend you get and compile GNU make instead.

     For plotting, you will need to have gnuplot installed on your
     system.  Gnuplot is a command-driven interactive function plotting
     program.  Gnuplot is copyrighted, but freely distributable.  The
     `gnu' in gnuplot is a coincidence--it is not related to the GNU
     project or the FSF in any but the most peripheral sense.

     For version 1.1.1, you must have the GNU C++ compiler (gcc)
     version 2.6.3 or later to compile Octave.  You will also need
     version 2.6.1 of the GNU C++ class library (libg++).  If you plan
     to modify the parser you will also need GNU bison and fles.  If
     you modify the documentation, you will need GNU Texinfo, along
     with the patch for the makeinfo program that is distributed with
     Octave.

     GNU make, gcc, and libg++, gnuplot, bison, flex, and Texinfo are
     all available from many anonymous ftp archives, including
     ftp.che.utexas.edu, ftp.uu.net, prep.ai.mit.edu, and
     wuarchive.wustl.edu.

     If you don't have a Fortran compiler, or if your Fortran compiler
     doesn't work like the traditional Unix f77, you will need to have
     the Fortran to C translator f2c.  You can get f2c from any number
     of anonymous ftp archives.  The most recent version of f2c is
     always available from research.att.com.

     On an otherwise idle SPARCstation II, it will take somewhere
     between 60 and 90 minutes to compile everything, depending on
     whether you are compiling the Fortran libraries with f2c or using
     the Fortran compiler directly.  You will need about 50 megabytes
     of disk storage to work with (considerably less if you don't
     compile with debugging symbols).  To do that, use the command

          make CFLAGS=-O CXXFLAGS=-O LDFLAGS=

     instead of just `make'.

   * If you encounter errors while compiling Octave, first check the
     list of known problems below to see if there is a workaround or
     solution for your problem.  If not, see *Note Trouble::, for
     information about how to report bugs.

   * Once you have successfully compiled Octave, run `make install'.

     This will install a copy of octave, its libraries, and its
     documentation in the destination directory.  As distributed,
     Octave is installed in the following directories:

    `PREFIX/bin'
          Octave and other binaries that people will want to run
          directly.

    `PREFIX/lib'
          Libraries like libcruft.a and liboctave.a.

    `PREFIX/include/octave'
          Include files distributed with Octave.

    `PREFIX/man/man1'
          Unix-style man pages describing Octave.

    `PREFIX/info'
          Info files describing Octave.

    `PREFIX/lib/octave/VERSION/m'
          Function files distributed with Octave.  This includes the
          Octave version, so that multiple versions of Octave may be
          installed at the same time.

    `PREFIX/lib/octave/VERSION/exec/HOST_TYPE'
          Executables to be run by Octave rather than the user.

    `PREFIX/lib/octave/VERSION/oct/HOST_TYPE'
          Object files that will be dynamically loaded.

    `PREFIX/lib/octave/VERSION/imagelib'
          Image files that are distributed with Octave.

     where PREFIX defaults to `/usr/local', VERSION stands for the
     current version number of the interpreter, and HOST_TYPE is the
     type of computer on which Octave is installed (for example,
     `i486-unknown-gnu').

* Menu:

* Installation Problems::
* Binary Distributions::


File: octave.info,  Node: Installation Problems,  Next: Binary Distributions,  Prev: Installation,  Up: Installation

Installation Problems
=====================

   This section contains a list of problems (and some apparent problems
that don't really mean anything is wrong) that may show up during
installation of Octave.

   * On AIX (and possibly other) systems, GCC 2.6.2 generates invalid
     assembly code when compiling some parts of Octave.  On AIX
     systems, it is possible to get a working binary by not using the
     compiler flag `-fno-implicit-templates'.  You can specify this as
     an option to make by using a command like

          make NO_IMPLICIT_TEMPLATES=

   * You may need to edit some files in the gcc include subdirectory to
     add prototypes for functions there.  For example, Ultrix 4.2 needs
     proper declarations for the `signal()' and the `SIG_IGN' macro in
     the file `signal.h'.

     On some systems the `SIG_IGN' macro is defined to be something like
     this:

          #define  SIG_IGN  (void (*)())1

     when it should really be something like:

          #define  SIG_IGN  (void (*)(int))1

     to match the prototype declaration for `signal()'.

     The gcc fixincludes/fixproto script should probably fix this when
     gcc installs its modified set of header files, but I don't think
     that's been done yet.

   * There is a bug with the makeinfo program that is distributed with
     texinfo-3.1 that causes the indices in Octave's on-line manual to
     be generated incorrectly.  If you need to recreate the on-line
     documentation, you should get the makeinfo program that is
     distributed with texinfo-3.1 and apply the patch for makeinfo that
     is distributed with Octave.  See the file MAKEINFO.PATCH for more
     details.

   * If you don't have NPSOL but you still want to be able to solve
     NLPs, or if you don't have QPSOL but you still want to solve QPs,
     you'll need to find replacements or order them from Stanford.  If
     you know of a freely redistributable replacement, please let us
     know--we might be interested in distributing it with Octave.

     You can get more information about NPSOL and QPSOL from

          Stanford University
          Office of Technology Licensing
          857 Serra Street
          Stanford CA 94305-6225
          Tel: (415) 723-0651
          Fax: (415) 725-7295

     Octave may soon support FSQP, an NLP solver from Andre Tits
     (andre@src.umd.edu) of the University of Maryland.  FSQP is
     available free of charge to academic sites, but can not be
     redistributed to third parties.

   * Some of the Fortran subroutines may fail to compile with older
     versions of the Sun Fortran compiler.  If you get errors like

          zgemm.f:
          	zgemm:
          warning: unexpected parent of complex expression subtree
          zgemm.f, line 245: warning: unexpected parent of complex expression subtree
          warning: unexpected parent of complex expression subtree
          zgemm.f, line 304: warning: unexpected parent of complex expression subtree
          warning: unexpected parent of complex expression subtree
          zgemm.f, line 327: warning: unexpected parent of complex expression subtree
          pcc_binval: missing IR_CONV in complex op
          make[2]: *** [zgemm.o] Error 1

     when compiling the Fortran subroutines in the `libcruft'
     subdirectory, you should either upgrade your compiler or try
     compiling with optimization turned off.

   * On NeXT systems, if you get errors like this:

          /usr/tmp/cc007458.s:unknown:Undefined local symbol LBB7656
          /usr/tmp/cc007458.s:unknown:Undefined local symbol LBE7656

     when compiling `Array.cc' and `Matrix.cc', try recompiling these
     files without `-g'.

   * Some people have reported that calls to shell_cmd and the pager do
     not work on SunOS systems.  This is apparently due to having
     `G_HAVE_SYS_WAIT' defined to be 0 instead of 1 when compiling
     libg++.

   * On NeXT systems, linking to `libsys_s.a' may fail to resolve the
     following functions

          _tcgetattr
          _tcsetattr
          _tcflow

     which are part of `libposix.a'.  Unfortunately, linking Octave with
     `-posix' results in the following undefined symbols.

          .destructors_used
          .constructors_used
          _objc_msgSend
          _NXGetDefaultValue
          _NXRegisterDefaults
          .objc_class_name_NXStringTable
          .objc_class_name_NXBundle

     One kludge around this problem is to extract `termios.o' from
     `libposix.a', put it in Octave's `src' directory, and add it to
     the list of files to link together in the Makefile.  Suggestions
     for better ways to solve this problem are welcome!

   * With g++ 2.6.3 (and possibly other 2.6.x versions) on some Intel
     x86 systems, compiling `Array-d.cc' fails with the messages like

          as: /tmp/cc005254.s:4057: Local symbol LBB103 never defined.
          as: /tmp/cc005254.s:4057: Local symbol LBE103 never defined.

     A possible workaround for this is to compile without `-g'.

   * If Octave crashes immediately with a floating point exception, it
     is likely that it is failing to initialize the IEEE floating point
     values for infinity and NaN.

     If your system actually does support IEEE arithmetic, you should
     be able to fix this problem by modifying the function
     `octave_ieee_init' in the file `sysdep.cc' to correctly initialize
     Octave's internal infinity and NaN variables.

     If your system does not support IEEE arithmetic but Octave's
     configure script incorrectly determined that it does, you can work
     around the problem by editing the file `config.h' to not define
     `HAVE_ISINF', `HAVE_FINITE', and `HAVE_ISNAN'.

     In any case, please report this as a bug since it might be
     possible to modify Octave's configuration script to automatically
     determine the proper thing to do.


File: octave.info,  Node: Binary Distributions,  Prev: Installation Problems,  Up: Installation

Binary Distributions
====================

   This section contains instructions for creating and installing a
binary distribution.

* Menu:

* Installing Octave from a Binary Distribution::
* Creating a Binary Distribution::


File: octave.info,  Node: Installing Octave from a Binary Distribution,  Next: Creating a Binary Distribution,  Prev: Binary Distributions,  Up: Binary Distributions

Installing Octave from a Binary Distribution
--------------------------------------------

   * To install Octave from a binary distribution, execute the command

          sh ./doinstall.sh

     in the top level directory of the distribution.

     Binary distributions are normally compiled assuming that Octave
     will be installed in the following subdirectories of `/usr/local'.

    `bin'
          Octave and other binaries that people will want to run
          directly.

    `man/man1'
          Unix-style man pages describing Octave.

    `info'
          Info files describing Octave.

    `lib/octave/VERSION/m'
          Function files distributed with Octave.  This includes the
          Octave version, so that multiple versions of Octave may be
          installed at the same time.

    `lib/octave/VERSION/exec/HOST_TYPE'
          Executables to be run by Octave rather than the user.

    `lib/octave/VERSION/imagelib'
          Image files that are distributed with Octave.

     where VERSION stands for the current version number of the
     interpreter, and HOST_TYPE is the type of computer on which Octave
     is installed (for example, `i486-unknown-gnu').

     If these directories don't exist, the script `doinstall.sh' will
     create them for you.

     If this is possible for you to install Octave in `/usr/local', or
     if you would prefer to install it in a different directory, you can
     specify the name of the top level directory as an argument to the
     doinstall.sh script.  For example:

          sh ./doinstall.sh /some/other/directory

     Octave will then be installed in subdirectories of the directory
     `/some/other/directory'


File: octave.info,  Node: Creating a Binary Distribution,  Prev: Installing Octave from a Binary Distribution,  Up: Binary Distributions

Creating a Binary Distribution
------------------------------

   Here is how to build a binary distribution for others.

   * Build Octave in the same directory as the source.  This is required
     since the `binary-dist' targets in the Makefiles will not work if
     you compile outside the source tree.

   * Use `CFLAGS=-O CXXFLAGS=-O LDFLAGS=' as arguments for Make because
     most people who get the binary distributions are probably not
     going to be interested in debugging Octave.

   * Type `make binary-dist'.  This will build everything and then pack
     it up for distribution.


File: octave.info,  Node: Trouble,  Next: Command Line Editing,  Prev: Installation,  Up: Top

Known Causes of Trouble with Octave
***********************************

   This section describes known problems that affect users of Octave.
Most of these are not Octave bugs per se--if they were, we would fix
them.  But the result for a user may be like the result of a bug.

   Some of these problems are due to bugs in other software, some are
missing features that are too much work to add, and some are places
where people's opinions differ as to what is best.

* Menu:

* Actual Bugs::                 Bugs we will fix later.
* Reporting Bugs::
* Bug Criteria::
* Bug Lists::
* Bug Reporting::
* Sending Patches::
* Service::


File: octave.info,  Node: Actual Bugs,  Next: Reporting Bugs,  Prev: Trouble,  Up: Trouble

Actual Bugs We Haven't Fixed Yet
================================

   * Output that comes directly from Fortran functions is not sent
     through the pager and may appear out of sequence with other output
     that is sent through the pager.  One way to avoid this is to force
     pending output to be flushed before calling a function that will
     produce output from within Fortran functions.  To do this, use the
     command

          fflush (stdout)

     Another possible workaround is to use the command

          page_screen_output = "false"

     to turn the pager off.

   * Control-C doesn't work properly in the pager on DEC Alpha systems
     running OSF/1 3.0.

     This appears to be a bug in the OSF/1 3.0 Bourne shell.  The
     problem doesn't appear on systems running OSF/1 1.3.

   * If you get messages like

          Input line too long

     when trying to plot many lines on one graph, you have probably
     generated a plot command that is too larger for `gnuplot''s
     fixed-length buffer for commands.  Splitting up the plot command
     doesn't help because replot is implemented in gnuplot by simply
     appending the new plotting commands to the old command line and
     then evaluating it again.

     You can demonstrate this `feature' by running gnuplot and doing
     something like

            plot sin (x), sin (x), sin (x), ... lots more ..., sin (x)

     and then

            replot sin (x), sin (x), sin (x), ... lots more ..., sin (x)

     after repeating the replot command a few times, gnuplot will give
     you an error.

     Also, it doesn't help to use backslashes to enter a plot command
     over several lines, because the limit is on the overall command
     line length, once the backslashed lines are all pasted together.

     Because of this, Octave tries to use as little of the command-line
     length as possible by using the shortest possible abbreviations for
     all the plot commands and options.  Unfortunately, the length of
     the temporary file names is probably what is taking up the most
     space on the command line.

     You can buy a little bit of command line space by setting the
     environment variable `TMPDIR' to be "." before starting Octave, or
     you can increase the maximum command line length in gnuplot by
     changing the following limits in the file plot.h in the gnuplot
     distribution and recompiling gnuplot.

          #define MAX_LINE_LEN 32768  /* originally 1024 */
          #define MAX_TOKENS 8192     /* originally 400 */

     Of course, this doesn't really fix the problem, but it does make it
     much less likely that you will run into trouble unless you are
     putting a very large number of lines on a given plot.

   * String handling could use some work.

   A list of ideas for future enhancements is distributed with Octave.
See the file `PROJECTS' in the top level directory in the source
distribution.


File: octave.info,  Node: Reporting Bugs,  Next: Bug Criteria,  Prev: Actual Bugs,  Up: Trouble

Reporting Bugs
==============

   Your bug reports play an essential role in making Octave reliable.

   When you encounter a problem, the first thing to do is to see if it
is already known.  *Note Trouble::.  If it isn't known, then you should
report the problem.

   Reporting a bug may help you by bringing a solution to your problem,
or it may not.  In any case, the principal function of a bug report is
to help the entire community by making the next version of Octave work
better.  Bug reports are your contribution to the maintenance of Octave.

   In order for a bug report to serve its purpose, you must include the
information that makes it possible to fix the bug.

   If you have Octave working at all, the easiest way to prepare a
complete bug report is to use the Octave function `bug_report'.  When
you execute this function, Octave will prompt you for a subject and then
invoke the editor on a file that already contains all the configuration
information.  When you exit the editor, Octave will mail the bug report
for you.

* Menu:

* Bug Criteria::
* Where: Bug Lists.             Where to send your bug report.
* Reporting: Bug Reporting.     How to report a bug effectively.
* Patches: Sending Patches.     How to send a patch for Octave.

