[MATRIX-SIG] integer division -- what a concept!
Fri, 16 Jan 1998 17:29:58 -0700 (MST)
On Sat, 17 Jan 1998, Rupert Mazzucco wrote:
> On Fri, 16 Jan 1998, Carlos Maltzahn wrote:
> > I disagree:
> > Assuming n is an integer matrix. If you expect float results from matrix
> > operations you should have the matrices typed as float in the first
> > place. This would ensure that all operations result in floats.
> I'm afraid I don't quite get your point. If I write e.g.
> dphi = zeros(( max,), Complex )
> for n in xrange( 1, max ):
> dphi[n] = phi[n-1] - ( n / ( n+1 )) * phi[n]
> how would "typing my matrices as float in the first place" help?
It wouldn't. My point was that integer division can hurt you if you aren't
sure of the argument types of a division. In your example it is very
clear what n is: an integer loop variable. I would be very surprised if
the subexpression ( n / ( n+1 )) would result in a float since it
obviously only consists of integers. But that might be because I'm a
computer scientist and not a mathematician.
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: email@example.com
administrivia to: firstname.lastname@example.org