Skip to content

Commit

Permalink
doc: grammarcheck Octave manual before 9.1 release.
Browse files Browse the repository at this point in the history
* doc/interpreter/func.txi, doc/interpreter/numbers.txi,
doc/interpreter/octave.texi, doc/interpreter/plot.txi,
doc/interpreter/sparse.txi, doc/interpreter/vectorize.txi,
scripts/miscellaneous/jupyter_notebook.m, scripts/plot/draw/stemleaf.m:
grammarcheck Octave manual before 9.1 release.
  • Loading branch information
Rik committed Nov 24, 2023
1 parent d46ac79 commit 5aadaf1
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 42 deletions.
20 changes: 9 additions & 11 deletions doc/interpreter/container.txi
Original file line number Diff line number Diff line change
Expand Up @@ -949,9 +949,8 @@ using the @code{cell2mat} and @code{cell2struct} functions.
@cindex cs-lists

Comma-separated lists @footnote{Comma-separated lists are also sometimes
informally referred to as @dfn{cs-lists}.} are the basic argument type
to all Octave functions - both for input and return arguments. In the
example
referred to as @dfn{cs-lists}.} are the basic argument type to all Octave
functions---both for input and return arguments. In the example

@example
max (@var{a}, @var{b})
Expand All @@ -971,14 +970,13 @@ x = [1 0 1 0 0 1 1; 0 0 0 0 0 0 7];

@noindent
Here, @samp{@var{x}, 2, "last"} is a comma-separated list constituting
the input arguments of @code{find}. @code{find} returns a comma
separated list of output arguments which is assigned element by
element to the comma-separated list @samp{@var{i}, @var{j}}.

Another example of where comma-separated lists are used is in the
creation of a new array with @code{[]} (@pxref{Matrices}) or the
creation of a cell array with @code{@{@}} (@pxref{Basic Usage of Cell
Arrays}). In the expressions
the input arguments of @code{find}. @code{find} returns a comma-separated list
of output arguments which is assigned element by element to the comma-separated
list @samp{@var{i}, @var{j}}.

Another example of where comma-separated lists are used is in the creation of a
new array with @code{[]} (@pxref{Matrices}) or the creation of a cell array
with @code{@{@}} (@pxref{Basic Usage of Cell Arrays}). In the expressions

@example
@group
Expand Down
13 changes: 7 additions & 6 deletions doc/interpreter/expr.txi
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ A([1; 2]) # result is a column vector: ans = [1; 2]
@end example

The shape rules for @var{A}(@var{P}) are:

@itemize @bullet
@item When at least one of @var{A} or @var{P} has two or more dimensions, then
@var{A}(@var{P}) takes the shape of @var{P}. This happens when at least one
Expand Down Expand Up @@ -1103,28 +1104,28 @@ the equivalent of the operation @code{all (@var{boolean1}(:))}. If
@var{boolean1} is not a logical value, it is considered true if its value
is nonzero, and false if its value is zero. If @var{boolean1} is an array,
it is considered true only if it is non-empty and all elements are
non-zero. If @var{boolean1} evaluates to false, the result of the overall
nonzero. If @var{boolean1} evaluates to false, the result of the overall
expression is false. If it is true, the expression @var{boolean2} is
evaluated in the same way as @var{boolean1}. If it is true, the result of
evaluated in the same way as @var{boolean1}. If it is true, the result of
the overall expression is true. Otherwise the result of the overall
expression is false.

@strong{Warning:} the one exception to the equivalence with evaluating
@code{all (@var{boolean1}(:))} is when @code{boolean1} an the empty array.
For @sc{MATLAB} compatibility, the truth value of an empty array is always
For @sc{matlab} compatibility, the truth value of an empty array is always
@code{false} so @code{[] && true} evaluates to @code{false} even though
@code{all ([])} is @code{true}.

@item @var{boolean1} || @var{boolean2}
@opindex ||
The expression @var{boolean1} is evaluated and converted to a scalar using
the equivalent of the operation @code{all (@var{boolean1}(:))}. If
the equivalent of the operation @code{all (@var{boolean1}(:))}. If
@var{boolean1} is not a logical value, it is considered true if its value
is nonzero, and false if its value is zero. If @var{boolean1} is an array,
it is considered true only if it is non-empty and all elements are
non-zero. If @var{boolean1} evaluates to true, the result of the overall
nonzero. If @var{boolean1} evaluates to true, the result of the overall
expression is true. If it is false, the expression @var{boolean2} is
evaluated in the same way as @var{boolean1}. If it is true, the result of
evaluated in the same way as @var{boolean1}. If it is true, the result of
the overall expression is true. Otherwise the result of the overall
expression is false.

Expand Down
17 changes: 14 additions & 3 deletions doc/interpreter/func.txi
Original file line number Diff line number Diff line change
Expand Up @@ -1987,17 +1987,19 @@ create apparent ambiguities with mathematical and logical expressions that
use function syntax. For example, all three of the statements

@example
@group
arg1 - arg2
arg1 -arg2
arg1-arg2
@end group
@end example

@noindent
could be intended by a user to be subtraction operations between
@code{arg1} and @code{arg2}. The first two, however, could also have been
meant as a command syntax call to function @code{arg1}, in the first case
with options @code{-} and @code{arg2}, and in the second case with option
@code{-arg2}.
@option{-arg2}.

Octave uses whitespace to interpret such expressions according to the
following rules:
Expand All @@ -2013,43 +2015,52 @@ arg1 arg2 arg3 ... argn

@item
Statements without any whitespace are always treated as function syntax:

@example
@group
arg1+arg2
arg1&&arg2||arg3
arg1+=arg2*arg3
@end group
@end example

@item
If the first symbol is a constant (or special-valued named constant pi, i,
I, j, J, e, NaN, or Inf) followed by a binary operator, the statement is
treated as function syntax regardless of any whitespace or what follows the
second symbol:

@example
@group
7 -arg2
pi+ arg2
j * arg2 -arg3
@end group
@end example

@item
If the first symbol is a function or variable and there is no whitespace
separating the operator and the second symbol, the statement is treated
as command syntax:

@example
@group
arg1 -arg2
arg1 &&arg2 ||arg3
arg1 +=arg2*arg3
@end group
@end example

@item
Any other whitespace combination will result in the statement being treated
as function syntax.
@end itemize

Note 1: If a special-valued named constant has been redefined as a
Note 1: If a special-valued named constant has been redefined as a
variable, the interpreter will still process the statement with function
syntax.

Note 2: Attempting to use a variable as @code{arg1} in a command being
Note 2: Attempting to use a variable as @code{arg1} in a command being
processed as command syntax will result in an error.


Expand Down
16 changes: 14 additions & 2 deletions doc/interpreter/numbers.txi
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,11 @@ the range is not always included in the set of values. This can be useful
in some contexts. For example:

@example
@group
## x is some predefined range or vector or matrix or array
x(1:2:end) += 1; # increment all odd-numbered elements
x(2:2:end) -= 1; # decrement all even-numbered elements
@end group
@end example

The above code works correctly whether @var{x} has an odd number of elements
Expand All @@ -448,51 +450,61 @@ range. As a result, defining ranges with floating-point values can result
in pitfalls like these:

@example
@group
a = -2
b = (0.3 - 0.2 - 0.1)
x = a : b
@end group
@end example

Due to floating point rounding, @var{b} may or may not equal zero exactly,
and if it does not, it may be above zero or below zero, hence the final range
@var{x} may or may not include zero as its final value. Similarly:

@example
@group
x = 1.80 : 0.05 : 1.90
y = 1.85 : 0.05 : 1.90
@end group
@end example

@noindent
is not as predictable as it looks. As of Octave 8.3, the results obtained are
that @var{x} has three elements (1.80, 1.85, and 1.90), and @var{y} has only
one element (1.85 but not 1.90). Thus, when using floating points in ranges,
changing the start of the range can easily affect the end of the range even
though the ending value was not touched in the above example.

To avoid such pitfalls with floating-points in ranges, you should use one of
the following patterns. This change to the previous code:
the following patterns. This change to the previous code:

@example
@group
x = (0:2) * 0.05 + 1.80
y = (0:1) * 0.05 + 1.85
@end group
@end example

@noindent
makes it much safer and much more repeatable across platforms, compilers,
and compiler settings. If you know the number of elements, you can also use
the @code{linspace} function (@pxref{Special Utility Matrices}), which will
include the endpoints of a range. You can also make judicious use of
@code{round}, @code{floor}, @code{ceil}, @code{fix}, etc to set the
@code{round}, @code{floor}, @code{ceil}, @code{fix}, etc.@: to set the
limits and the increment without getting interference from floating-point
rounding. For example, the earlier example can be made safer and much more
repeatable with one of the following:

@example
@group
a = -2
b = round ((0.3 - 0.2 - 0.1) * 1e12) / 1e12 # rounds to 12 digits
c = floor (0.3 - 0.2 - 0.1) # floors as integer
d = floor ((0.3 - 0.2 - 0.1) * 1e12) / 1e12 # floors at 12 digits
x = a : b
y = a : c
z = a : d
@end group
@end example

When adding a scalar to a range, subtracting a scalar from it (or subtracting a
Expand Down
2 changes: 1 addition & 1 deletion doc/interpreter/octave.texi
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ Object Groups
Graphics Toolkits
* Customizing Toolkit Behavior::
* Hardware vs Software Rendering::
* Hardware vs. Software Rendering::
* Precision issues::
Matrix Manipulation
Expand Down
10 changes: 5 additions & 5 deletions doc/interpreter/plot.txi
Original file line number Diff line number Diff line change
Expand Up @@ -2764,7 +2764,7 @@ Data source variables.

@menu
* Customizing Toolkit Behavior::
* Hardware vs Software Rendering::
* Hardware vs. Software Rendering::
* Precision issues::
@end menu

Expand Down Expand Up @@ -2794,8 +2794,8 @@ plot (1:10)
@end group
@end example

@node Hardware vs Software Rendering
@subsubsection Hardware vs Software Rendering
@node Hardware vs. Software Rendering
@subsubsection Hardware vs. Software Rendering
@cindex opengl rendering slow windows

When using the Octave for Windows installer, the user has the option to select
Expand All @@ -2804,7 +2804,7 @@ whether software rendering is used for the OpenGL graphics toolkits
(@qcode{"qt"} and @qcode{"fltk"}). Software rendering can be used to avoid
rendering and printing issues due to imperfect OpenGL driver implementations
for diverse graphic cards from different vendors (notably integrated Intel
graphics). As a down-side, software rendering might be considerably slower
graphics). As a downside, software rendering might be considerably slower
than hardware accelerated rendering (and it might not work correctly on 32-bit
platforms or WoW64). To permanently switch between hardware accelerated
rendering with your graphics card drivers and software rendering, use the
Expand All @@ -2813,7 +2813,7 @@ Alternatively, rename the following file while Octave is closed:

@file{@var{octave-home}\bin\opengl32.dll}
@*where @var{octave-home} is the directory returned by
@ref{XREFOCTAVE_HOME, , @w{@qcode{OCTAVE_HOME}}}, i.e., the directory in which
@ref{XREFOCTAVE_HOME, , @w{@code{OCTAVE_HOME}}}, i.e., the directory in which
Octave is installed (the default is
@file{C:\Program Files\GNU Octave\Octave\Octave-@var{version}\mingw64}).
Change the file extension to @file{.bak} for hardware rendering or to
Expand Down
6 changes: 3 additions & 3 deletions doc/interpreter/sparse.txi
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ contents of these three vectors for the above matrix will be

Note that this is the representation of these elements with the first row
and column assumed to start at zero, while in Octave itself the row and
column indexing starts at one. Thus the number of elements in the
@var{i}-th column is given by @code{@var{cidx} (@var{i} + 1) -
@var{cidx} (@var{i})}.
column indexing starts at one. Thus, the number of elements in the
@var{i}-th column is given by
@code{@var{cidx} (@var{i} + 1) - @var{cidx} (@var{i})}.

Although Octave uses a compressed column format, it should be noted
that compressed row formats are equally possible. However, in the
Expand Down
4 changes: 2 additions & 2 deletions doc/interpreter/vectorize.txi
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ subtraction takes place.

A special case of broadcasting that may be familiar is when all
dimensions of the array being broadcast are 1, i.e., the array is a
scalar. Thus for example, operations like @code{x - 42} and @code{max
(x, 2)} are basic examples of broadcasting.
scalar. Thus, for example, operations like @code{x - 42} and
@code{max (x, 2)} are basic examples of broadcasting.

For a higher-dimensional example, suppose @code{img} is an RGB image of
size @code{[m n 3]} and we wish to multiply each color by a different
Expand Down
16 changes: 8 additions & 8 deletions scripts/miscellaneous/jupyter_notebook.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
##
## @itemize @bullet
## @item
## "%plot -f <format>" or "%plot --format <format>": specifies the
## image storage format. Supported formats are:
## "@code{%plot -f <format>}" or "@code{%plot --format <format>}": specifies
## the image storage format. Supported formats are:
##
## @itemize @minus
## @item
Expand All @@ -67,16 +67,16 @@
## @end itemize
##
## @item
## "%plot -r <number>" or "%plot --resolution <number>": specifies the
## image resolution.
## "@code{%plot -r <number>}" or "@code{%plot --resolution <number>}":
## specifies the image resolution.
##
## @item
## "%plot -w <number>" or "%plot --width <number>": specifies the
## image width.
## "@code{%plot -w <number>}" or "@code{%plot --width <number>}": specifies
## the image width.
##
## @item
## "%plot -h <number>" or "%plot --height <number>": specifies the
## image height.
## "@code{%plot -h <number>}" or "@code{%plot --height <number>}": specifies
## the image height.
## @end itemize
##
## Examples:
Expand Down
2 changes: 1 addition & 1 deletion scripts/plot/draw/stemleaf.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
## The default stem width is 10.
##
## The output of @code{stemleaf} is composed of two parts: a
## "Fenced Letter Display," followed by the stem-and-leaf plot itself.
## "Fenced Letter Display", followed by the stem-and-leaf plot itself.
## The Fenced Letter Display is described in @cite{Exploratory Data Analysis}.
## Briefly, the entries are as shown:
##
Expand Down

0 comments on commit 5aadaf1

Please sign in to comment.