Exemplo n.º 1
0
        public static void InitHeNorm <T>(NdArray <T> array) where T : unmanaged, IComparable <T>
        {
            switch (array)
            {
            case NdArray <float> arrayF:
                InitializerF.InitHeNorm(arrayF);
                break;

            case NdArray <double> arrayD:
                InitializerD.InitHeNorm(arrayD);
                break;
            }
        }
Exemplo n.º 2
0
        //多次元配列を作る
        public static T GetRandomValues <T>(int[] shape, Real max, Real min = 0) where T : ICollection, IEnumerable, ICloneable, IList, IStructuralComparable, IStructuralEquatable
        {
            Array result = Array.CreateInstance(typeof(T).GetElementType(), shape);

            Array tmp = Array.CreateInstance(typeof(T).GetElementType(), result.Length);

            switch (tmp)
            {
            case float[] tmpF:
                InitializerF.GetRealArray(tmpF, max, min);
                break;

            case double[] tmpD:
                InitializerD.GetRealArray(tmpD, max, min);
                break;
            }

            Buffer.BlockCopy(tmp, 0, result, 0, result.Length * Marshal.SizeOf(typeof(T).GetElementType()));

            return((T)(object)result);
        }