MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Division by Zero (Error Handling)


For the first part:

f[x_List,y_List]:= 
    x/(y/.(0->Infinity))/;
      Dimensions[x]==Dimensions[y];

A=Table[Random[Integer,{1,3}],{3},{3}]

{{3, 1, 2}, {1, 3, 2}, {1, 3, 1}}

B=Table[Random[Integer,{0,3}],{3},{3}]

{{1, 2, 2}, {0, 3, 1}, {3, 1, 3}}

f[A,B]

{{3, 1/2, 1}, {0, 1, 2}, {1/3, 3, 1/3}}


Bob Hanlon

---- Bruce Colletti <vze269bv at verizon.net> wrote: 
> When dividing (elementwise) two matrices of similar dimension (e.g., A/B), zero-elements in B cause a "division by zero" error message.  In such a case, regardless of numerator, I want the pair's ratio to be zero.
> 
> Without building a module that defines modified matrix division, how can I establish that whenever (throughout the notebook) division by zero occurs (regardless of numerator), that the result can be zero?
> 
> Thanks.
> 
> Bruce
> 

--

Bob Hanlon
hanlonr at cox.net



  • Prev by Date: Re: Function argument
  • Next by Date: RE: Function argument
  • Previous by thread: Re: Division by Zero (Error Handling)
  • Next by thread: Function argument