I am having a Hermitian Matrix(HCF[k]
) depending on a parameter $k$.
My job is to plot the Eigenvalues of the matrix as the parameter $k$ is changed.
But I am facing some problems.
(i) My Mathematica file size, which is of around whopping 90Mb, when HCF[k]
is around $284\times284$.
(ii) This part of code is very slow as the size of HCF[k]
is increasing.
kdel = 0.00001; (* offset *)
kIn = -π - kdel; (*Initial value of k *)
kFin = π + kdel; (*Final value of k *)
kInc = 0.001; (*Increment of k*)
eigeng =
ParallelTable[Eigenvalues[HCF[k]], {k, kIn, kFin, kInc}];
kList = ParallelTable[k, {k, kIn, kFin, kInc}];
kFList = ParallelTable[kList, {i, Transpose@eigeng}];
dataToPlot = Flatten[{kFList\[Transpose], eigeng}\[Transpose], {{1, 3}, {2}}];
Graphics[{Point[{#1, #2}]} & @@@ dataToPlot, Frame -> True,
...(* for the aesthetic of plot, i.e. axis title, range and bla bla*)]
- Is there a way the size issue can be overcome?
- Is there a way the code can be sped up a little bit?(I checked my rest of the code, it is very fast, which I did by breaking and evaluating it into small cells).
Addendum
- Form of
HCF[k]
, as it is huge I will try to show you how it looks for small size say
\left( \begin{array}{cccccc} -20 \pi & -\frac{e^{i k}}{2} & 0 & -\frac{1}{2} & 0 & 0 \\ -\frac{1}{2} e^{-i k} & -20 \pi & -\frac{1}{2} & 0 & 0 & 0 \\ 0 & -\frac{1}{2} & 0 & -\frac{e^{i k}}{2} & 0 & -\frac{1}{2} \\ -\frac{1}{2} & 0 & -\frac{1}{2} e^{-i k} & 0 & -\frac{1}{2} & 0 \\ 0 & 0 & 0 & -\frac{1}{2} & 20 \pi & -\frac{e^{i k}}{2} \\ 0 & 0 & -\frac{1}{2} & 0 & -\frac{1}{2} e^{-i k} & 20 \pi \\ \end{array} \right)
HCF
look like? $\endgroup$kList
andkFList
do not need to be defined usingParallelTable
; a simpleRange
would work, and probably be faster too. In general, have you tried without parallelization? Are you sure that parallel execution leads to a speedup? $\endgroup$Parallel
does work fast(may be I was in some illusion). So, never thought of out of parallelization. I am sorry I can't give the code that generated the matrix as there is some work going on(some restrictions on me), I really hope you will understand it(take it good). I gave you the matrix and your help will definitely show some light on the problem. $\endgroup$kFList
usingRange
, I failed in doing that. But able to do thekList
$\endgroup$