Examples of IRectangularArea


Examples of net.algart.math.IRectangularArea

                maxTileDim[k] = Math.min(dim[k], processingTileDim[k]);
                // so, there is a guarantee that maxTileDim are allowed matrix dimensions
                tileCount *= tileCounts[k]; // overflow impossible, because tileCounts[k] <= dim[k]
            }
            final int nt = (int)Math.min(numberOfTasks, tileCount);
            final IRectangularArea maxAperture = maxDependenceAperture(srcCopy.keySet());
            DependenceApertureBuilder.extendDimensions(dim, maxAperture); // overflow check before any calculations
            long maxExtTileSize = Arrays.longMul(DependenceApertureBuilder.extendDimensions(maxTileDim, maxAperture));
            double estimatedMemory = estimateWorkMemory(maxExtTileSize, destCopy.values(), srcCopy.values(), nt);
            MemoryModel betterModel = estimatedMemory < maxTempJavaMemory ? Arrays.SMM : memoryModel();
            final List<Map<K, UpdatableArray>> srcTileMem = allocateTile(betterModel, maxExtTileSize, srcCopy, nt);
            final List<Map<K, UpdatableArray>> destTileMem = allocateTile(betterModel, maxExtTileSize, destCopy, nt);

            final Matrix<?> enumerator = Matrices.matrix(Arrays.nIntCopies(tileCount, 157), tileCounts);
            // - this trivial virtual matrix is a simplest way to enumerate all tiles
            ArrayContext context = this.context(); // maybe, already not a context of TilingProcessorFactory!
            if (nt > 1) {
                context = context == null ? ArrayContext.DEFAULT_SINGLE_THREAD : context.singleThreadVersion();
            } else if (context == null) {
                context = ArrayContext.DEFAULT;
            }
            Runnable[] tasks = new Runnable[nt];
            Runnable[] postprocessing = new Runnable[nt]; // non-parallel
            long readyElementsCount = 0;
            int taskIndex = 0;
//            System.out.println("Number of tasks/tiles: " + nt + "/" + tileCount + ", " + maxAperture + "; "
//                + src.size() + " arguments and " + dest.size() + " results " + JArrays.toString(dim, "x", 1000));
            for (long tileIndex = 0; tileIndex < tileCount; tileIndex++) {
                long[] tileIndexes = enumerator.coordinates(tileIndex, null);
                final long[] tilePos = new long[dimCount];
                final long[] tileDim = new long[dimCount];
                final long[] tileMax = new long[dimCount];
                final long[] extTilePos = new long[dimCount];
                final long[] extTileDim = new long[dimCount];
                final long[] extTileMax = new long[dimCount];
                long tileSize = 1;
                for (int k = 0; k < dimCount; k++) {
                    tilePos[k] = tileIndexes[k] * processingTileDim[k];
                    assert tilePos[k] < dim[k];
                    tileDim[k] = Math.min(processingTileDim[k], dim[k] - tilePos[k]); // exclusive
                    assert tileDim[k] > 0; // because processingTileDim[k] > 0: checked in the constructor
                    tileMax[k] = tilePos[k] + tileDim[k] - 1;
                    extTileDim[k] = DependenceApertureBuilder.safelyAdd(tileDim[k], maxAperture.width(k));
                    extTilePos[k] = tilePos[k] + maxAperture.min(k);
                    extTileMax[k] = tileMax[k] + maxAperture.max(k);
                    tileSize *= tileDim[k];
                }
                final ArrayContext ac =
                    nt == 1 ?
                        context.part(readyElementsCount, readyElementsCount + tileSize, matrixSize) :
View Full Code Here

Examples of net.algart.math.IRectangularArea

        private IRectangularArea maxDependenceAperture(Set<K> srcKeys) {
            long[] min = new long[dimCount]; // zero-filled by Java
            long[] max = new long[dimCount]; // zero-filled by Java
            for (K key : srcKeys) {
                IRectangularArea a = oneTileProcessor.dependenceAperture(key);
                for (int k = 0; k < dimCount; k++) {
                    min[k] = Math.min(min[k], a.min(k));
                    max[k] = Math.max(max[k], a.max(k));
                }
            }
            return IRectangularArea.valueOf(IPoint.valueOf(min), IPoint.valueOf(max));
        }
View Full Code Here

Examples of net.algart.math.IRectangularArea

            long[] preciseTilePos = new long[dimCount];
            int i = 0, n = src.size();
            for (Map.Entry<K, Matrix<?>> e : src.entrySet()) {
                K key = e.getKey();
                Matrix<UpdatableArray> tileMatrix = Matrices.matrix(srcTileMem.get(key).subArr(0, len), extTileDim);
                IRectangularArea a = oneTileProcessor.dependenceAperture(key);
                assert a != null : "Null dependenceAperture(" + key + ")";
                for (int k = 0; k < dimCount; k++) {
                    inTilePos[k] = a.min(k) - maxAperture.min(k);
                    preciseTilePos[k] = tilePos[k] + a.min(k);
                    preciseTileDim[k] = DependenceApertureBuilder.safelyAdd(tileDim[k], a.width(k));
                }
                Matrices.copy(ac.part(i, ++i, n),
                    tileMatrix.subMatr(inTilePos, preciseTileDim),
                    e.getValue().subMatr(preciseTilePos, preciseTileDim, continuationMode));
                srcTile.put(key, tileMatrix);
View Full Code Here

Examples of net.algart.math.IRectangularArea

        if (additionalMatrices == null)
            throw new NullPointerException("Null additionalMatrices argument");
        additionalMatrices = new ArrayList<Matrix<? extends PArray>>(additionalMatrices);
        // - to avoid changing by parallel threads
        checkArguments(src, src, additionalMatrices, pattern);
        IRectangularArea a = DependenceApertureBuilder.SUM_MAX_0.getAperture(src.dimCount(), pattern, false);
        // SUM_MAX_0 can be necessary if the parent processor is not pseudo-cyclic
        Matrix<? extends PArray> continued = DependenceApertureBuilder.extend(src, a, continuationMode);
        additionalMatrices = extendAdditionalMatrices(additionalMatrices, a);
        Matrix<T> parentResult = parent.asProcessed(requiredType, continued, additionalMatrices, pattern);
        return DependenceApertureBuilder.reduce(parentResult, a);
View Full Code Here

Examples of net.algart.math.IRectangularArea

        if (additionalMatrices == null)
            throw new NullPointerException("Null additionalMatrices argument");
        additionalMatrices = new ArrayList<Matrix<? extends PArray>>(additionalMatrices);
        // - to avoid changing by parallel threads
        checkArguments(dest, src, additionalMatrices, pattern);
        IRectangularArea a = DependenceApertureBuilder.SUM_MAX_0.getAperture(src.dimCount(), pattern, false);
        // SUM_MAX_0: including the origin is necessary while extending the destination matrix
        Matrix<? extends PArray> continued = DependenceApertureBuilder.extend(src, a, continuationMode);
        additionalMatrices = extendAdditionalMatrices(additionalMatrices, a);
        Matrix<? extends UpdatablePArray> continuedDest = DependenceApertureBuilder.extend(dest, a,
            Matrix.ContinuationMode.ZERO_CONSTANT);
View Full Code Here

Examples of net.algart.math.IRectangularArea

    public double increment(Class<?> elementType) {
        return parent.increment(elementType);
    }

    public Matrix<? extends PArray> asConvolution(Matrix<? extends PArray> src, WeightedPattern pattern) {
        IRectangularArea a = (parent.isPseudoCyclic() ? SUM : SUM_MAX_0).getAperture(src.dimCount(), pattern, false);
        src = DependenceApertureBuilder.extend(src, a, tiler.continuationMode());
        return DependenceApertureBuilder.reduce(parent.asConvolution(src, pattern), a);
    }
View Full Code Here

Examples of net.algart.math.IRectangularArea

    }

    public <T extends PArray> Matrix<T> asConvolution(Class<? extends T> requiredType,
        Matrix<? extends PArray> src, WeightedPattern pattern)
    {
        IRectangularArea a = (parent.isPseudoCyclic() ? SUM : SUM_MAX_0).getAperture(src.dimCount(), pattern, false);
        src = DependenceApertureBuilder.extend(src, a, tiler.continuationMode());
        return DependenceApertureBuilder.reduce(parent.asConvolution(requiredType, src, pattern), a);
    }
View Full Code Here

Examples of net.algart.math.IRectangularArea

               SUM         ==> SUM,,SUM,,SUM,,
                               SUM_MAX_0,,SUM_MAX_0,,MAX;;
               (extends\s+PArray)(?!>\s+src) ==> $1,,extends UpdatablePArray,,...
    */
    public Matrix<? extends PArray> asDilation(Matrix<? extends PArray> src, Pattern pattern) {
        IRectangularArea a = SUM.getAperture(src.dimCount(), pattern, false);
        return reduce(parent.asDilation(extend(src, a), pattern), a);
    }
View Full Code Here

Examples of net.algart.math.IRectangularArea

        IRectangularArea a = SUM.getAperture(src.dimCount(), pattern, false);
        return reduce(parent.asDilation(extend(src, a), pattern), a);
    }
    /*Repeat.AutoGeneratedStart !! Auto-generated: NOT EDIT !! */
    public Matrix<? extends PArray> asErosion(Matrix<? extends PArray> src, Pattern pattern) {
        IRectangularArea a = SUM.getAperture(src.dimCount(), pattern, true);
        return reduce(parent.asErosion(extend(src, a), pattern), a);
    }
View Full Code Here

Examples of net.algart.math.IRectangularArea

        IRectangularArea a = SUM.getAperture(src.dimCount(), pattern, true);
        return reduce(parent.asErosion(extend(src, a), pattern), a);
    }

    public Matrix<? extends UpdatablePArray> dilation(Matrix<? extends PArray> src, Pattern pattern) {
        IRectangularArea a = SUM.getAperture(src.dimCount(), pattern, false);
        return reduce(parent.dilation(extend(src, a), pattern), a);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.