TITLE: Could we write Fourier transform as a matrix?
QUESTION [9 upvotes]: I have heard that Fourier transform is a linear transformation.
I have also heard that any linear transformation can be written as a matrix multiplication.
(probably I'm missing some details in the above two statements)
So my guess is, the above two notions are related (may be not). Carrying on with the question, I also know that Fourier transform acts on the space of $L^2$ functions (again correct me please if wrong).
So my questions are: 
How can we write the Fourier transform as a matrix operator say $\mathcal{F}$? 
What are the elements of that matrix $\mathcal{F}$?
What is the dimension of that matrix $\mathcal{F}$?
When $\mathcal{F}$ acts on a function $g$, how do we write $g$ as a vector, to apply the matrix $\mathcal{F}$?
I know these can be done in DFT, but can it be done in continuous case is my question?
I read the following posts and they are related but not the same.
Is a Fourier transform a change of basis, or is it a linear transformation?
How is the Fourier transform "linear"?
Thanks a lot in advance.

REPLY [10 votes]: What are the elements of that matrix $\mathcal F$?

Depends on the basis we choose. The same linear operator is represented by different matrices in different bases.

What is the dimension of that matrix $\mathcal F$?

It is an infinite matrix (so, strictly speaking, not a matrix). 

When $\mathcal F$ acts on a function $g$, how do we write $g$ as a vector, to apply the matrix $F$?

Complex-valued functions are vectors, if a vector is understood abstractly, as an element of a vector space. (That is to say, functions form a vector space). If you mean the concrete representation of a vector as a row or column of numbers, then that can be obtained by expanding $g$ in a basis. The row/column will be infinite.  
More details below the cut.

To represent a linear operator as a matrix, we need to choose a basis for our space. The most convenient space on which to study $\mathcal F$ is $L^2(\mathbb R)$, the space of square-integrable functions. One convenient basis of that space is given by Hermite functions 
$$\Phi_n(x)= (-1)^n (2^{n}n! \sqrt{\pi})^{-1/2} e^{x^2/2}\frac{d^n(e^{-x^2})}{dx^n}, \quad n=0,1,2,\dots$$ 
This basis is orthonormal (sketch here), which makes it easy to expand a given function $g\in L^2(\mathbb R)$ in this basis: 
$$
g=\sum_{n=0}^\infty g_n \Phi_n,\quad g_n = \langle g,\Phi_n\rangle = \int_{-\infty}^\infty g(x)\Phi_n(x)\,dx 
$$
(I did not need conjugation over $\Phi_n$, since it happens to be real-valued.)
Each $\Phi_n$ is an eigenvector (eigenfunction) of $\mathcal F$, with eigenvalue $(-i)^n$, see Wikipedia. Therefore, the matrix of $\mathcal F$ in this basis is diagonal with the periodic sequence   $(-i)^n$ along the diagonal:
$$\begin{pmatrix} 1 & 0& 0 & 0  &0 &\dots \\
0 & -i &  0 & 0  &0 &\dots \\
0 & 0 & -1 & 0  &0 &\dots \\
0 & 0 & 0 & i  &0 &\dots \\
0 & 0 & 0 & 0  &1 &\dots \\
\vdots & \vdots &\vdots &\vdots &\vdots &\ddots
\end{pmatrix} $$