[Top][All Lists]

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

Re: Create a logical array of 0

From: John W. Eaton
Subject: Re: Create a logical array of 0
Date: Fri, 3 Sep 2004 17:05:42 -0400

On  3-Sep-2004, David Bateman <address@hidden> wrote:

| According to John W. Eaton <address@hidden> (on 09/03/04):
| > Even if Matlab cannot do it, I don't see why we should prohibit it.
| Wouldn't this mean we'd need to adapt data-conv.{cc,h} to allow a
| data_type of "logical".  Easier enough just to add the flag, but then 
| you're asking to add all of the conversion between logical data types.
| Then what is the size of the logical data type? Is it compile dependent?
| So need to modify configure.base..... Its all pretty direct, but also
| a pain...

Yes, it would make sense to add logical (or bool?) to the list of data
types in the oct_data_conv::data_type enum.  But I don't think we have
to allow "logical" to work everywhere.  For example, we don't have to
allow it as an output type for fwrite, or as an input type for fread.
But we should allow logical types to be written (using some other
native representation as the output type).  Currently we have

  octave:1> fwrite (f, ! eye (2))
  error: octave_base_value::write(): wrong type argument `bool matrix'

I think this was just an oversight on my part when I was working on
these functions in the last few days.  Writing logical data should
work, with the output written in the default uchar format.  I think
it might also be good to be able to use

  fwrite (f, logical_var, "uint64")

  fread (f, Inf, "uint8=>logical")

It would not be difficult to make these things work, and it would be a
little more efficient than

  fwrite (f, int8 (logical_var), "uint64")


  x = logical (fread (f, Inf, "uint8"))

because converting and then writing or reading and then convting
requires twice the memory.

I'm not sure what you mean by "add the flag" or "add all of the
conversion ...".


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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