/// <summary> /// Produces a blocked vector /// </summary> /// <param name="random">The random source</param> /// <param name="domain">The domain of the random variable</param> /// <typeparam name="T">The vector component type</typeparam> public static BlockVector <T> BlockVec <T>(this IPolyrand random, int len, Interval <T>?domain = null) where T : struct { var dst = BlockVector.Alloc <T>(len); if (domain != null) { random.StreamTo(domain.Value, len, ref dst[0]); } else { random.StreamTo(len, ref dst[0]); } return(dst); }
/// <summary> /// Produces a blocked vector /// </summary> /// <param name="random">The random source</param> /// <param name="domain">The domain of the random variable</param> /// <typeparam name="T">The vector component type</typeparam> public static Vector <T> Vector <T>(this IPolyrand random, int len, Interval <T>?domain = null) where T : unmanaged { var dst = Z0.Vector.Alloc <T>(len); if (domain != null) { random.StreamTo(domain.Value, len, ref dst[0]); } else { random.StreamTo(len, ref dst[0]); } return(dst); }
static void MarkovVec(this IPolyrand random, Span <double> dst) { var length = dst.Length; random.StreamTo(closed(1.0, length << 4), length, ref dst[0]); mathspan.fdiv(dst, dst.Avg() * length); }
public static Span <T> Span <T>(this IPolyrand random, int length, Interval <T>?domain = null, Func <T, bool> filter = null) where T : struct { Span <T> dst = new T[length]; random.StreamTo(domain.Configure(), length, ref head(dst), filter); return(dst); }
static BlockVector <double> MarkovVec(this IPolyrand random, int length, double min, double max) { var dst = Z0.Span256.AllocBlocks <double>(Z0.Span256.MinBlocks <double>(length)); random.StreamTo(closed(min, max), length, ref dst[0]); mathspan.fdiv(dst.Unblocked, dst.Avg() * length); return(dst); }
public static void Fill <N, T>(this IPolyrand random, ref BlockVector <N, T> vector, N n = default) where T : struct where N : ITypeNat, new() => random.StreamTo <T>(nati <N>(), ref vector.Unsized[0]);
public static void Fill <N, T>(this IPolyrand random, ref Vector <N, T> vector, N n = default) where T : unmanaged where N : ITypeNat, new() => random.StreamTo <T>(nati <N>(), ref vector.Data[0]);