Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startval"></param>
        /// <param name="endval"></param>
        /// <param name="steps"></param>
        /// <returns></returns>
        public static Vector Linspace(GPU gpu, float startval, float endval, int steps, int columns = 1)
        {
            float interval = MathF.Abs(endval - startval) / (steps - 1);

            if (endval < startval)
            {
                interval = -interval;
            }
            return(new Vector(gpu, (from val in Enumerable.Range(0, steps) select startval + (val * interval)).ToArray(), columns));
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startval"></param>
        /// <param name="endval"></param>
        /// <param name="interval"></param>
        /// <returns></returns>
        public static Vector Arange(GPU gpu, float startval, float endval, float interval, int Columns = 1)
        {
            int steps = (int)((endval - startval) / interval);

            if (endval < startval && interval > 0)
            {
                steps = Math.Abs(steps); interval = -interval;
            }
            if (endval % interval != 0)
            {
                steps++;
            }

            return(new Vector(gpu, (from val in Enumerable.Range(0, steps)
                                    select startval + (val * interval)).ToArray(), Columns));
        }
Example #3
0
 public static Vector Ones(GPU gpu, int Length, int Columns = 1)
 {
     return(new Vector(gpu, Enumerable.Repeat(1f, Length).ToArray(), Columns));
 }
Example #4
0
 public static Vector Zeros(GPU gpu, int Length, int Columns = 1)
 {
     return(new Vector(gpu, new float[Length], Columns));
 }
Example #5
0
 // CREATION
 #region
 /// <summary>
 /// Creates a UNIFORM Vector where all values are equal to Value
 /// </summary>
 /// <param name="Value"></param>
 /// <param name="Size"></param>
 /// <param name="Columns"></param>
 /// <returns></returns>
 public static Vector Fill(GPU gpu, float Value, int Length, int Columns = 1)
 {
     return(new Vector(gpu, Enumerable.Repeat(Value, Length).ToArray(), Columns));
 }
Example #6
0
 // CONSTRUCTOR
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <param name="columns"></param>
 public Vector(GPU gpu, float[] value, int columns = 1)
 {
     this.gpu     = gpu;
     this.Value   = value;
     this.Columns = columns;
 }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startval"></param>
        /// <param name="endval"></param>
        /// <param name="interval"></param>
        /// <returns></returns>
        public static Vector Arange(GPU gpu, float startval, float endval, float interval)
        {
            int steps = (int)((Math.Abs(startval) + Math.Abs(endval)) / interval);

            return(new Vector(gpu, (from val in Enumerable.Range(0, steps) select startval + (val * interval)).ToArray(), 1));
        }