nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ndarray/BaseSparseNDArrayCOO.java
private int[] updateFlags(int[] viewFlags, int[] newShape) {
        // Check if flags is well-formed
        int count = 0;
        for (int i = 0; i < viewFlags.length; i++) {
            if (viewFlags[i] == 0) {
                count++;
            }
        }

        for (int dim = 0; dim < viewFlags.length; dim++) {
            if (viewFlags[dim] == 1) {
                if (newShape[dim] == 1 && count < 2) {
                    viewFlags[dim] = 0;
                }

            }
        }
        // Take the original Fixed into account
        int[] extendedFlags = new int[underlyingRank()];
        int notFixedDim = 0;
        for (int dim = 0; dim < underlyingRank(); dim++) {
            int[] temp = flags();
            if (flags()[dim] == 0) {
                extendedFlags[dim] = viewFlags[notFixedDim];
                notFixedDim++;
            } else {
                extendedFlags[dim] = 1;
            }
        }
        return extendedFlags;
    }
private int[] updateFlags(int[] viewFlags, int[] newShape) {
        // Check if flags is well-formed
        int count = 0;
        for (int i = 0; i < viewFlags.length; i++) {
            if (viewFlags[i] == 0) {
                count++;
            }
        }

        for (int dim = 0; dim < viewFlags.length; dim++) {
            if (viewFlags[dim] == 1) {
                if (newShape[dim] == 1 && count < 2) {
                    viewFlags[dim] = 0;
                }

            }
        }
        // Take the original Fixed into account
        int[] extendedFlags = new int[underlyingRank()];
        int notFixedDim = 0;
        for (int dim = 0; dim < underlyingRank(); dim++) {
            int[] temp = flags();
            if (flags()[dim] == 0) {
                extendedFlags[dim] = viewFlags[notFixedDim];
                notFixedDim++;
            } else {
                extendedFlags[dim] = 1;
            }
        }
        return extendedFlags;
    }
private int [ ] updateFlags ( int [ ] viewFlags , int [ ] newShape ) { // Check if flags is well-formed int count = 0 ; for ( int i = 0 ; i < viewFlags . length ; i ++ ) { if ( viewFlags [ i ] == 0 ) { count ++ ; } } for ( int dim = 0 ; dim < viewFlags . length ; dim ++ ) { if ( viewFlags [ dim ] == 1 ) { if ( newShape [ dim ] == 1 && count < 2 ) { viewFlags [ dim ] = 0 ; } } } // Take the original Fixed into account int [ ] extendedFlags = new int [ underlyingRank ( ) ] ; int notFixedDim = 0 ; for ( int dim = 0 ; dim < underlyingRank ( ) ; dim ++ ) { int [ ] temp = flags ( ) ; if ( flags ( ) [ dim ] == 0 ) { extendedFlags [ dim ] = viewFlags [ notFixedDim ] ; notFixedDim ++ ; } else { extendedFlags [ dim ] = 1 ; } } return extendedFlags ; }
Adjust the flags array according on the current context:
- In case of a vector or a scalar, we need to keep flags to 0
- There must always be at least 2 non-flags dimensions
- We must keep the flags dimensions of the original array

@param viewFlags the Fixed array calculate within the view
@param newShape the shape of the view
Adjust the flags array according on the current context : - In case of a vector or a scalar we need to keep flags to 0 - There must always be at least 2 non - flags dimensions - We must keep the flags dimensions of the original array