Utils.h
#pragma once class Utils { public: static double* array_diff(double*A,double B[],int n); static double* array_multiplication(double*A, double B[], int n); static double array_sum(double*A, int n); static double* array_pow(double*A, int m, int n); };
Utils.cpp
#include "Utils.h" #include "math.h" double* Utils::array_diff(double*A, double B[], int n) { double *diff = new double[n]; for (int i = 0; i < n; i++) { diff[i] = A[i]-B[i]; } return diff; } double* Utils::array_multiplication(double*A, double B[], int n) { double *mul = new double[n]; for (int i = 0; i < n; i++) { mul[i] = A[i] * B[i]; } return mul; } double Utils::array_sum(double*A, int n) { double sum = 0; for (int i = 0; i < n; i++) { sum = sum + A[i]; } return sum; } double* Utils::array_pow(double*A, int m, int n) { double* sqt = new double[m]; for (int i = 0; i < m; i++) { sqt[i] = pow(A[i], n); } return sqt; }