Package stallone.api.doubles

Examples of stallone.api.doubles.IDoubleArray


{
    InnerProduct ip = new InnerProduct(true);

    public IDoubleArray multiplyToNew(final IDoubleArray a, final IDoubleArray b)
    {
        IDoubleArray res;
        if (a.isSparse() && b.isSparse())
        {
            res = doublesNew.sparseMatrix(a.rows(), b.columns());
            multiplySparseSparse(a,b,res);
        }
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);
        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) * 1.1));
        }
        //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, 0.1 * lagtimes.get(i));
            //System.out.println(lagtimes.get(i)+"\t"+averageWidths.get(i));
        }
        //System.out.println();

        SmoothedCorrelator correlator = new SmoothedCorrelator(lagtimes, averageWidths);


        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

    }
   
    @Override
    public IDoubleArray transform(IDoubleArray c)
    {
        IDoubleArray res;
        if (order == 1)
            res = doublesNew.array(dimension);
        else
            res = doublesNew.matrix(dim1,dim2);
        transform(c, res);
View Full Code Here

    public IDoubleArray forwardCommittor()
    {
        if (qforward != null)
            return(qforward);

        IDoubleArray U = K.view(notAB.getArray(), notAB.getArray());

        IDoubleArray v = Doubles.create.array(notAB.size());
        for (int i=0; i<v.size(); i++)
            for (int k=0; k<B.size(); k++)
                v.set(i, v.get(i)-K.get(notAB.get(i),B.get(k)));

        IDoubleArray qI = Algebra.util.solve(U, v);

        qforward = Doubles.create.array(K.rows());
        for (int i=0; i<A.size(); i++)
            qforward.set(A.get(i), 0);
        for (int i=0; i<B.size(); i++)
            qforward.set(B.get(i), 1);
        for (int i=0; i<notAB.size(); i++)
            qforward.set(notAB.get(i), qI.get(i));

        return(qforward);
    }
View Full Code Here

            return(qbackward);

        if (pi == null)
            pi = StationaryDistribution.calculate(T);

        IDoubleArray U = Doubles.create.array(notAB.size(),notAB.size());
  for (int i=0; i<U.rows(); i++)
      for (int j=0; j<U.columns(); j++)
    U.set(i,j, pi.get(notAB.get(j)) * K.get(notAB.get(j),notAB.get(i)) / pi.get(notAB.get(i)));

        IDoubleArray v = Doubles.create.array(notAB.size());
        for (int i=0; i<v.size(); i++)
            for (int k=0; k<A.size(); k++)
                v.set(i, v.get(i) - pi.get(A.get(k))*K.get(A.get(k),notAB.get(i)) / pi.get(notAB.get(i)));

        IDoubleArray qI = Algebra.util.solve(U, v);

        qbackward = Doubles.create.array(K.rows());
        for (int i=0; i<A.size(); i++)
            qbackward.set(A.get(i), 1);
        for (int i=0; i<B.size(); i++)
            qbackward.set(B.get(i), 0);
        for (int i=0; i<notAB.size(); i++)
            qbackward.set(notAB.get(i), qI.get(i));

        return(qbackward);
    }
View Full Code Here


    @Override
    public IDoubleIterator iterator()
    {
        IDoubleArray sum = Algebra.util.add(prior, obs);
        IDoubleIterator itElements = sum.iterator();
        return(new PosteriorCountMatrixIterator(this, itElements));
    }
View Full Code Here

    }

    @Override
    public IDoubleIterator nonzeroIterator()
    {
        IDoubleArray sum = Algebra.util.add(prior, obs);
        IDoubleIterator itElements = sum.nonzeroIterator();
        return(new PosteriorCountMatrixIterator(this, itElements));
    }
View Full Code Here

     * Return the Householder vectors.
     *
     * @return  lower trapezoidal matrix whose columns define the reflections
     */
    public IDoubleArray getH() {
        final IDoubleArray X = Doubles.create.array(m, n);

        for (int i = 0; i < m; i++) {

            for (int j = 0; j < n; j++) {

                if (i >= j) {
                    X.set(i, j, qrMatrix.get(i, j));
                } else {
                    X.set(i, j, 0.0d);
                }
            }
        }

        return X;
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.