private static ILLogicalArray LogicalBinaryCharOperator ( ILArray<char> A, ILArray<char> B, ILLogicalFunctionCharChar operation) { ILDimension inDim = A.m_dimensions; if (!inDim.IsSameSize ( B.m_dimensions )) throw new ILDimensionMismatchException (); byte [] retSystemArr; // build ILDimension int newLength = inDim.NumberOfElements; retSystemArr = new byte [newLength]; int leadDim = 0; int leadDimLen = inDim [0]; if (A.IsReference || B.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 (byte* pOutArr = retSystemArr) { int c = 0; byte* poutarr = pOutArr; byte* outEnd = poutarr + newLength; while (poutarr < outEnd) { *poutarr++ = operation ( A.GetValue(c), B.GetValue(c++) ); } } } // ============================================================== #endregion } else { // physical -> pointer arithmetic #region physical storage unsafe { fixed ( char * pInArr1 = A.m_data) fixed ( char * pInArr2 = B.m_data) fixed (byte* pOutArr = retSystemArr) { byte* poutarr = pOutArr; byte* poutend = poutarr + newLength; char * pIn1 = pInArr1; char * pIn2 = pInArr2; while (poutarr < poutend) *poutarr++ = operation ( *pIn1++, *pIn2++ ); } } #endregion } return new ILLogicalArray ( retSystemArr, inDim.ToIntArray () ); }
internal oplogical__char ( char parameter, ILLogicalFunctionCharChar applyFunc) { m_parameter = parameter; m_applyFun = applyFunc; }