Package stallone.api.doubles

Examples of stallone.api.doubles.IDoubleArray


     * @param time
     * @param data
     */
    public void add(IDoubleArray time, IDoubleArray data)
    {
        IDoubleArray c = correlate(time, data);
        for (int i = 0; i < c.size(); i++)
        {
            if (!Double.isNaN(c.get(i)))
            {
                correlation.set(i, correlation.get(i) + data.size() * c.get(i));
                weights.set(i, weights.get(i) + data.size());
            }
        }

        sum += doubles.sum(data);
View Full Code Here


        sumOfWeights += time.size();
    }

    public IDoubleArray getCorrelation()
    {
        IDoubleArray res = doublesNew.array(correlation.size());
        for (int i = 0; i < res.size(); i++)
        {
            res.set(i, correlation.get(i) / weights.get(i));
        }
        return res;
    }
View Full Code Here

        return res;
    }

    public IDoubleArray getCorrelationMeanFree()
    {
        IDoubleArray res = doublesNew.array(correlation.size());
        double shift = (sum / sumOfWeights) * (sum / sumOfWeights);
        System.out.println("# square mean = "+shift);
        for (int i = 0; i < res.size(); i++)
        {
            res.set(i, (correlation.get(i) / weights.get(i)) - shift);
        }
        return res;
    }
View Full Code Here

        while (lagtimes.get(lagtimes.size() - 1) < maxtime)
        {
            lagtimes.append((int) ((lagtimes.get(lagtimes.size() - 1) + 1) * lagtmult));
        }
        //IDoubleArray lagtimes = doublesNew.arrayFrom(1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000);
        IDoubleArray averageWidths = doublesNew.array(lagtimes.size());
        for (int i = 0; i < averageWidths.size(); i++)
        {
            averageWidths.set(i, 1.0);
            //averageWidths.set(i, Math.max(1.0, windowfraction * lagtimes.get(i)));
            //System.out.println(lagtimes.get(i)+"\t"+averageWidths.get(i));
        }
        //System.out.println();
        //System.exit(0);
        EventBinningCorrelator correlator = new EventBinningCorrelator(lagtimes, averageWidths, samplingtime);


        for (int i = 0; i < inputFiles.size(); i++)
        {
            IDoubleArray time = data.readColumn(inputFiles.get(i), timecol);
            IDoubleArray don = data.readColumn(inputFiles.get(i), col1);
            IDoubleArray acc = data.readColumn(inputFiles.get(i), col2);
            IDoubleArray E = doublesNew.array(don.size());
            for (int j = 0; j < E.size(); j++)
            {
                E.set(j, acc.get(j) / (don.get(j) + acc.get(j)));
            }

            correlator.add(time, E);
        }

        IDoubleArray corr = null;
        if (subtractMean)
        {
            corr = correlator.getCorrelationMeanFree();
        }
        else
        {
            corr = correlator.getCorrelation();
        }


        //IDoubleArray corr = correlator.correlate(time, E);

        for (int i = 0; i < lagtimes.size(); i++)
        {
            System.out.println(lagtimes.get(i) + "\t" + corr.get(i));
        }
    }
View Full Code Here

*/
public class ArrayElementProduct //implements IMatrixSum
{
    public IDoubleArray multiplyToNewDense(final IDoubleArray a, final IDoubleArray b)
    {
        IDoubleArray target = a.copy();
        multiplyDense(a,b,target);
        return target;
    }
View Full Code Here

        return target;
    }

    public IDoubleArray multiplyToNewSparse(final IDoubleArray a, final IDoubleArray b)
    {
        IDoubleArray target = a.copy();
        multiplySparse(a,b,target);
        return target;
    }
View Full Code Here

*/
public class DiscretePotentialMetropolisMarkovChain extends MarkovChain
{
    public DiscretePotentialMetropolisMarkovChain(IGriddedFunction f, double kT)
    {
        IDoubleArray _T = Doubles.create.array(f.size(), f.size());

        for (int i=0; i<f.size(); i++)
        {
            IDoubleArray xi = f.get(i);
            double Ei = f.f(xi);
            IIntArray neighbors = f.getNeighborIndexes(i);

            double psum = 0;

            for (int j=0; j<neighbors.size(); j++)
            {
                int n = neighbors.get(j);
                IDoubleArray xj = f.get(neighbors.get(j));
                double Ej = f.f(xj);
                double pjump = (1.0 / neighbors.size()) * Math.min(1, Math.exp(-(Ej-Ei) / kT));
                psum += pjump;
                _T.set(i, n, pjump);
            }
View Full Code Here

    @Override
    public boolean step()
    {
        model.setCoordinates(x);
        model.calculate();
        IDoubleArray grad = model.getGradient();

        //System.out.println("step, d="+DoubleArrays.norm(x.getAll()));

        for (int i=0; i<x.size(); i++)
        {
            double gm = (gamma*masses.get(i));
            double r = random.nextGaussian();
            //System.out.println(" grad "+i+" "+grad.get(i));
            double dx = -dt * grad.get(i) / gm  + Math.sqrt(2*dt*kT/gm)*r;
            //System.out.println(" dx "+i+" "+dx);
            x.set(i, x.get(i) + dx);
        }

        return(true);
View Full Code Here

*/
public class ArrayTranspose //implements IMatrixTranspose
{
    public IDoubleArray transposeToNew(final IDoubleArray a)
    {
        IDoubleArray res = a.create(a.columns(),a.rows());
        transpose(a,res);
        return res;
    }
View Full Code Here

     * @return The upper triangular decomposition matrix R, or {@code null} if
     * the algorithm fails.
     */
    private IDoubleArray computeDecomposition(IDoubleArray input) {
        int n = input.rows();
        IDoubleArray result = Doubles.create.array(n, n);
        result.zero();

        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                double sum = 0.0;
                for (int k = 0; k < j; k++) {
                    sum += result.get(i, k) * result.get(j, k);
                }
                if (i == j) {
                    result.set(i, i, Math.sqrt(input.get(i, i) - sum));
                } else {
                    result.set(i, j, 1 / result.get(j, j) *
                            (input.get(i, j) - sum));
                }
            }
            if (result.get(i, i) <= 0) {
                result = null;
                break;
            }
        }

View Full Code Here

TOP

Related Classes of stallone.api.doubles.IDoubleArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.