internal void CheckCellType(CCellTypeEnum aCellTypeEnum) { if (aCellTypeEnum != this.CellTypeEnum) { throw new InvalidOperationException("CellTypeEnum missmatch."); } }
public void ReallocateInternal(int aSize, CCellTypeEnum aCellTypeEnum, int aDimensionCount, int[] aDimensionSizes, int[] aStrides, int aPlaneCount) { var aByteCount = aDimensionCount == 0 ? 0 : aStrides[aDimensionCount - 1] * aDimensionSizes[aDimensionCount - 1] ; if (aSize != aByteCount) { throw new ArgumentException("Size does not match DimensionSizes/Stride"); } else { var aCellSize = GetCellSize(aCellTypeEnum); if (aByteCount != this.ByteCount) { this.Buffer = new byte[aByteCount]; } else { for (var aIdx = 0; aIdx < aByteCount; ++aIdx) { this.Buffer[aIdx] = 0; } } this.CellTypeEnum = aCellTypeEnum; this.DimensionCountM = aDimensionCount; this.DimensionSizesM = aDimensionSizes; this.DimensionStridesM = aStrides; this.PlaneCountM = aPlaneCount; this.CellSize = aCellSize; } }
public void Reallocate(CCellTypeEnum aCellTypeEnum, int aDimensionCount, int[] aDimensionSizes, int aPlaneCount) { var aStrides = new int[aDimensionCount]; var aStride = aPlaneCount * GetCellSize(aCellTypeEnum); aStrides[0] = aStride; for (var aIdx = 1; aIdx < aDimensionCount; ++aIdx) { aStride = aStride * aDimensionSizes[aIdx]; aStrides[aIdx] = aStride; } var aSize = aStrides[aDimensionCount - 1] * aDimensionSizes[aDimensionCount - 1]; this.Reallocate(aSize, aCellTypeEnum, aDimensionCount, aDimensionSizes, aStrides, aPlaneCount); }
public static int GetCellSize(CCellTypeEnum aCellTypeEnum) { switch (aCellTypeEnum) { case CCellTypeEnum.Char: return(1); case CCellTypeEnum.Float32: return(4); case CCellTypeEnum.Float64: return(8); case CCellTypeEnum.Long: return(4); default: throw new ArgumentException("CellTypeEnum missmatch."); } }
public void Reallocate(int aSize, CCellTypeEnum aCellTypeEnum, int aDimensionCount, int[] aDimensionSizes, int[] aStrides, int aPlaneCount) { this.CheckWrite(); this.ReallocateInternal(aSize, aCellTypeEnum, aDimensionCount, aDimensionSizes, aStrides, aPlaneCount); }