Commit 227ec73c by Francois Gygi

Changed norm() function to norm2() in D3vector.h for consistency.


git-svn-id: http://qboxcode.org/svn/qb/branches/efield@1609 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 4adecbff
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
// AngleCmd.h: // AngleCmd.h:
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// $Id: AngleCmd.h,v 1.5 2008-09-08 15:56:17 fgygi Exp $
#ifndef ANGLECMD_H #ifndef ANGLECMD_H
#define ANGLECMD_H #define ANGLECMD_H
...@@ -85,7 +84,7 @@ class AngleCmd : public Cmd ...@@ -85,7 +84,7 @@ class AngleCmd : public Cmd
D3vector r12(a1->position()-a2->position()); D3vector r12(a1->position()-a2->position());
D3vector r32(a3->position()-a2->position()); D3vector r32(a3->position()-a2->position());
if ( norm(r12) == 0.0 || norm(r32) == 0.0 ) if ( norm2(r12) == 0.0 || norm2(r32) == 0.0 )
{ {
if ( ui->onpe0() ) if ( ui->onpe0() )
{ {
......
...@@ -323,8 +323,8 @@ void AngleConstraint::grad_sigma(const D3vector &r1, const D3vector &r2, ...@@ -323,8 +323,8 @@ void AngleConstraint::grad_sigma(const D3vector &r1, const D3vector &r2,
{ {
D3vector r12(r1-r2); D3vector r12(r1-r2);
D3vector r32(r3-r2); D3vector r32(r3-r2);
assert(norm(r12) > 0.0); assert(norm2(r12) > 0.0);
assert(norm(r32) > 0.0); assert(norm2(r32) > 0.0);
D3vector e12(normalized(r12)); D3vector e12(normalized(r12));
D3vector e32(normalized(r32)); D3vector e32(normalized(r32));
const double ss = length(e12^e32); const double ss = length(e12^e32);
...@@ -344,7 +344,7 @@ void AngleConstraint::grad_sigma(const D3vector &r1, const D3vector &r2, ...@@ -344,7 +344,7 @@ void AngleConstraint::grad_sigma(const D3vector &r1, const D3vector &r2,
{ {
// choose direction e as e12+e32 // choose direction e as e12+e32
D3vector e(e12+e32); D3vector e(e12+e32);
assert(norm(e)>0.0); assert(norm2(e)>0.0);
e = normalized(e); e = normalized(e);
const double r12_inv = 1.0/length(r12); const double r12_inv = 1.0/length(r12);
const double r32_inv = 1.0/length(r32); const double r32_inv = 1.0/length(r32);
......
...@@ -309,7 +309,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell, ...@@ -309,7 +309,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell,
// defcell: cell used to define which vectors are contained in the Basis // defcell: cell used to define which vectors are contained in the Basis
// if refcell is defined, defcell = refcell // if refcell is defined, defcell = refcell
// otherwise, defcell = cell // otherwise, defcell = cell
if ( norm(refcell.b(0)) + norm(refcell.b(1)) + norm(refcell.b(2)) == 0.0 ) if ( norm2(refcell.b(0)) + norm2(refcell.b(1)) + norm2(refcell.b(2)) == 0.0 )
{ {
defcell = cell; defcell = cell;
} }
...@@ -322,7 +322,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell, ...@@ -322,7 +322,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell,
const D3vector b1 = defcell.b(1); const D3vector b1 = defcell.b(1);
const D3vector b2 = defcell.b(2); const D3vector b2 = defcell.b(2);
const double normb2 = norm(b2); const double normb2 = norm2(b2);
const double b2inv2 = 1.0 / normb2; const double b2inv2 = 1.0 / normb2;
const D3vector kp = kpx*b0 + kpy*b1 + kpz*b2; const D3vector kp = kpx*b0 + kpy*b1 + kpz*b2;
...@@ -382,7 +382,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell, ...@@ -382,7 +382,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell,
bool found = false; bool found = false;
for ( int l = lmin; l <= lmax; l++ ) for ( int l = lmin; l <= lmax; l++ )
{ {
const double two_e = norm(k*b1+l*b2); const double two_e = norm2(k*b1+l*b2);
if ( two_e < two_ecut ) if ( two_e < two_ecut )
{ {
lstart = min(l,lstart); lstart = min(l,lstart);
...@@ -412,7 +412,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell, ...@@ -412,7 +412,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell,
bool found = false; bool found = false;
for ( int l = lmin; l <= lmax; l++ ) for ( int l = lmin; l <= lmax; l++ )
{ {
const double two_e = norm(h*b0+k*b1+l*b2); const double two_e = norm2(h*b0+k*b1+l*b2);
if ( two_e < two_ecut ) if ( two_e < two_ecut )
{ {
lstart = min(l,lstart); lstart = min(l,lstart);
...@@ -452,7 +452,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell, ...@@ -452,7 +452,7 @@ bool Basis::resize(const UnitCell& cell, const UnitCell& refcell,
bool found = false; bool found = false;
for ( int l = lmin; l <= lmax; l++ ) for ( int l = lmin; l <= lmax; l++ )
{ {
const double two_e = norm((kpx+h)*b0 + (kpy+k)*b1 + (kpz+l)*b2); const double two_e = norm2((kpx+h)*b0 + (kpy+k)*b1 + (kpz+l)*b2);
if ( two_e < two_ecut ) if ( two_e < two_ecut )
{ {
lstart = min(l,lstart); lstart = min(l,lstart);
...@@ -660,10 +660,10 @@ void Basis::update_g(void) ...@@ -660,10 +660,10 @@ void Basis::update_g(void)
kpgx_[locsize+i] = kpgt.y; kpgx_[locsize+i] = kpgt.y;
kpgx_[locsize+locsize+i] = kpgt.z; kpgx_[locsize+locsize+i] = kpgt.z;
g2_[i] = norm(gt); g2_[i] = norm2(gt);
g_[i] = sqrt( g2_[i] ); g_[i] = sqrt( g2_[i] );
kpg2_[i] = norm(kpgt); kpg2_[i] = norm2(kpgt);
kpg_[i] = sqrt( kpg2_[i] ); kpg_[i] = sqrt( kpg2_[i] );
gi_[i] = g_[i] > 0.0 ? 1.0 / g_[i] : 0.0; gi_[i] = g_[i] > 0.0 ? 1.0 / g_[i] : 0.0;
......
...@@ -149,7 +149,7 @@ class D3vector ...@@ -149,7 +149,7 @@ class D3vector
return sqrt( a.x * a.x + a.y * a.y + a.z * a.z ); return sqrt( a.x * a.x + a.y * a.y + a.z * a.z );
} }
friend double norm( const D3vector& a ) friend double norm2( const D3vector& a )
{ {
return a.x * a.x + a.y * a.y + a.z * a.z; return a.x * a.x + a.y * a.y + a.z * a.z;
} }
......
...@@ -162,7 +162,7 @@ EnergyFunctional::EnergyFunctional( Sample& s, const ChargeDensity& cd) ...@@ -162,7 +162,7 @@ EnergyFunctional::EnergyFunctional( Sample& s, const ChargeDensity& cd)
// Electric enthalpy // Electric enthalpy
el_enth_ = 0; el_enth_ = 0;
if ( norm(s_.ctrl.e_field) != 0.0 ) if ( norm2(s_.ctrl.e_field) != 0.0 )
el_enth_ = new ElectricEnthalpy(s_); el_enth_ = new ElectricEnthalpy(s_);
sf.init(tau0,*vbasis_); sf.init(tau0,*vbasis_);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
// TorsionCmd.h: // TorsionCmd.h:
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// $Id: TorsionCmd.h,v 1.6 2008-09-08 15:56:19 fgygi Exp $
#ifndef TORSIONCMD_H #ifndef TORSIONCMD_H
#define TORSIONCMD_H #define TORSIONCMD_H
...@@ -92,7 +91,7 @@ class TorsionCmd : public Cmd ...@@ -92,7 +91,7 @@ class TorsionCmd : public Cmd
D3vector r12(a1->position()-a2->position()); D3vector r12(a1->position()-a2->position());
D3vector r32(a3->position()-a2->position()); D3vector r32(a3->position()-a2->position());
D3vector r43(a4->position()-a3->position()); D3vector r43(a4->position()-a3->position());
if ( norm(r12) == 0.0 || norm(r32) == 0.0 || norm(r43) == 0.0 ) if ( norm2(r12) == 0.0 || norm2(r32) == 0.0 || norm2(r43) == 0.0 )
{ {
if ( ui->onpe0() ) if ( ui->onpe0() )
{ {
......
...@@ -124,8 +124,8 @@ void UnitCell::set(const D3vector& a0, const D3vector& a1, const D3vector& a2) ...@@ -124,8 +124,8 @@ void UnitCell::set(const D3vector& a0, const D3vector& a1, const D3vector& a2)
for ( int i = 0; i < 13; i++ ) for ( int i = 0; i < 13; i++ )
{ {
an2h_[i] = 0.5 * norm(an_[i]); an2h_[i] = 0.5 * norm2(an_[i]);
bn2h_[i] = 0.5 * norm(bn_[i]); bn2h_[i] = 0.5 * norm2(bn_[i]);
} }
for ( int i = 0; i < 3; i++ ) for ( int i = 0; i < 3; i++ )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment