Java AtomicReference expandSplineRoots(int n)

Here you can find the source of expandSplineRoots(int n)

Description

expand Spline Roots

License

Open Source License

Declaration

private static synchronized void expandSplineRoots(int n) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.atomic.AtomicReference;

public class Main {
    /**//from w  w  w  . ja v a2s  . c  om
     * The spline coefficient cache
     */
    private final static AtomicReference<float[][][]> coeffRoot = new AtomicReference<float[][][]>();

    private static synchronized void expandSplineRoots(int n) {
        float[][][] oldRoot = coeffRoot.get();
        if (oldRoot != null && oldRoot.length > n) {
            return;
        }

        float[][][] newRoot = new float[n + 1][][];

        // Coefficient for zeroth order spline
        newRoot[0] = new float[][] { { 1.0F } };

        // Compute coefficients for each spline order based on the coefficients from the previous order
        for (int o = 1; o < n + 1; o++) {
            newRoot[o] = new float[o + 1][o + 1];
            for (int i = 0; i < o; i++) {
                for (int p = 0; p < o; p++) {
                    newRoot[o][i][p + 1] += newRoot[o - 1][i][p] / (p + 1);
                    newRoot[o][i + 1][p + 1] -= newRoot[o - 1][i][p] / (p + 1);
                    newRoot[o][i + 1][0] += newRoot[o - 1][i][p] / (p + 1);
                }
            }
        }

        coeffRoot.set(newRoot);
    }
}

Related

  1. addParameter(final String key, final String value, final StringBuilder url, final AtomicReference thisSeparator, final String nextSeparator)
  2. addThrowable(AtomicReferenceFieldUpdater field, T instance, Throwable exception)
  3. asList(AtomicReferenceArray a)
  4. cancel(Future future, boolean mayInterruptIfRunning)
  5. cancelAll(Future[] futures, boolean mayInterruptIfRunning)
  6. getDefaultBaseUri()
  7. getIdentityName(final String identityType, final String displayName, final String attribute, final String attribute2, final int uniqueUserID, final AtomicReference outResolvableName, final AtomicReference outDisplayableName)
  8. getSplineCoefficients(int n, float x)
  9. isTerminated(AtomicReference field)