changeset 6570:49f0820425a8

[project @ 2007-04-24 23:06:56 by jwe]
author jwe
date Tue, 24 Apr 2007 23:07:44 +0000
parents 81a8ab62b2b9
children 24d9e0799603
files doc/ChangeLog doc/interpreter/func.txi doc/interpreter/octave.texi doc/interpreter/plot.txi doc/interpreter/sparse.txi doc/interpreter/strings.txi
diffstat 6 files changed, 62 insertions(+), 560 deletions(-) [+]
line wrap: on
line diff
--- a/doc/ChangeLog	Tue Apr 24 23:03:43 2007 +0000
+++ b/doc/ChangeLog	Tue Apr 24 23:07:44 2007 +0000
@@ -1,3 +1,31 @@
+2007-04-24  John W. Eaton  <jwe@octave.org>
+
+	* Makefile (EXAMPLE_SOURCES): New variable.
+	(octave.info, octave.dvi, octave.pdf, HTML/index.html):
+	Depend on $(EXAMPLE_SOURCES).
+	(DISTFILES): Include $(EXAMPLE_SOURCES) in the list.
+
+2007-04-24  David Bateman  <dbateman@free.fr>
+
+	* interpreter/octave.texi: Include dynamic.texi as appendix and
+	update menus.
+
+	* interpreter/plot.txi: Update menus.
+
+	* interpreter/strings.txi: @result -> @result{}.
+
+	* intrepreter/func.txi, intrepreter/sparse.txi:
+	Delete .oct file section and update menus.
+
+	* interpreter/addtwomatrices.cc, interpreter/celldemo.cc,
+	interpreter/fortdemo.cc, interpreter/funcdemo.cc,
+	interpreter/globaldemo.cc, interpreter/helloworld.cc,
+	interpreter/stringdemo.cc, interpreter/structdemo.cc,
+	interpreter/unwinddemo.cc, interpreter/fortsub.f,
+	interpreter/dynamic.txi: New files.
+
+	* Makefile.in (SUB_SOURCE): Include dynamic.txi in the list.
+
 2007-04-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/package.texi: New file.
--- a/doc/interpreter/func.txi	Tue Apr 24 23:03:43 2007 +0000
+++ b/doc/interpreter/func.txi	Tue Apr 24 23:07:44 2007 +0000
@@ -23,7 +23,6 @@
 * Default Arguments::   
 * Function Files::              
 * Script Files::                
-* Dynamically Linked Functions::  
 * Function Handles and Inline::
 * Commands::
 * Organization of Functions::   
@@ -769,205 +768,6 @@
 
 @DOCSTRING(source)
 
-@node Dynamically Linked Functions
-@section Dynamically Linked Functions
-@cindex dynamic linking
-
-On some systems, Octave can dynamically load and execute functions
-written in C++.  Octave can only directly call functions written in C++,
-but you can also load functions written in other languages
-by calling them from a simple wrapper function written in C++.
-
-Here is an example of how to write a C++ function that Octave can load,
-with commentary.  The source for this function is included in the source
-distributions of Octave, in the file @file{examples/oregonator.cc}.  It
-defines the same set of differential equations that are used in the
-example problem of @ref{Ordinary Differential Equations}.  By running
-that example and this one, we can compare the execution times to see
-what sort of increase in speed you can expect by using dynamically
-linked functions.
-
-The function defined in @file{oregonator.cc} contains just 8 statements,
-and is not much different than the code defined in the corresponding
-M-file (also distributed with Octave in the file
-@file{examples/oregonator.m}).
-
-Here is the complete text of @file{oregonator.cc}:
-
-@example
-@group
-#include <octave/oct.h>
-
-DEFUN_DLD (oregonator, args, ,
-  "The `oregonator'.")
-@{
-  ColumnVector dx (3);
-
-  ColumnVector x (args(0).vector_value ());
-
-  dx(0) = 77.27 * (x(1) - x(0)*x(1) + x(0)
-                   - 8.375e-06*pow (x(0), 2));
-
-  dx(1) = (x(2) - x(0)*x(1) - x(1)) / 77.27;
-
-  dx(2) = 0.161*(x(0) - x(2));
-
-  return octave_value (dx);
-@}
-@end group
-@end example
-
-The first line of the file,
-
-@example
-#include <octave/oct.h>
-@end example
-
-@noindent
-includes declarations for all of Octave's internal functions that you
-will need.  If you need other functions from the standard C++ or C
-libraries, you can include the necessary headers here.
-
-The next two lines
-@example
-@group
-DEFUN_DLD (oregonator, args, ,
-  "The `oregonator'.")
-@end group
-@end example
-
-@noindent
-declares the function.  The macro @code{DEFUN_DLD} and the macros that
-it depends on are defined in the files @file{defun-dld.h},
-@file{defun.h}, and @file{defun-int.h} (these files are included in the
-header file @file{octave/oct.h}).
-
-Note that the third parameter to @code{DEFUN_DLD} (@code{nargout}) is
-not used, so it is omitted from the list of arguments in order to
-avoid the warning from gcc about an unused function parameter.
-
-The next line,
-
-@example
-ColumnVector dx (3);
-@end example
-
-@noindent
-simply declares an object to store the right hand sides of the
-differential equation, and the statement
-
-@example
-ColumnVector x (args(0).vector_value ());
-@end example
-
-@noindent
-extracts a vector from the first input argument.  The
-@code{vector_value} method is used so that the user of the function
-can pass either a row or column vector.  The @code{ColumnVector}
-constructor is needed because the ODE class requires a column
-vector.  The variable @code{args} is passed to functions defined with
-@code{DEFUN_DLD} as an @code{octave_value_list} object, which includes
-methods for getting the length of the list and extracting individual
-elements.
-
-In this example, we don't check for errors, but that is not difficult.
-All of the Octave's built-in functions do some form of checking on their
-arguments, so you can check the source code for those functions for
-examples of various strategies for verifying that the correct number and
-types of arguments have been supplied.
-
-The next statements
-
-@example
-@group
-dx(0) = 77.27 * (x(1) - x(0)*x(1) + x(0)
-                 - 8.375e-06*pow (x(0), 2));
-
-dx(1) = (x(2) - x(0)*x(1) - x(1)) / 77.27;
-
-dx(2) = 0.161*(x(0) - x(2));
-@end group
-@end example
-
-@noindent
-define the right-hand side of the differential equation.  Finally, we
-can return @code{dx}:
-
-@example
-return octave_value (dx);
-@end example
-
-@noindent
-The actual return type is @code{octave_value_list}, but it is only
-necessary to convert the return type to an @code{octave_value} because
-there is a default constructor that can automatically create an object
-of that type from an @code{octave_value} object, so we can just use that
-instead.
-
-To use this file, your version of Octave must support dynamic linking.
-To find out if it does, type the command
-@kbd{octave_config_info ("dld")} at the Octave prompt.  Support for
-dynamic linking is included if this command returns 1.
-
-To compile the example file, type the command @samp{mkoctfile
-oregonator.cc} at the shell prompt.  The script @code{mkoctfile} should
-have been installed along with Octave.  Running it will create a file
-called @file{oregonator.oct} that can be loaded by Octave.  To test the
-@file{oregonator.oct} file, start Octave and type the command
-
-@example
-oregonator ([1, 2, 3], 0)
-@end example
-
-@noindent
-at the Octave prompt.  Octave should respond by printing
-
-@example
-@group
-ans =
-
-   77.269353
-   -0.012942
-   -0.322000
-@end group
-@end example
-
-You can now use the @file{oregonator.oct} file just as you would the
-@code{oregonator.m} file to solve the set of differential equations.
-
-On a 133 MHz Pentium running Linux, Octave can solve the problem shown
-in @ref{Ordinary Differential Equations}, in about 1.4 seconds using the
-dynamically linked function, compared to about 19 seconds using the
-M-file.  Similar decreases in execution time can be expected for other
-functions, particularly those that rely on functions like @code{lsode}
-that require user-supplied functions.
-
-Just as for M-files, Octave will automatically reload a dynamically linked
-function when the file that defines it is more recent than the last
-time that the function was loaded.  If more than one function is defined
-in a single @file{.oct} file, reloading the file may force other
-functions to be cleared and reloaded.  If all the functions loaded from
-a given @file{.oct} file are cleared, Octave will automatically unload
-the @file{.oct} file.
-
-@c FIXME -- is there a better place for this?
-
-@DOCSTRING(variables_can_hide_functions)
-
-Additional examples for writing dynamically linked functions are
-available in the files in the @file{src} directory of the Octave
-distribution.
-
-There is currently no detailed description of all the functions that you
-can call in a built-in function.  For the time being, you will have to
-read the source code for Octave.
-
-@DOCSTRING(mkoctfile)
-
-@DOCSTRING(mex)
-
-@DOCSTRING(mexext)
-
 @node Function Handles and Inline
 @section Function Handles and Inline
 @cindex handle, function handles
@@ -1000,7 +800,7 @@
 @end example
 
 @noindent
-Creates a function handle called @code{f} that refers to the the
+Creates a function handle called @code{f} that refers to the
 function @code{sin}.
 
 Function handles are used to call other functions indirectly, or to pass
@@ -1010,20 +810,20 @@
 @example
 f = @@sin;
 quad (f, 0, pi)
-    @result 1.8391
+    @result{} 1.8391
 @end example
 
 You may use @code{feval} to call a function using function handle, or
-simply write the name of the function handle follwed by an argument
+simply write the name of the function handle followed by an argument
 list.  If there are no arguments, you must use an empty argument list
 @samp{()}.  For example
 
 @example
 f = @@sin;
 feval (f, pi/4)
-    @result 0.70711
+    @result{} 0.70711
 f (pi/4)
-    @result 0.70711
+    @result{} 0.70711
 @end example
 
 @DOCSTRING(functions)
@@ -1032,7 +832,7 @@
 
 @DOCSTRING(str2func)
 
-@node Anonymous Functions::
+@node Anonymous Functions
 @subsection Anonymous Functions
 
 Anonymous functions are defined using the syntax
@@ -1051,7 +851,7 @@
 @example
 f = @@(x) x.^2;
 quad (f, 0, 10)
-    @result 333.33
+    @result{} 333.33
 @end example
 
 @noindent
@@ -1060,7 +860,7 @@
 
 @example
 quad (@@(x) sin (x), 0, pi)
-    @result 1.8391
+    @result{} 1.8391
 @end example
 
 @noindent
@@ -1070,7 +870,7 @@
 a = 1;
 b = 2;
 quad (@@(x) betainc (x, a, b), 0, 0.4)
-    @result 1.3867
+    @result{} 1.3867
 @end example
 
 @noindent
--- a/doc/interpreter/octave.texi	Tue Apr 24 23:03:43 2007 +0000
+++ b/doc/interpreter/octave.texi	Tue Apr 24 23:07:44 2007 +0000
@@ -153,14 +153,15 @@
 * Polynomial Manipulations::    
 * Interpolation::
 * Geometry::
-* Hashing::
+* Hashing Functions::
 * Control Theory::              
 * Signal Processing::           
 * Image Processing::            
 * Audio Processing::            
 * Quaternions::                 
 * System Utilities::            
-* Packages::            
+* Packages:: 
+* Dynamically Linked Functions::
 * Test and Demo Functions::
 * Tips::                        
 * Trouble::                     If you have trouble installing Octave.
@@ -320,7 +321,6 @@
 * Returning From a Function::   
 * Function Files::              
 * Script Files::                
-* Dynamically Linked Functions::  
 * Organization of Functions::   
 
 Error Handling
@@ -400,7 +400,6 @@
 * Sparse Linear Algebra::
 * Iterative Techniques::
 * Real Life Example::
-* Oct-Files::
 * Function Reference::
 
 Quadrature
@@ -426,6 +425,8 @@
 * Models::                      
 * Distributions::               
 
+Hashing Functions
+
 Control Theory
 
 * sysstruct::                   
@@ -486,6 +487,12 @@
 * The INDEX file::              
 * PKG_ADD and PKG_DEL directives::  
 
+Dynamically Linked Functions
+
+* Oct-Files::
+* Mex-Files::
+* Standalone Programs::
+
 Test and Demo Functions
 
 * Test Functions::
@@ -587,6 +594,7 @@
 @c for them, and there appears to be no way to go back to the original
 @c set of indices once a redirection has taken place.
 
+@include dynamic.texi
 @include testfun.texi
 @include tips.texi
 @include bugs.texi
--- a/doc/interpreter/plot.txi	Tue Apr 24 23:03:43 2007 +0000
+++ b/doc/interpreter/plot.txi	Tue Apr 24 23:07:44 2007 +0000
@@ -6,7 +6,7 @@
 @chapter Plotting
 
 @menu
-* Plotting::    
+* Two-Dimensional Plotting::    
 * Specialized Two-Dimensional Plots::  
 * Three-Dimensional Plotting::  
 * Manipulating Existing Plots::
@@ -17,8 +17,8 @@
 * Interaction with gnuplot::    
 @end menu
 
-@node Plotting
-@section Plotting
+@node Two-Dimensional Plotting
+@section Two-Dimensional Plotting
 
 The basic plotting commands are:
 
--- a/doc/interpreter/sparse.txi	Tue Apr 24 23:03:43 2007 +0000
+++ b/doc/interpreter/sparse.txi	Tue Apr 24 23:07:44 2007 +0000
@@ -17,7 +17,6 @@
 * Sparse Linear Algebra:: Linear Algebra on Sparse Matrices
 * Iterative Techniques:: Iterative Techniques applied to Sparse Matrices
 * Real Life Example:: Real Life Example of the use of Sparse Matrices
-* Oct-Files:: Using Sparse Matrices in Oct-files
 * Function Reference:: Documentation from the Specific Sparse Functions
 @end menu
 
@@ -258,11 +257,11 @@
 as much as possible to minimize the number of assignments and reduce the
 number of memory allocations.
 
-The above problem can be avoided in oct-files. However, the
-construction of a sparse matrix from an oct-file is more complex than
-can be discussed in this brief introduction, and you are referred to
-section @ref{Oct-Files}, to have a full description of the techniques
-involved.
+The above problem can be avoided in oct-files. However, the construction
+of a sparse matrix from an oct-file is more complex than can be
+discussed in this brief introduction, and you are referred to chapter
+@ref{Dynamically Linked Functions}, to have a full description of the
+techniques involved.
 
 @node Information, Operators and Functions, Creation, Basics
 @subsection Finding out Information about Sparse Matrices
@@ -739,7 +738,7 @@
 
 WRITE ME.
 
-@node Real Life Example, Oct-Files, Iterative Techniques, Sparse Matrices
+@node Real Life Example, Function Reference, Iterative Techniques, Sparse Matrices
 @section Real Life Example of the use of Sparse Matrices
 
 A common application for sparse matrices is in the solution of Finite
@@ -1005,340 +1004,7 @@
 @end ifset
 @end ifset
 
-@node Oct-Files, Function Reference, Real Life Example, Sparse Matrices
-@section Using Sparse Matrices in Oct-files
-
-An oct-file is a means of writing an Octave function in a compilable
-language like C++, rather than as a script file. This results in a
-significant acceleration in the code.  It is not the purpose of this
-section to discuss how to write an oct-file, or discuss what they
-are. There are already two @footnote{Paul Thomas "Dal Segno al Coda 
-- The octave dynamically linked function cookbook", 
-@url{http://perso.wanadoo.fr/prthomas/intro.html}, and Cristophe Spiel 
-"Del Coda Al Fine - Pushing Octave's Limits", 
-@url{http://octave.sourceforge.net/coda/coda.pdf}} very good
-references on oct-files themselves. Users who are not familiar with
-oct-files are urged to read these references to fully understand this
-chapter. The examples discussed here assume that the oct-file is written 
-entirely in C++.
-
-There are three classes of sparse objects that are of interest to the
-user.
-
-@table @asis
-@item SparseMatrix
-A double precision sparse matrix class
-@item SparseComplexMatrix
-A complex sparse matrix class
-@item SparseBoolMatrix
-A boolean sparse matrix class
-@end table
-
-All of these classes inherit from the @code{Sparse<T>} template class,
-and so all have similar capabilities and usage. The @code{Sparse<T>}
-class was based on Octave @code{Array<T>} class, and so users familiar
-with Octave's Array classes will be comfortable with the use of
-the sparse classes.
-
-The sparse classes will not be entirely described in this section, due
-to their similar with the existing Array classes. However, there are a
-few differences due the different nature of sparse objects, and these
-will be described. Firstly, although it is fundamentally possible to
-have N-dimensional sparse objects, the Octave sparse classes do
-not allow them at this time. So all operations of the sparse classes
-must be 2-dimensional.  This means that in fact @code{SparseMatrix} is
-similar to Octave's @code{Matrix} class rather than its
-@code{NDArray} class.
-
-@menu
-* OctDifferences:: The Differences between the Array and Sparse Classes
-* OctCreation:: Creating Spare Matrices in Oct-Files
-* OctUse:: Using Sparse Matrices in Oct-Files
-@end menu
-
-@node OctDifferences, OctCreation, Oct-Files, Oct-Files
-@subsection The Differences between the Array and Sparse Classes
-
-The number of elements in a sparse matrix is considered to be the number
-of non-zero elements rather than the product of the dimensions. Therefore
-
-@example
-  SparseMatrix sm;
-  @dots{}
-  int nel = sm.nelem ();
-@end example
-
-returns the number of non-zero elements. If the user really requires the 
-number of elements in the matrix, including the non-zero elements, they
-should use @code{numel} rather than @code{nelem}. Note that for very 
-large matrices, where the product of the two dimensions is large that
-the representation of the an unsigned int, then @code{numel} can overflow.
-An example is @code{speye(1e6)} which will create a matrix with a million
-rows and columns, but only a million non-zero elements. Therefore the
-number of rows by the number of columns in this case is more than two
-hundred times the maximum value that can be represented by an unsigned int.
-The use of @code{numel} should therefore be avoided useless it is known
-it won't overflow.
-
-Extreme care must be take with the elem method and the "()" operator,
-which perform basically the same function. The reason is that if a
-sparse object is non-const, then Octave will assume that a
-request for a zero element in a sparse matrix is in fact a request 
-to create this element so it can be filled. Therefore a piece of
-code like
-
-@example
-  SparseMatrix sm;
-  @dots{}
-  for (int j = 0; j < nc; j++)
-    for (int i = 0; i < nr; i++)
-      std::cerr << " (" << i << "," << j << "): " << sm(i,j) 
-                << std::endl;
-@end example
-
-is a great way of turning the sparse matrix into a dense one, and a
-very slow way at that since it reallocates the sparse object at each
-zero element in the matrix.
-
-An easy way of preventing the above from happening is to create a temporary
-constant version of the sparse matrix. Note that only the container for
-the sparse matrix will be copied, while the actual representation of the
-data will be shared between the two versions of the sparse matrix. So this
-is not a costly operation. For example, the above would become
-
-@example
-  SparseMatrix sm;
-  @dots{}
-  const SparseMatrix tmp (sm);
-  for (int j = 0; j < nc; j++)
-    for (int i = 0; i < nr; i++)
-      std::cerr << " (" << i << "," << j << "): " << tmp(i,j) 
-                << std::endl;
-@end example
-
-Finally, as the sparse types aren't just represented as a contiguous
-block of memory, the @code{fortran_vec} method of the @code{Array<T>}
-is not available. It is however replaced by three separate methods
-@code{ridx}, @code{cidx} and @code{data}, that access the raw compressed
-column format that the Octave sparse matrices are stored in.
-Additionally, these methods can be used in a manner similar to @code{elem},
-to allow the matrix to be accessed or filled. However, in that case it is
-up to the user to respect the sparse matrix compressed column format
-discussed previous.
-
-@node OctCreation, OctUse, OctDifferences, Oct-Files
-@subsection Creating Spare Matrices in Oct-Files
-
-The user has several alternatives in how to create a sparse matrix.
-They can first create the data as three vectors representing the
-row and column indexes and the data, and from those create the matrix.
-Or alternatively, they can create a sparse matrix with the appropriate
-amount of space and then fill in the values. Both techniques have their
-advantages and disadvantages.
-
-An example of how to create a small sparse matrix with the first technique
-might be seen the example
-
-@example
-  int nz = 4, nr = 3, nc = 4;
-  ColumnVector ridx (nz);
-  ColumnVector cidx (nz);
-  ColumnVector data (nz);
-
-  ridx(0) = 0; ridx(1) = 0; ridx(2) = 1; ridx(3) = 2;
-  cidx(0) = 0; cidx(1) = 1; cidx(2) = 3; cidx(3) = 3;
-  data(0) = 1; data(1) = 2; data(2) = 3; data(3) = 4;
-
-  SparseMatrix sm (data, ridx, cidx, nr, nc);
-@end example
-
-which creates the matrix given in section @ref{Storage}. Note that 
-the compressed matrix format is not used at the time of the creation
-of the matrix itself, however it is used internally. 
-
-As previously mentioned, the values of the sparse matrix are stored
-in increasing column-major ordering. Although the data passed by the
-user does not need to respect this requirement, the pre-sorting the
-data significantly speeds up the creation of the sparse matrix.
-
-The disadvantage of this technique of creating a sparse matrix is
-that there is a brief time where two copies of the data exists. Therefore
-for extremely memory constrained problems this might not be the right
-technique to create the sparse matrix.
-
-The alternative is to first create the sparse matrix with the desired
-number of non-zero elements and then later fill those elements in. The
-easiest way to do this is 
-
-@example 
-  int nz = 4, nr = 3, nc = 4;
-  SparseMatrix sm (nr, nc, nz);
-  sm(0,0) = 1; sm(0,1) = 2; sm(1,3) = 3; sm(2,3) = 4;
-@end example
-
-That creates the same matrix as previously. Again, although it is not
-strictly necessary, it is significantly faster if the sparse matrix is
-created in this manner that the elements are added in column-major
-ordering. The reason for this is that if the elements are inserted
-at the end of the current list of known elements then no element
-in the matrix needs to be moved to allow the new element to be
-inserted. Only the column indexes need to be updated.
-
-There are a few further points to note about this technique of creating
-a sparse matrix. Firstly, it is not illegal to create a sparse matrix 
-with fewer elements than are actually inserted in the matrix. Therefore
-
-@example 
-  int nz = 4, nr = 3, nc = 4;
-  SparseMatrix sm (nr, nc, 0);
-  sm(0,0) = 1; sm(0,1) = 2; sm(1,3) = 3; sm(2,3) = 4;
-@end example
-
-is perfectly legal. However it is a very bad idea. The reason is that 
-as each new element is added to the sparse matrix the space allocated
-to it is increased by reallocating the memory. This is an expensive
-operation, that will significantly slow this means of creating a sparse
-matrix. Furthermore, it is not illegal to create a sparse matrix with 
-too much storage, so having @var{nz} above equaling 6 is also legal.
-The disadvantage is that the matrix occupies more memory than strictly
-needed.
-
-It is not always easy to known the number of non-zero elements prior
-to filling a matrix. For this reason the additional storage for the
-sparse matrix can be removed after its creation with the
-@dfn{maybe_compress} function. Furthermore, the maybe_compress can
-deallocate the unused storage, but it can equally remove zero elements
-from the matrix.  The removal of zero elements from the matrix is
-controlled by setting the argument of the @dfn{maybe_compress} function
-to be 'true'. However, the cost of removing the zeros is high because it
-implies resorting the elements. Therefore, if possible it is better
-is the user doesn't add the zeros in the first place. An example of
-the use of @dfn{maybe_compress} is
-
-@example
-  int nz = 6, nr = 3, nc = 4;
-  SparseMatrix sm1 (nr, nc, nz);
-  sm1(0,0) = 1; sm1(0,1) = 2; sm1(1,3) = 3; sm1(2,3) = 4;
-  sm1.maybe_compress ();  // No zero elements were added
-
-  SparseMatrix sm2 (nr, nc, nz);
-  sm2(0,0) = 1; sm2(0,1) = 2; sm(0,2) = 0; sm(1,2) = 0; 
-  sm1(1,3) = 3; sm1(2,3) = 4;
-  sm2.maybe_compress (true);  // Zero elements were added
-@end example
-
-The use of the @dfn{maybe_compress} function should be avoided if
-possible, as it will slow the creation of the matrices.
-
-A third means of creating a sparse matrix is to work directly with
-the data in compressed row format. An example of this technique might
-be
-
-@c Note the @verbatim environment is a relatively new addition to texinfo.
-@c Therefore use the @example environment and replace @, with @@, 
-@c { with @{, etc
-
-@example
-  octave_value arg;
-  
-  @dots{}
-
-  int nz = 6, nr = 3, nc = 4;   // Assume we know the max no nz 
-  SparseMatrix sm (nr, nc, nz);
-  Matrix m = arg.matrix_value ();
-
-  int ii = 0;
-  sm.cidx (0) = 0;
-  for (int j = 1; j < nc; j++)
-    @{
-      for (int i = 0; i < nr; i++)
-        @{
-          double tmp = foo (m(i,j));
-          if (tmp != 0.)
-            @{
-              sm.data(ii) = tmp;
-              sm.ridx(ii) = i;
-              ii++;
-            @}
-        @}
-      sm.cidx(j+1) = ii;
-   @}
-  sm.maybe_compress ();  // If don't know a-priori the final no of nz.
-@end example
-
-which is probably the most efficient means of creating the sparse matrix.
-
-Finally, it might sometimes arise that the amount of storage initially
-created is insufficient to completely store the sparse matrix. Therefore,
-the method @code{change_capacity} exists to reallocate the sparse memory.
-The above example would then be modified as 
-
-@example
-  octave_value arg;
-  
-  @dots{}
-
-  int nz = 6, nr = 3, nc = 4;   // Assume we know the max no nz 
-  SparseMatrix sm (nr, nc, nz);
-  Matrix m = arg.matrix_value ();
-
-  int ii = 0;
-  sm.cidx (0) = 0;
-  for (int j = 1; j < nc; j++)
-    @{
-      for (int i = 0; i < nr; i++)
-        @{
-          double tmp = foo (m(i,j));
-          if (tmp != 0.)
-            @{
-              if (ii == nz)
-                @{
-                  nz += 2;   // Add 2 more elements
-                  sm.change_capacity (nz);
-                @}
-              sm.data(ii) = tmp;
-              sm.ridx(ii) = i;
-              ii++;
-            @}
-        @}
-      sm.cidx(j+1) = ii;
-   @}
-  sm.maybe_mutate ();  // If don't know a-priori the final no of nz.
-@end example
-
-Note that both increasing and decreasing the number of non-zero elements in
-a sparse matrix is expensive, as it involves memory reallocation. Also as
-parts of the matrix, though not its entirety, exist as the old and new copy
-at the same time, additional memory is needed. Therefore if possible this
-should be avoided.
-
-@node OctUse, , OctCreation, Oct-Files
-@subsection Using Sparse Matrices in Oct-Files
-
-Most of the same operators and functions on sparse matrices that are
-available from the Octave are equally available with oct-files.
-The basic means of extracting a sparse matrix from an @code{octave_value}
-and returning them as an @code{octave_value}, can be seen in the
-following example
-
-@example
-   octave_value_list retval;
-
-   SparseMatrix sm = args(0).sparse_matrix_value ();
-   SparseComplexMatrix scm = args(1).sparse_complex_matrix_value ();
-   SparseBoolMatrix sbm = args(2).sparse_bool_matrix_value ();
-
-   @dots{}
-
-   retval(2) = sbm;
-   retval(1) = scm;
-   retval(0) = sm;
-@end example
-
-The conversion to an octave-value is handled by the sparse
-@code{octave_value} constructors, and so no special care is needed.
-
-@node Function Reference, , Oct-Files, Sparse Matrices
+@node Function Reference, , Real Life Example, Sparse Matrices
 @section Function Reference
 
 @ifset htmltex
--- a/doc/interpreter/strings.txi	Tue Apr 24 23:03:43 2007 +0000
+++ b/doc/interpreter/strings.txi	Tue Apr 24 23:07:44 2007 +0000
@@ -41,9 +41,9 @@
 @example
 @group
 toascii ("\n")
-    @result 10
+    @result{} 10
 toascii ('\n')
-    @result [ 92 110 ]
+    @result{} [ 92 110 ]
 @end group
 @end example
 
@@ -52,7 +52,7 @@
 
 @example
 'I can''t escape'
-    @result I can't escape
+    @result{} I can't escape
 @end example
 
 Here is a table of all the escape sequences used in Octave.  They are