delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/29/03:15:24

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: On complex-number manipulation
Date: Thu, 29 Oct 1998 02:56:58 -0500
References: <199810290435 DOT NAA25539 AT inmac3 DOT snu DOT ac DOT kr>
Organization: Nocturnal Aviation
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en
Mime-Version: 1.0
Lines: 60
NNTP-Posting-Host: 1cust160.tnt11.nyc3.da.uu.net
X-ELN-Date: Thu Oct 29 00:05:05 1998
X-Mailer: Mozilla 4.5 [en] (Win95; I)
Message-ID: <36381FCA.D244B23C@earthlink.net>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Won-Seok Lee wrote:
> 
> $)CDear Sir:
> 
> I am professionally interested in complex-number manipulation.
> Until now, I have used Turbo C 3.0 for the complex-number calculation,
> but it has memory limitation in allocating an array.
> So, recently, I challenge the calculation on DJGPP.
> But I have a problem.
> I want the following program to be executed, but this program cannot
> be compiled. The filename is 'test.cc.'
> Please advise me which part should be modified for 'Compile' and
> 'Execution.'

> 
> #include  <stdio.h>
> #include  <math.h>
> #include  <complex.h>
> 
> complex  a ;
> 
> int   main( void ) {
>   a = complex( 1. , 0. ) ;
>   printf( "%.5e\n" , real( a ) ) ;
>   return  0 ;
> }

A C++ solution

#include  <stdio.h>
#include  <math.h>
#include  <complex>

complex<double> a;  // or double_complex a;

int main(void)
{
    a = complex<double>(1., 0.);
    printf("%.5e\n", real(a));
    return 0;
}

And a C solution

#include  <stdio.h>
#include  <math.h>

__complex__ double a;

int main(void)
{
    a = 1.;	/* or a = 1. + 0.i; */
    printf("%.5e\n", __real__ a);
    return 0;
}


-- 
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019