home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / doc / octave.i03 (.txt) < prev    next >
GNU Info File  |  2000-01-15  |  50KB  |  1,164 lines

  1. This is Info file octave, produced by Makeinfo-1.64 from the input file
  2. octave.tex.
  3. START-INFO-DIR-ENTRY
  4. * Octave: (octave).    Interactive language for numerical computations.
  5. END-INFO-DIR-ENTRY
  6.    Copyright (C) 1996, 1997 John W. Eaton.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided that
  12. the entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions.
  17. File: octave,  Node: Data Structures,  Next: Variables,  Prev: Strings,  Up: Top
  18. Data Structures
  19. ***************
  20.    Octave includes support for organizing data in structures.  The
  21. current implementation uses an associative array with indices limited to
  22. strings, but the syntax is more like C-style structures.  Here are some
  23. examples of using data structures in Octave.
  24.    Elements of structures can be of any value type.  For example, the
  25. three expressions
  26.      x.a = 1
  27.      x.b = [1, 2; 3, 4]
  28.      x.c = "string"
  29. create a structure with three elements.  To print the value of the
  30. structure, you can type its name, just as for any other variable:
  31.      octave:2> x
  32.      x =
  33.      {
  34.        a = 1
  35.        b =
  36.      
  37.          1  2
  38.          3  4
  39.      
  40.        c = string
  41.      }
  42. Note that Octave may print the elements in any order.
  43.    Structures may be copied.
  44.      octave:1> y = x
  45.      y =
  46.      {
  47.        a = 1
  48.        b =
  49.      
  50.          1  2
  51.          3  4
  52.      
  53.        c = string
  54.      }
  55.    Since structures are themselves values, structure elements may
  56. reference other structures.  The following statements change the value
  57. of the element `b' of the structure `x' to be a data structure
  58. containing the single element `d', which has a value of 3.
  59.      octave:1> x.b.d = 3
  60.      x.b.d = 3
  61.      octave:2> x.b
  62.      ans =
  63.      {
  64.        d = 3
  65.      }
  66.      octave:3> x
  67.      x =
  68.      {
  69.        a = 1
  70.        b =
  71.        {
  72.          d = 3
  73.        }
  74.      
  75.        c = string
  76.      }
  77.    Note that when Octave prints the value of a structure that contains
  78. other structures, only a few levels are displayed.  For example,
  79.      octave:1> a.b.c.d.e = 1;
  80.      octave:2> a
  81.      a =
  82.      {
  83.        b =
  84.        {
  85.          c = <structure>
  86.        }
  87.      }
  88. This prevents long and confusing output from large deeply nested
  89. structures.
  90.  - Built-in Variable: struct_levels_to_print
  91.      You can tell Octave how many structure levels to display by
  92.      setting the built-in variable `struct_levels_to_print'.  The
  93.      default value is 2.
  94.    Functions can return structures.  For example, the following function
  95. separates the real and complex parts of a matrix and stores them in two
  96. elements of the same structure variable.
  97.      octave:1> function y = f (x)
  98.      > y.re = real (x);
  99.      > y.im = imag (x);
  100.      > endfunction
  101.    When called with a complex-valued argument, `f' returns the data
  102. structure containing the real and imaginary parts of the original
  103. function argument.
  104.      octave:2> f (rand (2) + rand (2) * I);
  105.      ans =
  106.      {
  107.        im =
  108.      
  109.          0.26475  0.14828
  110.          0.18436  0.83669
  111.      
  112.        re =
  113.      
  114.          0.040239  0.242160
  115.          0.238081  0.402523
  116.      }
  117.    Function return lists can include structure elements, and they may be
  118. indexed like any other variable.  For example,
  119.      octave:1> [ x.u, x.s(2:3,2:3), x.v ] = svd ([1, 2; 3, 4])
  120.      x.u =
  121.      
  122.        -0.40455  -0.91451
  123.        -0.91451   0.40455
  124.      
  125.      x.s =
  126.      
  127.        0.00000  0.00000  0.00000
  128.        0.00000  5.46499  0.00000
  129.        0.00000  0.00000  0.36597
  130.      
  131.      x.v =
  132.      
  133.        -0.57605   0.81742
  134.        -0.81742  -0.57605
  135.    It is also possible to cycle through all the elements of a structure
  136. in a loop, using a special form of the `for' statement (*note The for
  137. Statement::.)
  138.    The following functions are available to give you information about
  139. structures.
  140.  - Built-in Function:  is_struct (EXPR)
  141.      Return 1 if the value of the expression EXPR is a structure.
  142.  - Built-in Function:  struct_contains (EXPR, NAME)
  143.      Return 1 if the expression EXPR is a structure and it includes an
  144.      element named NAME.  The first argument must be a structure and
  145.      the second must be a string.
  146.  - Built-in Function:  struct_elements (STRUCT)
  147.      Return a list of strings naming the elements of the structure
  148.      STRUCT.  It is an error to call `struct_elements' with an argument
  149.      that is not a structure.
  150.    % DO NOT EDIT!  Generated automatically by munge-texi.
  151. File: octave,  Node: Variables,  Next: Expressions,  Prev: Data Structures,  Up: Top
  152. Variables
  153. *********
  154.    Variables let you give names to values and refer to them later.  You
  155. have already seen variables in many of the examples.  The name of a
  156. variable must be a sequence of letters, digits and underscores, but it
  157. may not begin with a digit.  Octave does not enforce a limit on the
  158. length of variable names, but it is seldom useful to have variables
  159. with names longer than about 30 characters.  The following are all
  160. valid variable names
  161.      x
  162.      x15
  163.      __foo_bar_baz__
  164.      fucnrdthsucngtagdjb
  165. However, names like `__foo_bar_baz__' that begin and end with two
  166. underscores are understood to be reserved for internal use by Octave.
  167. You should not use them in code you write, except to access Octave's
  168. documented internal variables and built-in symbolic constants.
  169.    Case is significant in variable names.  The symbols `a' and `A' are
  170. distinct variables.
  171.    A variable name is a valid expression by itself.  It represents the
  172. variable's current value.  Variables are given new values with
  173. "assignment operators" and "increment operators".  *Note Assignment
  174. Expressions: Assignment Ops.
  175.    A number of variables have special built-in meanings.  For example,
  176. `ans' holds the current working directory, and `pi' names the ratio of
  177. the circumference of a circle to its diameter. *Note Summary of
  178. Built-in Variables::, for a list of all the predefined variables.  Some
  179. of these built-in symbols are constants and may not be changed.  Others
  180. can be used and assigned just like all other variables, but their values
  181. are also used or changed automatically by Octave.
  182.    Variables in Octave do not have fixed types, so it is possible to
  183. first store a numeric value in a variable and then to later use the
  184. same name to hold a string value in the same program.  Variables may
  185. not be used before they have been given a value.  Doing so results in
  186. an error.
  187. * Menu:
  188. * Global Variables::
  189. * Status of Variables::
  190. * Summary of Built-in Variables::
  191. * Defaults from the Environment::
  192. File: octave,  Node: Global Variables,  Next: Status of Variables,  Prev: Variables,  Up: Variables
  193. Global Variables
  194. ================
  195.    A variable that has been declared "global" may be accessed from
  196. within a function body without having to pass it as a formal parameter.
  197.    A variable may be declared global using a `global' declaration
  198. statement.  The following statements are all global declarations.
  199.      global a
  200.      global b = 2
  201.      global c = 3, d, e = 5
  202.    It is necessary declare a variable as global within a function body
  203. in order to access it.  For example,
  204.      global x
  205.      function f ()
  206.        x = 1;
  207.      endfunction
  208.      f ()
  209. does *not* set the value of the global variable `x' to 1.  In order to
  210. change the value of the global variable `x', you must also declare it
  211. to be global within the function body, like this
  212.      function f ()
  213.        global x;
  214.        x = 1;
  215.      endfunction
  216.    Passing a global variable in a function parameter list will make a
  217. local copy and not modify the global value.  For example, given the
  218. function
  219.      function f (x)
  220.        x = 0
  221.      endfunction
  222. and the definition of `x' as a global variable at the top level,
  223.      global x = 13
  224. the expression
  225.      f (x)
  226. will display the value of `x' from inside the function as 0, but the
  227. value of `x' at the top level remains unchanged, because the function
  228. works with a *copy* of its argument.
  229.  - Built-in Variable: default_global_variable_value
  230.      The default for value for otherwise uninitialized global variables.
  231.      Only used if the variable initialize_global_variables is nonzero.
  232.      If `initialize_global_variables' is nonzero, the value of
  233.      `default_glbaol_variable_value' is used as the initial value of
  234.      global variables that are not explicitly initialized.  for example,
  235.           initialize_global_variables = 1;
  236.           default_global_variable_value = 13;
  237.           global foo;
  238.           foo
  239.                => 13
  240.      the variable `default_global_variable_value' is initially
  241.      undefined.
  242.  - Built-in Function:  is_global (NAME)
  243.      Return 1 if NAME is globally visible.  Otherwise, return 0.  For
  244.      example,
  245.           global x
  246.           is_global ("x")
  247.                => 1
  248. File: octave,  Node: Status of Variables,  Next: Summary of Built-in Variables,  Prev: Global Variables,  Up: Variables
  249. Status of Variables
  250. ===================
  251.  - Command: clear [-X] PATTERN ...
  252.      Delete the names matching the given patterns from the symbol
  253.      table.  The pattern may contain the following special characters:
  254.     `?'
  255.           Match any single character.
  256.     `*'
  257.           Match zero or more characters.
  258.     `[ LIST ]'
  259.           Match the list of characters specified by LIST.  If the first
  260.           character is `!' or `^', match all characters except those
  261.           specified by LIST.  For example, the pattern `[a-zA-Z]' will
  262.           match all lower and upper case alphabetic characters.
  263.      For example, the command
  264.           clear foo b*r
  265.      clears the name `foo' and all names that begin with the letter `b'
  266.      and end with the letter `r'.
  267.      If `clear' is called without any arguments, all user-defined
  268.      variables (local and global) are cleared from the symbol table.  If
  269.      `clear' is called with at least one argument, only the visible
  270.      names matching the arguments are cleared.  For example, suppose
  271.      you have defined a function `foo', and then hidden it by
  272.      performing the assignment `foo = 2'.  Executing the command `clear
  273.      foo' once will clear the variable definition and restore the
  274.      definition of `foo' as a function.  Executing `clear foo' a second
  275.      time will clear the function definition.
  276.      With -x, clear the variables that don't match the patterns.
  277.      This command may not be used within a function body.
  278.  - Command: who OPTIONS PATTERN ...
  279.  - Command: whos OPTIONS PATTERN ...
  280.      List currently defined symbols matching the given patterns.  The
  281.      following are valid options.  They may be shortened to one
  282.      character but may not be combined.
  283.     `-all'
  284.           List all currently defined symbols.
  285.     `-builtins'
  286.           List built-in variables and functions.  This includes all
  287.           currently compiled function files, but does not include all
  288.           function files that are in the `LOADPATH'.
  289.     `-functions'
  290.           List user-defined functions.
  291.     `-long'
  292.           Print a long listing including the type and dimensions of any
  293.           symbols.  The symbols in the first column of output indicate
  294.           whether it is possible to redefine the symbol, and whether it
  295.           is possible for it to be cleared.
  296.     `-variables'
  297.           List user-defined variables.
  298.      Valid patterns are the same as described for the `clear' command
  299.      above.  If no patterns are supplied, all symbols from the given
  300.      category are listed.  By default, only user defined functions and
  301.      variables visible in the local scope are displayed.
  302.      The command `whos' is equivalent to `who -long'.
  303.  - Built-in Function:  exist (NAME)
  304.      Return 1 if the name exists as a variable, 2 if the name (after
  305.      appending `.m') is a function file in the path, 3 if the name is a
  306.      `.oct' file in the path, or 5 if the name is a built-in function.
  307.      Otherwise, return 0.
  308.      This function also returns 2 if a regular file called NAME exists
  309.      in Octave's `LOADPATH'.  If you want information about other types
  310.      of files, you should use some combination of the functions
  311.      `file_in_path' and `stat' instead.
  312.  - Built-in Function:  document (SYMBOL, TEXT)
  313.      Set the documentation string for SYMBOL to TEXT.
  314.  - Command: type OPTIONS NAME ...
  315.      Display the definition of each NAME that refers to a function.
  316.      Normally also displays if each NAME is user-defined or builtin;
  317.      the `-q' option suppresses this behaviour.
  318.      Currently, Octave can only display functions that can be compiled
  319.      cleanly, because it uses its internal representation of the
  320.      function to recreate the program text.
  321.      Comments are not displayed because Octave's parser currently
  322.      discards them as it converts the text of a function file to its
  323.      internal representation.  This problem may be fixed in a future
  324.      release.
  325.  - Command: which NAME ...
  326.      Display the type of each NAME.  If NAME is defined from a function
  327.      file, the full name of the file is also displayed.
  328. File: octave,  Node: Summary of Built-in Variables,  Next: Defaults from the Environment,  Prev: Status of Variables,  Up: Variables
  329. Summary of Built-in Variables
  330. =============================
  331.    Here is a summary of all of Octave's built-in variables along with
  332. cross references to additional information and their default values.  In
  333. the following table OCTAVE-HOME stands for the root directory where all
  334. of Octave is installed (the default is `', VERSION stands for the
  335. Octave version number (for example, 2.1.23) and ARCH stands for the
  336. type of system for which Octave was compiled (for example,
  337. `i486-pc-os/2').
  338. `DEFAULT_LOADPATH'
  339.      *Note Function Files::.
  340.      Default value: `".:OCTAVE-HOME/lib/VERSION"'.
  341. `EDITOR'
  342.      *Note Commands For History::.
  343.      Default value: `"emacs"'.
  344. `EXEC_PATH'
  345.      *Note Controlling Subprocesses::.
  346.      Default value: `":$PATH"'.
  347. `INFO_FILE'
  348.      *Note Getting Help::.
  349.      Default value: `"OCTAVE-HOME/info/octave.info"'.
  350. `INFO_PROGRAM'
  351.      *Note Getting Help::.
  352.      Default value:
  353.      `"OCTAVE-HOME/libexec/octave/VERSION/exec/ARCH/info"'.
  354. `LOADPATH'
  355.      *Note Function Files::.
  356.      Default value: `":"', which tells Octave to use the directories
  357.      specified by the built-in variable `DEFAULT_LOADPATH'.
  358. `OCTAVE_HOME'
  359.      Default value: `""'.
  360. `PAGER'
  361.      *Note Input and Output::.
  362.      Default value: `"less", or "more"'.
  363. `PS1'
  364.      *Note Customizing the Prompt::.
  365.      Default value: `"\s:\#> "'.
  366. `PS2'
  367.      *Note Customizing the Prompt::.
  368.      Default value: `"> "'.
  369. `PS4'
  370.      *Note Customizing the Prompt::.
  371.      Default value: `"+ "'.
  372. `auto_unload_dot_oct_files'
  373.      *Note Dynamically Linked Functions::.
  374.      Default value: 0.
  375. `automatic_replot'
  376.      *Note Two-Dimensional Plotting::.
  377.      Default value: 0.
  378. `beep_on_error'
  379.      *Note Error Handling::.
  380.      Default value: 0.
  381. `completion_append_char'
  382.      *Note Commands For Completion::.
  383.      Default value: `" "'.
  384. `default_eval_print_flag'
  385.      *Note Evaluation::.
  386.      Default value: 1.
  387. `default_return_value'
  388.      *Note Multiple Return Values::.
  389.      Default value: `[]'.
  390. `default_save_format'
  391.      *Note Simple File I/O::.
  392.      Default value: `"ascii"'.
  393. `do_fortran_indexing'
  394.      *Note Index Expressions::.
  395.      Default value: 0.
  396. `crash_dumps_octave_core'
  397.      *Note Simple File I/O::.
  398.      Default value: 1.
  399. `define_all_return_values'
  400.      *Note Multiple Return Values::.
  401.      Default value: 0.
  402. `empty_list_elements_ok'
  403.      *Note Empty Matrices::.
  404.      Default value: `"warn"'.
  405. `fixed_point_format'
  406.      *Note Matrices::.
  407.      Default value: 0.
  408. `gnuplot_binary'
  409.      *Note Three-Dimensional Plotting::.
  410.      Default value: `"gnuplot"'.
  411. `history_file'
  412.      *Note Commands For History::.
  413.      Default value: `"~/.octave_hist"'.
  414. `history_size'
  415.      *Note Commands For History::.
  416.      Default value: 1024.
  417. `ignore_function_time_stamp'
  418.      *Note Function Files::.
  419.      Default value: `"system"'.
  420. `implicit_num_to_str_ok'
  421.      *Note String Conversions::.
  422.      Default value: 0.
  423. `implicit_str_to_num_ok'
  424.      *Note String Conversions::.
  425.      Default value: 0.
  426. `max_recursion_depth'
  427.      *Note Recursion::.
  428.      Default value: 256.
  429. `ok_to_lose_imaginary_part'
  430.      *Note Special Utility Matrices::.
  431.      Default value: `"warn"'.
  432. `output_max_field_width'
  433.      *Note Matrices::.
  434.      Default value: 10.
  435. `output_precision'
  436.      *Note Matrices::.
  437.      Default value: 5.
  438. `page_screen_output'
  439.      *Note Input and Output::.
  440.      Default value: 1.
  441. `prefer_column_vectors'
  442.      *Note Index Expressions::.
  443.      Default value: 1.
  444. `print_answer_id_name'
  445.      *Note Terminal Output::.
  446.      Default value: 1.
  447. `print_empty_dimensions'
  448.      *Note Empty Matrices::.
  449.      Default value: 1.
  450. `resize_on_range_error'
  451.      *Note Index Expressions::.
  452.      Default value: 1.
  453. `return_last_computed_value'
  454.      *Note Returning From a Function::.
  455.      Default value: 0.
  456. `save_precision'
  457.      *Note Simple File I/O::.
  458.      Default value: 17.
  459. `saving_history'
  460.      *Note Commands For History::.
  461.      Default value: 1.
  462. `silent_functions'
  463.      *Note Defining Functions::.
  464.      Default value: 0.
  465. `split_long_rows'
  466.      *Note Matrices::.
  467.      Default value: 1.
  468. `struct_levels_to_print'
  469.      *Note Data Structures::.
  470.      Default value: 2.
  471. `suppress_verbose_help_message'
  472.      *Note Getting Help::.
  473.      Default value: 1.
  474. `treat_neg_dim_as_zero'
  475.      *Note Special Utility Matrices::.
  476.      Default value: 0.
  477. `warn_assign_as_truth_value'
  478.      *Note The if Statement::.
  479.      Default value: 1.
  480. `warn_comma_in_global_decl'
  481.      *Note Global Variables::.
  482.      Default value: 1.
  483. `warn_divide_by_zero'
  484.      *Note Arithmetic Ops::.
  485.      Default value: 1.
  486. `warn_function_name_clash'
  487.      *Note Function Files::.
  488.      Default value: 1.
  489. `warn_reload_forces_clear'
  490.      *Note Dynamically Linked Functions::.
  491.      Default value: 1.
  492. `warn_variable_switch_label'
  493.      *Note The switch Statement::.
  494.      Default value: 0.
  495. `whitespace_in_literal_matrix'
  496.      *Note Matrices::.
  497.      Default value: `""'.
  498. File: octave,  Node: Defaults from the Environment,  Prev: Summary of Built-in Variables,  Up: Variables
  499. Defaults from the Environment
  500. =============================
  501.    Octave uses the values of the following environment variables to set
  502. the default values for the corresponding built-in variables.  In
  503. addition, the values from the environment may be overridden by
  504. command-line arguments.  *Note Command Line Options::.
  505. `EDITOR'
  506.      *Note Commands For History::.
  507.      Built-in variable: `EDITOR'.
  508. `OCTAVE_EXEC_PATH'
  509.      *Note Controlling Subprocesses::.
  510.      Built-in variable: `EXEC_PATH'.  Command-line argument:
  511.      `--exec-path'.
  512. `OCTAVE_PATH'
  513.      *Note Function Files::.
  514.      Built-in variable: `LOADPATH'.  Command-line argument: `--path'.
  515. `OCTAVE_INFO_FILE'
  516.      *Note Getting Help::.
  517.      Built-in variable: `INFO_FILE'.  Command-line argument:
  518.      `--info-file'.
  519. `OCTAVE_INFO_PROGRAM'
  520.      *Note Getting Help::.
  521.      Built-in variable: `INFO_PROGRAM'.  Command-line argument:
  522.      `--info-program'.
  523. `OCTAVE_HISTSIZE'
  524.      *Note Commands For History::.
  525.      Built-in variable: `history_size'.
  526. `OCTAVE_HISTFILE'
  527.      *Note Commands For History::.
  528.      Built-in variable: `history_file'.
  529.    % DO NOT EDIT!  Generated automatically by munge-texi.
  530. File: octave,  Node: Expressions,  Next: Evaluation,  Prev: Variables,  Up: Top
  531. Expressions
  532. ***********
  533.    Expressions are the basic building block of statements in Octave.  An
  534. expression evaluates to a value, which you can print, test, store in a
  535. variable, pass to a function, or assign a new value to a variable with
  536. an assignment operator.
  537.    An expression can serve as a statement on its own.  Most other kinds
  538. of statements contain one or more expressions which specify data to be
  539. operated on.  As in other languages, expressions in Octave include
  540. variables, array references, constants, and function calls, as well as
  541. combinations of these with various operators.
  542. * Menu:
  543. * Index Expressions::
  544. * Calling Functions::
  545. * Arithmetic Ops::
  546. * Comparison Ops::
  547. * Boolean Expressions::
  548. * Assignment Ops::
  549. * Increment Ops::
  550. * Operator Precedence::
  551. File: octave,  Node: Index Expressions,  Next: Calling Functions,  Prev: Expressions,  Up: Expressions
  552. Index Expressions
  553. =================
  554.    An "index expression" allows you to reference or extract selected
  555. elements of a matrix or vector.
  556.    Indices may be scalars, vectors, ranges, or the special operator
  557. `:', which may be used to select entire rows or columns.
  558.    Vectors are indexed using a single expression.  Matrices require two
  559. indices unless the value of the built-in variable `do_fortran_indexing'
  560. is nonzero, in which case matrices may also be indexed by a single
  561. expression.
  562.  - Built-in Variable: do_fortran_indexing
  563.      If the value of `do_fortran_indexing' is nonzero, Octave allows
  564.      you to select elements of a two-dimensional matrix using a single
  565.      index by treating the matrix as a single vector created from the
  566.      columns of the matrix.  The default value is 0.
  567.    Given the matrix
  568.      a = [1, 2; 3, 4]
  569. all of the following expressions are equivalent
  570.      a (1, [1, 2])
  571.      a (1, 1:2)
  572.      a (1, :)
  573. and select the first row of the matrix.
  574.    A special form of indexing may be used to select elements of a
  575. matrix or vector.  If the indices are vectors made up of only ones and
  576. zeros, the result is a new matrix whose elements correspond to the
  577. elements of the index vector that are equal to one.  For example,
  578.      a = [1, 2; 3, 4];
  579.      a ([1, 0], :)
  580. selects the first row of the matrix `a'.
  581.    This operation can be useful for selecting elements of a matrix
  582. based on some condition, since the comparison operators return matrices
  583. of ones and zeros.
  584.    This special zero-one form of indexing leads to a conflict with the
  585. standard indexing operation.  For example, should the following
  586. statements
  587.      a = [1, 2; 3, 4];
  588.      a ([1, 1], :)
  589. return the original matrix, or the matrix formed by selecting the first
  590. row twice?  Although this conflict is not likely to arise very often in
  591. practice, you may select the behavior you prefer by setting the built-in
  592. variable `prefer_zero_one_indexing'.
  593.  - Built-in Variable: prefer_zero_one_indexing
  594.      If the value of `prefer_zero_one_indexing' is nonzero, Octave will
  595.      perform zero-one style indexing when there is a conflict with the
  596.      normal indexing rules.  *Note Index Expressions::.  For example,
  597.      given a matrix
  598.           a = [1, 2, 3, 4]
  599.      with `prefer_zero_one_indexing' is set to nonzero, the expression
  600.           a ([1, 1, 1, 1])
  601.      results in the matrix `[ 1, 2, 3, 4 ]'.  If the value of
  602.      `prefer_zero_one_indexing' set to 0, the result would be the
  603.      matrix `[ 1, 1, 1, 1 ]'.
  604.      In the first case, Octave is selecting each element corresponding
  605.      to a `1' in the index vector.  In the second, Octave is selecting
  606.      the first element multiple times.
  607.      The default value for `prefer_zero_one_indexing' is 0.
  608.    Finally, indexing a scalar with a vector of ones can be used to
  609. create a vector the same size as the index vector, with each element
  610. equal to the value of the original scalar.  For example, the following
  611. statements
  612.      a = 13;
  613.      a ([1, 1, 1, 1])
  614. produce a vector whose four elements are all equal to 13.
  615.    Similarly, indexing a scalar with two vectors of ones can be used to
  616. create a matrix.  For example the following statements
  617.      a = 13;
  618.      a ([1, 1], [1, 1, 1])
  619. create a 2 by 3 matrix with all elements equal to 13.
  620.    This is an obscure notation and should be avoided.  It is better to
  621. use the function `ones' to generate a matrix of the appropriate size
  622. whose elements are all one, and then to scale it to produce the desired
  623. result.  *Note Special Utility Matrices::.
  624.  - Built-in Variable: prefer_column_vectors
  625.      If `prefer_column_vectors' is nonzero, operations like
  626.           for i = 1:10
  627.             a (i) = i;
  628.           endfor
  629.      (for `a' previously  undefined) produce column vectors.
  630.      Otherwise, row vectors are preferred.  The default value is 1.
  631.      If a variable is already defined to be a vector (a matrix with a
  632.      single row or column), the original orientation is respected,
  633.      regardless of the value of `prefer_column_vectors'.
  634.  - Built-in Variable: resize_on_range_error
  635.      If the value of `resize_on_range_error' is nonzero, expressions
  636.      like
  637.           for i = 1:10
  638.             a (i) = sqrt (i);
  639.           endfor
  640.      (for `a' previously undefined) result in the variable `a' being
  641.      resized to be just large enough to hold the new value.  New
  642.      elements that have not been given a value are set to zero.  If the
  643.      value of `resize_on_range_error' is 0, an error message is printed
  644.      and control is returned to the top level.  The default value is 1.
  645.    Note that it is quite inefficient to create a vector using a loop
  646. like the one shown in the example above.  In this particular case, it
  647. would have been much more efficient to use the expression
  648.      a = sqrt (1:10);
  649. thus avoiding the loop entirely.  In cases where a loop is still
  650. required, or a number of values must be combined to form a larger
  651. matrix, it is generally much faster to set the size of the matrix first,
  652. and then insert elements using indexing commands.  For example, given a
  653. matrix `a',
  654.      [nr, nc] = size (a);
  655.      x = zeros (nr, n * nc);
  656.      for i = 1:n
  657.        x(:,(i-1)*n+1:i*n) = a;
  658.      endfor
  659. is considerably faster than
  660.      x = a;
  661.      for i = 1:n-1
  662.        x = [x, a];
  663.      endfor
  664. particularly for large matrices because Octave does not have to
  665. repeatedly resize the result.
  666. File: octave,  Node: Calling Functions,  Next: Arithmetic Ops,  Prev: Index Expressions,  Up: Expressions
  667. Calling Functions
  668. =================
  669.    A "function" is a name for a particular calculation.  Because it has
  670. a name, you can ask for it by name at any point in the program.  For
  671. example, the function `sqrt' computes the square root of a number.
  672.    A fixed set of functions are "built-in", which means they are
  673. available in every Octave program.  The `sqrt' function is one of
  674. these.  In addition, you can define your own functions.  *Note
  675. Functions and Scripts::, for information about how to do this.
  676.    The way to use a function is with a "function call" expression,
  677. which consists of the function name followed by a list of "arguments"
  678. in parentheses. The arguments are expressions which give the raw
  679. materials for the calculation that the function will do.  When there is
  680. more than one argument, they are separated by commas.  If there are no
  681. arguments, you can omit the parentheses, but it is a good idea to
  682. include them anyway, to clearly indicate that a function call was
  683. intended.  Here are some examples:
  684.      sqrt (x^2 + y^2)      # One argument
  685.      ones (n, m)           # Two arguments
  686.      rand ()               # No arguments
  687.    Each function expects a particular number of arguments.  For
  688. example, the `sqrt' function must be called with a single argument, the
  689. number to take the square root of:
  690.      sqrt (ARGUMENT)
  691.    Some of the built-in functions take a variable number of arguments,
  692. depending on the particular usage, and their behavior is different
  693. depending on the number of arguments supplied.
  694.    Like every other expression, the function call has a value, which is
  695. computed by the function based on the arguments you give it.  In this
  696. example, the value of `sqrt (ARGUMENT)' is the square root of the
  697. argument.  A function can also have side effects, such as assigning the
  698. values of certain variables or doing input or output operations.
  699.    Unlike most languages, functions in Octave may return multiple
  700. values.  For example, the following statement
  701.      [u, s, v] = svd (a)
  702. computes the singular value decomposition of the matrix `a' and assigns
  703. the three result matrices to `u', `s', and `v'.
  704.    The left side of a multiple assignment expression is itself a list of
  705. expressions, and is allowed to be a list of variable names or index
  706. expressions.  See also *Note Index Expressions::, and *Note Assignment
  707. Ops::.
  708. * Menu:
  709. * Call by Value::
  710. * Recursion::
  711. File: octave,  Node: Call by Value,  Next: Recursion,  Prev: Calling Functions,  Up: Calling Functions
  712. Call by Value
  713. -------------
  714.    In Octave, unlike Fortran, function arguments are passed by value,
  715. which means that each argument in a function call is evaluated and
  716. assigned to a temporary location in memory before being passed to the
  717. function.  There is currently no way to specify that a function
  718. parameter should be passed by reference instead of by value.  This
  719. means that it is impossible to directly alter the value of function
  720. parameter in the calling function.  It can only change the local copy
  721. within the function body.  For example, the function
  722.      function f (x, n)
  723.        while (n-- > 0)
  724.          disp (x);
  725.        endwhile
  726.      endfunction
  727. displays the value of the first argument N times.  In this function,
  728. the variable N is used as a temporary variable without having to worry
  729. that its value might also change in the calling function.  Call by
  730. value is also useful because it is always possible to pass constants
  731. for any function parameter without first having to determine that the
  732. function will not attempt to modify the parameter.
  733.    The caller may use a variable as the expression for the argument, but
  734. the called function does not know this: it only knows what value the
  735. argument had.  For example, given a function called as
  736.      foo = "bar";
  737.      fcn (foo)
  738. you should not think of the argument as being "the variable `foo'."
  739. Instead, think of the argument as the string value, `"bar"'.
  740.    Even though Octave uses pass-by-value semantics for function
  741. arguments, values are not copied unnecessarily.  For example,
  742.      x = rand (1000);
  743.      f (x);
  744. does not actually force two 1000 by 1000 element matrices to exist
  745. *unless* the function `f' modifies the value of its argument.  Then
  746. Octave must create a copy to avoid changing the value outside the scope
  747. of the function `f', or attempting (and probably failing!) to modify
  748. the value of a constant or the value of a temporary result.
  749. File: octave,  Node: Recursion,  Prev: Call by Value,  Up: Calling Functions
  750. Recursion
  751. ---------
  752.    With some restrictions(1), recursive function calls are allowed.  A
  753. "recursive function" is one which calls itself, either directly or
  754. indirectly.  For example, here is an inefficient(2) way to compute the
  755. factorial of a given integer:
  756.      function retval = fact (n)
  757.        if (n > 0)
  758.          retval = n * fact (n-1);
  759.        else
  760.          retval = 1;
  761.        endif
  762.      endfunction
  763.    This function is recursive because it calls itself directly.  It
  764. eventually terminates because each time it calls itself, it uses an
  765. argument that is one less than was used for the previous call.  Once the
  766. argument is no longer greater than zero, it does not call itself, and
  767. the recursion ends.
  768.    The built-in variable `max_recursion_depth' specifies a limit to the
  769. recursion depth and prevents Octave from recursing infinitely.
  770.  - Built-in Variable: max_recursion_depth
  771.      Limit the number of times a function may be called recursively.
  772.      If the limit is exceeded, an error message is printed and control
  773.      returns to the top level.
  774.      The default value is 256.
  775.    ---------- Footnotes ----------
  776.    (1)  Some of Octave's function are implemented in terms of functions
  777. that cannot be called recursively.  For example, the ODE solver `lsode'
  778. is ultimately implemented in a Fortran subroutine that cannot be called
  779. recursively, so `lsode' should not be called either directly or
  780. indirectly from within the user-supplied function that `lsode'
  781. requires.  Doing so will result in undefined behavior.
  782.    (2)  It would be much better to use `prod (1:n)', or `gamma (n+1)'
  783. instead, after first checking to ensure that the value `n' is actually a
  784. positive integer.
  785. File: octave,  Node: Arithmetic Ops,  Next: Comparison Ops,  Prev: Calling Functions,  Up: Expressions
  786. Arithmetic Operators
  787. ====================
  788.    The following arithmetic operators are available, and work on scalars
  789. and matrices.
  790. `X + Y'
  791.      Addition.  If both operands are matrices, the number of rows and
  792.      columns must both agree.  If one operand is a scalar, its value is
  793.      added to all the elements of the other operand.
  794. `X .+ Y'
  795.      Element by element addition.  This operator is equivalent to `+'.
  796. `X - Y'
  797.      Subtraction.  If both operands are matrices, the number of rows and
  798.      columns of both must agree.
  799. `X .- Y'
  800.      Element by element subtraction.  This operator is equivalent to
  801.      `-'.
  802. `X * Y'
  803.      Matrix multiplication.  The number of columns of X must agree with
  804.      the number of rows of Y.
  805. `X .* Y'
  806.      Element by element multiplication.  If both operands are matrices,
  807.      the number of rows and columns must both agree.
  808. `X / Y'
  809.      Right division.  This is conceptually equivalent to the expression
  810.           (inverse (y') * x')'
  811.      but it is computed without forming the inverse of Y'.
  812.      If the system is not square, or if the coefficient matrix is
  813.      singular, a minimum norm solution is computed.
  814. `X ./ Y'
  815.      Element by element right division.
  816. `X \ Y'
  817.      Left division.  This is conceptually equivalent to the expression
  818.           inverse (x) * y
  819.      but it is computed without forming the inverse of X.
  820.      If the system is not square, or if the coefficient matrix is
  821.      singular, a minimum norm solution is computed.
  822. `X .\ Y'
  823.      Element by element left division.  Each element of Y is divided by
  824.      each corresponding element of X.
  825. `X ^ Y'
  826. `X ** Y'
  827.      Power operator.  If X and Y are both scalars, this operator
  828.      returns X raised to the power Y.  If X is a scalar and Y is a
  829.      square matrix, the result is computed using an eigenvalue
  830.      expansion.  If X is a square matrix. the result is computed by
  831.      repeated multiplication if Y is an integer, and by an eigenvalue
  832.      expansion if Y is not an integer.  An error results if both X and
  833.      Y are matrices.
  834.      The implementation of this operator needs to be improved.
  835. `X .^ Y'
  836. `X .** Y'
  837.      Element by element power operator.  If both operands are matrices,
  838.      the number of rows and columns must both agree.
  839.      Negation.
  840.      Unary plus.  This operator has no effect on the operand.
  841.      Complex conjugate transpose.  For real arguments, this operator is
  842.      the same as the transpose operator.  For complex arguments, this
  843.      operator is equivalent to the expression
  844.           conj (x.')
  845. `X.''
  846.      Transpose.
  847.    Note that because Octave's element by element operators begin with a
  848. `.', there is a possible ambiguity for statements like
  849.      1./m
  850. because the period could be interpreted either as part of the constant
  851. or as part of the operator.  To resolve this conflict, Octave treats the
  852. expression as if you had typed
  853.      (1) ./ m
  854. and not
  855.      (1.) / m
  856. Although this is inconsistent with the normal behavior of Octave's
  857. lexer, which usually prefers to break the input into tokens by
  858. preferring the longest possible match at any given point, it is more
  859. useful in this case.
  860.  - Built-in Variable: warn_divide_by_zero
  861.      If the value of `warn_divide_by_zero' is nonzero, a warning is
  862.      issued when Octave encounters a division by zero.  If the value is
  863.      0, the warning is omitted.  The default value is 1.
  864. File: octave,  Node: Comparison Ops,  Next: Boolean Expressions,  Prev: Arithmetic Ops,  Up: Expressions
  865. Comparison Operators
  866. ====================
  867.    "Comparison operators" compare numeric values for relationships such
  868. as equality.  They are written using *relational operators*.
  869.    All of Octave's comparison operators return a value of 1 if the
  870. comparison is true, or 0 if it is false.  For matrix values, they all
  871. work on an element-by-element basis.  For example,
  872.      [1, 2; 3, 4] == [1, 3; 2, 4]
  873.           =>  1  0
  874.               0  1
  875.    If one operand is a scalar and the other is a matrix, the scalar is
  876. compared to each element of the matrix in turn, and the result is the
  877. same size as the matrix.
  878. `X < Y'
  879.      True if X is less than Y.
  880. `X <= Y'
  881.      True if X is less than or equal to Y.
  882. `X == Y'
  883.      True if X is equal to Y.
  884. `X >= Y'
  885.      True if X is greater than or equal to Y.
  886. `X > Y'
  887.      True if X is greater than Y.
  888. `X != Y'
  889. `X ~= Y'
  890. `X <> Y'
  891.      True if X is not equal to Y.
  892.    String comparisons may also be performed with the `strcmp' function,
  893. not with the comparison operators listed above.  *Note Strings::.
  894. File: octave,  Node: Boolean Expressions,  Next: Assignment Ops,  Prev: Comparison Ops,  Up: Expressions
  895. Boolean Expressions
  896. ===================
  897. * Menu:
  898. * Element-by-element Boolean Operators::
  899. * Short-circuit Boolean Operators::
  900. File: octave,  Node: Element-by-element Boolean Operators,  Next: Short-circuit Boolean Operators,  Prev: Boolean Expressions,  Up: Boolean Expressions
  901. Element-by-element Boolean Operators
  902. ------------------------------------
  903.    An "element-by-element boolean expression" is a combination of
  904. comparison expressions using the boolean operators "or" (`|'), "and"
  905. (`&'), and "not" (`!'), along with parentheses to control nesting.  The
  906. truth of the boolean expression is computed by combining the truth
  907. values of the corresponding elements of the component expressions.  A
  908. value is considered to be false if it is zero, and true otherwise.
  909.    Element-by-element boolean expressions can be used wherever
  910. comparison expressions can be used.  They can be used in `if' and
  911. `while' statements.  However, if a matrix value used as the condition
  912. in an `if' or `while' statement is only true if *all* of its elements
  913. are nonzero.
  914.    Like comparison operations, each element of an element-by-element
  915. boolean expression also has a numeric value (1 if true, 0 if false) that
  916. comes into play if the result of the boolean expression is stored in a
  917. variable, or used in arithmetic.
  918.    Here are descriptions of the three element-by-element boolean
  919. operators.
  920. `BOOLEAN1 & BOOLEAN2'
  921.      Elements of the result are true if both corresponding elements of
  922.      BOOLEAN1 and BOOLEAN2 are true.
  923. `BOOLEAN1 | BOOLEAN2'
  924.      Elements of the result are true if either of the corresponding
  925.      elements of BOOLEAN1 or BOOLEAN2 is true.
  926. `! BOOLEAN'
  927. `~ BOOLEAN'
  928.      Each element of the result is true if the corresponding element of
  929.      BOOLEAN is false.
  930.    For matrix operands, these operators work on an element-by-element
  931. basis.  For example, the expression
  932.      [1, 0; 0, 1] & [1, 0; 2, 3]
  933. returns a two by two identity matrix.
  934.    For the binary operators, the dimensions of the operands must
  935. conform if both are matrices.  If one of the operands is a scalar and
  936. the other a matrix, the operator is applied to the scalar and each
  937. element of the matrix.
  938.    For the binary element-by-element boolean operators, both
  939. subexpressions BOOLEAN1 and BOOLEAN2 are evaluated before computing the
  940. result.  This can make a difference when the expressions have side
  941. effects.  For example, in the expression
  942.      a & b++
  943. the value of the variable B is incremented even if the variable A is
  944. zero.
  945.    This behavior is necessary for the boolean operators to work as
  946. described for matrix-valued operands.
  947. File: octave,  Node: Short-circuit Boolean Operators,  Prev: Element-by-element Boolean Operators,  Up: Boolean Expressions
  948. Short-circuit Boolean Operators
  949. -------------------------------
  950.    Combined with the implicit conversion to scalar values in `if' and
  951. `while' conditions, Octave's element-by-element boolean operators are
  952. often sufficient for performing most logical operations.  However, it
  953. is sometimes desirable to stop evaluating a boolean expression as soon
  954. as the overall truth value can be determined.  Octave's "short-circuit"
  955. boolean operators work this way.
  956. `BOOLEAN1 && BOOLEAN2'
  957.      The expression BOOLEAN1 is evaluated and converted to a scalar
  958.      using the equivalent of the operation `all (all (BOOLEAN1))'.  If
  959.      it is false, the result of the overall expression is 0.  If it is
  960.      true, the expression BOOLEAN2 is evaluated and converted to a
  961.      scalar using the equivalent of the operation `all (all
  962.      (BOOLEAN1))'.  If it is true, the result of the overall expression
  963.      is 1.  Otherwise, the result of the overall expression is 0.
  964. `BOOLEAN1 || BOOLEAN2'
  965.      The expression BOOLEAN1 is evaluated and converted to a scalar
  966.      using the equivalent of the operation `all (all (BOOLEAN1))'.  If
  967.      it is true, the result of the overall expression is 1.  If it is
  968.      false, the expression BOOLEAN2 is evaluated and converted to a
  969.      scalar using the equivalent of the operation `all (all
  970.      (BOOLEAN1))'.  If it is true, the result of the overall expression
  971.      is 1.  Otherwise, the result of the overall expression is 0.
  972.    The fact that both operands may not be evaluated before determining
  973. the overall truth value of the expression can be important.  For
  974. example, in the expression
  975.      a && b++
  976. the value of the variable B is only incremented if the variable A is
  977. nonzero.
  978.    This can be used to write somewhat more concise code.  For example,
  979. it is possible write
  980.      function f (a, b, c)
  981.        if (nargin > 2 && isstr (c))
  982.          ...
  983. instead of having to use two `if' statements to avoid attempting to
  984. evaluate an argument that doesn't exist.  For example, without the
  985. short-circuit feature, it would be necessary to write
  986.      function f (a, b, c)
  987.        if (nargin > 2)
  988.          if (isstr (c))
  989.            ...
  990.    Writing
  991.      function f (a, b, c)
  992.        if (nargin > 2 & isstr (c))
  993.          ...
  994. would result in an error if `f' were called with one or two arguments
  995. because Octave would be forced to try to evaluate both of the operands
  996. for the operator `&'.
  997. File: octave,  Node: Assignment Ops,  Next: Increment Ops,  Prev: Boolean Expressions,  Up: Expressions
  998. Assignment Expressions
  999. ======================
  1000.    An "assignment" is an expression that stores a new value into a
  1001. variable.  For example, the following expression assigns the value 1 to
  1002. the variable `z':
  1003.      z = 1
  1004.    After this expression is executed, the variable `z' has the value 1.
  1005. Whatever old value `z' had before the assignment is forgotten.  The `='
  1006. sign is called an "assignment operator".
  1007.    Assignments can store string values also.  For example, the following
  1008. expression would store the value `"this food is good"' in the variable
  1009. `message':
  1010.      thing = "food"
  1011.      predicate = "good"
  1012.      message = [ "this " , thing , " is " , predicate ]
  1013. (This also illustrates concatenation of strings.)
  1014.    Most operators (addition, concatenation, and so on) have no effect
  1015. except to compute a value.  If you ignore the value, you might as well
  1016. not use the operator.  An assignment operator is different.  It does
  1017. produce a value, but even if you ignore the value, the assignment still
  1018. makes itself felt through the alteration of the variable.  We call this
  1019. a "side effect".
  1020.    The left-hand operand of an assignment need not be a variable (*note
  1021. Variables::.).  It can also be an element of a matrix (*note Index
  1022. Expressions::.) or a list of return values (*note Calling
  1023. Functions::.).  These are all called "lvalues", which means they can
  1024. appear on the left-hand side of an assignment operator.  The right-hand
  1025. operand may be any expression.  It produces the new value which the
  1026. assignment stores in the specified variable, matrix element, or list of
  1027. return values.
  1028.    It is important to note that variables do *not* have permanent types.
  1029. The type of a variable is simply the type of whatever value it happens
  1030. to hold at the moment.  In the following program fragment, the variable
  1031. `foo' has a numeric value at first, and a string value later on:
  1032.      octave:13> foo = 1
  1033.      foo = 1
  1034.      octave:13> foo = "bar"
  1035.      foo = bar
  1036. When the second assignment gives `foo' a string value, the fact that it
  1037. previously had a numeric value is forgotten.
  1038.    Assignment of a scalar to an indexed matrix sets all of the elements
  1039. that are referenced by the indices to the scalar value.  For example, if
  1040. `a' is a matrix with at least two columns,
  1041.      a(:, 2) = 5
  1042. sets all the elements in the second column of `a' to 5.
  1043.    Assigning an empty matrix `[]' works in most cases to allow you to
  1044. delete rows or columns of matrices and vectors.  *Note Empty Matrices::.
  1045. For example, given a 4 by 5 matrix A, the assignment
  1046.      A (3, :) = []
  1047. deletes the third row of A, and the assignment
  1048.      A (:, 1:2:5) = []
  1049. deletes the first, third, and fifth columns.
  1050.    An assignment is an expression, so it has a value.  Thus, `z = 1' as
  1051. an expression has the value 1.  One consequence of this is that you can
  1052. write multiple assignments together:
  1053.      x = y = z = 0
  1054. stores the value 0 in all three variables.  It does this because the
  1055. value of `z = 0', which is 0, is stored into `y', and then the value of
  1056. `y = z = 0', which is 0, is stored into `x'.
  1057.    This is also true of assignments to lists of values, so the
  1058. following is a valid expression
  1059.      [a, b, c] = [u, s, v] = svd (a)
  1060. that is exactly equivalent to
  1061.      [u, s, v] = svd (a)
  1062.      a = u
  1063.      b = s
  1064.      c = v
  1065.    In expressions like this, the number of values in each part of the
  1066. expression need not match.  For example, the expression
  1067.      [a, b, c, d] = [u, s, v] = svd (a)
  1068. is equivalent to the expression above, except that the value of the
  1069. variable `d' is left unchanged, and the expression
  1070.      [a, b] = [u, s, v] = svd (a)
  1071. is equivalent to
  1072.      [u, s, v] = svd (a)
  1073.      a = u
  1074.      b = s
  1075.    You can use an assignment anywhere an expression is called for.  For
  1076. example, it is valid to write `x != (y = 1)' to set `y' to 1 and then
  1077. test whether `x' equals 1.  But this style tends to make programs hard
  1078. to read.  Except in a one-shot program, you should rewrite it to get
  1079. rid of such nesting of assignments.  This is never very hard.
  1080. File: octave,  Node: Increment Ops,  Next: Operator Precedence,  Prev: Assignment Ops,  Up: Expressions
  1081. Increment Operators
  1082. ===================
  1083.    *Increment operators* increase or decrease the value of a variable
  1084. by 1.  The operator to increment a variable is written as `++'.  It may
  1085. be used to increment a variable either before or after taking its value.
  1086.    For example, to pre-increment the variable X, you would write `++X'.
  1087. This would add one to X and then return the new value of X as the
  1088. result of the expression.  It is exactly the same as the expression `X
  1089. = X + 1'.
  1090.    To post-increment a variable X, you would write `X++'.  This adds
  1091. one to the variable X, but returns the value that X had prior to
  1092. incrementing it.  For example, if X is equal to 2, the result of the
  1093. expression `X++' is 2, and the new value of X is 3.
  1094.    For matrix and vector arguments, the increment and decrement
  1095. operators work on each element of the operand.
  1096.    Here is a list of all the increment and decrement expressions.
  1097. `++X'
  1098.      This expression increments the variable X.  The value of the
  1099.      expression is the *new* value of X.  It is equivalent to the
  1100.      expression `X = X + 1'.
  1101. `--X'
  1102.      This expression decrements the variable X.  The value of the
  1103.      expression is the *new* value of X.  It is equivalent to the
  1104.      expression `X = X - 1'.
  1105. `X++'
  1106.      This expression causes the variable X to be incremented.  The
  1107.      value of the expression is the *old* value of X.
  1108. `X--'
  1109.      This expression causes the variable X to be decremented.  The
  1110.      value of the expression is the *old* value of X.
  1111.    It is not currently possible to increment index expressions.  For
  1112. example, you might expect that the expression `V(4)++' would increment
  1113. the fourth element of the vector V, but instead it results in a parse
  1114. error.  This problem may be fixed in a future release of Octave.
  1115. File: octave,  Node: Operator Precedence,  Prev: Increment Ops,  Up: Expressions
  1116. Operator Precedence
  1117. ===================
  1118.    "Operator precedence" determines how operators are grouped, when
  1119. different operators appear close by in one expression.  For example,
  1120. `*' has higher precedence than `+'.  Thus, the expression `a + b * c'
  1121. means to multiply `b' and `c', and then add `a' to the product (i.e.,
  1122. `a + (b * c)').
  1123.    You can overrule the precedence of the operators by using
  1124. parentheses.  You can think of the precedence rules as saying where the
  1125. parentheses are assumed if you do not write parentheses yourself.  In
  1126. fact, it is wise to use parentheses whenever you have an unusual
  1127. combination of operators, because other people who read the program may
  1128. not remember what the precedence is in this case.  You might forget as
  1129. well, and then you too could make a mistake.  Explicit parentheses will
  1130. help prevent any such mistake.
  1131.    When operators of equal precedence are used together, the leftmost
  1132. operator groups first, except for the assignment and exponentiation
  1133. operators, which group in the opposite order.  Thus, the expression `a
  1134. - b + c' groups as `(a - b) + c', but the expression `a = b = c' groups
  1135. as `a = (b = c)'.
  1136.    The precedence of prefix unary operators is important when another
  1137. operator follows the operand.  For example, `-x^2' means `-(x^2)',
  1138. because `-' has lower precedence than `^'.
  1139.    Here is a table of the operators in Octave, in order of increasing
  1140. precedence.
  1141. `statement separators'
  1142.      `;', `,'.
  1143. `assignment'
  1144.      `='.  This operator groups right to left.
  1145. `logical "or" and "and"'
  1146.      `||', `&&'.
  1147. `element-wise "or" and "and"'
  1148.      `|', `&'.
  1149. `relational'
  1150.      `<', `<=', `==', `>=', `>', `!=', `~=', `<>'.
  1151. `colon'
  1152.      `:'.
  1153. `add, subtract'
  1154.      `+', `-'.
  1155. `multiply, divide'
  1156.      `*', `/', `\', `.\', `.*', `./'.
  1157. `transpose'
  1158.      `'', `.''
  1159. `unary plus, minus, increment, decrement, and ``not'''
  1160.      `+', `-', `++', `--', `!', `~'.
  1161. `exponentiation'
  1162.      `^', `**', `.^', `.**'.
  1163.    % DO NOT EDIT!  Generated automatically by munge-texi.
  1164.