You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include "ExtendedVector.hpp"
|
|
|
|
using namespace std;
|
|
|
|
const vector<double> vec1 = {1, 2, 3, 4, 5};
|
|
const vector<double> vec2 = {5, 4, 3, 2, 1};
|
|
|
|
// pretty vector printing
|
|
ostream& operator<<(ostream& os,
|
|
const vector<double>& v) {
|
|
os << "< ";
|
|
for (auto it = v.begin(); it != v.end()-1; ++it) {
|
|
os << *it << ", ";
|
|
}
|
|
os << *v.end() << " > ";
|
|
return os;
|
|
}
|
|
|
|
int main() {
|
|
cout << "Max vec1: " << ExtendedVector::max(vec1) << endl;
|
|
cout << "Max vec2: " << ExtendedVector::max(vec2) << endl;
|
|
|
|
cout << "Beide Vektoren sind jeweils ausschließlich positiven Werten gefüllt: " << (ExtendedVector::allPositive(vec1) && ExtendedVector::allPositive(vec2)) << endl;
|
|
|
|
cout << "Skalarprodukt vec1 x vec2: " << ExtendedVector::product(vec1, vec2) << endl;
|
|
cout << "vec1 * 5: " << ExtendedVector::product(vec1, 5) << endl;
|
|
cout << "Norm von vec1: " << ExtendedVector::norm(vec1) << endl;
|
|
|
|
vector<double> vec_copy;
|
|
copy(vec1.begin(), vec1.end(), back_inserter(vec_copy));
|
|
ExtendedVector::normalise(vec_copy);
|
|
|
|
cout << "Normalisierung von vec1: " << vec_copy << endl;
|
|
return 0;
|
|
}
|