Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 446

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<html lang="en">
<head>
<title>Zeros Treatment - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Diagonal-and-Permutation-Matrices.html#Diagonal-and-Permutation-Matrices" title="Diagonal and Permutation Matrices">
<link rel="prev" href="Example-Codes.html#Example-Codes" title="Example Codes">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Zeros-Treatment"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="Example-Codes.html#Example-Codes">Example Codes</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Diagonal-and-Permutation-Matrices.html#Diagonal-and-Permutation-Matrices">Diagonal and Permutation Matrices</a>
<hr>
</div>

<h3 class="section">20.5 The Differences in Treatment of Zero Elements</h3>

<p>Making diagonal and permutation matrices special matrix objects in their own
right and the consequent usage of smarter algorithms for certain operations
implies, as a side effect, small differences in treating zeros. 
The contents of this section applies also to sparse matrices, discussed in
the following chapter.

   <p>The IEEE standard defines the result of the expressions <code>0*Inf</code> and
<code>0*NaN</code> as <code>NaN</code>, as it has been generally agreed that this is the
best compromise. 
Numerical software dealing with structured and sparse matrices (including
Octave) however, almost always makes a distinction between a "numerical zero"
and an "assumed zero". 
A "numerical zero" is a zero value occurring in a place where any floating-point
value could occur.  It is normally stored somewhere in memory as an explicit
value. 
An "assumed zero", on the contrary, is a zero matrix element implied by the
matrix structure (diagonal, triangular) or a sparsity pattern; its value is
usually not stored explicitly anywhere, but is implied by the underlying
data structure.

   <p>The primary distinction is that an assumed zero, when multiplied
by any number, or divided by any nonzero number,
yields *always* a zero, even when, e.g., multiplied by <code>Inf</code>
or divided by <code>NaN</code>. 
The reason for this behavior is that the numerical multiplication is not
actually performed anywhere by the underlying algorithm; the result is
just assumed to be zero.  Equivalently, one can say that the part of the
computation involving assumed zeros is performed symbolically, not numerically.

   <p>This behavior not only facilitates the most straightforward and efficient
implementation of algorithms, but also preserves certain useful invariants,
like:
     <ul>
<li>scalar * diagonal matrix is a diagonal matrix
<li>sparse matrix / scalar preserves the sparsity pattern
<li>permutation matrix * matrix is equivalent to permuting rows
</ul>
   all of these natural mathematical truths would be invalidated by treating
assumed zeros as numerical ones.

   <p>Note that certain competing software does not strictly follow this principle
and converts assumed zeros to numerical zeros in certain cases, while not doing
so in other cases.  As of today, there are no intentions to mimic such behavior
in Octave.

   <p>Examples of effects of assumed zeros vs. numerical zeros:
<pre class="example">     Inf * eye (3)
     &rArr;
        Inf     0     0
          0   Inf     0
          0     0   Inf
     
     Inf * speye (3)
     &rArr;
     Compressed Column Sparse (rows = 3, cols = 3, nnz = 3 [33%])
     
       (1, 1) -&gt; Inf
       (2, 2) -&gt; Inf
       (3, 3) -&gt; Inf
     
     Inf * full (eye (3))
     &rArr;
        Inf   NaN   NaN
        NaN   Inf   NaN
        NaN   NaN   Inf
     
</pre>
   <pre class="example">     diag(1:3) * [NaN; 1; 1]
     &rArr;
        NaN
          2
          3
     
     sparse(1:3,1:3,1:3) * [NaN; 1; 1]
     &rArr;
        NaN
          2
          3
     [1,0,0;0,2,0;0,0,3] * [NaN; 1; 1]
     &rArr;
        NaN
        NaN
        NaN
</pre>
   <!-- DO NOT EDIT!  Generated automatically by munge-texi. -->
<!-- Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 David Bateman -->
<!-- This file is part of Octave. -->
<!-- Octave is free software; you can redistribute it and/or modify it -->
<!-- under the terms of the GNU General Public License as published by the -->
<!-- Free Software Foundation; either version 3 of the License, or (at -->
<!-- your option) any later version. -->
<!-- Octave is distributed in the hope that it will be useful, but WITHOUT -->
<!-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -->
<!-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License -->
<!-- for more details. -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with Octave; see the file COPYING.  If not, see -->
<!-- <http://www.gnu.org/licenses/>. -->
   </body></html>