octave-maintainers
[Top][All Lists]
Advanced

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

Re: What is the correct NDArray behavior of printf?


From: David Bateman
Subject: Re: What is the correct NDArray behavior of printf?
Date: Thu, 22 Apr 2004 18:18:59 +0200
User-agent: Mutt/1.4.1i

According to John W. Eaton <address@hidden> (on 04/22/04):
> On 22-Apr-2004, David Bateman <address@hidden> wrote:
> 
> | The behavior of Matlab for printf, kron etc, is to horizontally or
> | vertically stack the 2-D cuts of the NDArray objects. Thus in matlab
> | 
> | a = [1, 2; 3, 4]; a(:,:,2) = [5, 6; 7, 8]; sprintf('%f %f\n', a)
> | 
> | is legal and give
> | 
> | ans =
> | 
> | 1.000000 3.000000
> | 2.000000 4.000000
> | 5.000000 7.000000
> | 6.000000 8.000000
> | 
> | 
> | However, printf etc in octave called with NDArray arguments gives an
> | error (when trying to transpose the NDArray). 
> 
> I don't see a transpose error, I see
> 
>   octave:4> printf ("%f %f\n", a)
>   error: invalid conversion of NDArray to Matrix

Sorry, I was thinking about num2str which gives the transpose error.

> | What is the correct behavior for these functions called with NDArrays?
> | Is the Matlab behavior of reducing these arrays to 2-D objects the way
> | to go? 
> 
> I think it is equivalent to
> 
>   printf ("%f %f\n", a(:))
> 
> which gives the compatible result.  I think the following change
> should be all that is needed for this particular case.  There are a
> number of other things that will also need to be changed in
> oct-stream.cc to handle N-d arrays.


Humm, ok I'll try this patch...

D.

-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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