예제 #1
0
파일: Markov.cs 프로젝트: 0xCM/arrows
 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>();
     }
 }
예제 #2
0
파일: Markov.cs 프로젝트: 0xCM/arrows
 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>();
     }
 }
예제 #3
0
파일: Markov.cs 프로젝트: 0xCM/arrows
 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);
 }
예제 #4
0
파일: Markov.cs 프로젝트: 0xCM/arrows
        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);
        }
예제 #5
0
파일: Markov.cs 프로젝트: 0xCM/arrows
        /// <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));
        }
예제 #6
0
파일: Markov.cs 프로젝트: 0xCM/arrows
        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);
        }