This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvector.h
166 lines (165 loc) · 5.79 KB
/
vector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#ifndef VECTOR_H
#define VECTOR_H
#pragma once
class Vector {
public:
std::vector<double> vec;
unsigned int vectorPrecision;
Vector();
~Vector();
Vector(std::vector<double> v);
Vector(int n);
Vector(double* x, int size);
void clear();
size_t size();
void convertCartesianToPolar();
void convertCylindricalToRectangular();
void convertCylindricalToSpherical();
void convertPolarToCartesian();
void convertRectangularToCylindrical();
void convertRectangularToSpherical();
void convertSphericalToRectangular();
bool isIntegerVector();
Vector crossProduct(Vector a, Vector b);
double dotProduct(Vector a, Vector b);
double scalarTripleProduct(Vector a, Vector b, Vector c);
Vector vectorTripleProduct(Vector a, Vector b, Vector c);
double mean();
double geometricMean();
double norm();
double pNorm(double p);
double normSquared();
void normalize();
void randomize();
void randomizeBoolean();
void randomizeInteger();
double multiply(Vector A, Vector B);
Vector multiply(Vector A, double B);
Vector multiply(double B, Vector A);
Vector add(Vector A, Vector B);
Vector add(Vector A, double B);
Vector subtract(Vector A, Vector B);
Vector subtract(Vector A, double B);
Vector exponent(Vector A, int b);
Vector& operator*=(Vector& rhs);
Vector& operator*=(double x);
double operator*(Vector& rhs);
Vector& operator*(double x);
Vector& operator+=(Vector& rhs);
Vector& operator+=(double x);
Vector& operator+(Vector& rhs);
Vector& operator+(double x);
Vector& operator-=(Vector& rhs);
Vector& operator-=(double x);
Vector& operator-(Vector& rhs);
Vector& operator-(double x);
bool operator==(Vector& B);
friend std::wostream& operator<<(std::wostream& os, Vector& rhs);
Quaternion createRotationQuaternion();
Quaternion createRotationQuaternion(std::vector<double> v);
double getAngle(Vector A, Vector B);
void sort();
double sum();
double sumSquares();
double vectorScalarProjection(Vector a, Vector b);
Vector unitNormal(Vector a, Vector b);
Matrix Vandermonde();
Vector directSum(Vector A, Vector B);
Vector tensorProduct(Vector A, Vector B);
double populationVariance();
double populationStandardDeviation();
double sampleVariance();
double sampleStandardDeviation();
double standardErrorOfMean();
double covariance(Vector v1, Vector v2);
Matrix outerProduct(Vector v1, Vector v2);
ComplexNumber toComplexNumber();
ComplexVector toComplexVector();
Matrix toHomogeneousCoordinates();
Matrix toDiagonalMatrix();
Matrix toMatrix();
Matrix toMatrix(int r, int c);
Quaternion toQuaternion();
DualQuaternion toDualQuaternion();
std::wstring toString();
void display();
};
//================================
class ComplexVector {
public:
std::vector<ComplexNumber> vec;
unsigned int complexVectorPrecision;
ComplexVector();
~ComplexVector();
ComplexVector(std::vector<ComplexNumber> v);
ComplexVector(std::vector<std::complex<double>> v);
ComplexVector(int n);
ComplexVector(ComplexNumber n);
ComplexVector(ComplexNumber* x, int size);
void clear();
size_t size();
ComplexVector toExponentialForm();
bool isIntegerVector();
ComplexVector crossProduct(ComplexVector a, ComplexVector b);
ComplexNumber dotProduct(ComplexVector a, ComplexVector b);
ComplexNumber scalarTripleProduct(ComplexVector a, ComplexVector b, ComplexVector c);
ComplexVector vectorTripleProduct(ComplexVector a, ComplexVector b, ComplexVector c);
ComplexNumber mean();
ComplexNumber geometricMean();
double norm();
ComplexNumber pNorm(double p);
double normSquared();
void normalize();
void randomize();
void randomizeBoolean();
void randomizeInteger();
ComplexNumber multiply(ComplexVector A, ComplexVector B);
ComplexVector multiply(ComplexVector A, double B);
ComplexVector multiply(double B, ComplexVector A);
ComplexVector add(ComplexVector A, ComplexVector B);
ComplexVector add(ComplexVector A, double B);
ComplexVector subtract(ComplexVector A, ComplexVector B);
ComplexVector subtract(ComplexVector A, double B);
ComplexVector exponent(ComplexVector A, int b);
ComplexVector& operator*=(ComplexVector& rhs);
ComplexVector& operator*=(double x);
ComplexNumber operator*(ComplexVector& rhs);
ComplexVector& operator*(double x);
ComplexVector& operator+=(ComplexVector& rhs);
ComplexVector& operator+=(double x);
ComplexVector& operator+(ComplexVector& rhs);
ComplexVector& operator+(double x);
ComplexVector& operator-=(ComplexVector& rhs);
ComplexVector& operator-=(double x);
ComplexVector& operator-(ComplexVector& rhs);
ComplexVector& operator-(double x);
bool operator==(ComplexVector& B);
friend std::wostream& operator<<(std::wostream& os, ComplexVector& rhs);
/*Quaternion createRotationQuaternion();
Quaternion createRotationQuaternion(std::vector<double> v);*/
double getAngle(ComplexVector A, ComplexVector B);
void sort();
ComplexNumber sum();
ComplexNumber sumSquares();
ComplexNumber vectorScalarProjection(ComplexVector a, ComplexVector b);
ComplexVector unitNormal(ComplexVector a, ComplexVector b);
ComplexMatrix Vandermonde();
ComplexVector directSum(ComplexVector A, ComplexVector B);
ComplexVector tensorProduct(ComplexVector A, ComplexVector B);
/*ComplexNumber populationVariance();
ComplexNumber populationStandardDeviation();
ComplexNumber sampleVariance();
ComplexNumber sampleStandardDeviation();
ComplexNumber standardErrorOfMean();
ComplexNumber covariance(ComplexVector v1, ComplexVector v2);*/
ComplexMatrix outerProduct(ComplexVector v1, ComplexVector v2);
ComplexNumber interiorProduct(ComplexVector a, ComplexVector b);
ComplexNumber exteriorProduct(ComplexVector a, ComplexVector b);
ComplexMatrix toComplexMatrix(int r, int c);
ComplexMatrix toHomogeneousCoordinates();
Quaternion toQuaternion();
DualQuaternion toDualQuaternion();
std::wstring toString();
void display();
};
#endif