octave-maintainers
[Top][All Lists]
Advanced

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

Re: Complex mappers for real values


From: Dmitri A. Sergatskov
Subject: Re: Complex mappers for real values
Date: Thu, 22 Jun 2017 13:14:58 -0500



On Thu, Jun 22, 2017 at 1:01 PM, Mike Miller <address@hidden> wrote:
On Thu, Jun 22, 2017 at 12:47:49 -0500, Dmitri A. Sergatskov wrote:
> using sample code with
> gcc-4.8.5/gcc-7.1.1/clang-4.0.0 (with either libc++ or libstdc++) all give
> the same (correct) answer.

Hm? They give different answers:

​I meant the code from
http://en.cppreference.com/w/cpp/numeric/complex/conj

#include <iostream>
#include <complex>
 
int main()
{
    std::complex<double> z(1,2);
    std::cout << "The conjugate of " << z << " is " << std::conj(z) << '\n'
              << "Their product is " << z*std::conj(z) << '\n';
}

​returns the same with all compilers I tried:

​The conjugate of (1,2) is (1,-2)
Their product is (5,0)


​But ​Carnë Draug's code has a discrepancies.

 

> gcc-4.8.5 returns
> g++ -std=c++11 t1.cc
> d
>
> (gcc 7.1.1)  g++ t1.cc
> ./a.out
> St7complexIdE

So std::conj has been fixed in gcc 7.

With gcc 6, it still returns a double.

​I found a computer with gcc 6.3.1 and it does return "d".​

 

Octave wants conj to return a double, so it looks like it should
continue to use the octave::math::conj adapter.

--
mike


​Dmitri.
--


reply via email to

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