-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.cpp
More file actions
66 lines (51 loc) · 1.81 KB
/
Copy pathutils.cpp
File metadata and controls
66 lines (51 loc) · 1.81 KB
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
#include "utils.h"
// template <typename T>
// void inplace_reorder_vector(std::vector<T>& vector, std::vector<size_t>& order) {
// std::vector<T> temp(vector.size());
// for (size_t i = 0; i < order.size(); ++i)
// temp[i] = vector[order[i]];
// vector.swap(temp);
// }
// template <typename T>
// std::vector<size_t> sort_indexes(const std::vector<T> &v, bool reverse) {
// // initialize original index locations
// std::vector<size_t> idx(v.size());
// std::iota(idx.begin(), idx.end(), 0);
// // sort indexes based on comparing values in v
// // using std::stable_sort instead of std::sort
// // to avoid unnecessary index re-orderings
// // when v contains elements of equal values
// std::stable_sort(idx.begin(), idx.end(),
// [&v](size_t i1, size_t i2) {return v[i1] < v[i2];});
// if (reverse)
// std::reverse(idx.begin(), idx.end());
// return idx;
// }
// double dydx(double x, double y)
// {
// return((x - y)/2);
// }
// //https://www.geeksforgeeks.org/runge-kutta-4th-order-method-solve-differential-equation/
// double rungeKutta(double x0, double y0, double x, double h)
// {
// // Count number of iterations using step size or
// // step height h
// int n = (int)((x - x0) / h);
// double k1, k2, k3, k4;
// // Iterate for number of iterations
// double y = y0;
// for (int i=1; i<=n; i++)
// {
// // Apply Runge Kutta Formulas to find
// // next value of y
// k1 = h * dydx(x0, y);
// k2 = h * dydx(x0 + 0.5*h, y + 0.5*k1);
// k3 = h * dydx(x0 + 0.5*h, y + 0.5*k2);
// k4 = h * dydx(x0 + h, y + k3);
// // Update next value of y
// y = y + (1.0/6.0)*(k1 + 2*k2 + 2*k3 + k4);
// // Update next value of x
// x0 = x0 + h;
// }
// return y;
// }