Package stallone.api.ints

Examples of stallone.api.ints.IIntArray


    /**
       Drop all entries starting with the given pattern
    */
    public static String[] dropLeading(String[] arr, String pattern)
    {
  IIntArray droplist = Ints.create.array(0);
  for (int i=0; i<arr.length; i++)
      if (arr[i].startsWith(pattern))
    droplist = Ints.util.mergeToNew(droplist, i);
  return(drop(arr, droplist));
    }
View Full Code Here


                C = alg.addWeightedToNew(0.5, C, 0.5, alg.transposeToNew(C));
            }

            if (arg.hasCommand("subset"))
            {
                IIntArray S = intseq.loadIntSequence(arg.getArgument("subset"));
                C = C.view(S.getArray(), S.getArray());
            }

            doubles.writeMatrixSparse(C, System.out);
        }
        if (arg.hasCommand("submatrix"))
        {
            IDoubleArray C = doublesNew.fromFile(arg.getArgument("submatrix", 0));
            IIntArray S = intseq.loadIntSequence(arg.getArgument("submatrix", 1));
            C = C.view(S.getArray(), S.getArray());
            doubles.writeMatrixSparse(C, System.out);
        }
        if (arg.hasCommand("populousSet"))
        {
            IDoubleArray C = doublesNew.fromFile(arg.getArgument("populousSet", 0));
            int n = C.rows();
            double minCount = arg.getIntArgument("populousSet",1);
            double minIn = arg.getIntArgument("populousSet",2);
            double minOut = arg.getIntArgument("populousSet",3);

            IDoubleArray counts = alg.rowSums(C);
            IDoubleArray ins = alg.columnSums(C);
            IDoubleArray outs = alg.rowSums(C);
            for (int i=0; i<n; i++)
            {
                ins.set(i,i, ins.get(i,i)-C.get(i,i));
                outs.set(i,i, outs.get(i,i)-C.get(i,i));
            }

            IIntArray iC = doubles.largeValueIndexes(counts, minCount);
            IIntArray iI = doubles.largeValueIndexes(ins, minIn);
            IIntArray iO = doubles.largeValueIndexes(outs, minOut);
            IIntArray I = ints.intersectionToNew(ints.intersectionToNew(iC, iI), iO);
            ints.print(I,"\n");
        }
    }
View Full Code Here

        // define leaves
        int nClusters = _clusterMethodFull.getNumberOfClusters();
        for (int i=0; i<nClusters; i++)
        {
            IDoubleArray leafCenter = centers.get(i);
            IIntArray leafIndexes = ints.findAll(micro2macro, i);
            leaves.add(new Leaf(leafIndexes));
        }
    }
View Full Code Here

        //System.out.println("Reassignment table: "+IntArrays.toString(reassign));

        // assignment
        IDiscretization assignment = this.clusterMethodLeaves.getClusterAssignment();
        IDataSequence centers = this.clusterMethodLeaves.getClusterCenters();
        IIntArray micro2macroLeaf = cluster.discretize(subset, assignment);
        // update global assignment
        for (int i=0; i<leaf.indexes.size(); i++)
        {
            int globalIndex = leaf.indexes.get(i);
            int newClusterIndex = reassign[micro2macroLeaf.get(i)];
            micro2macroNew.set(globalIndex, newClusterIndex);
        }
        // create new leaves
        IIntArray[] newLeaveIndexes = new IIntArray[nPieces];
        for (int i=0; i<nPieces; i++)
View Full Code Here

        micro2macroNew = micro2macro.copy();
        leavesNew = (ArrayList<Leaf>)leaves.clone();

        // start splitting
        boolean couldsplit = false;
        IIntArray I = ints.sortedIndexes(leafIndexes);
        for (int i=I.size()-1; i>=0; i--)
        {
            int splitIndex = leafIndexes.get(I.get(i));
            if (split(splitIndex))
                couldsplit = true;
        }
        return couldsplit;
    }
View Full Code Here

        leavesNew.add(newLeaf);

        // refresh assignment
        for (int s=0; s<leavesNew.size(); s++)
        {
            IIntArray I = leavesNew.get(s).indexes;
            for (int i=0; i<I.size(); i++)
                micro2macroNew.set(I.get(i), s);
        }
    }
View Full Code Here

        System.out.println("Strong Components: "+I.length);
        System.out.println("Lengths: "+intArrays.toString(I,", "));
        System.out.println("members: ");
        for (int i=0; i<I.length; i++)
        {
            IIntArray c = components.get(I[i]);
            System.out.println(ints.toString(c)+" ");
        }
       
        if (arg.hasCommand("oGiant"))
        {
View Full Code Here

    public IDiscretization regularSelectionDiscretization(IDataSequence data,
        IMetric<IDoubleArray> metric, int k)
    {
        DataList clusterCenters = new DataList(k);
        IIntArray indexes = Ints.create.arrayRange(0, data.size(), data.size() / k);
        for (int i = 0; i < indexes.size(); i++)
        {
            clusterCenters.set(i, data.get(indexes.get(i)));
        }
        VoronoiDiscretization vd = new VoronoiDiscretization(clusterCenters, metric);
        return (vd);
    }
View Full Code Here

    public IDiscretization randomSelectionDiscretization(IDataSequence data,
        IMetric<IDoubleArray> metric, int k)
    {
        DataList clusterCenters = new DataList(k);
        IIntArray indexes = Ints.create.arrayRandomIndexes(data.size(), k);
        for (int i = 0; i < indexes.size(); i++)
        {
            clusterCenters.add(data.get(indexes.get(i)));
        }

        VoronoiDiscretization vd = new VoronoiDiscretization(clusterCenters, metric);
        return (vd);
    }
View Full Code Here

        return (perform(clusterNew.densitybased(data,N)));
    }

    public IIntArray discretize(IDataSequence data, IDiscretization disc)
    {
        IIntArray res = Ints.create.array(data.size());
        for (int i=0; i<data.size(); i++)
        {
            res.set(i, disc.assign(data.get(i)));
        }
        return(res);
    }
View Full Code Here

TOP

Related Classes of stallone.api.ints.IIntArray

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.