Package stallone.api.doubles

Examples of stallone.api.doubles.IDoubleArray


        System.out.println("rows: " + rows);
        int cols = rows;
        int size = rows*cols;
        ByteBuffer bb = ByteBuffer.allocateDirect(Double.SIZE/8*size);
        ForeignBufferDoubleArray da = new ForeignBufferDoubleArray(bb, rows,cols);
        IDoubleArray d2 = da.create(cols,rows);
        API.doubles.fill(da, 1);
        API.doubles.fill(d2, 2);
        System.out.println("arrays filled");
       
        IDoubleArray da2 = alg.product(da, d2);
        System.out.println("product calculated.\n"+da2);
    }
View Full Code Here


    @Override
    public IDoubleArray gradientX(IDoubleArray x, IDoubleArray y)
    {
        double dxy = distance(x, y);
        IDoubleArray res = x.copy();
        size = res.size();

        if (dxy == 0)
        {
            for (i = 0; i < size; i++)
            {
                res.set(i, 0);
            }
        }
        else
        {
            for (i = 0; i < size; i++)
            {
                res.set(i, (x.get(i) - y.get(i)) / dxy);
            }
        }
        return (res);
    }
View Full Code Here

    @Override
    public IDoubleArray gradientY(IDoubleArray x, IDoubleArray y)
    {
        double dxy = distance(x, y);
        IDoubleArray res = x.copy();

        if (dxy == 0)
        {
            for (i = 0; i < res.size(); i++)
            {
                res.set(i, 0);
            }
        }
        else
        {
            for (i = 0; i < res.size(); i++)
            {
                res.set(i, -(x.get(i) - y.get(i)) / dxy);
            }
        }
        return (res);
    }
View Full Code Here

    }

    @Override
    public IDoubleArray copy()
    {
        IDoubleArray res = data.create(map.rows(), map.columns());
        copyInto(res);
        return (res);
    }
View Full Code Here

            if (rowLength == m.columns())
            {

                // creation should be moved outside
                final IDoubleArray row = m.viewRow(currentMatrixRow);

                for (int j = 0; j < rowLength; j++)
                {
                    final double value = Double.parseDouble(elements[j]);
                    row.set(j, value);
                }
            }
            else
            {
                throw new RuntimeException("Too many or too few entries for matrix in line " + i + " of file.");
View Full Code Here

        int nRows = (Integer.valueOf(str[0].trim())).intValue();
        int nColumns = (Integer.valueOf(str[1].trim())).intValue();
//        int nNonZeros = (Integer.valueOf(str[2].trim())).intValue();

        // now we're into the data section
        IDoubleArray matrix = API.doublesNew.sparseMatrix(nRows, nColumns);
        double x;
        while ((line = br.readLine()) != null)
        {
            str = line.split("( )+");
            int i = (Integer.valueOf(str[0].trim())).intValue();
            int j = (Integer.valueOf(str[1].trim())).intValue();
            if(str.length < 3) // for pattern matrices set a dummy value of 1.
                x = 1;
            else
                x = (Double.valueOf(str[2].trim())).doubleValue();
            matrix.set(i - 1, j - 1, x);
        }

        br.close();
        return matrix;
    }
View Full Code Here

        if (!(o instanceof IDoubleArray))
        {
            return (false);
        }

        IDoubleArray oo = (IDoubleArray) o;

        if (oo.size () != size())
            return false;

        if (oo.rows() != rows())
            return false;

        if (oo.columns() != columns())
            return false;

        for (int i = 0; i < oo.size(); i++)
        {
            if (oo.get(i) != this.get(i))
            {
                return (false);
            }
        }
        return (true);
View Full Code Here

        micro2macro = cluster.discretize(data, assignment);
        // 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

     * @param in
     * @return
     */
    private IDoubleArray getDataView(IDoubleArray in)
    {
        IDoubleArray view = in.view(selectedRows, selectedColumns);
        return view;
    }
View Full Code Here

    }

    @Override
    public IDoubleArray next()
    {
        IDoubleArray res = reader.get(index);
        index++;
        return (res);
    }
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.