Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
vector.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file numeric/kinematic_closure/vector.hh
11 /// @brief Implement the primitive vector operations (again).
12 /// @author Kale Kundert
13 ///
14 /// This file should really not exist, because rosetta already has an xyzVector
15 /// class which implements all of this functionality. However, for historical
16 /// reasons, the kinematic closure algorithms do not use xyzVector and must
17 /// therefore reimplement the primitive vector arithmetic operations. Although
18 /// a better solution would be to refactor the kinematic closure algorithms,
19 /// this would be a much larger undertaking.
20 
21 #ifndef INCLUDED_numeric_kinematic_closure_vector_HH
22 #define INCLUDED_numeric_kinematic_closure_vector_HH
23 
24 // Unit Headers
26 #include <numeric/xyzVector.hh>
27 
28 // C++ Headers
29 #include <iosfwd>
30 
31 namespace numeric {
32 namespace kinematic_closure {
33 
34 // Vector Arithmetic Functions
35 
36 Real dot (Coordinate const &a, Coordinate const &b);
37 Coordinate cross (Coordinate const &a, Coordinate const &b);
38 Coordinate norm (Coordinate const &a);
39 
40 // Overloaded Operators
41 
42 std::ostream& operator << (std::ostream &out, ParameterList const &a);
43 std::ostream& operator << (std::ostream &out, ParameterMatrix const &a);
46 Coordinate operator * (Coordinate const &a, Real const &k);
47 Coordinate operator * (Real const &k, Coordinate const &a);
48 Coordinate operator / (Coordinate const &a, Real const &k);
49 Coordinate operator / (Real const &k, Coordinate const &a);
50 
51 // Pseudo-Assignment Operators
52 
53 // I decided to overload the stream operators to copy utility::vector1 objects
54 // into xyzVectors and vice versa. The assignment operator would have been a
55 // better choice, but it can only be overloaded by member functions and I don't
56 // want to make any changes to the utility::vector1 class. Regardless, this is
57 // really an abuse of the stream operator, so be careful and make sure you know
58 // what's going on when using it.
59 
60 template <class T>
61 Coordinate& operator << (Coordinate &a, xyzVector<T> const &b) {
62  a.resize(3);
63 
64  a[1] = b.x();
65  a[2] = b.y();
66  a[3] = b.z();
67 
68  return a;
69 }
70 
71 template <class T>
72 xyzVector<T>& operator << (xyzVector<T> &a, Coordinate const &b) {
73  a.x() = b[1];
74  a.y() = b[2];
75  a.z() = b[3];
76 
77  return a;
78 }
79 
80 } // end namespace kinematic_closure
81 } // end namespace numeric
82 
83 #endif
84 
utility::vector1< ParameterList > ParameterMatrix
Definition: types.hh:28
Coordinate operator/(Coordinate const &a, Real const &k)
Definition: vector.cc:116
Coordinate norm(Coordinate const &a)
Definition: vector.cc:40
utility::vector1< numeric::Real > Coordinate
Definition: types.hh:24
Coordinate operator+(Coordinate const &a, Coordinate const &b)
Definition: vector.cc:76
Coordinate operator*(Coordinate const &a, Real const &k)
Definition: vector.cc:96
Define the numeric types that are commonly used in this namespace.
std::ostream & operator<<(std::ostream &out, ParameterList const &x)
Definition: vector.cc:56
Real dot(Coordinate const &a, Coordinate const &b)
Definition: vector.cc:26
std::vector with 1-based indexing
Definition: vector1.fwd.hh:44
double Real
Definition: types.hh:39
void cross(const utility::vector1< Real > &L, const utility::vector1< Real > &r0, utility::vector1< Real > &r)
utility::vector1< numeric::Real > ParameterList
Definition: types.hh:27
Fast (x,y,z)-coordinate numeric vector.
Coordinate operator-(Coordinate const &a, Coordinate const &b)
Definition: vector.cc:86