コード例 #1
0
ファイル: ILMathBasic.cs プロジェクト: wdxa/ILNumerics
            internal /*!HC:Tcls3Name*/ opdouble_double (/*!HC:inArr2*/ double parameter,
                     /*!HC:delegate_binary*/ ILDoubleFunctionDoubleDouble applyFunc) {
					m_parameter = parameter; 
					m_applyFun = applyFunc; 
			} 
コード例 #2
0
 internal /*!HC:Tcls3Name*/ opdouble_double(/*!HC:inArr2*/ double parameter,
                                            /*!HC:delegate_binary*/ ILDoubleFunctionDoubleDouble applyFunc)
 {
     m_parameter = parameter;
     m_applyFun  = applyFunc;
 }
コード例 #3
0
ファイル: ILMath_Walker.cs プロジェクト: wdxa/ILNumerics
        /*!HC:TYPELIST:
<hycalper>
    <type>
        <source	locate="after">
        inArr1
        </source>
        <destination>byte</destination>
        <destination>char</destination>
        <destination>complex</destination>
        <destination>fcomplex</destination>
        <destination>float</destination>
        <destination>Int16</destination>
        <destination>Int32</destination>
        <destination>Int64</destination>
        <destination>UInt16</destination>
        <destination>UInt32</destination>
        <destination>UInt64</destination>
    </type>
    <type>
        <source	locate="after">
            inArr2
        </source>
        <destination>byte</destination>
        <destination>char</destination>
        <destination>complex</destination>
        <destination>fcomplex</destination>
        <destination>float</destination>
        <destination>Int16</destination>
        <destination>Int32</destination>
        <destination>Int64</destination>
        <destination>UInt16</destination>
        <destination>UInt32</destination>
        <destination>UInt64</destination>
    </type>
    <type>
        <source	locate="after">
            inCls1
        </source>
        <destination><![CDATA[ILArray<byte>]]></destination>
        <destination><![CDATA[ILArray<char>]]></destination>
        <destination><![CDATA[ILArray<complex>]]></destination>
        <destination><![CDATA[ILArray<fcomplex>]]></destination>
        <destination><![CDATA[ILArray<float>]]></destination>
        <destination><![CDATA[ILArray<Int16>]]></destination>
        <destination><![CDATA[ILArray<Int32>]]></destination>
        <destination><![CDATA[ILArray<Int64>]]></destination>
        <destination><![CDATA[ILArray<UInt16>]]></destination>
        <destination><![CDATA[ILArray<UInt32>]]></destination>
        <destination><![CDATA[ILArray<UInt64>]]></destination>
    </type>
    <type>
        <source	locate="after">
            inCls2
        </source>
        <destination><![CDATA[ILArray<byte>]]></destination>
        <destination><![CDATA[ILArray<char>]]></destination>
        <destination><![CDATA[ILArray<complex>]]></destination>
        <destination><![CDATA[ILArray<fcomplex>]]></destination>
        <destination><![CDATA[ILArray<float>]]></destination>
        <destination><![CDATA[ILArray<Int16>]]></destination>
        <destination><![CDATA[ILArray<Int32>]]></destination>
        <destination><![CDATA[ILArray<Int64>]]></destination>
        <destination><![CDATA[ILArray<UInt16>]]></destination>
        <destination><![CDATA[ILArray<UInt32>]]></destination>
        <destination><![CDATA[ILArray<UInt64>]]></destination>
    </type>
    <type>
        <source	locate="after">
            outCls1
        </source>
        <destination><![CDATA[ILArray<byte>]]></destination>
        <destination><![CDATA[ILArray<char>]]></destination>
        <destination><![CDATA[ILArray<complex>]]></destination>
        <destination><![CDATA[ILArray<fcomplex>]]></destination>
        <destination><![CDATA[ILArray<float>]]></destination>
        <destination><![CDATA[ILArray<Int16>]]></destination>
        <destination><![CDATA[ILArray<Int32>]]></destination>
        <destination><![CDATA[ILArray<Int64>]]></destination>
        <destination><![CDATA[ILArray<UInt16>]]></destination>
        <destination><![CDATA[ILArray<UInt32>]]></destination>
        <destination><![CDATA[ILArray<UInt64>]]></destination>
    </type>
    <type>
        <source	locate="after">
            outArr1
        </source>
        <destination>byte</destination>
        <destination>char</destination>
        <destination>complex</destination>
        <destination>fcomplex</destination>
        <destination>float</destination>
        <destination>Int16</destination>
        <destination>Int32</destination>
        <destination>Int64</destination>
        <destination>UInt16</destination>
        <destination>UInt32</destination>
        <destination>UInt64</destination>
    </type>
    <type>
        <source	locate="after">
            delegate_binary
        </source>
        <destination>ILByteFunctionByteByte</destination>
        <destination>ILCharFunctionCharChar</destination>
        <destination>ILComplexFunctionComplexComplex</destination>
        <destination>ILFcomplexFunctionFcomplexFcomplex</destination>
        <destination>ILFloatFunctionFloatFloat</destination>
        <destination>ILInt16FunctionInt16Int16</destination>
        <destination>ILInt32FunctionInt32Int32</destination>
        <destination>ILInt64FunctionInt64Int64</destination>
        <destination>ILUInt16FunctionUInt16UInt16</destination>
        <destination>ILUInt32FunctionUInt32UInt32</destination>
        <destination>ILUInt64FunctionUInt64UInt64</destination>
    </type>
    <type>
        <source	locate="after">
            hcfunctionName
        </source>
        <destination>ByteOperatorByteByte</destination>
        <destination>CharOperatorCharChar</destination>
        <destination>ComplexOperatorComplexComplex</destination>
        <destination>FcomplexOperatorFcomplexFcomplex</destination>
        <destination>FloatOperatorFloatFloat</destination>
        <destination>Int16OperatorInt16Int16</destination>
        <destination>Int32OperatorInt32Int32</destination>
        <destination>Int64OperatorInt64Int64</destination>
        <destination>UInt16OperatorUInt16UInt16</destination>
        <destination>UInt32OperatorUInt32UInt32</destination>
        <destination>UInt64OperatorUInt64UInt64</destination>
    </type>
</hycalper>
*/
        /// <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[ /*!HC:outCls1*/ ILArray<double> ]]> 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 /*!HC:outCls1*/ ILArray<double> /*!HC:hcfunctionName*/ DoubleOperatorDoubleDouble (/*!HC:inCls1*/ ILArray<double> inArray1,/*!HC:inCls2*/ ILArray<double> inArray2,
            /*!HC:delegate_binary*/ ILDoubleFunctionDoubleDouble operation) {
            ILDimension inDim = inArray1.Dimensions;
            if (!inDim.IsSameSize ( inArray2.Dimensions ))
                throw new ILDimensionMismatchException ();
            /*!HC:outArr1*/ double [] retSystemArr;
            // build ILDimension
            int newLength = inDim.NumberOfElements;
            retSystemArr = new /*!HC:outArr1*/ double [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 (/*!HC:outArr1*/ double * pOutArr = retSystemArr)
                    fixed (/*!HC:inArr1*/ double * inA1 = inArray1.m_data) 
                    fixed (/*!HC:inArr2*/ double * inA2 = inArray2.m_data) {
                        /*!HC:inArr1*/ double * pInA1 = inA1; 
                        /*!HC:inArr2*/ double * pInA2 = inA2;
                        int c = 0; 
                        /*!HC:outArr1*/ double * poutarr = pOutArr;
                        /*!HC:outArr1*/ double * 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 (/*!HC:inArr1*/ double * pInArr1 = inArray1.m_data)
                    fixed (/*!HC:inArr2*/ double * pInArr2 = inArray2.m_data)
                    fixed (/*!HC:outArr1*/ double * pOutArr = retSystemArr) {
                        /*!HC:outArr1*/ double * poutarr = pOutArr;
                        /*!HC:outArr1*/ double * poutend = poutarr + newLength;
                        /*!HC:inArr1*/ double * pIn1 = pInArr1;
                        /*!HC:inArr2*/ double * pIn2 = pInArr2;
                        while (poutarr < poutend)
                            *poutarr++ = operation ( *pIn1++, *pIn2++ );

                    }
                }
                #endregion
            }
            return new /*!HC:outCls1*/ ILArray<double> ( retSystemArr, inDim.ToIntArray () );
        }
コード例 #4
0
        /*!HC:TYPELIST:
         * <hycalper>
         * <type>
         * <source	locate="after">
         * inArr1
         * </source>
         * <destination>byte</destination>
         * <destination>complex</destination>
         * </type>
         * <type>
         * <source	locate="after">
         *  inArr2
         * </source>
         * <destination>byte</destination>
         * <destination>complex</destination>
         * </type>
         * <type>
         * <source	locate="after">
         *  inCls1
         * </source>
         * <destination><![CDATA[ILArray<byte>]]></destination>
         * <destination><![CDATA[ILArray<complex>]]></destination>
         * </type>
         * <type>
         * <source	locate="after">
         *  inCls2
         * </source>
         * <destination><![CDATA[ILArray<byte>]]></destination>
         * <destination><![CDATA[ILArray<complex>]]></destination>
         * </type>
         * <type>
         * <source	locate="after">
         *  outCls1
         * </source>
         * <destination><![CDATA[ILArray<byte>]]></destination>
         * <destination><![CDATA[ILArray<complex>]]></destination>
         * </type>
         * <type>
         * <source	locate="after">
         *  outArr1
         * </source>
         * <destination>byte</destination>
         * <destination>complex</destination>
         * </type>
         * <type>
         * <source	locate="after">
         *  delegate_binary
         * </source>
         * <destination>ILByteFunctionByteByte</destination>
         * <destination>ILComplexFunctionComplexComplex</destination>
         * </type>
         * <type>
         * <source	locate="after">
         *  hcfunctionName
         * </source>
         * <destination>ByteOperatorByteByte</destination>
         * <destination>ComplexOperatorComplexComplex</destination>
         * </type>
         * </hycalper>
         */
        /// <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[ /*!HC:outCls1*/ ILArray<double> ]]> 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 /*!HC:outCls1*/ ILArray <double> /*!HC:hcfunctionName*/ DoubleOperatorDoubleDouble(/*!HC:inCls1*/ ILArray <double> inArray1, /*!HC:inCls2*/ ILArray <double> inArray2,
                                                                                                          /*!HC:delegate_binary*/ ILDoubleFunctionDoubleDouble operation)
        {
            ILDimension inDim = inArray1.Dimensions;

            if (!inDim.IsSameSize(inArray2.Dimensions))
            {
                throw new ILDimensionMismatchException();
            }
            /*!HC:outArr1*/ double [] retSystemArr;
            // build ILDimension
            int newLength = inDim.NumberOfElements;

            retSystemArr = new /*!HC:outArr1*/ double [newLength];
            int leadDimLen = inDim [0];

            // physical -> pointer arithmetic
            unsafe
            {
                fixed(/*!HC:inArr1*/ double *pInArr1 = inArray1.m_data)
                fixed(/*!HC:inArr2*/ double *pInArr2  = inArray2.m_data)
                fixed(/*!HC:outArr1*/ double *pOutArr = retSystemArr)
                {
                    /*!HC:outArr1*/ double *poutarr = pOutArr;
                    /*!HC:outArr1*/ double *poutend = poutarr + newLength;
                    /*!HC:inArr1*/ double * pIn1    = pInArr1;
                    /*!HC:inArr2*/ double * pIn2    = pInArr2;

                    while (poutarr < poutend)
                    {
                        *poutarr++ = operation(*pIn1++, *pIn2++);
                    }
                }
            }

            return(new /*!HC:outCls1*/ ILArray <double> (retSystemArr, inDim.ToIntArray()));
        }
コード例 #5
0
ファイル: ILMath_Walker.cs プロジェクト: wdxa/ILNumerics
        /*!HC:TYPELIST:
<hycalper>
    <type>
        <source	locate="after">
        inArr1
        </source>
        <destination>byte</destination>
        <destination>complex</destination>
    </type>
    <type>
        <source	locate="after">
            inArr2
        </source>
        <destination>byte</destination>
        <destination>complex</destination>
    </type>
    <type>
        <source	locate="after">
            inCls1
        </source>
        <destination><![CDATA[ILArray<byte>]]></destination>
        <destination><![CDATA[ILArray<complex>]]></destination>
    </type>
    <type>
        <source	locate="after">
            inCls2
        </source>
        <destination><![CDATA[ILArray<byte>]]></destination>
        <destination><![CDATA[ILArray<complex>]]></destination>
    </type>
    <type>
        <source	locate="after">
            outCls1
        </source>
        <destination><![CDATA[ILArray<byte>]]></destination>
        <destination><![CDATA[ILArray<complex>]]></destination>
    </type>
    <type>
        <source	locate="after">
            outArr1
        </source>
        <destination>byte</destination>
        <destination>complex</destination>
    </type>
    <type>
        <source	locate="after">
            delegate_binary
        </source>
        <destination>ILByteFunctionByteByte</destination>
        <destination>ILComplexFunctionComplexComplex</destination>
    </type>
    <type>
        <source	locate="after">
            hcfunctionName
        </source>
        <destination>ByteOperatorByteByte</destination>
        <destination>ComplexOperatorComplexComplex</destination>
    </type>
</hycalper>
*/
        /// <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[ /*!HC:outCls1*/ ILArray<double> ]]> 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 /*!HC:outCls1*/ ILArray<double> /*!HC:hcfunctionName*/ DoubleOperatorDoubleDouble (/*!HC:inCls1*/ ILArray<double> inArray1,/*!HC:inCls2*/ ILArray<double> inArray2,
            /*!HC:delegate_binary*/ ILDoubleFunctionDoubleDouble operation) {
            ILDimension inDim = inArray1.Dimensions;
            if (!inDim.IsSameSize ( inArray2.Dimensions ))
                throw new ILDimensionMismatchException ();
            /*!HC:outArr1*/ double [] retSystemArr;
            // build ILDimension
            int newLength = inDim.NumberOfElements;
            retSystemArr = new /*!HC:outArr1*/ double [newLength];
            int leadDimLen = inDim [0];

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

                }
            }

            return new /*!HC:outCls1*/ ILArray<double> ( retSystemArr, inDim.ToIntArray () );
        }