コード例 #1
0
        // VECTOR COPY

        internal override void CopyToUnchecked(VectorStorage <T> target, ExistingData existingData = ExistingData.Clear)
        {
            var sparseTarget = target as SparseVectorStorage <T>;

            if (sparseTarget != null)
            {
                CopyToUnchecked(sparseTarget);
                return;
            }

            // FALL BACK

            if (existingData == ExistingData.Clear)
            {
                target.Clear();
            }

            if (ValueCount != 0)
            {
                for (int i = 0; i < ValueCount; i++)
                {
                    target.At(Indices[i], Values[i]);
                }
            }
        }
コード例 #2
0
        // COLUMN COPY

        internal override void CopySubColumnToUnchecked(VectorStorage <T> target, int columnIndex,
                                                        int sourceRowIndex, int targetRowIndex, int rowCount, ExistingData existingData)
        {
            if (existingData == ExistingData.Clear)
            {
                target.Clear(targetRowIndex, rowCount);
            }

            if (columnIndex >= sourceRowIndex && columnIndex < sourceRowIndex + rowCount && columnIndex < Data.Length)
            {
                target.At(columnIndex - sourceRowIndex + targetRowIndex, Data[columnIndex]);
            }
        }
        // ROW COPY

        internal override void CopySubRowToUnchecked(VectorStorage <T> target, int rowIndex,
                                                     int sourceColumnIndex, int targetColumnIndex, int columnCount, ExistingData existingData)
        {
            if (existingData == ExistingData.Clear)
            {
                target.Clear(targetColumnIndex, columnCount);
            }

            if ((rowIndex >= sourceColumnIndex) && (rowIndex < (sourceColumnIndex + columnCount)) && (rowIndex < Data.Length))
            {
                target.At((rowIndex - sourceColumnIndex) + targetColumnIndex, Data[rowIndex]);
            }
        }
コード例 #4
0
        // COLUMN COPY

        internal override void CopySubColumnToUnchecked(VectorStorage <T> target, int columnIndex,
                                                        int sourceRowIndex, int targetRowIndex, int rowCount,
                                                        bool skipClearing = false)
        {
            if (!skipClearing)
            {
                target.Clear(targetRowIndex, rowCount);
            }

            if (columnIndex >= sourceRowIndex && columnIndex < sourceRowIndex + rowCount && columnIndex < Data.Length)
            {
                target.At(columnIndex - sourceRowIndex + targetRowIndex, Data[columnIndex]);
            }
        }
コード例 #5
0
        // SUB-VECTOR COPY

        internal override void CopySubVectorToUnchecked(VectorStorage <T> target,
                                                        int sourceIndex, int targetIndex, int count,
                                                        ExistingData existingData = ExistingData.Clear)
        {
            var sparseTarget = target as SparseVectorStorage <T>;

            if (sparseTarget != null)
            {
                CopySubVectorToUnchecked(sparseTarget, sourceIndex, targetIndex, count, existingData);
                return;
            }

            // FALL BACK

            var offset = targetIndex - sourceIndex;

            var sourceFirst = Array.BinarySearch(Indices, 0, ValueCount, sourceIndex);
            var sourceLast  = Array.BinarySearch(Indices, 0, ValueCount, sourceIndex + count - 1);

            if (sourceFirst < 0)
            {
                sourceFirst = ~sourceFirst;
            }
            if (sourceLast < 0)
            {
                sourceLast = ~sourceLast - 1;
            }

            if (existingData == ExistingData.Clear)
            {
                target.Clear(targetIndex, count);
            }

            for (int i = sourceFirst; i <= sourceLast; i++)
            {
                target.At(Indices[i] + offset, Values[i]);
            }
        }