23 #ifndef COM_DAFER45_TBTK_SMOOTH
24 #define COM_DAFER45_TBTK_SMOOTH
40 template<
typename DataType>
48 template<
typename DataType>
49 static std::vector<DataType>
gaussian(
50 const std::vector<DataType> &data,
56 template<
typename DataType>
57 static std::vector<DataType>
gaussian(
87 template<
typename DataType>
96 "'windowSize' must be larger than zero.",
101 "Smooth::gaussian()",
102 "'windowSize' must be odd.",
107 "Smooth::gaussian()",
108 "Array must have rank 1, but the rank is "
113 DataType normalization = 0;
114 for(
int n = -windowSize/2; n <= windowSize/2; n++){
115 normalization += exp(-n*n/(2*sigma*sigma));
117 normalization = DataType(1)/normalization;
120 for(
int n = 0; n < (int)data.
getRanges()[0]; n++){
122 int c = std::max(0, (
int)n - (
int)windowSize/2);
124 (
int)n + (
int)windowSize/2 + 1,
129 result[{(
unsigned int)n}]
132 ]*exp(-(c-n)*(c-n)/(2*sigma*sigma));
134 result[{(
unsigned int)n}] *= normalization;
140 template<
typename DataType>
142 const std::vector<DataType> &data,
148 "Smooth::gaussian()",
149 "'windowSize' must be larger than zero.",
154 "Smooth::gaussian()",
155 "'windowSize' must be odd.",
159 DataType normalization = 0;
160 for(
int n = -windowSize/2; n <= windowSize/2; n++){
161 normalization += exp(-n*n/(2*sigma*sigma));
163 normalization = DataType(1)/normalization;
165 std::vector<DataType> result;
166 for(
int n = 0; n < (int)data.size(); n++){
169 int c = std::max(0, (
int)n - (
int)windowSize/2);
171 (
int)n + (
int)windowSize/2 + 1,
176 result.at(n) += data.at(c)*exp(-(c-n)*(c-n)/(2*sigma*sigma));
178 result.at(n) *= normalization;
184 template<
typename DataType>
186 const DataType *data,
191 std::vector<DataType> dataVector;
192 for(
unsigned int n = 0; n < size; n++)
193 dataVector.push_back(data[n]);
207 const std::vector<double> &data = dos.
getData();
208 std::vector<double> dataVector;
209 for(
unsigned int n = 0; n < data.size(); n++)
210 dataVector.push_back(data[n]);
215 double scaledSigma = sigma/(upperBound - lowerBound)*resolution;
217 std::vector<double> smoothedData =
gaussian(
237 std::vector<double> &newData = newLdos.
getDataRW();
239 const std::vector<double> &data = ldos.
getData();
241 unsigned int numBlocks = ldos.
getSize()/blockSize;
245 double scaledSigma = sigma/(upperBound - lowerBound)*resolution;
246 for(
unsigned int block = 0; block < numBlocks; block++){
247 std::vector<double> blockData(blockSize);
248 for(
unsigned int n = 0; n < blockSize; n++)
249 blockData[n] = data[block*blockSize + n];
252 std::vector<double> smoothedData =
gaussian(
258 for(
unsigned int n = 0; n < blockSize; n++)
259 newData[block*blockSize + n] = smoothedData[n];
271 std::vector<SpinMatrix> &newData = newSpinPolarizedLDOS.
getDataRW();
273 const std::vector<SpinMatrix> &data = spinPolarizedLDOS.
getData();
274 unsigned int blockSize = spinPolarizedLDOS.
getBlockSize();
275 unsigned int numBlocks = spinPolarizedLDOS.
getSize()/blockSize;
279 double scaledSigma = sigma/(upperBound - lowerBound)*resolution;
280 for(
unsigned int block = 0; block < numBlocks; block++){
281 std::vector<SpinMatrix> blockData(blockSize);
282 for(
unsigned int n = 0; n < blockSize; n++)
283 blockData[n] = data[block*blockSize + n];
286 std::vector<std::complex<double>>
287 > spinMatrixComponents(
289 std::vector<std::complex<double>>(blockSize)
291 for(
unsigned int n = 0; n < blockSize; n++){
292 spinMatrixComponents[0][n] = blockData[n].at(0, 0);
293 spinMatrixComponents[1][n] = blockData[n].at(0, 1);
294 spinMatrixComponents[2][n] = blockData[n].at(1, 0);
295 spinMatrixComponents[3][n] = blockData[n].at(1, 1);
298 for(
unsigned int n = 0; n < 4; n++){
300 spinMatrixComponents[n],
306 for(
unsigned int n = 0; n < blockSize; n++){
307 newData[block*blockSize + n].at(0, 0)
308 = spinMatrixComponents[0][n];
309 newData[block*blockSize + n].at(0, 1)
310 = spinMatrixComponents[1][n];
311 newData[block*blockSize + n].at(1, 0)
312 = spinMatrixComponents[2][n];
313 newData[block*blockSize + n].at(1, 1)
314 = spinMatrixComponents[3][n];
318 return newSpinPolarizedLDOS;