ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/devel_omp/src/math/Vector3.hpp
(Generate patch)

Comparing:
trunk/src/math/Vector3.hpp (file contents), Revision 1442 by gezelter, Mon May 10 17:28:26 2010 UTC vs.
branches/devel_omp/src/math/Vector3.hpp (file contents), Revision 1595 by chuckv, Tue Jul 19 18:50:04 2011 UTC

# Line 132 | Line 132 | namespace OpenMD {
132     * @see #vector::dot
133     */
134    template<typename Real>
135 <  Vector3<Real> cross( const Vector3<Real>& v1, const Vector3<Real>& v2 ) {
135 >  inline Vector3<Real> cross( const Vector3<Real>& v1, const Vector3<Real>& v2 ) {
136      Vector3<Real> result;
137      
138      result.x() = v1.y() * v2.z() - v1.z() * v2.y();
# Line 142 | Line 142 | namespace OpenMD {
142      return result;
143    }
144  
145 +
146 +  /**
147 +   * Returns the linear indexing for integer vectors. Compare to
148 +   * Rapaport's VLinear
149 +   *
150 +   * @param p first vector
151 +   * @param s second vector
152 +   */
153 +  template<typename Real>
154 +  inline Real Vlinear( const Vector3<Real>& p, const Vector3<Real>& s ) {
155 +    return (p.z() * s.y() + p.y()) * s.x() + p.x();
156 +  }
157 +
158 +  /**
159 +   * Returns integer vector for the linear index.
160 +   *
161 +   * @param p first vector
162 +   * @param s second vector
163 +   */
164 +  template<typename Real>
165 +  inline Vector3<Real> idxToV( const Real i, const Vector3<Real>& s ) {
166 +          Vector3<Real> v;
167 +
168 +          v.z() = i / (s.y() * s.x());
169 +          v.y() = (i % (s.y() * s.x())) / s.x();
170 +          v.x() = (i % (s.y() * s.x())) % s.x();
171 +          return v;
172 +  }
173 +
174    typedef Vector3<int> Vector3i;
175    
176    typedef Vector3<RealType> Vector3d;    
# Line 149 | Line 178 | namespace OpenMD {
178    const Vector3d V3Zero(0.0 , 0.0, 0.0);
179    const Vector3d V3X( 1.0, 0.0, 0.0 ) ;
180    const Vector3d V3Y( 0.0, 1.0, 0.0 ) ;
181 <  const Vector3d V3Z ( 0.0, 0.0, 1.0 ) ;    
182 <  
181 >  const Vector3d V3Z ( 0.0, 0.0, 1.0 ) ;
182 >
183   }
184  
185   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines