get real part from fftw_complex in FFTW [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
this is maybe newbei question , but i dont know how to fast acces to real part of fftw_complex with FFFTW, i cant use .real() method,
I need convert this to double array, dynamic array in c++;

From the docs, 2 second Google search:
4.1.1 Complex numbers
The default FFTW interface uses double precision for all floating-point numbers, and defines a fftw_complex type to hold complex numbers as:
typedef double fftw_complex[2];
Here, the [0] element holds the real part and the 1 element holds the imaginary part.

Related

How do I get the 10 lowest values in an array? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have an array of type double. How do I get the 10 lowest values?
double values[1000];
This is what I've come up before:
double similar[num_img];
copy(begin(values), end(values), begin(similar)); //copy values to another variable
int elements = sizeof(similar) / sizeof(similar[0]);
sort(similar, similar + elements);
So that I could get the 10 values. But what I'm actually after is the indices.. So sorting it would not help, I guess.
Sort the array and grab the first 10 elements (values[0] through values[9]).

Calculating large numbers in C++ without external libraries [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I need to write a program that will perform operations on float numbers higher than 10^100.
I can't use any arbitrary precision mathematics libraries that are not included in GCC package by default.
I have NO idea how how to go about it.
Can you point me in the right direction?
You can create a class that can store larger numbers. 12345678 equals to 1234 * 10e4 + 5678.
For large numbers I use string buffers and do manual computation on it. It is much overhead and slow but you get infinite precision.

Obtaining an algorithm [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Let's say I have a variable a and b. Now I want to find a value for c such that the fraction a / c is a positive integer, and where c is as close to b as possible.
For example: a = 100 and b = 30.
In this case I want c to be 25; because a / c is an integer, and c is as close as b for which this holds.
Any ideas how I can program a function in C++ which does exactly this?
Find the factors of a. (search web for methods)
Scan resulting list for minimum difference vs b.
Is this a homework assignment? Either way, think about how you would solve this problem without writing any code. A good algorithm comes from a good design. Break the problem down into pieces and walk through some more examples. For example, how would you solve the problem of determining whether the division results in an integer value? Hint: There is a different operator you could use as opposed to division to achieve this easily. Now, how would you solve the problem of determining what number to start at for c in the algorithm? Do not write any code until you have the pseudocode figured out.

How to design an algorithm that multiplies two floats without '*'? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
How do I design an algorithm that takes two floats and multiplies them using only addition, bit shifting and bitwise operations?
I have already found one like this for integers, but that doesn't work with floats.
I have also found another that is much like what I need but log is also prohibited in my case.
The floats are stored according to the IEEE754 standard. I have also tried to keep their exponent part, and bitwise multiply their fractional part with no luck.
According to http://en.wikipedia.org/wiki/IEEE_floating_point, an IEEE754 number x = (-1)^s * c * b^q is represented by s,c,b,q , all are integers. for Two floating point numbers with the same base b is the same.
So the multiplication of two floating point numbers x and y is:
(-1)^(s1+s2)*c1*c2*b^(q1+q2) so the new floating point is represented by: s1+s2, c1*c2, b q1+q2 so you only have left to deal with multiplication of c1 and c2, both are integers so you are done.

Double precision error in C++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am using openCV C++ libraries and calculated a double. It does the arithmetic but when I read out the number, prints out -1.#QNAN on the command prompt. What does that mean?
I am using a 64-bit i3 processor.
It means you got a quiet NAN, probably by dividing -Inf / Inf or multiplying something with -Inf, or perhaps casing a non-double into a double. It's not so much a precision error as much as it's an arithmetic exception.
EDIT: or adding/substracting Inf ... read more on NaNs here
That's not an error, read more about floating point here