示例#1
0
 public static NdArray <T> Fill <T>(this NdArray <T> array, Func <long, long, T> f, int axis1 = 0, int axis2 = 1, long[] idx = null)
 {
     idx = idx ?? new long[array.Shape.Dimensions.Length];
     for (idx[axis1] = 0; idx[axis1] < array.Count(axis1); idx[axis1]++)
     {
         for (idx[axis2] = 0; idx[axis2] < array.Count(axis2); idx[axis2]++)
         {
             array.Value[idx] = f(idx[axis1], idx[axis2]);
         }
     }
     return(array);
 }
示例#2
0
        public new static DateTimeSeries Range(int count, DateTime start, DateTime end)
        {
            var delta = (end - start).ToDateTime64() / count;
            var r     = new NdArray <long>(new Shape(count));

            for (int i = 0; i < r.Count(); i++)
            {
                r.Value[i] = start.ToDateTime64() + delta * i;
            }
            return(new DateTimeSeries(new Series <long>(r)));
        }