Exemple #1
0
        static MArray()
        {
            // Ensure the generic type is one that supports being in arrays.
            var type = MType.FromCliType(typeof(TScalar));

            Contract.Assert(type != null && type.IsPrimitive);
        }
Exemple #2
0
        static MFullArray()
        {
            var type = MType.FromCliType(typeof(TScalar));

            Contract.Assert(type != null && type.IsPrimitive);
            repr = new MRepr(type, MStructuralClass.FullArray);
        }
Exemple #3
0
        static MComplex()
        {
            // Ensure the generic type is one that supports complex numbers.
            var @class = MType.FromCliType(typeof(TNumeric)) as MClass;

            if (@class == null || (@class.Kind & MClassKinds.SupportsComplexMask) == 0)
            {
                throw new InvalidOperationException("Invalid scalar type for MComplex type.");
            }
        }
Exemple #4
0
        public static MRepr FromCliType(Type type)
        {
            Contract.Requires(type != null);

            var mtype = MType.FromCliType(type);

            if (mtype != null)
            {
                return(new MRepr(mtype, mtype.IsPrimitive ? MStructuralClass.Scalar : null));
            }

            if (!type.IsGenericType)
            {
                return(Any);
            }

            mtype = MType.FromCliType(type.GetGenericArguments()[0]);
            if (mtype == null)
            {
                return(Any);
            }

            var genericTypeDefinition = type.GetGenericTypeDefinition();

            if (genericTypeDefinition == typeof(MArray <>))
            {
                return(new MRepr(mtype, MStructuralClass.Array));
            }
            if (genericTypeDefinition == typeof(MFullArray <>))
            {
                return(new MRepr(mtype, MStructuralClass.FullArray));
            }
            if (genericTypeDefinition == typeof(MIntegralRange <>))
            {
                return(new MRepr(mtype, MStructuralClass.IntegralRange));
            }
            return(Any);
        }
Exemple #5
0
        static MIntegralRange()
        {
            var @class = MType.FromCliType(typeof(TReal));

            Contract.Assert(@class != null && @class.IsNumeric && [email protected]);
        }