25 #ifndef COM_DAFER45_TBTK_SOLVER_CHEBYSHEV_EXPANDER
26 #define COM_DAFER45_TBTK_SOLVER_CHEBYSHEV_EXPANDER
170 bool generateGreensFunctionsOnGPU
205 std::vector<Index> &to,
244 const std::vector<std::complex<double>> &coefficients,
245 Type type = Type::Retarded
252 void calculateCoefficientsWithCutoff(
255 std::complex<double> *coefficients,
257 double componentCutoff,
258 double broadening = 0.000001
272 std::complex<double> getMonolopoulosABCDamping(
273 double distanceToEdge,
283 void setDamping(std::complex<double> *damping);
296 int energyResolution;
306 bool calculateCoefficientsOnGPU;
310 bool generateGreensFunctionsOnGPU;
317 std::complex<double> *damping;
321 std::complex<double> **generatingFunctionLookupTable;
324 std::complex<double> ***generatingFunctionLookupTable_device;
328 int lookupTableNumCoefficients;
332 int lookupTableResolution;
335 double lookupTableLowerBound;
338 double lookupTableUpperBound;
341 void ensureLookupTableIsReady();
351 void generateLookupTable(
353 int energyResolution,
354 double lowerBound = -1.,
355 double upperBound = 1.
359 void destroyLookupTable();
362 bool getLookupTableIsGenerated();
366 void loadLookupTableGPU();
370 void destroyLookupTableGPU();
373 bool getLookupTableIsLoadedGPU();
388 std::vector<std::complex<double>>
389 > calculateCoefficientsCPU(
390 std::vector<Index> &to,
403 std::vector<std::complex<double>> calculateCoefficientsCPU(
420 std::vector<std::complex<double>>
421 > calculateCoefficientsGPU(
422 std::vector<Index> &to,
434 std::vector<std::complex<double>> calculateCoefficientsGPU(
471 std::vector<std::complex<double>> generateGreensFunctionCPU(
472 const std::vector<std::complex<double>> &coefficients,
473 Type type = Type::Retarded
486 std::vector<std::complex<double>> generateGreensFunctionGPU(
487 const std::vector<std::complex<double>> &coefficients,
488 Type type = Type::Retarded
493 if(generatingFunctionLookupTable !=
nullptr)
494 destroyLookupTable();
495 if(generatingFunctionLookupTable_device !=
nullptr)
496 destroyLookupTableGPU();
498 this->scaleFactor = scaleFactor;
506 if(generatingFunctionLookupTable !=
nullptr)
507 destroyLookupTable();
508 if(generatingFunctionLookupTable_device !=
nullptr)
509 destroyLookupTableGPU();
511 this->numCoefficients = numCoefficients;
515 return numCoefficients;
519 this->broadening = broadening;
527 if(generatingFunctionLookupTable !=
nullptr)
528 destroyLookupTable();
529 if(generatingFunctionLookupTable_device !=
nullptr)
530 destroyLookupTableGPU();
532 this->energyResolution = energyResolution;
536 return energyResolution;
540 if(generatingFunctionLookupTable !=
nullptr)
541 destroyLookupTable();
542 if(generatingFunctionLookupTable_device !=
nullptr)
543 destroyLookupTableGPU();
545 this->lowerBound = lowerBound;
553 if(generatingFunctionLookupTable !=
nullptr)
554 destroyLookupTable();
555 if(generatingFunctionLookupTable_device !=
nullptr)
556 destroyLookupTableGPU();
558 this->upperBound = upperBound;
566 bool calculateCoefficientsOnGPU
568 this->calculateCoefficientsOnGPU = calculateCoefficientsOnGPU;
572 return calculateCoefficientsOnGPU;
576 bool generateGreensFunctionsOnGPU
578 this->generateGreensFunctionsOnGPU = generateGreensFunctionsOnGPU;
582 return generateGreensFunctionsOnGPU;
587 if(generatingFunctionLookupTable !=
nullptr)
588 destroyLookupTable();
589 if(generatingFunctionLookupTable_device !=
nullptr)
590 destroyLookupTableGPU();
593 this->useLookupTable = useLookupTable;
597 return useLookupTable;
601 std::vector<std::complex<double>>
603 std::vector<Index> &to,
606 if(calculateCoefficientsOnGPU){
607 return calculateCoefficientsGPU(
613 return calculateCoefficientsCPU(
624 if(calculateCoefficientsOnGPU){
625 return calculateCoefficientsGPU(
631 return calculateCoefficientsCPU(
638 inline bool ChebyshevExpander::getLookupTableIsGenerated(){
639 if(generatingFunctionLookupTable != NULL)
645 inline bool ChebyshevExpander::getLookupTableIsLoadedGPU(){
646 if(generatingFunctionLookupTable_device != NULL)
653 const std::vector<std::complex<double>> &coefficients,
656 if(generateGreensFunctionsOnGPU){
657 return generateGreensFunctionGPU(coefficients, type);
660 return generateGreensFunctionCPU(coefficients, type);
664 inline void ChebyshevExpander::setDamping(std::complex<double> *damping){
665 this->damping = damping;
668 inline void ChebyshevExpander::ensureLookupTableIsReady(){
670 if(!generatingFunctionLookupTable)
671 generateLookupTable(numCoefficients, energyResolution, lowerBound, upperBound);
672 if(generateGreensFunctionsOnGPU && !generatingFunctionLookupTable_device)
673 loadLookupTableGPU();
675 else if(generateGreensFunctionsOnGPU){
677 "Solver::ChebyshevSolver::ensureLookupTableIsReady()",
678 "Green's functions can only be generated on GPU using"
679 <<
" lookup tables.",
680 "Use Solver::ChebyshevExpander::setGenerateGreensFunctionOnGPU()"
682 <<
" Solver::ChebyshevExpander::setUseLookupTable() to"
683 <<
" configure the Solver::ChebyshevExpander."