FFT Algorithm C Code Explaination [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
http://www.tech.dmu.ac.uk/~eg/tensiometer/fft/fft.c
http://www.tech.dmu.ac.uk/~eg/tensiometer/fft/fft_test.c
I have found a good working C Code for FFT Algorithm for converting Time Domain to Frequency Domain and vice versa in the above links. But I wanted to know the flowchart or step by step process of how this code works. I am trying to analyze the code with butterfly method of decimation in time for FFT but i am facing difficulties in understanding the code. The code is working very well and giving me the correct results but it would be very helpful to me if someone could give a brief or detailed explaination on how this code works.
I am confused with the array and the pointers used in the fft.c code. Also I am not getting what are the variables offset and delta mean in the code. How the rectangular matrix of real and imaginary terms are considered/used in the code?? Please guide me.
Thanks,
Psbk

I strongly recommend to read this: https://stackoverflow.com/a/26355569/2521214
Now from the first look the offset and delta is used to:
make the butterfly shuffle permutation
you start with step 1 and half of the interval
and by recursion you will get to log2(N) step and interval of 1 item ...
+/- one recursion level
I usually do the butterfly in reverse order
The XX array
is a buffer to store the subresult or input data
you can not perform FFT inplace easily (if at all)
so you compute to/from the temp buffer instead
and on each recursion just swap the data and temp buffers (physically or their meaning)

Related

When does an algorithm become considered artificial intelligence? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I understand that an algorithm is a set of instructions. Ai is essentially the same thing, only, more complicated? Let's say I use a minmax algorithm to allow moves to be played on a tic tac toe board, generally people would consider this ai. But if I implement an algorithm to solve a rubiks cube, is that considered ai?
I guess what I'm asking is, is it the complexity of the algorithm, the fact that situations change on the fly in an algorithm, the ignorance of the user/programmer as to how the algorithm works or all/some of the above? Or am I missing something?
I feel like this field is quite arbitrary. I imagine for good reason.I imagine because complexity is complex.
It is indeed quite arbitrary.
If you consult wikipedia you might find following definition which in my personal opinion catches the load quite accurately:
Computer science defines AI research as the study of "intelligent
agents": any device that perceives its environment and takes actions
that maximize its chance of successfully achieving its goals. A more
elaborate definition characterizes AI as "a system's ability to
correctly interpret external data, to learn from such data, and to use
those learnings to achieve specific goals and tasks through flexible
adaptation."
To take your Rubiks Cube as an example, there would be at least 2 ways you could write the algoritm to solve the puzzle. Firstly, any cube can be solved by following a hardcoded path or set of instructions once you have a certain start position. Implementing this would not be considered AI in my opinion as the machine itself is not learning anything. It just follows a well defined path of instructions till the end.
A second way to implement this would be to have the program just start solving it randomly. But the machine remembers it's moves, and learns the most effective path to reach the solution. When solving the next cube, the machine can build upon this newly learned information to solve it faster and again learn from this iteration to improve it's algorithm.
So in short, as far as I'm concerned, it can be considered AI when a machine is capable of optimizing/extending its own algorithms to become more efficient in its tasks.

graph traversal in C [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have to implement a backtracing algorithm in C which will emulate a hardware in purely software, and trace a single path from output of a system to the input pin, registering all the gates, their outputs and inputs(taken) on the path in a reverse order. I figured out that it can be done in graph traversal algorithm but not able to implement in C. Any useful suggestions shall be helpful indeed!
I've done a few maze solving algorithms, both breadth and depth first search.
I'd say you should first build a graph and make sure its perfectly built and without any incoherence, and something i found to be very useful was to find a way to print my graph to check for errors :).
Other than that, good luck !
Depends on what kind of path tracing, it can follow both breadth first search or else Depth first search. I have tried both of them and it works.

Code that is supposed to solve Laplace's equation iteratively - numbers stored in array change unexpectedly to random large numbers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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.
Closed 9 years ago.
Improve this question
I've written a program in C that iteratively solves Laplace's equation on a square domain by successive over-relaxation, but although it was working perfectly a few days ago, I've come back to it and now it's doing really weird things.
The program involves creating two 7x7 arrays, one to hold the values of phi (the dependent variable in Laplace's equation) and one to hold the residuals from the successive over-relaxation. The array of residuals is filled with zeroes initially because I thought that was probably a good idea, but thinking about it now it shouldn't make much difference either way.
The problem is that certain values in the array (specifically R[4][6]) jump around randomly to enormous numbers, even though I've set them to zero and then not touched them. I know this because I put another line in to output the value of the residual at (4,6) to the screen after each iteration. This problem is causing my method of checking for convergence to fail, and also somehow causing the final solution (plotted as a surface using gnuplot) to look correct except for small peaks and valleys in the surface.
I'm coding in C, Dev-C++ 4.9.9.2 is the compiler I'm using (the files are definitely saved as C files and not C++ ones too), outputting the data into a DATA file which comes up in notepad when opened, and finally using gnuplot to produce the 3D contour plots that are my results. I'm working on windows 7.
I've put the code here: https://gist.github.com/anonymous/8220425 and you need to enter 1.35 for alpha when the program asks you for it.
If anyone could help at all I would be very grateful!
printf("Residual at (4,6)=%lf\n",R[4,6]);
You mean:
printf("Residual at (4,6)=%lf\n",R[4][6]);
The issue here is that R[4,6] basically means R[6] (4,6 means: evaluate 4, then evaluate 6), which is some sort of pointer rather than a double. So it will print random-looking values depending on where your array has been allocated in memory.

C Program Function [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
I don't want an answer in the form of code, but I do need to know how to start working on this problem. I have just begun learning C language and during the learning process, I am stuck with this confusing question. The question is as follows:
Write a function to compute the distance between two points and use it to develop another function that will compute the area of the triangle whose vertices are *A(x1,y1), B(x2,y2), and C(x3,y3).* Use these functions to develop a function which returns the value 1 if the point (x,y) lines inside the triangle ABC, otherwise returns a value 0.
Please suggest me the appropriate coding for this problem in C language and kindly include comments for better understanding.
I know both the formulas by the way.
Approach this problem, like all other coding problems, in increments. Your problem statement states pretty much what you need to do:
first, write a routine to compute the distance between two points. You need to find the formula to do this. Probably easiest to use double variables, be sure to read about how to specify the format statement for printf so that it can print double variables.
next, find the formula to use in order to compute the area of a triangle.
the last step is the hardest, and you will need to use everything you learned in steps one and two. Again, dig out your calculus or algebra book and see how this is done and then write code to do the same thing. It is interesting to see how a math description gets translated to computer code, they are not the same thing and unless you write a lot comments in your code it will be difficult to see how they do the same function.
good luck.
PS. when defining a function that returns a double variable, code:
double distance_calc(double x1, double x2, double y1, double y2)
{
double computed_value;
// do the formula and compute: computed_value = etc.
return computed_value;
}
Hope this helps.

How to implement CRC using C language [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
I am bit new to programming and i want to send a float data to eeprom from a controller and i want to implement crc for the error detection of the data when ever i tries to read or write.
This is my intention.But i found many algorithms for implementing crc and its been quite confusing for me to follow which one.
The compiler provides 4 bytes of space for all data and its function sends each byte one at a time.So i trust i would be required to do the crc of each 8bit data or can implement it as a whole.
And i am using C language.
In brief:
i just need to do a
1.Crc implementation.
2.Common Data size =32 bits
3.Compiler function sends one byte at a time.
4.And how do we fix which algorithm to go for.
Thank you very much
Try Reading this article(It Contains C Codes and Diagrams Which you need) :
http://www.barrgroup.com/Embedded-Systems/How-To/CRC-Calculation-C-Code
CRCs are among the best checksums available to detect and/or correct errors in communications transmissions. Unfortunately, the modulo-2 arithmetic used to compute CRCs doesn't map easily into software. This article shows how to implement an efficient CRC in C.

Resources