コード例 #1
0
 /// <summary>
 /// Division outarray[i] / val
 /// </summary>
 public static void Div(Bytearray outarray, byte val)
 {
     for (int i = 0; i < outarray.Length1d(); i++)
     {
         outarray.Put1d(i, (byte)(outarray.At1d(i) / val));
     }
 }
コード例 #2
0
 /// <summary>
 /// Subtraction val - outarray[i]
 /// </summary>
 public static void Sub(byte val, Bytearray outarray)
 {
     for (int i = 0; i < outarray.Length1d(); i++)
     {
         outarray.Put1d(i, (byte)(val - outarray.At1d(i)));
     }
 }
コード例 #3
0
 /// <summary>
 /// Add outarray[i] + val
 /// </summary>
 public static void Add(Bytearray outarray, byte val)
 {
     for (int i = 0; i < outarray.Length1d(); i++)
     {
         outarray.UnsafePut1d(i, (byte)(outarray.UnsafeAt1d(i) + val));
     }
 }
コード例 #4
0
 public static void Greater(Bytearray outa, byte inval, byte no, byte yes)
 {
     for (int i = 0; i < outa.Length1d(); i++)
     {
         if (outa.UnsafeAt1d(i) > inval)
         {
             outa.UnsafePut1d(i, yes);
         }
         else
         {
             outa.UnsafePut1d(i, no);
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Compute the global max of the array.
        /// </summary>
        public static byte Max(Bytearray a)
        {
            byte value = a.At1d(0);

            for (int i = 1; i < a.Length1d(); i++)
            {
                byte nvalue = a.At1d(i);
                if (nvalue <= value)
                {
                    continue;
                }
                value = nvalue;
            }
            return(value);
        }
コード例 #6
0
        public static int ArgMin(Bytearray a)
        {
            if (!(/*a.Rank() == 1 && **/ a.Dim(0) > 0))
            {
                throw new Exception("CHECK_ARG: a.Rank()==1 && a.Dim(0)>0");
            }
            byte value = a.At1d(0);
            int  index = 0;

            for (int i = 1; i < a.Length1d(); i++)
            {
                byte nvalue = a.At1d(i);
                if (nvalue >= value)
                {
                    continue;
                }
                value = nvalue;
                index = i;
            }
            return(index);
        }