// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! /// <summary> /// operate on elements of both storages by the given function -> relational operations /// </summary> /// <param name="inArray1">First storage array</param> /// <param name="inArray2">Second storage array</param> /// <param name="operation">operation to apply to the elements of inArray. This /// acts like a function pointer.</param> /// <returns><![CDATA[ ILArray<complex> ]]> with result of operation for corresponding /// elements of both arrays.</returns> /// <remarks>The values of inArray1 nor inArray2 will not be altered.The dimensions /// of both arrays must match.</remarks> private static ILArray <complex> ComplexOperatorComplexComplex(ILArray <complex> inArray1, ILArray <complex> inArray2, ILComplexFunctionComplexComplex operation) { ILDimension inDim = inArray1.Dimensions; if (!inDim.IsSameSize(inArray2.Dimensions)) { throw new ILDimensionMismatchException(); } complex [] retSystemArr; // build ILDimension int newLength = inDim.NumberOfElements; retSystemArr = new complex [newLength]; int leadDimLen = inDim [0]; // physical -> pointer arithmetic unsafe { fixed(complex *pInArr1 = inArray1.m_data) fixed(complex * pInArr2 = inArray2.m_data) fixed(complex * pOutArr = retSystemArr) { complex *poutarr = pOutArr; complex *poutend = poutarr + newLength; complex *pIn1 = pInArr1; complex *pIn2 = pInArr2; while (poutarr < poutend) { *poutarr++ = operation(*pIn1++, *pIn2++); } } } return(new ILArray <complex> (retSystemArr, inDim.ToIntArray())); }
internal opcomplex_complex ( complex parameter, ILComplexFunctionComplexComplex applyFunc) { m_parameter = parameter; m_applyFun = applyFunc; }
internal opcomplex_complex(complex parameter, ILComplexFunctionComplexComplex applyFunc) { m_parameter = parameter; m_applyFun = applyFunc; }
/// <summary> /// operate on elements of both storages by the given function -> relational operations /// </summary> /// <param name="inArray1">First storage array</param> /// <param name="inArray2">Second storage array</param> /// <param name="operation">operation to apply to the elements of inArray. This /// acts like a function pointer.</param> /// <returns><![CDATA[ ILArray<complex> ]]> with result of operation for corresponding /// elements of both arrays.</returns> /// <remarks>The values of inArray1 nor inArray2 will not be altered.The dimensions /// of both arrays must match.</remarks> private static ILArray<complex> ComplexOperatorComplexComplex ( ILArray<complex> inArray1, ILArray<complex> inArray2, ILComplexFunctionComplexComplex operation) { ILDimension inDim = inArray1.Dimensions; if (!inDim.IsSameSize ( inArray2.Dimensions )) throw new ILDimensionMismatchException (); complex [] retSystemArr; // build ILDimension int newLength = inDim.NumberOfElements; retSystemArr = new complex [newLength]; int leadDim = 0; int leadDimLen = inDim [0]; if (inArray1.IsReference || inArray2.IsReference) { // this will most probably be not very fast, but .... :| #region Reference storage // walk along the longest dimension (for performance reasons) for (int i = 1; i < inDim.NumberOfDimensions; i++) { if (leadDimLen < inDim [i]) { leadDimLen = inDim [i]; leadDim = i; } } unsafe { fixed ( complex * pOutArr = retSystemArr) fixed ( complex * inA1 = inArray1.m_data) fixed ( complex * inA2 = inArray2.m_data) { complex * pInA1 = inA1; complex * pInA2 = inA2; int c = 0; complex * poutarr = pOutArr; complex * outEnd = poutarr + newLength; if (inArray1.IsReference && !inArray2.IsReference) while (poutarr < outEnd) { *poutarr++ = operation ( *(pInA1 + inArray1.getBaseIndex(c++)), *pInA2++); } else if (!inArray1.IsReference && inArray2.IsReference) while (poutarr < outEnd) { *poutarr++ = operation ( *pInA1++, *(pInA2 + inArray2.getBaseIndex(c++))); } else if (!inArray1.IsReference && !inArray2.IsReference) while (poutarr < outEnd) { *poutarr++ = operation ( *pInA1++, *pInA2++); } else if (inArray1.IsReference && inArray2.IsReference) if (inArray1.Dimensions.NumberOfDimensions < 3 && inArray2.Dimensions.NumberOfDimensions < 3) { fixed (int * pA1idx0 = inArray1.m_indexOffset[0]) fixed (int * pA1idx1 = inArray1.m_indexOffset[1]) fixed (int * pA2idx0 = inArray2.m_indexOffset[0]) fixed (int * pA2idx1 = inArray2.m_indexOffset[1]) { int r = 0, rLen = inArray1.m_dimensions[0]; int cLen = inArray1.m_dimensions[1]; while (poutarr < outEnd) { *poutarr++ = operation ( *(pInA1 + *(pA1idx0 + r) + *(pA1idx1 + c)), *(pInA2+ *(pA2idx0 + r) + *(pA2idx1 + c))); if (++r == rLen) { r = 0; c++; } } } } else { while (poutarr < outEnd) { *poutarr++ = operation ( *(pInA1 + inArray1.getBaseIndex(c)), *(pInA2+inArray2.getBaseIndex(c++))); } } } } // ============================================================== #endregion } else { // physical -> pointer arithmetic #region physical storage unsafe { fixed ( complex * pInArr1 = inArray1.m_data) fixed ( complex * pInArr2 = inArray2.m_data) fixed ( complex * pOutArr = retSystemArr) { complex * poutarr = pOutArr; complex * poutend = poutarr + newLength; complex * pIn1 = pInArr1; complex * pIn2 = pInArr2; while (poutarr < poutend) *poutarr++ = operation ( *pIn1++, *pIn2++ ); } } #endregion } return new ILArray<complex> ( retSystemArr, inDim.ToIntArray () ); }
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! /// <summary> /// operate on elements of both storages by the given function -> relational operations /// </summary> /// <param name="inArray1">First storage array</param> /// <param name="inArray2">Second storage array</param> /// <param name="operation">operation to apply to the elements of inArray. This /// acts like a function pointer.</param> /// <returns><![CDATA[ ILArray<complex> ]]> with result of operation for corresponding /// elements of both arrays.</returns> /// <remarks>The values of inArray1 nor inArray2 will not be altered.The dimensions /// of both arrays must match.</remarks> private static ILArray<complex> ComplexOperatorComplexComplex ( ILArray<complex> inArray1, ILArray<complex> inArray2, ILComplexFunctionComplexComplex operation) { ILDimension inDim = inArray1.Dimensions; if (!inDim.IsSameSize ( inArray2.Dimensions )) throw new ILDimensionMismatchException (); complex [] retSystemArr; // build ILDimension int newLength = inDim.NumberOfElements; retSystemArr = new complex [newLength]; int leadDimLen = inDim [0]; // physical -> pointer arithmetic unsafe { fixed ( complex * pInArr1 = inArray1.m_data) fixed ( complex * pInArr2 = inArray2.m_data) fixed ( complex * pOutArr = retSystemArr) { complex * poutarr = pOutArr; complex * poutend = poutarr + newLength; complex * pIn1 = pInArr1; complex * pIn2 = pInArr2; while (poutarr < poutend) *poutarr++ = operation ( *pIn1++, *pIn2++ ); } } return new ILArray<complex> ( retSystemArr, inDim.ToIntArray () ); }