[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
some questions about the complex datatype
From: |
Peter Jay Salzman |
Subject: |
some questions about the complex datatype |
Date: |
Thu, 17 Jan 2002 23:04:45 -0800 |
User-agent: |
Mutt/1.3.25i |
hi there,
the libc page mentioned that questions can be forwarded to this list.
if there's a better place to ask questions, please advise me where to
go. also, is there a way to subscribe to this list?
a couple of questions about the complex datatype:
how can i get gdb to print out the value of a long double complex? i
tried everything that was obvious to me. for a long double complex a:
(gdb) ptype a
type = complex long double
(gdb) p a
$2 = Invalid C/C++ type code 20 in symbol table.
(gdb) p creall(a)
$3 = 1
(gdb) p cimagl(a)
$4 = 1
(gdb) printf "%Le, %Le", a
Wrong number of arguments for specified format-string
(gdb) printf "%Le", a
Value can't be converted to integer.
at this point, i'm stumped. what's the magic here?
also, if Psi[i] is a long double complex, i'm a little confused how to
print |Psi[i]|^2. the obvious thing from a math standpoint would be
fprintf(fp, "%Le", conj(Psi[i]) * Psi[i]);
which doesn't work. gcc complains that %Le is for long doubles and
conj(Psi[i]) * Psi[i]) is long double complex. the abs() function
takes doubles. and the info pages don't mention anything about a
cabsl() function (which would be really nice).
how can i print the real number conj(z) * z to a file? do i really
have to resort to something really horrible like:
fprintf(fp, "%Le", sqrtl( creal(Psi[i]) * Psi[i]) creal(Psi[i]) * Psi[i])
+ cimagl(Psi[i]) * Psi[i]) cimagl(Psi[i]) * Psi[i]) ) );
(i'm staying away from pow() for speed considerations).
thanks! :)
pete
ps - sorry if this is gcc related and not libc related. it's my
understanding that these questions are library related, not compiler
related. but the truth is i'm a physicist, not a CS major...
--
The mathematics [of physics] has become ever more abstract, rather than more
complicated. The mind of God appears to be abstract but not complicated.
He also appears to like group theory. -- Tony Zee's `Fearful Symmetry'
PGP Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
- some questions about the complex datatype,
Peter Jay Salzman <=