MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
vector3.h
1//
2// vector3.h
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef _math_scmat_vector3_h
29#define _math_scmat_vector3_h
30
31#include <iostream>
32#include <math.h>
33
34#include <util/misc/exenv.h>
35#include <util/keyval/keyval.h>
36
37namespace sc {
38
39class RefSCVector;
40class SCMatrix3;
41
44{
45 friend class SCMatrix3;
46 private:
47 double _v[3];
48 public:
49 SCVector3() {}
50 SCVector3(const double p[3]) {
51 _v[0] = p[0]; _v[1] = p[1]; _v[2] = p[2];
52 }
53 SCVector3(double d) { _v[0] = d; _v[1] = d; _v[2] = d; }
54 SCVector3(double x,double y,double z) {
55 _v[0] = x; _v[1] = y; _v[2] = z;
56 }
57 SCVector3(const SCVector3&p) {
58 _v[0] = p._v[0]; _v[1] = p._v[1]; _v[2] = p._v[2];
59 }
60 SCVector3(const RefSCVector&);
61 SCVector3(const Ref<KeyVal>&);
62 ~SCVector3() {}
63 void normalize();
64 SCVector3 operator -() { return SCVector3(-_v[0],-_v[1],-_v[2]); }
65 SCVector3 operator*(double) const;
66 void operator = (const double *x) {
67 _v[0] = x[0];
68 _v[1] = x[1];
69 _v[2] = x[2];
70 }
71 void operator = (const SCVector3& x) {
72 _v[0] = x._v[0];
73 _v[1] = x._v[1];
74 _v[2] = x._v[2];
75 }
76 void operator = (double d) { _v[0] = d; _v[1] = d; _v[2] = d; }
77 void operator -= (const SCVector3& v) {
78 _v[0] -= v._v[0];
79 _v[1] -= v._v[1];
80 _v[2] -= v._v[2];
81 }
82 void operator += (const SCVector3& v) {
83 _v[0] += v._v[0];
84 _v[1] += v._v[1];
85 _v[2] += v._v[2];
86 }
87 void operator *= (double m) { _v[0] *= m; _v[1] *= m; _v[2] *= m; }
88 SCVector3 operator+(const SCVector3&v) const {
89 SCVector3 result;
90 result._v[0] = _v[0] + v._v[0];
91 result._v[1] = _v[1] + v._v[1];
92 result._v[2] = _v[2] + v._v[2];
93 return result;
94 }
95 SCVector3 operator-(const SCVector3&v) const {
96 SCVector3 result;
97 result._v[0] = _v[0] - v._v[0];
98 result._v[1] = _v[1] - v._v[1];
99 result._v[2] = _v[2] - v._v[2];
100 return result;
101 }
102 double dot(const SCVector3&v) const {
103 return _v[0]*v._v[0] + _v[1]*v._v[1] + _v[2]*v._v[2]; }
104 SCVector3 cross(const SCVector3&) const;
105 // returns a unit vector that is perpendicular to the two vectors
106 SCVector3 perp_unit(const SCVector3&) const;
107 void spherical_coord(double theta, double phi,
108 double r);
109 void spherical_to_cartesian(SCVector3&cart) const;
110 double maxabs() const;
111 // this returns the length of the difference vector
112 double dist(const SCVector3&) const;
113 void rotate(double theta,SCVector3 &v);
114 double norm() const { return sqrt(this->dot(*this)); }
115 double& elem(int xyz) { return _v[xyz]; }
116 const double& elem(int xyz) const { return _v[xyz]; }
117 double& operator [] (int i) { return _v[i]; }
118 const double& operator [] (int i) const { return _v[i]; }
119 double& operator () (int i) { return _v[i]; }
120 const double& operator () (int i) const { return _v[i]; }
121 const double* data() const { return _v; }
122 double* data() { return _v; }
123 double& x() { return _v[0]; }
124 double& y() { return _v[1]; }
125 double& z() { return _v[2]; }
126 const double& x() const { return _v[0]; }
127 const double& y() const { return _v[1]; }
128 const double& z() const { return _v[2]; }
129 double& r() { return _v[0]; }
130 double& theta() { return _v[1]; }
131 double& phi() { return _v[2]; }
132 const double& r() const { return _v[0]; }
133 const double& theta() const { return _v[1]; }
134 const double& phi() const { return _v[2]; }
135 void print(std::ostream& =ExEnv::out0()) const;
136};
137SCVector3 operator*(double,const SCVector3&);
138std::ostream &operator<<(std::ostream&, const SCVector3 &);
139
141bool operator==(const SCVector3& a, const SCVector3& b);
143inline bool operator!=(const SCVector3& a, const SCVector3& b) { return not (a==b); }
144}
145
146#ifdef INLINE_FUNCTIONS
147#include <math/scmat/vector3_i.h>
148#endif
149
150#endif
151
152// Local Variables:
153// mode: c++
154// c-file-style: "CLJ"
155// End:
static std::ostream & out0()
Return an ostream that writes from node 0.
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition matrix.h:55
A template class that maintains references counts.
Definition ref.h:361
Definition matrix3.h:40
a 3-element version of SCVector
Definition vector3.h:44
std::vector< unsigned int > operator<<(const GaussianBasisSet &B, const GaussianBasisSet &A)
computes a map from basis functions in A to the equivalent basis functions in B.
bool operator==(const Atom &a, const Atom &b)
bool operator!=(const Atom &a, const Atom &b)
Definition atom.h:170
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.