예제 #1
0
 private static ILLogicalArray /*!HC:logicalbinaryop*/ LogicalBinaryDoubleOperator (
     /*!HC:inCls1*/ ILArray<double> A,
     /*!HC:inCls2*/ ILArray<double> B,
     /*!HC:delegate_logicalbinary*/ ILLogicalFunctionDoubleDouble 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 (/*!HC:inArr1*/ double * pInArr1 = A.m_data)
             fixed (/*!HC:inArr2*/ double * pInArr2 = B.m_data)
             fixed (byte* pOutArr = retSystemArr) {
                 byte* poutarr = pOutArr;
                 byte* poutend = poutarr + newLength;
                 /*!HC:inArr1*/ double * pIn1 = pInArr1;
                 /*!HC:inArr2*/ double * pIn2 = pInArr2;
                 while (poutarr < poutend)
                     *poutarr++ = operation ( *pIn1++, *pIn2++ );
             }
         }
         #endregion
     }
     return new ILLogicalArray ( retSystemArr, inDim.ToIntArray () );
 }
예제 #2
0
 internal /*!HC:TclsRelopUnary*/ oplogical_double (/*!HC:inArr2*/ double parameter,
          /*!HC:delegate_logicalbinary*/ ILLogicalFunctionDoubleDouble applyFunc) {
     m_parameter = parameter;
     m_applyFun = applyFunc;
 }
예제 #3
0
        private static ILLogicalArray /*!HC:logicalbinaryop*/ LogicalBinaryDoubleOperator (
            /*!HC:inCls1*/ ILArray<double> A,
            /*!HC:inCls2*/ ILArray<double> B,
            /*!HC:delegate_logicalbinary*/ ILLogicalFunctionDoubleDouble 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 leadDimLen = inDim [0];

            // physical -> pointer arithmetic
            unsafe {
                fixed (/*!HC:inArr1*/ double * pInArr1 = A.m_data)
                fixed (/*!HC:inArr2*/ double * pInArr2 = B.m_data)
                fixed (byte* pOutArr = retSystemArr) {
                    byte* poutarr = pOutArr;
                    byte* poutend = poutarr + newLength;
                    /*!HC:inArr1*/ double * pIn1 = pInArr1;
                    /*!HC:inArr2*/ double * pIn2 = pInArr2;
                    while (poutarr < poutend)
                        *poutarr++ = operation ( *pIn1++, *pIn2++ );
                }
            }

            return new ILLogicalArray ( retSystemArr, inDim.ToIntArray () );
        }