Esempio n. 1
0
        public static Matrix <T> One <T>(int size)
        {
            var traits = TypeTraits.GetGenericTraits <T>() as ITypeInstanceTraits <T>;

            if (traits == null)
            {
                throw new InvalidOperationException("Type instance traits required, please use method One<T>(int size, ITypeInstanceTraits<T> traits)");
            }
            return(new DiagMatrix <T>(size, traits.GetOne(), traits.GetZero()));
        }
Esempio n. 2
0
        public static Matrix <T> Zero <T>(int size0, int size1)
        {
            T   zero   = default(T);
            var traits = TypeTraits.GetGenericTraits <T>() as ITypeInstanceTraits <T>;

            if (traits != null)
            {
                zero = traits.GetZero();
            }
            return(new ZeroMatrix <T>(size0, size1, zero));
        }
Esempio n. 3
0
        public static Vector <T> Zero <T>(int size)
        {
            T   zero   = default(T);
            var traits = TypeTraits.GetGenericTraits <T>() as ITypeInstanceTraits <T>;

            if (traits != null)
            {
                zero = traits.GetZero();
            }
            return(new ZeroVector <T>(size, zero));
        }
Esempio n. 4
0
        public static Box <T> One <T>(int rank, int size)
        {
            var traits = TypeTraits.GetGenericTraits <T>() as ITypeInstanceTraits <T>;

            if (traits == null)
            {
                throw new InvalidOperationException(
                          string.Format("Require type instance traits for type {0}, please use method One<T>(int rank, int size, ITypeInstanceTraits<T> traits)",
                                        typeof(T).Name));
            }
            return(new DiagBox <T>(rank, size, traits.GetOne()));
        }
Esempio n. 5
0
        public static Box <T> Zero <T>(params int[] sizes)
        {
            Contract.Requires <ArgumentNullException>(sizes != null, "sizes");

            T   zero   = default(T);
            var traits = TypeTraits.GetGenericTraits <T>() as ITypeInstanceTraits <T>;

            if (traits != null)
            {
                zero = traits.GetZero();
            }
            return(new ZeroBox <T>(sizes.AsVector(), zero));
        }
Esempio n. 6
0
 public MatrixGenericTypeTraits()
 {
     _elemTraits = TypeTraits.GetGenericTraits <T>();
 }
Esempio n. 7
0
 public VectorGenericTypeTraits()
 {
     _elemTraits = TypeTraits.GetGenericTraits <T>();
 }