Hi,
I'm wondering how to get the cubic root for a complex number? It seems
that cbrt does not work complex numbers.
Thanks,
Peng
#include <complex>
#include <iostream>
int main () {
std::complex<doublex(2, 2);
std::cout << cbrt(x) << std::endl;
} 4 4422
Peng Yu wrote:
Hi,
I'm wondering how to get the cubic root for a complex number? It seems
that cbrt does not work complex numbers.
I cannot find cbrt() in the standard anyway.
Thanks,
Peng
#include <complex>
#include <iostream>
int main () {
std::complex<doublex(2, 2);
std::cout << cbrt(x) << std::endl;
}
#include <cmath>
#include <complex>
#include <iostream>
#include <ostream>
int main () {
std::complex<doublex(2, 2);
std::complex<doubler = std::pow( x, 1.0/3.0 );
std::cout << r << '\n'
<< r*r*r << '\n';
}
Best
Kai-Uwe Bux
On Sep 9, 8:10 pm, Kai-Uwe Bux <jkherci...@gmx.netwrote:
Peng Yu wrote:
Hi,
I'm wondering how to get the cubic root for a complex number? It seems
that cbrt does not work complex numbers.
I cannot find cbrt() in the standard anyway.
cbrt() is conforming to C99.
Thanks,
Peng
On Tue, 9 Sep 2008 18:20:45 -0700 (PDT), Peng Yu <Pe*******@gmail.com>
wrote in comp.lang.c++:
On Sep 9, 8:10 pm, Kai-Uwe Bux <jkherci...@gmx.netwrote:
Peng Yu wrote:
Hi,
I'm wondering how to get the cubic root for a complex number? It seems
that cbrt does not work complex numbers.
I cannot find cbrt() in the standard anyway.
cbrt() is conforming to C99.
....then wait until it is added to C++, which it probably will be.
Because it is not part of the standard C++ library today.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Jack Klein wrote:
On Tue, 9 Sep 2008 18:20:45 -0700 (PDT), Peng Yu <Pe*******@gmail.com>
wrote in comp.lang.c++:
>On Sep 9, 8:10 pm, Kai-Uwe Bux <jkherci...@gmx.netwrote:
>>Peng Yu wrote: Hi, I'm wondering how to get the cubic root for a complex number? It seems that cbrt does not work complex numbers. I cannot find cbrt() in the standard anyway.
cbrt() is conforming to C99.
...then wait until it is added to C++, which it probably will be.
Because it is not part of the standard C++ library today.
You don't need to wait. Write yourself a function to call cbrt(),
compile under C99, link it with the rest of your program.
Ben This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Philip KOCH |
last post by:
I'm trying to calculate the cubic root of a fonction, what syntax should I
use?
Thanx
PHIL
|
by: Marc Schellens |
last post by:
Does anybody know an easy way to get the atan of a complex number in C++?
thanks,
marc
|
by: JKop |
last post by:
Could someone please point me to somewhere where I can get a full
complete reference of the C++ Standard Libaries, how to use all their
functions and global varibles.
Is there any function in...
|
by: zender |
last post by:
Hi,
Is it possible to a value separately to the real or imaginary
part of a complex number?
Any help appreciated,
Charlie
The following code shows that .real() and .imag() are not lvalues:
|
by: Protoman |
last post by:
I'm trying to print a complex number and i get this as output: Phi:
(1.618034,0.000000).
What does it mean? How do I get it to print normally? Here's the code:
----------fib.hpp-------------...
|
by: jraul |
last post by:
Suppose we have a complex number class and we overload the conversion
to double to return the real part. We also overload operator* to do
complex multiplication. Consider now:
complex a(...);...
|
by: jraul |
last post by:
Suppose you have a complex number class, and you overload conversions
to double by only taking the real part. You also overload operator* to
do complex multiplication.
You then write:
...
|
by: schaefer.mp |
last post by:
To compute the absolute value of a negative base raised to a
fractional exponent such as:
z = (-3)^4.5
you can compute the real and imaginary parts and then convert to the
polar form to get...
|
by: Reshmi |
last post by:
Hi,
I have this C code which does complex number arithmetic. When I try to
write a similar file for C++, it says that "creal’ was not declared in
this scope". Can anyone give a better idea to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |