help-octave
[Top][All Lists]

## Re: FW: Scalars and Matrices:

 From: John W. Eaton Subject: Re: FW: Scalars and Matrices: Date: Tue, 12 Oct 1999 16:33:47 -0500 (CDT)

```On 12-Oct-1999, John Day <address@hidden> wrote:

| But MATLAB does have 1x1 matrices! What it doesn't have is
| scalars. Any attempt to enter a "scalar" results in a 1x1 matrix.
| Here's proof:
|
| » m = 1
| m =
|      1
| » size(m)
| ans =
|      1     1

I'm not sure that's proof that it doesn't have a scalar type.  Octave
DOES have scalar types (real and complex) and here is what it says:

GNU Octave, version 2.0.14 (i686-pc-linux-gnu).
Copyright (C) 1996, 1997, 1998, 1999 John W. Eaton.
This is free software with ABSOLUTELY NO WARRANTY.
For details, type `warranty'.

octave:1> s = 1; m = [1,2;3,4];
octave:2> size (s)
ans =

1  1

octave:3> whos s m

*** local user variables:

prot  type               rows   cols  name
====  ====               ====   ====  ====
wd   matrix                2      2  m
wd   scalar                1      1  s

For size and whos, it is just convenient (and somewhat Matlab
compatible) to report both rows and columns, even for scalars.

Actually, even this isn't proof that Octave has a scalar data type,
since whos could just be reporting `scalar' when it sees a 1x1 matrix.
But I know that Octave does have a scalar type, and, since you have
the source for Octave (or you can easily get it), you don't have to
just take my word for it.  You can check it out for yourself.  :-)

jwe

---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure