/// <summary> /// Subarray from this array /// </summary> /// <param name="range"> strings specifying the ranges to create subarray from</param> /// <returns>subarray as specified</returns> public override ILBaseArray <BaseT> Subarray(params string [] range) { if (range == null) { return(ShiftDimensions(0)); } ILRange rng = new ILRange(m_dimensions, RangeSide.Right, range); if (rng.NumberOfElements == 0) { return(ILArray <BaseT> .empty(0, 0)); } return(CreatePhysicalSubarrayFromPhysical(rng)); }
/// <summary> /// Subarray from this ILArray + dimension shift /// </summary> /// <param name="range"> arrays specifying the ranges to create subarray from</param> /// <param name="shift"> Number of dimensions to shift the result.</param> /// <returns>shifted subarray as specified</returns> public override ILBaseArray <BaseT> Subarray(int shift, ILBaseArray[] range) { if (shift == 0) { return(Subarray(range)); } if (range.Length == 0) { return(ILArray <BaseT> .empty(0, 0)); } else if (range.Length == 1) { #region sequential indices access if (range[0] is ILArray <double> ) { return(CreatePhysicalSubarrayFromPhysicalSequentialShifted((ILArray <double>)range[0], shift)); } else if (range[0] is ILLogicalArray) { return(CreatePhysicalSubarrayFromPhysicalSequentialShifted(ILNumerics.BuiltInFunctions.ILMath.find((ILLogicalArray)range[0]), shift)); } else if (range[0] is ILArray <complex> ) { return(CreatePhysicalSubarrayFromPhysicalSequentialShifted((ILArray <complex>)range[0], shift)); } else if (range[0] is ILArray <byte> ) { return(CreatePhysicalSubarrayFromPhysicalSequentialShifted((ILArray <byte>)range[0], shift)); } else { throw new ILArgumentException("specified type of indices array is not supported for sequential addressing!"); } #endregion sequential index access } else { ILRange rng = new ILRange(m_dimensions, RangeSide.Right, range); if (rng.NumberOfElements == 0) { return(ILArray <BaseT> .empty(0, 0)); } return(CreatePhysicalSubarrayFromPhysicalShifted((short)shift, rng)); } }
/// <summary> /// Subarray from this array /// </summary> /// <param name="range">Strings specifying the ranges to create subarray from</param> /// <returns>subarray as specified</returns> public ILBaseArray <BaseT> SubarrayPython(params object[] range) { if (range is ILBaseArray[]) { return(Subarray(range as ILBaseArray[])); } if (range == null) { return(ShiftDimensions(0)); } ILRange rng = new ILRange(m_dimensions, RangeSide.Right, range); if (rng.NumberOfElements == 0) { return(ILArray <BaseT> .empty(0, 0)); } if (rng.nonSingletonDimensions >= MinimumRefDimensions) { // create reference if (IsReference) { return(CreateReferenceSubarrayFromReference(rng)); } else { return(CreateReferenceSubarrayFromPhysical(rng)); } } else { // create physical if (IsReference) { return(CreatePhysicalSubarrayFromReference(rng)); } else { return(CreatePhysicalSubarrayFromPhysical(rng)); } } }