Esempio n. 1
0
 public static void MarkovVec <T>(this IPolyrand random, Span <T> dst)
     where T : struct
 {
     if (typeof(T) == typeof(float))
     {
         random.MarkovVec(As.float32(dst));
     }
     else if (typeof(T) == typeof(double))
     {
         random.MarkovVec(As.float64(dst));
     }
     else
     {
         throw unsupported <T>();
     }
 }
Esempio n. 2
0
 public static BlockVector <T> MarkovVec <T>(this IPolyrand random, int length)
     where T : struct
 {
     if (typeof(T) == typeof(float))
     {
         return(random.MarkovVec(length, 1f, length << 4).As <T>());
     }
     else if (typeof(T) == typeof(double))
     {
         return(random.MarkovVec(length, 1.0, length << 4).As <T>());
     }
     else
     {
         throw unsupported <T>();
     }
 }
Esempio n. 3
0
 public static ref BlockVector <N, T> MarkovVec <N, T>(this IPolyrand random, ref BlockVector <N, T> dst)
     where N : ITypeNat, new()
     where T : struct
 {
     random.MarkovVec(dst.Unsized);
     return(ref dst);
 }
Esempio n. 4
0
        public static BlockVector <N, T> MarkovVec <N, T>(this IPolyrand random)
            where N : ITypeNat, new()
            where T : struct
        {
            var dst = BlockVector.Alloc <N, T>();

            random.MarkovVec(dst.Unsized);
            return(dst);
        }
Esempio n. 5
0
        /// <summary>
        /// Allocates and populates a right-stochastic matrix, otherwise known as a Markov matrix;
        /// each row records a stocastic vector
        /// </summary>
        /// <param name="random">The random source</param>
        /// <param name="rep"></param>
        /// <param name="dim"></param>
        /// <typeparam name="N">The order type</typeparam>
        /// <typeparam name="T"></typeparam>
        public static BlockMatrix <N, T> MarkovMat <N, T>(this IPolyrand random, T rep = default, N dim = default)
            where T : struct
            where N : ITypeNat, new()
        {
            var data = Z0.Span256.Alloc <N, N, T>();
            var n    = nati <N>();

            for (int row = 0; row < n; row++)
            {
                random.MarkovVec <T>(data.Slice(row * n, n));
            }
            return(Z0.BlockMatrix.Load <N, T>(data));
        }
Esempio n. 6
0
        public static ref BlockMatrix <N, T> MarkovMat <N, T>(this IPolyrand random, ref BlockMatrix <N, T> dst)
            where T : struct
            where N : ITypeNat, new()
        {
            var data = dst.Unsized;
            var n    = nati <N>();

            for (int row = 0; row < n; row++)
            {
                random.MarkovVec <T>(data.Slice(row * n, n));
            }
            return(ref dst);
        }