# Tutor profile: Aprameyo R.

## Questions

### Subject: Computer Science (General)

How to visualize the difference between throughput and latency of a a system. When is it advantageous to have low latency and when is it advantageous to have high throughput ? Are they the same.?

Basically : Latency is the time required to perform a task. Latency is measured in units of time i.e clock periods. Throughput is the number of such tasks executed per unit of time. Now to answer whether it is suitable to have a low latency or a high throughput , the answer solely lies in the requirements. Currently the processors have become extremely fast and have clock speeds more than 4 GHz and can process streams of information very quickly , thus latency is very low . Therefore for serial processing of data , low latency is very useful , but if we need more work done per unit time irrespective of how much each time each single tasks takes , we need to take the throughput in consideration. Here comes the fundamental difference between a CPU and GPU , the GPU works with the main aim of achieving maximum throughput whereas the CPU aims at reducing latency of each task . Ideally the best system is that having a good throughput and low latency but its difficult to realize that due to very different hardware logic for both of them. The GPU therefore takes the cake in the department of parallel processing due to the large number of processing cores it has and a particularly low latency too.

### Subject: Calculus

What happens when Fourier Series of a function is calculated at the point of discontinuity?Assume the function is piece-wise continuous. NOTE: This type of discontinuity is called jump discontinuity.

The Fourier Series is easily calculated for continuous function normally , but at the point of discontinuity the result converges at the average of the values of the function just before and after the point of discontinuity. i.e.{ f(p+)+f(p-)} / 2 . This can be proven by checking the energy contained in the frequency or the Fourier domain and equating it with that of the Time domain, this comes as the Parseval's Theorem. Parseval's Theorem states that the energy stored in time domain is equal to that stored in time domain. Thus integral/summation(for dicsrete) of square of the time domain signal must be equal to that of the square of the Fourier series coefficients. Thus after equating them we can deduce that the value of the Fourier Series at the discontinuity is the average of the Left hand and right hand limits of the function the point of jump discontinuity.

### Subject: C++ Programming

Create a C++ program which calculates the Discrete Fourier Transform of a given vector of any length without using the Fast Fourier Transform algorithm. NOTE: Use Dynamic Memory Allocation for speed and relevance.

#include <iostream> #include <complex.h> #include <cmath> #include<stdio.h> #include <fstream> #include <vector> using namespace std; int main() { ifstream fin("input1.txt", ios::in); vector<double> col1; double a, b; char space; if (fin.good()) { while (!fin.eof()) { fin >> a; col1.push_back(a); } } cout << endl << col1.size() <<endl; int i = 0; double pi = 3.14; double *Re, *Im, *FFT; Re = new double[col1.size()+ 1](); Im = new double[col1.size()+ 1](); FFT = new double[col1.size() + 1](); int j = 0; for (int k = 0; k < col1.size(); k++) { for (int n = 0; n < col1.size(); n++) { Re[k] += col1[n] *cos(2 * pi*k*n/col1.size()); Im[k] -= col1[n] *sin(2 * pi*k*n / col1.size()); FFT[k] = sqrt(Im[k] * Im[k] + Re[k] * Re[k]); if (j % 1000 == 0) { cout << "this is iteration" << j; j++; } } } ofstream fout("output.txt", ios::out); for (int l = 0; l <col1.size(); l++) { fout<< Re[l]<<"\t"<<Im[l]<<"\t"<<FFT[l]<< endl; } delete Re; delete Im; delete FFT; system("pause"); return(0); } The code above achieves the requirements of the question and calculates the real , imaginary and the absolute values of the Discrete Fourier Transform using input of any length(from input file 'input.txt') and also uses dynamic memory allocation for relevance and speed. The use of vector class is also involved to make the code much more portable. We can also see that deletion of the dynamically allocated arrays. This is to avoid wastage of memory on the next run of the code , as it will keep on creating new arrays every time we run it again. Also notice Re = new double[col1.size()+ 1](); , the '()' is used for ensuring the value of all the elements of the array is initially set to zero. We have used various headers including cmath for sin and cosine calculations , fstream for accessing files and their data , iostream for commands like cout for displaying the result. NOTE: I have used VISUAL STUDIO 2013 for this purpose.

## Contact tutor

needs and Aprameyo will reply soon.