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); }
static MFullArray() { var type = MType.FromCliType(typeof(TScalar)); Contract.Assert(type != null && type.IsPrimitive); repr = new MRepr(type, MStructuralClass.FullArray); }
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."); } }
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); }
static MIntegralRange() { var @class = MType.FromCliType(typeof(TReal)); Contract.Assert(@class != null && @class.IsNumeric && [email protected]); }