home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / doc / octave.i11 < prev    next >
Encoding:
GNU Info File  |  1999-05-13  |  45.3 KB  |  1,251 lines

  1. This is Info file octave, produced by Makeinfo-1.64 from the input file
  2. octave.tex.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Octave: (octave).    Interactive language for numerical computations.
  6. END-INFO-DIR-ENTRY
  7.  
  8.    Copyright (C) 1996, 1997 John W. Eaton.
  9.  
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.  
  14.    Permission is granted to copy and distribute modified versions of
  15. this manual under the conditions for verbatim copying, provided that
  16. the entire resulting derived work is distributed under the terms of a
  17. permission notice identical to this one.
  18.  
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions.
  22.  
  23. 
  24. File: octave,  Node: Controlling Subprocesses,  Next: Process ID Information,  Prev: Filesystem Utilities,  Up: System Utilities
  25.  
  26. Controlling Subprocesses
  27. ========================
  28.  
  29.    Octave includes some high-level commands like `system' and `popen'
  30. for starting subprocesses.  If you want to run another program to
  31. perform some task and then look at its output, you will probably want
  32. to use these functions.
  33.  
  34.    Octave also provides several very low-level Unix-like functions which
  35. can also be used for starting subprocesses, but you should probably only
  36. use them if you can't find any way to do what you need with the
  37. higher-level functions.
  38.  
  39.  - Built-in Function:  system (STRING, RETURN_OUTPUT, TYPE)
  40.      Execute a shell command specified by STRING.  The second argument
  41.      is optional.  If TYPE is `"async"', the process is started in the
  42.      background and the process id of the child process is returned
  43.      immediately.  Otherwise, the process is started, and Octave waits
  44.      until it exits.  If TYPE argument is omitted, a value of `"sync"'
  45.      is assumed.
  46.  
  47.      If two input arguments are given (the actual value of
  48.      RETURN_OUTPUT is irrelevant) and the subprocess is started
  49.      synchronously, or if SYSTEM is called with one input argument and
  50.      one or more output arguments, the output from the command is
  51.      returned.  Otherwise, if the subprocess is executed synchronously,
  52.      it's output is sent to the standard output.  To send the output of
  53.      a command executed with SYSTEM through the pager, use a command
  54.      like
  55.  
  56.           disp (system (cmd, 1));
  57.  
  58.      or
  59.  
  60.           printf ("%s\n", system (cmd, 1));
  61.  
  62.      The `system' function can return two values.  The first is any
  63.      output from the command that was written to the standard output
  64.      stream, and the second is the output status of the command.  For
  65.      example,
  66.  
  67.           [output, status] = system ("echo foo; exit 2");
  68.  
  69.      will set the variable `output' to the string `foo', and the
  70.      variable `status' to the integer `2'.
  71.  
  72.  - Built-in Function: fid = popen (COMMAND, MODE)
  73.      Start a process and create a pipe.  The name of the command to run
  74.      is given by COMMAND.  The file identifier corresponding to the
  75.      input or output stream of the process is returned in FID.  The
  76.      argument MODE may be
  77.  
  78.     `"r"'
  79.           The pipe will be connected to the standard output of the
  80.           process, and open for reading.
  81.  
  82.     `"w"'
  83.           The pipe will be connected to the standard input of the
  84.           process, and open for writing.
  85.  
  86.      For example,
  87.  
  88.           fid = popen ("ls -ltr / | tail -3", "r");
  89.           while (isstr (s = fgets (fid)))
  90.             fputs (stdout, s);
  91.           endwhile
  92.                -| drwxr-xr-x  33 root  root  3072 Feb 15 13:28 etc
  93.                -| drwxr-xr-x   3 root  root  1024 Feb 15 13:28 lib
  94.                -| drwxrwxrwt  15 root  root  2048 Feb 17 14:53 tmp
  95.  
  96.  - Built-in Function:  pclose (FID)
  97.      Close a file identifier that was opened by `popen'.  You may also
  98.      use `fclose' for the same purpose.
  99.  
  100.  - Built-in Function: [IN, OUT, PID] = popen2 (COMMAND, ARGS)
  101.      Start a subprocess with two-way communication.  The name of the
  102.      process is given by COMMAND, and ARGS is an array of strings
  103.      containing options for the command.  The file identifiers for the
  104.      input and output streams of the subprocess are returned in IN and
  105.      OUT.  If execution of the command is successful, PID contains the
  106.      process ID of the subprocess.  Otherwise, PID is -1.
  107.  
  108.      For example,
  109.  
  110.           [in, out, pid] = popen2 ("sort", "-nr");
  111.           fputs (in, "these\nare\nsome\nstrings\n");
  112.           fclose (in);
  113.           while (isstr (s = fgets (out)))
  114.             fputs (stdout, s);
  115.           endwhile
  116.           fclose (out);
  117.                -| are
  118.                -| some
  119.                -| strings
  120.                -| these
  121.  
  122.  - Built-in Variable: EXEC_PATH
  123.      The variable `EXEC_PATH' is a colon separated list of directories
  124.      to search when executing subprograms.  Its initial value is taken
  125.      from the environment variable `OCTAVE_EXEC_PATH' (if it exists) or
  126.      `PATH', but that value can be overridden by the command line
  127.      argument `--exec-path PATH', or by setting the value of
  128.      `EXEC_PATH' in a startup script.  If the value of `EXEC_PATH'
  129.      begins (ends) with a colon, the directories
  130.  
  131.           OCTAVE-HOME/libexec/octave/site/exec/ARCH
  132.           OCTAVE-HOME/libexec/octave/VERSION/exec/ARCH
  133.  
  134.      are prepended (appended) to `EXEC_PATH', where OCTAVE-HOME is the
  135.      top-level directory where all of Octave is installed (the default
  136.      value is `').  If you don't specify a value for `EXEC_PATH'
  137.      explicitly, these special directories are prepended to your shell
  138.      path.
  139.  
  140.    In most cases, the following functions simply decode their arguments
  141. and make the corresponding Unix system calls.  For a complete example
  142. of how they can be used, look at the definition of the function
  143. `popen2'.
  144.  
  145.  - Built-in Function: [PID, MSG] = fork ()
  146.      Create a copy of the current process.
  147.  
  148.      Fork can return one of the following values:
  149.  
  150.     > 0
  151.           You are in the parent process.  The value returned from
  152.           `fork' is the process id of the child process.  You should
  153.           probably arrange to wait for any child processes to exit.
  154.  
  155.     0
  156.           You are in the child process.  You can call `exec' to start
  157.           another process.  If that fails, you should probably call
  158.           `exit'.
  159.  
  160.     < 0
  161.           The call to `fork' failed for some reason.  You must take
  162.           evasive action.  A system dependent error message will be
  163.           waiting in MSG.
  164.  
  165.  - Built-in Function: [ERR, MSG] = exec (FILE, ARGS)
  166.      Replace current process with a new process.  Calling `exec' without
  167.      first calling `fork' will terminate your current Octave process and
  168.      replace it with the program named by FILE.  For example,
  169.  
  170.           exec ("ls" "-l")
  171.  
  172.      will run `ls' and return you to your shell prompt.
  173.  
  174.      If successful, `exec' does not return.  If `exec' does return, ERR
  175.      will be nonzero, and MSG will contain a system-dependent error
  176.      message.
  177.  
  178.  - Built-in Function: [FILE_IDS, ERR, MSG] = pipe ()
  179.      Create a pipe and return the vector FILE_IDS, which corresponding
  180.      to the reading and writing ends of the pipe.
  181.  
  182.      If successful, ERR is 0 and MSG is an empty string.  Otherwise,
  183.      ERR is nonzero and MSG contains a system-dependent error message.
  184.  
  185.  - Built-in Function: [FID, MSG] = dup2 (OLD, NEW)
  186.      Duplicate a file descriptor.
  187.  
  188.      If successful, FID is greater than zero and contains the new file
  189.      ID.  Otherwise, FID is negative and MSG contains a
  190.      system-dependent error message.
  191.  
  192.  - Built-in Function: [PID, MSG] = waitpid (PID, OPTIONS)
  193.      Wait for process PID to terminate.  The PID argument can be:
  194.  
  195.     -1
  196.           Wait for any child process.
  197.  
  198.     0
  199.           Wait for any child process whose process group ID is equal to
  200.           that of the Octave interpreter process.
  201.  
  202.     > 0
  203.           Wait for termination of the child process with ID PID.
  204.  
  205.      The OPTIONS argument can be:
  206.  
  207.     0
  208.           Wait until signal is received or a child process exits (this
  209.           is the default if the OPTIONS argument is missing).
  210.  
  211.     1
  212.           Do not hang if status is not immediately available.
  213.  
  214.     2
  215.           Report the status of any child processes that are stopped,
  216.           and whose status has not yet been reported since they stopped.
  217.  
  218.     3
  219.           Implies both 1 and 2.
  220.  
  221.      If the returned value of PID is greater than 0, it is the process
  222.      ID of the child process that exited.  If an error occurs, PID will
  223.      be less than zero and MSG will contain a system-dependent error
  224.      message.
  225.  
  226.  - Built-in Function: [ERR, MSG] = fcntl (FID, REQUEST, ARG)
  227.      Change the properties of the open file FID.  The following values
  228.      may be passed as REQUEST:
  229.  
  230.     `F_DUPFD'
  231.           Return a duplicate file descriptor.
  232.  
  233.     `F_GETFD'
  234.           Return the file descriptor flags for FID.
  235.  
  236.     `F_SETFD'
  237.           Set the file descriptor flags for FID.
  238.  
  239.     `F_GETFL'
  240.           Return the file status flags for FID.  The following codes
  241.           may be returned (some of the flags may be undefined on some
  242.           systems).
  243.  
  244.          `O_RDONLY'
  245.                Open for reading only.
  246.  
  247.          `O_WRONLY'
  248.                Open for writing only.
  249.  
  250.          `O_RDWR'
  251.                Open for reading and writing.
  252.  
  253.          `O_APPEND'
  254.                Append on each write.
  255.  
  256.          `O_NONBLOCK'
  257.                Nonblocking mode.
  258.  
  259.          `O_SYNC'
  260.                Wait for writes to complete.
  261.  
  262.          `O_ASYNC'
  263.                Asynchronous I/O.
  264.  
  265.     `F_SETFL'
  266.           Set the file status flags for FID to the value specified by
  267.           ARG.  The only flags that can be changed are `O_APPEND' and
  268.           `O_NONBLOCK'.
  269.  
  270.      If successful, ERR is 0 and MSG is an empty string.  Otherwise,
  271.      ERR is nonzero and MSG contains a system-dependent error message.
  272.  
  273. 
  274. File: octave,  Node: Process ID Information,  Next: Environment Variables,  Prev: Controlling Subprocesses,  Up: System Utilities
  275.  
  276. Process, Group, and User IDs
  277. ============================
  278.  
  279.  - Built-in Function:  getpgrp ()
  280.      Return the process group id of the current process.
  281.  
  282.  - Built-in Function:  getpid ()
  283.      Return the process id of the current process.
  284.  
  285.  - Built-in Function:  getppid ()
  286.      Return the process id of the parent process.
  287.  
  288.  - Built-in Function:  geteuid ()
  289.      Return the effective user id of the current process.
  290.  
  291.  - Built-in Function:  getuid ()
  292.      Return the real user id of the current process.
  293.  
  294.  - Built-in Function:  getegid ()
  295.      Return the effective group id of the current process.
  296.  
  297.  - Built-in Function:  getgid ()
  298.      Return the real group id of the current process.
  299.  
  300. 
  301. File: octave,  Node: Environment Variables,  Next: Current Working Directory,  Prev: Process ID Information,  Up: System Utilities
  302.  
  303. Environment Variables
  304. =====================
  305.  
  306.  - Built-in Function:  getenv (VAR)
  307.      Return the value of the environment variable VAR.  For example,
  308.  
  309.           getenv ("PATH")
  310.  
  311.      returns a string containing the value of your path.
  312.  
  313.  - Built-in Function:  putenv (VAR, VALUE)
  314.      Set the value of the environment variable VAR to VALUE.
  315.  
  316. 
  317. File: octave,  Node: Current Working Directory,  Next: Password Database Functions,  Prev: Environment Variables,  Up: System Utilities
  318.  
  319. Current Working Directory
  320. =========================
  321.  
  322.  - Command: cd DIR
  323.  - Command: chdir DIR
  324.      Change the current working directory to DIR.  For example,
  325.  
  326.           cd ~/octave
  327.  
  328.      Changes the current working directory to `~/octave'.  If the
  329.      directory does not exist, an error message is printed and the
  330.      working directory is not changed.
  331.  
  332.  - Built-in Function:  pwd ()
  333.      Return the current working directory.
  334.  
  335.  - Command: ls OPTIONS
  336.  - Command: dir OPTIONS
  337.      List directory contents.  For example,
  338.  
  339.           ls -l
  340.                -| total 12
  341.                -| -rw-r--r--   1 jwe  users  4488 Aug 19 04:02 foo.m
  342.                -| -rw-r--r--   1 jwe  users  1315 Aug 17 23:14 bar.m
  343.  
  344.      The `dir' and `ls' commands are implemented by calling your
  345.      system's directory listing command, so the available options may
  346.      vary from system to system.
  347.  
  348. 
  349. File: octave,  Node: Password Database Functions,  Next: Group Database Functions,  Prev: Current Working Directory,  Up: System Utilities
  350.  
  351. Password Database Functions
  352. ===========================
  353.  
  354.    Octave's password database functions return information in a
  355. structure with the following fields.
  356.  
  357. `name'
  358.      The user name.
  359.  
  360. `passwd'
  361.      The encrypted password, if available.
  362.  
  363. `uid'
  364.      The numeric user id.
  365.  
  366. `gid'
  367.      The numeric group id.
  368.  
  369. `gecos'
  370.      The GECOS field.
  371.  
  372. `dir'
  373.      The home directory.
  374.  
  375. `shell'
  376.      The initial shell.
  377.  
  378.    In the descriptions of the following functions, this data structure
  379. is referred to as a PW_STRUCT.
  380.  
  381.  - Loadable Function: PW_STRUCT =  getpwent ()
  382.      Return a structure containing an entry from the password database,
  383.      opening it if necessary. Once the end of the data has been reached,
  384.      `getpwent' returns 0.
  385.  
  386.  - Loadable Function: PW_STRUCT =  getpwuid (UID).
  387.      Return a structure containing the first entry from the password
  388.      database with the user ID UID.  If the user ID does not exist in
  389.      the database, `getpwuid' returns 0.
  390.  
  391.  - Loadable Function: PW_STRUCT =  getpwnam (NAME)
  392.      Return a structure containing the first entry from the password
  393.      database with the user name NAME.  If the user name does not exist
  394.      in the database, `getpwname' returns 0.
  395.  
  396.  - Loadable Function:  setpwent ()
  397.      Return the internal pointer to the beginning of the password
  398.      database.
  399.  
  400.  - Loadable Function:  endpwent ()
  401.      Close the password database.
  402.  
  403. 
  404. File: octave,  Node: Group Database Functions,  Next: System Information,  Prev: Password Database Functions,  Up: System Utilities
  405.  
  406. Group Database Functions
  407. ========================
  408.  
  409.    Octave's group database functions return information in a structure
  410. with the following fields.
  411.  
  412. `name'
  413.      The user name.
  414.  
  415. `passwd'
  416.      The encrypted password, if available.
  417.  
  418. `gid'
  419.      The numeric group id.
  420.  
  421. `mem'
  422.      The members of the group.
  423.  
  424.    In the descriptions of the following functions, this data structure
  425. is referred to as a GRP_STRUCT.
  426.  
  427.  - Loadable Function: GRP_STRUCT = getgrent ()
  428.      Return an entry from the group database, opening it if necessary.
  429.      Once the end of the data has been reached, `getgrent' returns 0.
  430.  
  431.  - Loadable Function: GRP_STRUCT = getgrgid (GID).
  432.      Return the first entry from the group database with the group ID
  433.      GID.  If the group ID does not exist in the database, `getgrgid'
  434.      returns 0.
  435.  
  436.  - Loadable Function: GRP_STRUCT = getgrnam (NAME)
  437.      Return the first entry from the group database with the group name
  438.      NAME.  If the group name does not exist in the database,
  439.      `getgrname' returns 0.
  440.  
  441.  - Loadable Function:  setgrent ()
  442.      Return the internal pointer to the beginning of the group database.
  443.  
  444.  - Loadable Function:  endgrent ()
  445.      Close the group database.
  446.  
  447. 
  448. File: octave,  Node: System Information,  Prev: Group Database Functions,  Up: System Utilities
  449.  
  450. System Information
  451. ==================
  452.  
  453.  - Built-in Function:  computer ()
  454.      Print or return a string of the form CPU-VENDOR-OS that identifies
  455.      the kind of computer Octave is running on.  If invoked with an
  456.      output argument, the value is returned instead of printed.  For
  457.      example,
  458.  
  459.           computer ()
  460.                -| i586-pc-linux-gnu
  461.           
  462.           x = computer ()
  463.                => x = "i586-pc-linux-gnu"
  464.  
  465.  - Built-in Function:  isieee ()
  466.      Return 1 if your computer claims to conform to the IEEE standard
  467.      for floating point calculations.
  468.  
  469.  - Built-in Function:  version ()
  470.      Return Octave's version number as a string.  This is also the
  471.      value of the built-in variable `OCTAVE_VERSION'.
  472.  
  473.  - Built-in Variable: OCTAVE_VERSION
  474.      The version number of Octave, as a string.
  475.  
  476.  - Built-in Function:  octave_config_info ()
  477.      Return a structure containing configuration and installation
  478.      information.
  479.  
  480.  - Loadable Function:  getrusage ()
  481.      Return a structure containing a number of statistics about the
  482.      current Octave process.  Not all fields are available on all
  483.      systems.  If it is not possible to get CPU time statistics, the
  484.      CPU time slots are set to zero.  Other missing data are replaced
  485.      by NaN.  Here is a list of all the possible fields that can be
  486.      present in the structure returned by `getrusage':
  487.  
  488.     `'
  489.     `idrss'
  490.           Unshared data size.
  491.  
  492.     `inblock'
  493.           Number of block input operations.
  494.  
  495.     `isrss'
  496.           Unshared stack size.
  497.  
  498.     `ixrss'
  499.           Shared memory size.
  500.  
  501.     `majflt'
  502.           Number of major page faults.
  503.  
  504.     `maxrss'
  505.           Maximum data size.
  506.  
  507.     `minflt'
  508.           Number of minor page faults.
  509.  
  510.     `msgrcv'
  511.           Number of messages received.
  512.  
  513.     `msgsnd'
  514.           Number of messages sent.
  515.  
  516.     `nivcsw'
  517.           Number of involuntary context switches.
  518.  
  519.     `nsignals'
  520.           Number of signals received.
  521.  
  522.     `nswap'
  523.           Number of swaps.
  524.  
  525.     `nvcsw'
  526.           Number of voluntary context switches.
  527.  
  528.     `oublock'
  529.           Number of block output operations.
  530.  
  531.     `stime'
  532.           A structure containing the system CPU time used.  The
  533.           structure has the elements `sec' (seconds) `usec'
  534.           (microseconds).
  535.  
  536.     `utime'
  537.           A structure containing the user CPU time used.  The structure
  538.           has the elements `sec' (seconds) `usec' (microseconds).
  539.  
  540. 
  541. File: octave,  Node: Tips,  Next: Trouble,  Prev: System Utilities,  Up: Top
  542.  
  543. Tips and Standards
  544. ******************
  545.  
  546.    This chapter describes no additional features of Octave.  Instead it
  547. gives advice on making effective use of the features described in the
  548. previous chapters.
  549.  
  550. * Menu:
  551.  
  552. * Style Tips::                  Writing clean and robust programs.
  553. * Coding Tips::                 Making code run faster.
  554. * Documentation Tips::          Writing readable documentation strings.
  555. * Comment Tips::                Conventions for writing comments.
  556. * Function Headers::            Standard headers for functions.
  557.  
  558. 
  559. File: octave,  Node: Style Tips,  Next: Coding Tips,  Prev: Tips,  Up: Tips
  560.  
  561. Writing Clean Octave Programs
  562. =============================
  563.  
  564.    Here are some tips for avoiding common errors in writing Octave code
  565. intended for widespread use:
  566.  
  567.    * Since all global variables share the same name space, and all
  568.      functions share another name space, you should choose a short word
  569.      to distinguish your program from other Octave programs.  Then take
  570.      care to begin the names of all global variables, constants, and
  571.      functions with the chosen prefix.  This helps avoid name conflicts.
  572.  
  573.      If you write a function that you think ought to be added to Octave
  574.      under a certain name, such as `fiddle_matrix', don't call it by
  575.      that name in your program.  Call it `mylib_fiddle_matrix' in your
  576.      program, and send mail to (bug-octave@bevo.che.wisc.edu)
  577.      suggesting that it be added to Octave.  If and when it is, the
  578.      name can be changed easily enough.
  579.  
  580.      If one prefix is insufficient, your package may use two or three
  581.      alternative common prefixes, so long as they make sense.
  582.  
  583.      Separate the prefix from the rest of the symbol name with an
  584.      underscore `_'.  This will be consistent with Octave itself and
  585.      with most Octave programs.
  586.  
  587.    * When you encounter an error condition, call the function `error'
  588.      (or `usage').  The `error' and `usage' functions do not return.
  589.      *Note Errors::.
  590.  
  591.    * Please put a copyright notice on the file if you give copies to
  592.      anyone.  Use the same lines that appear at the top of the function
  593.      files distributed with Octave.  If you have not signed papers to
  594.      assign the copyright to anyone else, then place your name in the
  595.      copyright notice.
  596.  
  597. 
  598. File: octave,  Node: Coding Tips,  Next: Documentation Tips,  Prev: Style Tips,  Up: Tips
  599.  
  600. Tips for Making Code Run Faster.
  601. ================================
  602.  
  603.    Here are some ways of improving the execution speed of Octave
  604. programs.
  605.  
  606.    * Avoid looping wherever possible.
  607.  
  608.    * Use iteration rather than recursion whenever possible.  Function
  609.      calls are slow in Octave.
  610.  
  611.    * Avoid resizing matrices unnecessarily.  When building a single
  612.      result matrix from a series of calculations, set the size of the
  613.      result matrix first, then insert values into it.  Write
  614.  
  615.           result = zeros (big_n, big_m)
  616.           for i = over:and_over
  617.             r1 = ...
  618.             r2 = ...
  619.             result (r1, r2) = new_value ();
  620.           endfor
  621.  
  622.      instead of
  623.  
  624.           result = [];
  625.           for i = ever:and_ever
  626.             result = [ result, new_value() ];
  627.           endfor
  628.  
  629.    * Avoid calling `eval' or `feval' whenever possible, because they
  630.      require Octave to parse input or look up the name of a function in
  631.      the symbol table.
  632.  
  633.      If you are using `eval' as an exception handling mechanism and not
  634.      because you need to execute some arbitrary text, use the `try'
  635.      statement instead.  *Note The try Statement::.
  636.  
  637.    * If you are calling lots of functions but none of them will need to
  638.      change during your run, set the variable
  639.      `ignore_function_time_stamp' to `"all"' so that Octave doesn't
  640.      waste a lot of time checking to see if you have updated your
  641.      function files.
  642.  
  643. 
  644. File: octave,  Node: Documentation Tips,  Next: Comment Tips,  Prev: Coding Tips,  Up: Tips
  645.  
  646. Tips for Documentation Strings
  647. ==============================
  648.  
  649.    Here are some tips for the writing of documentation strings.
  650.  
  651.    * Every command, function, or variable intended for users to know
  652.      about should have a documentation string.
  653.  
  654.    * An internal variable or subroutine of an Octave program might as
  655.      well have a documentation string.
  656.  
  657.    * The first line of the documentation string should consist of one
  658.      or two complete sentences that stand on their own as a summary.
  659.  
  660.      The documentation string can have additional lines that expand on
  661.      the details of how to use the function or variable.  The
  662.      additional lines should also be made up of complete sentences.
  663.  
  664.    * For consistency, phrase the verb in the first sentence of a
  665.      documentation string as an infinitive with "to" omitted.  For
  666.      instance, use "Return the frob of A and B." in preference to
  667.      "Returns the frob of A and B«"  Usually it looks good to do
  668.      likewise for the rest of the first paragraph.  Subsequent
  669.      paragraphs usually look better if they have proper subjects.
  670.  
  671.    * Write documentation strings in the active voice, not the passive,
  672.      and in the present tense, not the future.  For instance, use
  673.      "Return a list containing A and B." instead of "A list containing
  674.      A and B will be returned."
  675.  
  676.    * Avoid using the word "cause" (or its equivalents) unnecessarily.
  677.      Instead of, "Cause Octave to display text in boldface," write just
  678.      "Display text in boldface."
  679.  
  680.    * Do not start or end a documentation string with whitespace.
  681.  
  682.    * Format the documentation string so that it fits in an Emacs window
  683.      on an 80-column screen.  It is a good idea for most lines to be no
  684.      wider than 60 characters.
  685.  
  686.      However, rather than simply filling the entire documentation
  687.      string, you can make it much more readable by choosing line breaks
  688.      with care.  Use blank lines between topics if the documentation
  689.      string is long.
  690.  
  691.    * *Do not* indent subsequent lines of a documentation string so that
  692.      the text is lined up in the source code with the text of the first
  693.      line.  This looks nice in the source code, but looks bizarre when
  694.      users view the documentation.  Remember that the indentation
  695.      before the starting double-quote is not part of the string!
  696.  
  697.    * The documentation string for a variable that is a yes-or-no flag
  698.      should start with words such as "Nonzero means...", to make it
  699.      clear that all nonzero values are equivalent and indicate
  700.      explicitly what zero and nonzero mean.
  701.  
  702.    * When a function's documentation string mentions the value of an
  703.      argument of the function, use the argument name in capital letters
  704.      as if it were a name for that value.  Thus, the documentation
  705.      string of the operator `/' refers to its second argument as
  706.      `DIVISOR', because the actual argument name is `divisor'.
  707.  
  708.      Also use all caps for meta-syntactic variables, such as when you
  709.      show the decomposition of a list or vector into subunits, some of
  710.      which may vary.
  711.  
  712. 
  713. File: octave,  Node: Comment Tips,  Next: Function Headers,  Prev: Documentation Tips,  Up: Tips
  714.  
  715. Tips on Writing Comments
  716. ========================
  717.  
  718.    Here are the conventions to follow when writing comments.
  719.  
  720. `#'
  721.      Comments that start with a single sharp-sign, `#', should all be
  722.      aligned to the same column on the right of the source code.  Such
  723.      comments usually explain how the code on the same line does its
  724.      job.  In the Emacs mode for Octave, the `M-;'
  725.      (`indent-for-comment') command automatically inserts such a `#' in
  726.      the right place, or aligns such a comment if it is already present.
  727.  
  728. `##'
  729.      Comments that start with two semicolons, `##', should be aligned to
  730.      the same level of indentation as the code.  Such comments usually
  731.      describe the purpose of the following lines or the state of the
  732.      program at that point.
  733.  
  734. The indentation commands of the Octave mode in Emacs, such as `M-;'
  735. (`indent-for-comment') and `TAB' (`octave-indent-line') automatically
  736. indent comments according to these conventions, depending on the number
  737. of semicolons.  *Note Manipulating Comments: (emacs)Comments.
  738.  
  739. 
  740. File: octave,  Node: Function Headers,  Prev: Comment Tips,  Up: Tips
  741.  
  742. Conventional Headers for Octave Functions
  743. =========================================
  744.  
  745.    Octave has conventions for using special comments in function files
  746. to give information such as who wrote them.  This section explains these
  747. conventions.
  748.  
  749.    The top of the file should contain a copyright notice, followed by a
  750. block of comments that can be used as the help text for the function.
  751. Here is an example:
  752.  
  753.      ## Copyright (C) 1996, 1997 John W. Eaton
  754.      ##
  755.      ## This file is part of Octave.
  756.      ##
  757.      ## Octave is free software; you can redistribute it and/or
  758.      ## modify it under the terms of the GNU General Public
  759.      ## License as published by the Free Software Foundation;
  760.      ## either version 2, or (at your option) any later version.
  761.      ##
  762.      ## Octave is distributed in the hope that it will be useful,
  763.      ## but WITHOUT ANY WARRANTY; without even the implied
  764.      ## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  765.      ## PURPOSE.  See the GNU General Public License for more
  766.      ## details.
  767.      ##
  768.      ## You should have received a copy of the GNU General Public
  769.      ## License along with Octave; see the file COPYING.  If not,
  770.      ## write to the Free Software Foundation, 59 Temple Place -
  771.      ## Suite 330, Boston, MA 02111-1307, USA.
  772.      
  773.      ## usage: [IN, OUT, PID] = popen2 (COMMAND, ARGS)
  774.      ##
  775.      ## Start a subprocess with two-way communication.  COMMAND
  776.      ## specifies the name of the command to start.  ARGS is an
  777.      ## array of strings containing options for COMMAND.  IN and
  778.      ## OUT are the file ids of the input and streams for the
  779.      ## subprocess, and PID is the process id of the subprocess,
  780.      ## or -1 if COMMAND could not be executed.
  781.      ##
  782.      ## Example:
  783.      ##
  784.      ##  [in, out, pid] = popen2 ("sort", "-nr");
  785.      ##  fputs (in, "these\nare\nsome\nstrings\n");
  786.      ##  fclose (in);
  787.      ##  while (isstr (s = fgets (out)))
  788.      ##    fputs (stdout, s);
  789.      ##  endwhile
  790.      ##  fclose (out);
  791.  
  792.    Octave uses the first block of comments in a function file that do
  793. not appear to be a copyright notice as the help text for the file.  For
  794. Octave to recognize the first comment block as a copyright notice, it
  795. must match the regular expression
  796.  
  797.      ^ Copyright (C).*\n\n This file is part of Octave.
  798.  
  799. or
  800.  
  801.      ^ Copyright (C).*\n\n This program is free softwar
  802.  
  803. (after stripping the leading comment characters).  This is a fairly
  804. strict requirement, and may be relaxed somewhat in the future.
  805.  
  806.    After the copyright notice and help text come several "header
  807. comment" lines, each beginning with `## HEADER-NAME:'.  For example,
  808.  
  809.      ## Author: jwe
  810.      ## Keywords: subprocesses input-output
  811.      ## Maintainer: jwe
  812.  
  813.    Here is a table of the conventional possibilities for HEADER-NAME:
  814.  
  815. `Author'
  816.      This line states the name and net address of at least the principal
  817.      author of the library.
  818.  
  819.           ## Author: John W. Eaton <jwe@bevo.che.wisc.edu>
  820.  
  821. `Maintainer'
  822.      This line should contain a single name/address as in the Author
  823.      line, or an address only, or the string `jwe'.  If there is no
  824.      maintainer line, the person(s) in the Author field are presumed to
  825.      be the maintainers.  The example above is mildly bogus because the
  826.      maintainer line is redundant.
  827.  
  828.      The idea behind the `Author' and `Maintainer' lines is to make
  829.      possible a function to "send mail to the maintainer" without
  830.      having to mine the name out by hand.
  831.  
  832.      Be sure to surround the network address with `<...>' if you
  833.      include the person's full name as well as the network address.
  834.  
  835. `Created'
  836.      This optional line gives the original creation date of the file.
  837.      For historical interest only.
  838.  
  839. `Version'
  840.      If you wish to record version numbers for the individual Octave
  841.      program, put them in this line.
  842.  
  843. `Adapted-By'
  844.      In this header line, place the name of the person who adapted the
  845.      library for installation (to make it fit the style conventions, for
  846.      example).
  847.  
  848. `Keywords'
  849.      This line lists keywords.  Eventually, it will be used by an
  850.      apropos command to allow people will find your package when
  851.      they're looking for things by topic area.  To separate the
  852.      keywords, you can use spaces, commas, or both.
  853.  
  854.    Just about every Octave function ought to have the `Author' and
  855. `Keywords' header comment lines.  Use the others if they are
  856. appropriate.  You can also put in header lines with other header
  857. names--they have no standard meanings, so they can't do any harm.
  858.  
  859. 
  860. File: octave,  Node: Trouble,  Next: Installation,  Prev: Tips,  Up: Top
  861.  
  862. Known Causes of Trouble
  863. ***********************
  864.  
  865.    This section describes known problems that affect users of Octave.
  866. Most of these are not Octave bugs per se--if they were, we would fix
  867. them.  But the result for a user may be like the result of a bug.
  868.  
  869.    Some of these problems are due to bugs in other software, some are
  870. missing features that are too much work to add, and some are places
  871. where people's opinions differ as to what is best.
  872.  
  873. * Menu:
  874.  
  875. * Actual Bugs::                 Bugs we will fix later.
  876. * Reporting Bugs::
  877. * Bug Criteria::
  878. * Bug Lists::
  879. * Bug Reporting::
  880. * Sending Patches::
  881. * Service::
  882.  
  883. 
  884. File: octave,  Node: Actual Bugs,  Next: Reporting Bugs,  Prev: Trouble,  Up: Trouble
  885.  
  886. Actual Bugs We Haven't Fixed Yet
  887. ================================
  888.  
  889.    * Output that comes directly from Fortran functions is not sent
  890.      through the pager and may appear out of sequence with other output
  891.      that is sent through the pager.  One way to avoid this is to force
  892.      pending output to be flushed before calling a function that will
  893.      produce output from within Fortran functions.  To do this, use the
  894.      command
  895.  
  896.           fflush (stdout)
  897.  
  898.      Another possible workaround is to use the command
  899.  
  900.           page_screen_output = "false"
  901.  
  902.      to turn the pager off.
  903.  
  904.    * If you get messages like
  905.  
  906.           Input line too long
  907.  
  908.      when trying to plot many lines on one graph, you have probably
  909.      generated a plot command that is too larger for `gnuplot''s
  910.      fixed-length buffer for commands.  Splitting up the plot command
  911.      doesn't help because replot is implemented in gnuplot by simply
  912.      appending the new plotting commands to the old command line and
  913.      then evaluating it again.
  914.  
  915.      You can demonstrate this `feature' by running gnuplot and doing
  916.      something like
  917.  
  918.             plot sin (x), sin (x), sin (x), ... lots more ..., sin (x)
  919.  
  920.      and then
  921.  
  922.             replot sin (x), sin (x), sin (x), ... lots more ..., sin (x)
  923.  
  924.      after repeating the replot command a few times, gnuplot will give
  925.      you an error.
  926.  
  927.      Also, it doesn't help to use backslashes to enter a plot command
  928.      over several lines, because the limit is on the overall command
  929.      line length, once the backslashed lines are all pasted together.
  930.  
  931.      Because of this, Octave tries to use as little of the command-line
  932.      length as possible by using the shortest possible abbreviations for
  933.      all the plot commands and options.  Unfortunately, the length of
  934.      the temporary file names is probably what is taking up the most
  935.      space on the command line.
  936.  
  937.      You can buy a little bit of command line space by setting the
  938.      environment variable `TMPDIR' to be "." before starting Octave, or
  939.      you can increase the maximum command line length in gnuplot by
  940.      changing the following limits in the file plot.h in the gnuplot
  941.      distribution and recompiling gnuplot.
  942.  
  943.           #define MAX_LINE_LEN 32768  /* originally 1024 */
  944.           #define MAX_TOKENS 8192     /* originally 400 */
  945.  
  946.      Of course, this doesn't really fix the problem, but it does make it
  947.      much less likely that you will run into trouble unless you are
  948.      putting a very large number of lines on a given plot.
  949.  
  950.    A list of ideas for future enhancements is distributed with Octave.
  951. See the file `PROJECTS' in the top level directory in the source
  952. distribution.
  953.  
  954. 
  955. File: octave,  Node: Reporting Bugs,  Next: Bug Criteria,  Prev: Actual Bugs,  Up: Trouble
  956.  
  957. Reporting Bugs
  958. ==============
  959.  
  960.    Your bug reports play an essential role in making Octave reliable.
  961.  
  962.    When you encounter a problem, the first thing to do is to see if it
  963. is already known.  *Note Trouble::.  If it isn't known, then you should
  964. report the problem.
  965.  
  966.    Reporting a bug may help you by bringing a solution to your problem,
  967. or it may not.  In any case, the principal function of a bug report is
  968. to help the entire community by making the next version of Octave work
  969. better.  Bug reports are your contribution to the maintenance of Octave.
  970.  
  971.    In order for a bug report to serve its purpose, you must include the
  972. information that makes it possible to fix the bug.
  973.  
  974.    If you have Octave working at all, the easiest way to prepare a
  975. complete bug report is to use the Octave function `bug_report'.  When
  976. you execute this function, Octave will prompt you for a subject and then
  977. invoke the editor on a file that already contains all the configuration
  978. information.  When you exit the editor, Octave will mail the bug report
  979. for you.
  980.  
  981. * Menu:
  982.  
  983. * Bug Criteria::
  984. * Where: Bug Lists.             Where to send your bug report.
  985. * Reporting: Bug Reporting.     How to report a bug effectively.
  986. * Patches: Sending Patches.     How to send a patch for Octave.
  987.  
  988. 
  989. File: octave,  Node: Bug Criteria,  Next: Bug Lists,  Prev: Reporting Bugs,  Up: Trouble
  990.  
  991. Have You Found a Bug?
  992. =====================
  993.  
  994.    If you are not sure whether you have found a bug, here are some
  995. guidelines:
  996.  
  997.    * If Octave gets a fatal signal, for any input whatever, that is a
  998.      bug.  Reliable interpreters never crash.
  999.  
  1000.    * If Octave produces incorrect results, for any input whatever, that
  1001.      is a bug.
  1002.  
  1003.    * Some output may appear to be incorrect when it is in fact due to a
  1004.      program whose behavior is undefined, which happened by chance to
  1005.      give the desired results on another system.  For example, the
  1006.      range operator may produce different results because of
  1007.      differences in the way floating point arithmetic is handled on
  1008.      various systems.
  1009.  
  1010.    * If Octave produces an error message for valid input, that is a bug.
  1011.  
  1012.    * If Octave does not produce an error message for invalid input,
  1013.      that is a bug.  However, you should note that your idea of
  1014.      "invalid input" might be my idea of "an extension" or "support for
  1015.      traditional practice".
  1016.  
  1017.    * If you are an experienced user of programs like Octave, your
  1018.      suggestions for improvement are welcome in any case.
  1019.  
  1020. 
  1021. File: octave,  Node: Bug Lists,  Next: Bug Reporting,  Prev: Bug Criteria,  Up: Trouble
  1022.  
  1023. Where to Report Bugs
  1024. ====================
  1025.  
  1026.    If you have Octave working at all, the easiest way to prepare a
  1027. complete bug report is to use the Octave function `bug_report'.  When
  1028. you execute this function, Octave will prompt you for a subject and then
  1029. invoke the editor on a file that already contains all the configuration
  1030. information.  When you exit the editor, Octave will mail the bug report
  1031. for you.
  1032.  
  1033.    If for some reason you cannot use Octave's `bug_report' function,
  1034. send bug reports for Octave to (bug-octave@bevo.che.wisc.edu).
  1035.  
  1036.    *Do not send bug reports to `help-octave'*.  Most users of Octave do
  1037. not want to receive bug reports.  Those that do have asked to be on the
  1038. mailing list.
  1039.  
  1040.    As a last resort, send bug reports on paper to:
  1041.  
  1042.      Octave Bugs c/o John W. Eaton
  1043.      University of Wisconsin-Madison
  1044.      Department of Chemical Engineering
  1045.      1415 Engineering Drive
  1046.      Madison, Wisconsin 53706  USA
  1047.  
  1048. 
  1049. File: octave,  Node: Bug Reporting,  Next: Sending Patches,  Prev: Bug Lists,  Up: Trouble
  1050.  
  1051. How to Report Bugs
  1052. ==================
  1053.  
  1054.    Send bug reports for Octave to one of the addresses listed in *Note
  1055. Bug Lists::.
  1056.  
  1057.    The fundamental principle of reporting bugs usefully is this:
  1058. *report all the facts*.  If you are not sure whether to state a fact or
  1059. leave it out, state it!
  1060.  
  1061.    Often people omit facts because they think they know what causes the
  1062. problem and they conclude that some details don't matter.  Thus, you
  1063. might assume that the name of the variable you use in an example does
  1064. not matter.  Well, probably it doesn't, but one cannot be sure.
  1065. Perhaps the bug is a stray memory reference which happens to fetch from
  1066. the location where that name is stored in memory; perhaps, if the name
  1067. were different, the contents of that location would fool the
  1068. interpreter into doing the right thing despite the bug.  Play it safe
  1069. and give a specific, complete example.
  1070.  
  1071.    Keep in mind that the purpose of a bug report is to enable someone to
  1072. fix the bug if it is not known. Always write your bug reports on the
  1073. assumption that the bug is not known.
  1074.  
  1075.    Sometimes people give a few sketchy facts and ask, "Does this ring a
  1076. bell?"  This cannot help us fix a bug.  It is better to send a complete
  1077. bug report to begin with.
  1078.  
  1079.    Try to make your bug report self-contained.  If we have to ask you
  1080. for more information, it is best if you include all the previous
  1081. information in your response, as well as the information that was
  1082. missing.
  1083.  
  1084.    To enable someone to investigate the bug, you should include all
  1085. these things:
  1086.  
  1087.    * The version of Octave.  You can get this by noting the version
  1088.      number that is printed when Octave starts, or running it with the
  1089.      `-v' option.
  1090.  
  1091.    * A complete input file that will reproduce the bug.
  1092.  
  1093.      A single statement may not be enough of an example--the bug might
  1094.      depend on other details that are missing from the single statement
  1095.      where the error finally occurs.
  1096.  
  1097.    * The command arguments you gave Octave to execute that example and
  1098.      observe the bug.  To guarantee you won't omit something important,
  1099.      list all the options.
  1100.  
  1101.      If we were to try to guess the arguments, we would probably guess
  1102.      wrong and then we would not encounter the bug.
  1103.  
  1104.    * The type of machine you are using, and the operating system name
  1105.      and version number.
  1106.  
  1107.    * The command-line arguments you gave to the `configure' command when
  1108.      you installed the interpreter.
  1109.  
  1110.    * A complete list of any modifications you have made to the
  1111.      interpreter source.
  1112.  
  1113.      Be precise about these changes--show a context diff for them.
  1114.  
  1115.    * Details of any other deviations from the standard procedure for
  1116.      installing Octave.
  1117.  
  1118.    * A description of what behavior you observe that you believe is
  1119.      incorrect.  For example, "The interpreter gets a fatal signal,"
  1120.      or, "The output produced at line 208 is incorrect."
  1121.  
  1122.      Of course, if the bug is that the interpreter gets a fatal signal,
  1123.      then one can't miss it.  But if the bug is incorrect output, we
  1124.      might not notice unless it is glaringly wrong.
  1125.  
  1126.      Even if the problem you experience is a fatal signal, you should
  1127.      still say so explicitly.  Suppose something strange is going on,
  1128.      such as, your copy of the interpreter is out of synch, or you have
  1129.      encountered a bug in the C library on your system.  Your copy
  1130.      might crash and the copy here would not.  If you said to expect a
  1131.      crash, then when the interpreter here fails to crash, we would
  1132.      know that the bug was not happening.  If you don't say to expect a
  1133.      crash, then we would not know whether the bug was happening.  We
  1134.      would not be able to draw any conclusion from our observations.
  1135.  
  1136.      Often the observed symptom is incorrect output when your program
  1137.      is run.  Unfortunately, this is not enough information unless the
  1138.      program is short and simple.  It is very helpful if you can
  1139.      include an explanation of the expected output, and why the actual
  1140.      output is incorrect.
  1141.  
  1142.    * If you wish to suggest changes to the Octave source, send them as
  1143.      context diffs.  If you even discuss something in the Octave source,
  1144.      refer to it by context, not by line number, because the line
  1145.      numbers in the development sources probably won't match those in
  1146.      your sources.
  1147.  
  1148.    Here are some things that are not necessary:
  1149.  
  1150.    * A description of the envelope of the bug.
  1151.  
  1152.      Often people who encounter a bug spend a lot of time investigating
  1153.      which changes to the input file will make the bug go away and
  1154.      which changes will not affect it.  Such information is usually not
  1155.      necessary to enable us to fix bugs in Octave, but if you can find
  1156.      a simpler example to report *instead* of the original one, that is
  1157.      a convenience.  Errors in the output will be easier to spot,
  1158.      running under the debugger will take less time, etc. Most Octave
  1159.      bugs involve just one function, so the most straightforward way to
  1160.      simplify an example is to delete all the function definitions
  1161.      except the one in which the bug occurs.
  1162.  
  1163.      However, simplification is not vital; if you don't want to do
  1164.      this, report the bug anyway and send the entire test case you used.
  1165.  
  1166.    * A patch for the bug.  Patches can be helpful, but if you find a
  1167.      bug, you should report it, even if you cannot send a fix for the
  1168.      problem.
  1169.  
  1170. 
  1171. File: octave,  Node: Sending Patches,  Next: Service,  Prev: Bug Reporting,  Up: Trouble
  1172.  
  1173. Sending Patches for Octave
  1174. ==========================
  1175.  
  1176.    If you would like to write bug fixes or improvements for Octave,
  1177. that is very helpful.  When you send your changes, please follow these
  1178. guidelines to avoid causing extra work for us in studying the patches.
  1179.  
  1180.    If you don't follow these guidelines, your information might still be
  1181. useful, but using it will take extra work.  Maintaining Octave is a lot
  1182. of work in the best of circumstances, and we can't keep up unless you do
  1183. your best to help.
  1184.  
  1185.    * Send an explanation with your changes of what problem they fix or
  1186.      what improvement they bring about.  For a bug fix, just include a
  1187.      copy of the bug report, and explain why the change fixes the bug.
  1188.  
  1189.    * Always include a proper bug report for the problem you think you
  1190.      have fixed.  We need to convince ourselves that the change is
  1191.      right before installing it.  Even if it is right, we might have
  1192.      trouble judging it if we don't have a way to reproduce the problem.
  1193.  
  1194.    * Include all the comments that are appropriate to help people
  1195.      reading the source in the future understand why this change was
  1196.      needed.
  1197.  
  1198.    * Don't mix together changes made for different reasons.  Send them
  1199.      *individually*.
  1200.  
  1201.      If you make two changes for separate reasons, then we might not
  1202.      want to install them both.  We might want to install just one.
  1203.  
  1204.    * Use `diff -c' to make your diffs.  Diffs without context are hard
  1205.      for us to install reliably.  More than that, they make it hard for
  1206.      us to study the diffs to decide whether we want to install them.
  1207.      Unidiff format is better than contextless diffs, but not as easy
  1208.      to read as `-c' format.
  1209.  
  1210.      If you have GNU diff, use `diff -cp', which shows the name of the
  1211.      function that each change occurs in.
  1212.  
  1213.    * Write the change log entries for your changes.
  1214.  
  1215.      Read the `ChangeLog' file to see what sorts of information to put
  1216.      in, and to learn the style that we use.  The purpose of the change
  1217.      log is to show people where to find what was changed.  So you need
  1218.      to be specific about what functions you changed; in large
  1219.      functions, it's often helpful to indicate where within the
  1220.      function the change was made.
  1221.  
  1222.      On the other hand, once you have shown people where to find the
  1223.      change, you need not explain its purpose. Thus, if you add a new
  1224.      function, all you need to say about it is that it is new.  If you
  1225.      feel that the purpose needs explaining, it probably does--but the
  1226.      explanation will be much more useful if you put it in comments in
  1227.      the code.
  1228.  
  1229.      If you would like your name to appear in the header line for who
  1230.      made the change, send us the header line.
  1231.  
  1232. 
  1233. File: octave,  Node: Service,  Prev: Sending Patches,  Up: Trouble
  1234.  
  1235. How To Get Help with Octave
  1236. ===========================
  1237.  
  1238.    The mailing list (help-octave@bevo.che.wisc.edu) exists for the
  1239. discussion of matters related to using and installing Octave.  If would
  1240. like to join the discussion, please send a short note to
  1241. (help-octave*-request*@bevo.che.wisc.edu).
  1242.  
  1243.    *Please do not* send requests to be added or removed from the
  1244. mailing list, or other administrative trivia to the list itself.
  1245.  
  1246.    If you think you have found a bug in the installation procedure,
  1247. however, you should send a complete bug report for the problem to
  1248. (bug-octave@bevo.che.wisc.edu).  *Note Bug Reporting:: for information
  1249. that will help you to submit a useful report.
  1250.  
  1251.