#include "task_4+6.h"
#include "task_5.h"
#include "timing.h"
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

double norm(vector<double> const &x) {
    size_t N = x.size();
    double sum = 0.0;
    for (size_t i = 0; i < N; ++i) {
        sum += x[i] * x[i];
    }
    return sqrt(sum);
}

vector<double> init_norm(size_t N) {
    vector<double> x(N);
    for (size_t i = 0; i < N; ++i) {
        x[i] = i%219 + 1.0;
    }
    return x;
}

void benchmark_norm(vector<double> const &x, size_t NLOOPS) {
    double s(0.0), sum(0.0);
    for (size_t i = 0; i < NLOOPS; ++i) {
        s = norm(x);
        sum += s;
    }
    printf("||x|| = %f\n", sum/NLOOPS);
}