[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ranges?
From: |
John W. Eaton |
Subject: |
ranges? |
Date: |
Tue, 22 Aug 2006 18:23:36 -0400 |
On 22-Aug-2006, Dmitri A. Sergatskov wrote:
| I thought that ranges used to be a different class. But I just noticed that in
| 2.9.7 is is shown as "double" Is it OK?
|
| octave:1> idx = (1:10)
| idx =
|
| 1 2 3 4 5 6 7 8 9 10
|
| octave:2> whos idx
|
| *** local user variables:
|
| Prot Name Size Bytes Class
| ==== ==== ==== ===== =====
| rwd idx 1x10 24 double
|
| Total is 10 elements using 24 bytes
|
| octave:3> a = idx *1
| a =
|
| 1 2 3 4 5 6 7 8 9 10
|
| octave:4> whos a
|
| *** local user variables:
|
| Prot Name Size Bytes Class
| ==== ==== ==== ===== =====
| rwd a 1x10 80 double
|
| Total is 10 elements using 80 bytes
Class must be double for compatibilty. Internally, Octave still has a
special data type to represent ranges. That's why you see only 24
bytes used in the first case. Most (all?) arithmetic operations on
ranges result in matrices though, so that's why you see 80 bytes used
in the second case. Adding optimized operations for ranges is
possible, but someone has to do the work.
See also the typeinfo function, which returns the name of the internal
data type instead of the Matlab-compatible class name.
jwe
- ranges?, Dmitri A. Sergatskov, 2006/08/22
- ranges?,
John W. Eaton <=