Ejemplo n.º 1
0
 /// <summary>
 /// Add outarray[i] + val
 /// </summary>
 public static void Add(Floatarray outarray, float val)
 {
     for (int i = 0; i < outarray.Length1d(); i++)
     {
         outarray.UnsafePut1d(i, outarray.UnsafeAt1d(i) + val);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Normalize the 1-norm of the array.
        /// </summary>
        public static void Normalize1(Floatarray a)
        {
            double scale = 1.0 / Norm1(a);

            for (int i = 0; i < a.Length1d(); i++)
            {
                a.UnsafePut1d(i, (float)(a.UnsafeAt1d(i) * scale));
            }
        }
Ejemplo n.º 3
0
        public static Floatarray operator /(Floatarray array, double val)
        {
            Floatarray res = array;

            for (int i = 0; i < array.Length1d(); i++)
            {
                res.UnsafePut1d(i, (float)(array.UnsafeAt1d(i) / val));
            }
            return(res);
        }
Ejemplo n.º 4
0
        public static Floatarray operator -(Floatarray array, float val)
        {
            Floatarray res = array;

            for (int i = 0; i < array.Length1d(); i++)
            {
                res.UnsafePut1d(i, array.UnsafeAt1d(i) - val);
            }
            return(res);
        }
Ejemplo n.º 5
0
        public static void Shuffle <T>(Narray <T> values)
        {
            Floatarray temp  = new Floatarray(values.Length());
            Intarray   index = new Intarray();

            for (int i = 0; i < temp.Length(); i++)
            {
                temp.UnsafePut1d(i, DRandomizer.Default.drand());
            }
            Quicksort(index, temp);
            Permute(values, index);
        }
Ejemplo n.º 6
0
        public static Floatarray operator -(Floatarray outarray1, Floatarray array2)
        {
            if (!SameDims(outarray1, array2))
            {
                throw new Exception("outarray1 and array2 must be same dims!");
            }
            Floatarray res = outarray1;

            for (int i = 0; i < outarray1.Length1d(); i++)
            {
                res.UnsafePut1d(i, outarray1.UnsafeAt1d(i) - array2.UnsafeAt1d(i));
            }
            return(res);
        }