Multiply() публичный Метод

Multiply this vector by a scalar value
public Multiply ( double scalar ) : Vector
scalar double
Результат Vector
Пример #1
0
        /// <summary>
        /// Construct an initial simplex, given starting guesses for the constants, and
        /// initial step sizes for each dimension
        /// </summary>
        /// <param name="simplexConstants"></param>
        /// <returns></returns>
        private static Vector[] _initializeVertices(SimplexConstant[] simplexConstants)
        {
            int numDimensions = simplexConstants.Length;
            var vertices = new Vector[numDimensions + 1];

            // define one point of the simplex as the given initial guesses
            var p0 = new Vector(numDimensions);
            for (int i = 0; i < numDimensions; i++)
            {
                p0[i] = simplexConstants[i].Value;
            }

            // now fill in the vertices, creating the additional points as:
            // P(i) = P(0) + Scale(i) * UnitVector(i)
            vertices[0] = p0;
            for (int i = 0; i < numDimensions; i++)
            {
                double scale = simplexConstants[i].InitialPerturbationScale;
                var unitVector = new Vector(numDimensions);
                unitVector[i] = 1;
                vertices[i + 1] = p0.Add(unitVector.Multiply(scale));
            }
            return vertices;
        }
Пример #2
0
 /// <summary>
 /// Compute the centroid of all points except the worst
 /// </summary>
 /// <param name="vertices"></param>
 /// <param name="errorProfile"></param>
 /// <returns></returns>
 private static Vector _computeCentroid(Vector[] vertices, ErrorProfile errorProfile)
 {
     int numVertices = vertices.Length;
     // find the centroid of all points except the worst one
     var centroid = new Vector(numVertices - 1);
     for (int i = 0; i < numVertices; i++)
     {
         if (i != errorProfile.HighestIndex)
         {
             centroid = centroid.Add(vertices[i]);
         }
     }
     return centroid.Multiply(1.0d/(numVertices - 1));
 }