Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in YlmFunctor::operator()(const coord_3d& r) const; #29

Closed
justusc opened this issue Aug 26, 2014 · 4 comments
Closed

Error in YlmFunctor::operator()(const coord_3d& r) const; #29

justusc opened this issue Aug 26, 2014 · 4 comments
Assignees
Labels

Comments

@justusc
Copy link
Member

justusc commented Aug 26, 2014

I found an error in the following function ( source/apps/chem/gth_pseudopotential.h:290-307). It looks like the l=1, m=1 case is not checked or computed.

This is probably not performance critical code, but why is there so much computation with constants here? I doubt the complier will optimize them away.

double_complex operator()(const coord_3d& r) const {
    const double x = r[0]-center[0]; const double y = r[1]-center[1]; const double z = r[2]-center[2];
    double rr = std::sqrt(x*x + y*y + z*z);
    double PI = constants::pi;
    if (l == 0) {
        return (1./2.)*std::sqrt(1./PI); 
    } else if (l == 1) {
        if (m == -1) {
            return (1./2.)*std::sqrt(3./2./PI)*double_complex(x, -y)/rr;
        }
        if (m == 0) {
            return (1./2.)*std::sqrt(3./PI)*z/rr;
        }
        if (m == -1) {
            return -(1./2.)*std::sqrt(3./2./PI)*double_complex(x, y)/rr;
        }
    }
}
@justusc justusc added the bug label Aug 26, 2014
@justusc justusc added this to the Release Candidate 0.10 milestone Aug 27, 2014
@wsttiger
Copy link
Contributor

This is dead code, I'm deleting it. Thanks.

@wsttiger
Copy link
Contributor

As for all of the constants, I'll optimize more when I feel that everything is correct.

@wsttiger wsttiger self-assigned this Aug 28, 2014
@jeffhammond
Copy link
Member

A good compiler should optimize that stuff for you, but then again, there
are not a lot of good compilers out there.

Jeff

On Thu, Aug 28, 2014 at 12:00 PM, wsttiger notifications@github.com wrote:

As for all of the constants, I'll optimize more when I feel that
everything is correct.


Reply to this email directly or view it on GitHub
#29 (comment)
.

Jeff Hammond
jeff.science@gmail.com
http://jeffhammond.github.io/

@wsttiger
Copy link
Contributor

Deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants