reuder@lso.win.tue.nl (Peter Reuderink) (05/18/91)
Althoug I'm familiar with f.e. Pascal I always used FORTRAN (FORTRAN-IV; F77) for my programming. The main reason is that in FORTRAN it is possible to use complex numbers, while it offers an extensive set of intrinsic complex functions (CEXP,CSQRT,etc.), which are essential in wave-analysis. Although it is possible to define new types or records in Pascal, one is always confronted with problems when trying to write complex functions is Pascal since the output of a function can never be two values, i.e. real and imaginary. Therefore one is forced to use subroutines for even the most simple problems, making your code unreadable, and time-consuming. I was informed that originally in c-language it was not possible to use complex numbers in the way it's done in FORTRAN as well. However, can someone tell me if it can be done in c++?? Or are there any other languages able to deal with complex numbers. Not that I want to switch from FORTRAN to c, since many FEM-packages are programmed in FORTRAN, but I'm preparing "statements" for my thesis, and one is supposed to deal with programming and complex numbers. please answer on the net or my e-mail adress. Sincerely, Peter. ______________________________________________________________________ Sender: Peter Reuderink Adress: Eindhoven Univ. Technology WFW W-Hoog -1.131 Ici Jo-Jo-avec-le-gros-guele: P.O.Box 513 Il compte son argent. 5600 MB Eindhoven "Haut-les-mains!", the Netherlands dit commissaire Maigret. E-mail: reuder@wfw.wtb.tue.nl "Merde!" murmure Jo-Jo. ----------------------------------------------------------------------
steve@taumet.com (Stephen Clamage) (05/20/91)
reuder@lso.win.tue.nl (Peter Reuderink) writes: >I was informed that originally in c-language it was not possible >to use complex numbers in the way it's done in FORTRAN as well. >However, can someone tell me if it can be done in c++? One of the strengths of C++ is that user-defined data types have all the same properties and privileges as predefined data types. Many implementations of C++ come with a header and runtime library supporting complex numbers. Many C++ texts use complex numbers for simple examples of programming in C++. You can get the notational convenience and efficiency of built-in complex numbers, even though they are not built into C++. For example, you can make declarations like Complex a; Complex i(0, 1); // i == sqrt(-1) double d; int j; and write expressions like a = ((d + j) * i) / Complex(3.5, 1.234); -- Steve Clamage, TauMetric Corp, steve@taumet.com
koenig@urz.unibas.ch (05/21/91)
In article <480@al.wfw.wtb.tue.nl>, reuder@lso.win.tue.nl (Peter Reuderink) writes: > Although it is possible to define new types or records in Pascal, > one is always confronted with problems when trying to write complex > functions is Pascal since the output of a function can never be > two values, i.e. real and imaginary. Therefore one is forced to > use subroutines for even the most simple problems, making your > code unreadable, and time-consuming. > > However, can someone tell me if it can be done in c++?? Or are there > any other languages able to deal with complex numbers. The main requirement for convenient use of complex numbers is the general operator concept. Some existing programming languages offer this feature: ADA, Pascal-SC, Fortan-SC, Modula-SC. "SC" indicates that these languages are extensions for Scientific Computation. Complex numbers may be handled as in C++ like built-in types. If you like, see G. Bohlender et al., Pascal-SC: A Computer Language for Scientific Computation. Perspektives in computing, 17, 1987. Academic Press, Orlando. Bye, Stefan Koenig