1 /* 2 * This source code is part of 3 * 4 * HelFEM 5 * - 6 * Finite element methods for electronic structure calculations on small systems 7 * 8 * Written by Susi Lehtola, 2018- 9 * Copyright (c) 2018- Susi Lehtola 10 * 11 * This program is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; either version 2 14 * of the License, or (at your option) any later version. 15 */ 16 #ifndef LEGENDRE_TABLE_H 17 #define LEGENDRE_TABLE_H 18 19 #include <vector> 20 #include <armadillo> 21 22 namespace helfem { 23 namespace legendretable { 24 typedef struct { 25 /// Value of argument 26 double xi; 27 /// Plm values 28 arma::mat Plm; 29 /// Qlm values 30 arma::mat Qlm; 31 } legendre_table_t; 32 33 bool operator<(const legendre_table_t & lh, const legendre_table_t & rh); 34 35 class LegendreTable { 36 private: 37 /// Storage array 38 std::vector<legendre_table_t> stor; 39 /// Maximum L value used in the actual computation 40 int Lpad; 41 /// Maximum L value 42 int Lmax; 43 /// Maximum M value 44 int Mmax; 45 46 /// Find index in array 47 size_t get_index(double xi, bool check=true) const; 48 49 public: 50 /// Dummy constructor 51 LegendreTable(); 52 /// Constructor 53 LegendreTable(int Lpad, int Lmax, int Mmax); 54 /// Destructor 55 ~LegendreTable(); 56 /// Add value to table 57 void compute(double xi); 58 59 /// Get value from table 60 double get_Plm(int l, int m, double xi) const; 61 /// Get value from table 62 double get_Qlm(int l, int m, double xi) const; 63 64 /// Get value from table 65 arma::vec get_Plm(int l, int m, const arma::vec & xi) const; 66 /// Get value from table 67 arma::vec get_Qlm(int l, int m, const arma::vec & xi) const; 68 }; 69 } 70 } 71 72 #endif 73