// 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]); } }
// SUB-VECTOR COPY internal override void CopySubVectorToUnchecked(VectorStorage <T> target, int sourceIndex, int targetIndex, int count, ExistingData existingData) { 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]); } }