Finished assignment 4.1

main
Isabell Pflug 2 years ago
parent 8d4dba445e
commit f2a04aba27

@ -0,0 +1,37 @@
#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;
}
Loading…
Cancel
Save