help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Integer and floating point types


From: Jaroslav Hajek
Subject: Re: Integer and floating point types
Date: Thu, 21 Jan 2010 11:44:54 +0100

On Thu, Jan 21, 2010 at 11:13 AM, George <address@hidden> wrote:
> On 1/21/10, Jaroslav Hajek <address@hidden> wrote:
>
>
>> Octave defines the element-wise operations (+, -, .*, ./, .^). Matrix
>> operations are not defined, because it's more efficient to go through
>> doubles.
>
> How can it be more efficient to use doubles than to use uint16 for example?
>

First of all, Octave's arithmetic on integers is saturated, like in Matlab:

octave:1> a = int32 (1e3)
a = 1000
octave:2> a^5
ans = 2147483647
octave:3> warning ("on", "Octave:int-math-overflow")
octave:4> a^5
warning: data truncated for int32 scalar by scalar binary operator ^
ans = 2147483647

this means that Octave will cut-off overflows and underflows and
optionally warn about that. That alone imposes a performance penalty.
Further, matrix multiplication is heavily optimized for real matrices
by the BLAS library.
If you code a straightforward triple-loop C++ implementation of
integer matrix multiplication, it will be much slower for bigger
matrices than going via real conversion.

This is why matrix multiplication and division doesn't work for
integers. Other operations work (and saturate).

We might still add integer matrix multiplication, despite the
anticipated slowness. Division is out of question for obvious reasons.
Do you have a real-life application for integer matrix multiplication?

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]