MCPcopy Create free account
hub / github.com/SINGROUP/dscribe / legendre_poly

Function legendre_poly

dscribe/ext/soapGeneral.cpp:1602–1638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1600 return Flir;
1601}
1602double legendre_poly(int l, int m, double x)
1603{
1604 double fact,pll,pmm,pmmp1,somx2;
1605 int ll;
1606
1607 if (m < 0 || m > l || fabs(x) > 1.0) {
1608 printf("ERROR: Bad arguments in routine legendre_poly"); exit(1);
1609 }
1610
1611 pmm = 1.0;
1612
1613 if (m > 0) {
1614 somx2=sqrt((1.0 - x)*(1.0 + x));
1615 fact=1.0;
1616 for (int i=1; i <= m; i++) {
1617 pmm *= -fact*somx2;
1618 fact += 2.0;
1619 }
1620 }
1621
1622 if (l == m) {
1623 return pmm;
1624 } else {
1625 pmmp1 = x*(2*m+1)*pmm;
1626 if (l==(m+1)) {
1627 return pmmp1;
1628 } else {
1629 for (ll=m+2; ll<=l; ll++) {
1630 pll=(x*(2*ll-1)*pmmp1 - (ll+m-1)*pmm)/ (double) (ll-m);
1631 pmm = pmmp1;
1632 pmmp1= pll;
1633
1634 }
1635 return pll;
1636 }
1637 }
1638}
1639double* getYlmi(double* x, double* y, double* z, double* oOri, double* cf, int icount, int lMax)
1640{
1641 double* Ylmi = (double*) malloc(2*sd*(lMax+1)*(lMax+1)*icount);

Callers 1

getYlmiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected