25package umontreal.ssj.util;
48 double[] U =
new double[n];
49 double[] V =
new double[n];
55 for (
int i = 0; i < n; i++) {
91 for (
int i = 0; i < n; i++) {
122 med = (med + y) / 2.0;
140 med = (med + y) / 2.0;
175 throw new IllegalArgumentException(
"The starting index must not be negative");
178 throw new IllegalArgumentException(
"The ending index must be greater than or equal to the starting index");
179 if (t < times[start])
186 int mid = (start + end) / 2;
190 while (t < times[mid] || t >= times[mid + 1]) {
193 throw new IllegalStateException();
200 mid = (start + end) / 2;
221 public static void interpol(
int n,
double[] X,
double[] Y,
double[] C) {
224 for (j = 0; j <= n; ++j)
226 for (
int i = 1; i <= n; ++i)
227 for (j = n; j >= i; --j) {
228 if (X[j] == X[j - i])
231 C[j] = (C[j] - C[j - 1]) / (X[j] - X[j - i]);
248 public static double evalPoly(
int n,
double[] X,
double[] C,
double z) {
250 for (
int j = n - 1; j >= 0; --j)
251 v = v * (z - X[j]) + C[j];
266 public static double evalPoly(
double[] C,
int n,
double x) {
268 for (
int j = n - 1; j >= 0; --j)
static double evalPoly(double[] C, int n, double x)
Evaluates the polynomial of degree with coefficients C[j] at :
static int quickSelect(int[] A, int n, int k)
Returns the smallest item of the array of size.
static double quickSelect(double[] A, int n, int k)
Returns the smallest item of the array of size.
static void interpol(int n, double[] X, double[] Y, double[] C)
Computes the Newton interpolating polynomial.
static double evalPoly(int n, double[] X, double[] C, double z)
Given , and as described in interpol(n, X, Y, C), this function returns the value of the interpolat...
static int getTimeInterval(double[] times, int start, int end, double t)
Returns the index of the time interval corresponding to time t.
static double getMedian(int[] A, int n)
Returns the median of the first elements of array .
static double getMedian(double[] A, int n)
Returns the median of the first elements of array .