diff doc/interpreter/expr.txi @ 14116:951eacaf9381 stable

Initial documentation for broadcasting and general vectorization guidelines * vectorize.txi: New file. * NEWS: Update with location of broadcasting documentation. * Makefile.am: Add vectorize.texi * arith.txi: Move accumarray and accumdim docstring to vectorize.txi * container.txi: Move structfun docstring to vectorize.txi * expr.txi: Mention broadcasting where relevant. * func.txi: Move vectorize docstring to vectorize.txi * matrix.txi: Move function application section to vectorize.txi * octave.texi: Add vectorize.txi and its menu options * sparse.txi: Move spfun to vectorize.txi * tips.txi: Move and rewrite coding tips section in vectorize.txi * bsxfun.h (is_valid_bsxfun, is_valid_inplace_bsxfun): Rename warning to "Octave:broadcast" * accumdim.m: Reformat to use @example in lieu of @smallexample * warning_ids.m: Add Octave:broadcast * bsxfun.cc: Reword docstring to mention broadcasting * cellfun.cc: Move comment about efficiency from tips.txi * version.h.in: Add a big startup warning about broadcasting
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 27 Dec 2011 15:15:41 -0500
parents b0cdd60db5e5
children 94e2a76f1e5a
line wrap: on
line diff
--- a/doc/interpreter/expr.txi	Tue Dec 27 15:03:35 2011 -0500
+++ b/doc/interpreter/expr.txi	Tue Dec 27 15:15:41 2011 -0500
@@ -512,7 +512,8 @@
 @cindex complex-conjugate transpose
 
 The following arithmetic operators are available, and work on scalars
-and matrices.
+and matrices. They element-by-element operators and functions broadcast
+(@pxref{Broadcasting}).
 
 @table @asis
 @item @var{x} + @var{y}
@@ -715,7 +716,8 @@
 
 All of Octave's comparison operators return a value of 1 if the
 comparison is true, or 0 if it is false.  For matrix values, they all
-work on an element-by-element basis.  For example:
+work on an element-by-element basis.  Broadcasting rules apply.
+@xref{Broadcasting}. For example:
 
 @example
 @group
@@ -725,9 +727,9 @@
 @end group
 @end example
 
-If one operand is a scalar and the other is a matrix, the scalar is
-compared to each element of the matrix in turn, and the result is the
-same size as the matrix.
+According to broadcasting rules, if one operand is a scalar and the
+other is a matrix, the scalar is compared to each element of the matrix
+in turn, and the result is the same size as the matrix.
 
 @table @code
 @item @var{x} < @var{y}
@@ -862,8 +864,8 @@
 @var{boolean} is false.
 @end table
 
-For matrix operands, these operators work on an element-by-element
-basis.  For example, the expression
+These operators work on an element-by-element basis. For example, the
+expression
 
 @example
 [1, 0; 0, 1] & [1, 0; 2, 3]
@@ -872,8 +874,8 @@
 @noindent
 returns a two by two identity matrix.
 
-For the binary operators, the dimensions of the operands must conform if
-both are matrices.  If one of the operands is a scalar and the other a
+For the binary operators, broadcasting rules apply. @xref{Broadcasting}.
+In particular, if one of the operands is a scalar and the other a
 matrix, the operator is applied to the scalar and each element of the
 matrix.