octave-maintainers
[Top][All Lists]
Advanced

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

Re: Unnecessary initialization in octave_matrix::double_value ?


From: Julien Bect
Subject: Re: Unnecessary initialization in octave_matrix::double_value ?
Date: Sat, 17 Sep 2016 17:34:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0

Le 16/09/2016 à 10:40, Julien Bect a écrit :
Le 14/09/2016 à 17:21, Rik a écrit :
Julien,

I pushed your patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/6bf1cbb90705). If you do have the energy to tackle complex_value, matrix_value, etc. that would be very good.

Thanks,
Rik

One step at a time, here it is for complex_value():

http://savannah.gnu.org/patch/?9119

I chose to call the constructor of Complex explicitly when matrix(0, 0) is a double or a "real" type that can be cast to double (bool, float, unsigned char).

I am now looking at octave_complex_matrix::matrix_value(). I have a question (questionS, actually...).

The existing code would suggest to write the return statement like this :

return :: real (ComplexMatrix (matrix))

but it would seem more natural to me, and shorter, to write it like this :

return ::real (matrix).


The first form does the following conversions : ComplexNDArray --> ComplexMatrix --> Matrix.

The second form would do, I think ; ComplexNDArray --> NDArray --> Matrix.

Is there any reason to prefer the first form?


I have realized while working on this that I don't really understand the reason for having pairs of types such as Matrix / NDArray, ComplexMatrix / ComplexNDArray, etc.? What is the difference between them?

@++
Julien



reply via email to

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