nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ndarray/BaseSparseNDArrayCOO.java
@Override
    public INDArray get(INDArrayIndex... indexes) {

        sort();

        if (indexes.length == 1 && indexes[0] instanceof NDArrayIndexAll || (indexes.length == 2 && (isRowVector()
                        && indexes[0] instanceof PointIndex && indexes[0].offset() == 0
                        && indexes[1] instanceof NDArrayIndexAll
                        || isColumnVector() && indexes[1] instanceof PointIndex && indexes[0].offset() == 0
                                        && indexes[0] instanceof NDArrayIndexAll)))
            return this;

        indexes = NDArrayIndex.resolve(shapeInfoDataBuffer(), indexes);
        ShapeOffsetResolution resolution = new ShapeOffsetResolution(this);
        resolution.exec(indexes);

        if (indexes.length < 1)
            throw new IllegalStateException("Invalid index found of zero length");

        // FIXME: LONG
        int[] shape = LongUtils.toInts(resolution.getShapes());
        int numSpecifiedIndex = 0;

        for (int i = 0; i < indexes.length; i++)
            if (indexes[i] instanceof SpecifiedIndex)
                numSpecifiedIndex++;

        if (shape != null && numSpecifiedIndex > 0) {
            Generator<List<List<Long>>> gen = SpecifiedIndex.iterateOverSparse(indexes);
            INDArray ret = Nd4j.createSparseCOO(new double[] {}, new int[][] {}, shape);
            int count = 0;
            int maxValue = ArrayUtil.prod(shape());
            while (count < maxValue) {
                try {
                    List<List<Long>> next = gen.next();
                    List<Integer> coordsCombo = new ArrayList<>();
                    List<Integer> cooIdx = new ArrayList<>();
                    for (int i = 0; i < next.size(); i++) {
                        if (next.get(i).size() != 2)
                            throw new IllegalStateException("Illegal entry returned");
                        coordsCombo.add(next.get(i).get(0).intValue());
                        cooIdx.add(next.get(i).get(1).intValue());
                    }
                    count++;

                    /*
                    * if the coordinates are in the original array
                    *   -> add it in the new sparse ndarray
                    * else
                    *   -> do nothing
                    * */
                    int[] idx = Ints.toArray(coordsCombo);
                    if (!isZero(idx)) {
                        double val = getDouble(idx);
                        ret.putScalar(filterOutFixedDimensions(resolution.getFixed(), cooIdx), val);
                    }

                } catch (NoSuchElementException e) {
                    break;
                }
            }

            return ret;
        }

        int numNewAxis = 0;
        for (int i = 0; i < indexes.length; i++)
            if (indexes[i] instanceof NewAxis)
                numNewAxis++;
        if (numNewAxis != 0) {

        }

        INDArray ret = subArray(resolution);
        return ret;
    }
@Override
    public INDArray get(INDArrayIndex... indexes) {

        sort();

        if (indexes.length == 1 && indexes[0] instanceof NDArrayIndexAll || (indexes.length == 2 && (isRowVector()
                        && indexes[0] instanceof PointIndex && indexes[0].offset() == 0
                        && indexes[1] instanceof NDArrayIndexAll
                        || isColumnVector() && indexes[1] instanceof PointIndex && indexes[0].offset() == 0
                                        && indexes[0] instanceof NDArrayIndexAll)))
            return this;

        indexes = NDArrayIndex.resolve(shapeInfoDataBuffer(), indexes);
        ShapeOffsetResolution resolution = new ShapeOffsetResolution(this);
        resolution.exec(indexes);

        if (indexes.length < 1)
            throw new IllegalStateException("Invalid index found of zero length");

        // FIXME: LONG
        int[] shape = LongUtils.toInts(resolution.getShapes());
        int numSpecifiedIndex = 0;

        for (int i = 0; i < indexes.length; i++)
            if (indexes[i] instanceof SpecifiedIndex)
                numSpecifiedIndex++;

        if (shape != null && numSpecifiedIndex > 0) {
            Generator<List<List<Long>>> gen = SpecifiedIndex.iterateOverSparse(indexes);
            INDArray ret = Nd4j.createSparseCOO(new double[] {}, new int[][] {}, shape);
            int count = 0;
            int maxValue = ArrayUtil.prod(shape());
            while (count < maxValue) {
                try {
                    List<List<Long>> next = gen.next();
                    List<Integer> coordsCombo = new ArrayList<>();
                    List<Integer> cooIdx = new ArrayList<>();
                    for (int i = 0; i < next.size(); i++) {
                        if (next.get(i).size() != 2)
                            throw new IllegalStateException("Illegal entry returned");
                        coordsCombo.add(next.get(i).get(0).intValue());
                        cooIdx.add(next.get(i).get(1).intValue());
                    }
                    count++;

                    /*
                    * if the coordinates are in the original array
                    *   -> add it in the new sparse ndarray
                    * else
                    *   -> do nothing
                    * */
                    int[] idx = Ints.toArray(coordsCombo);
                    if (!isZero(idx)) {
                        double val = getDouble(idx);
                        ret.putScalar(filterOutFixedDimensions(resolution.getFixed(), cooIdx), val);
                    }

                } catch (NoSuchElementException e) {
                    break;
                }
            }

            return ret;
        }

        int numNewAxis = 0;
        for (int i = 0; i < indexes.length; i++)
            if (indexes[i] instanceof NewAxis)
                numNewAxis++;
        if (numNewAxis != 0) {

        }

        INDArray ret = subArray(resolution);
        return ret;
    }
@ Override public INDArray get ( INDArrayIndex ... indexes ) { sort ( ) ; if ( indexes . length == 1 && indexes [ 0 ] instanceof NDArrayIndexAll || ( indexes . length == 2 && ( isRowVector ( ) && indexes [ 0 ] instanceof PointIndex && indexes [ 0 ] . offset ( ) == 0 && indexes [ 1 ] instanceof NDArrayIndexAll || isColumnVector ( ) && indexes [ 1 ] instanceof PointIndex && indexes [ 0 ] . offset ( ) == 0 && indexes [ 0 ] instanceof NDArrayIndexAll ) ) ) return this ; indexes = NDArrayIndex . resolve ( shapeInfoDataBuffer ( ) , indexes ) ; ShapeOffsetResolution resolution = new ShapeOffsetResolution ( this ) ; resolution . exec ( indexes ) ; if ( indexes . length < 1 ) throw new IllegalStateException ( "Invalid index found of zero length" ) ; // FIXME: LONG int [ ] shape = LongUtils . toInts ( resolution . getShapes ( ) ) ; int numSpecifiedIndex = 0 ; for ( int i = 0 ; i < indexes . length ; i ++ ) if ( indexes [ i ] instanceof SpecifiedIndex ) numSpecifiedIndex ++ ; if ( shape != null && numSpecifiedIndex > 0 ) { Generator < List < List < Long >>> gen = SpecifiedIndex . iterateOverSparse ( indexes ) ; INDArray ret = Nd4j . createSparseCOO ( new double [ ] { } , new int [ ] [ ] { } , shape ) ; int count = 0 ; int maxValue = ArrayUtil . prod ( shape ( ) ) ; while ( count < maxValue ) { try { List < List < Long >> next = gen . next ( ) ; List < Integer > coordsCombo = new ArrayList <> ( ) ; List < Integer > cooIdx = new ArrayList <> ( ) ; for ( int i = 0 ; i < next . size ( ) ; i ++ ) { if ( next . get ( i ) . size ( ) != 2 ) throw new IllegalStateException ( "Illegal entry returned" ) ; coordsCombo . add ( next . get ( i ) . get ( 0 ) . intValue ( ) ) ; cooIdx . add ( next . get ( i ) . get ( 1 ) . intValue ( ) ) ; } count ++ ; /*
                    * if the coordinates are in the original array
                    *   -> add it in the new sparse ndarray
                    * else
                    *   -> do nothing
                    * */ int [ ] idx = Ints . toArray ( coordsCombo ) ; if ( ! isZero ( idx ) ) { double val = getDouble ( idx ) ; ret . putScalar ( filterOutFixedDimensions ( resolution . getFixed ( ) , cooIdx ) , val ) ; } } catch ( NoSuchElementException e ) { break ; } } return ret ; } int numNewAxis = 0 ; for ( int i = 0 ; i < indexes . length ; i ++ ) if ( indexes [ i ] instanceof NewAxis ) numNewAxis ++ ; if ( numNewAxis != 0 ) { } INDArray ret = subArray ( resolution ) ; return ret ; }
Returns a subset of this array based on the specified
indexes

@param indexes the indexes in to the array
@return a view of the array with the specified indices
Returns a subset of this array based on the specified indexes