当前位置: 首页>>代码示例>>C#>>正文


C# DoubleVector.GetDotProduct方法代码示例

本文整理汇总了C#中Altaxo.Calc.LinearAlgebra.DoubleVector.GetDotProduct方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleVector.GetDotProduct方法的具体用法?C# DoubleVector.GetDotProduct怎么用?C# DoubleVector.GetDotProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Altaxo.Calc.LinearAlgebra.DoubleVector的用法示例。


在下文中一共展示了DoubleVector.GetDotProduct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Search

		///<summary> Minimize the given cost function </summary>
		public override DoubleVector Search(DoubleVector x, DoubleVector d, double stp)
		{
			DoubleVector ret = new DoubleVector(x);
			double j = 0;
			double delta_d = d.GetDotProduct(d);
			double alpha;
			do
			{
				alpha = -GradientEvaluation(ret).GetDotProduct(d) /
					d.GetDotProduct(HessianEvaluation(ret) * d);
				ret = ret + alpha * d;
				j++;
			} while ((j < maxIteration) && (alpha * alpha * delta_d > tolerance * tolerance));
			return ret;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:16,代码来源:NewtonRaphsonLineSearch.cs

示例2: Search

 ///<summary> Minimize the given cost function </summary>
 public override DoubleVector Search(DoubleVector x, DoubleVector d, double step) 
 {
   DoubleVector ret = new DoubleVector(x);
   double j=0;
   double eta;
 
   double delta_d = d.GetDotProduct(d);
   double alpha = -sigma_0;
   double eta_prev = d.GetDotProduct(GradientEvaluation(ret+sigma_0*d));
   do 
   {
     eta = d.GetDotProduct(GradientEvaluation(ret));
     alpha = alpha*(eta/(eta_prev-eta));
     ret = ret + alpha*d;
     eta_prev = eta;
     j++;
   } while ((j<maxIteration) && (alpha*alpha*delta_d > tolerance*tolerance));
   return ret;
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:20,代码来源:SecantLineSearch.cs

示例3: InitializeMethod

 ///<summary> Initialize the optimization method </summary>
 ///<remarks> The use of this function is intended for testing/debugging purposes only </remarks>
 public override void InitializeMethod(DoubleVector initialvector) 
 {
   g = GradientEvaluation(initialvector);
         
   // Calculate Diagonal preconditioner
   DoubleMatrix h = HessianEvaluation(initialvector);
   DoubleMatrix m_inv = new DoubleMatrix(initialvector.Length,initialvector.Length);
   for (int i=0; i<initialvector.Length; i++)
     m_inv[i,i] = 1/h[i,i];
   s = m_inv*g;
   
   DoubleVector d = -s;
   
   delta_new = g.GetDotProduct(d);
   
   restartCounter=0;
   /* ------------------------------ */
   this.iterationVectors_ = new DoubleVector[endCriteria_.maxIteration+1];
   this.iterationVectors_[0] = initialvector;
   
   this.iterationValues_ = new double[endCriteria_.maxIteration+1];
   this.iterationValues_[0] = FunctionEvaluation(this.iterationVectors_[0]);
   
   this.iterationGradients_ = new DoubleVector[endCriteria_.maxIteration+1];
   this.iterationGradients_[0] = new DoubleVector(g);
   
   this.iterationGradientNorms_ = new double[endCriteria_.maxIteration+1];
   this.iterationGradientNorms_[0] = g.GetNorm();
   
   this.iterationDirections_ = new DoubleVector[endCriteria_.maxIteration+1];
   this.iterationDirections_[0] = d;
   
   this.iterationTrialSteps_ = new double[endCriteria_.maxIteration+1];
   this.iterationTrialSteps_[0] = 1/this.iterationGradientNorms_[0];
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:37,代码来源:ConjugateGradient.cs

示例4: IterateMethod

    ///<summary> Perform a single iteration of the optimization method </summary>
    ///<remarks> The use of this function is intended for testing/debugging purposes only </remarks>
    public override void IterateMethod() 
    {
    
      DoubleVector d = this.iterationDirections_[endCriteria_.iterationCounter-1];
      DoubleVector x = this.iterationVectors_[endCriteria_.iterationCounter-1];
      DoubleVector g = this.iterationGradients_[endCriteria_.iterationCounter-1];
      double stp = this.iterationTrialSteps_[endCriteria_.iterationCounter-1];
      
      // Shanno-Phua's Formula for Trial Step
      if (restartCounter==0 && endCriteria_.iterationCounter>1) 
      {
        double dg = d.GetDotProduct(g);
        double dg0 = this.iterationDirections_[endCriteria_.iterationCounter-2].GetDotProduct(
          this.iterationGradients_[endCriteria_.iterationCounter-2])/stp;
        stp = dg0/dg;
      }
      
      delta_mid = g.GetDotProduct(g);
      
      // Conduct line search
      x = lineSearchMethod_.Search(x,d,stp);
      g = GradientEvaluation(x);
      
      delta_old = delta_new;
      delta_mid = g.GetDotProduct(s);
      
      // Calculate Diagonal preconditioner
      DoubleMatrix h = HessianEvaluation(x);
      DoubleMatrix m_inv = new DoubleMatrix(x.Length,x.Length);
      for (int i=0; i<x.Length; i++)
        m_inv[i,i] = 1/h[i,i];
      s = m_inv*g;
  
      // Calculate Beta
      delta_new = g.GetDotProduct(s);
      double beta = (delta_new-delta_mid)/delta_old;

      // Check for restart conditions
      restartCounter++;
      if (restartCounter==restartCount || (restartCounter==x.Length && restartCount==0) || beta<=0) 
      {
        restartCount = 0;
        beta=0;
      }
      
      // Calculate next line search direction
      d = -s + beta*d;
      
      this.iterationVectors_[endCriteria_.iterationCounter] = x;
      this.iterationValues_[endCriteria_.iterationCounter] = FunctionEvaluation(x);
      this.iterationGradients_[endCriteria_.iterationCounter] = g;
      this.iterationGradientNorms_[endCriteria_.iterationCounter] = g.GetNorm();
      this.iterationDirections_[endCriteria_.iterationCounter] = d;
      this.iterationTrialSteps_[endCriteria_.iterationCounter] = stp;
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:57,代码来源:ConjugateGradient.cs

示例5: GetDotProduct

 public void GetDotProduct()
 {
   DoubleVector a = new DoubleVector(new double[4]{0,1,2,3});
   DoubleVector b = new DoubleVector(new double[4]{4,5,6,7});
   
   Assert.AreEqual(a.GetDotProduct(),14);
   Assert.AreEqual(b.GetDotProduct(),126);
   Assert.AreEqual(a.GetDotProduct(b),38);
   Assert.AreEqual(a.GetDotProduct(b),b.GetDotProduct(a));
   
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:11,代码来源:DoubleVectorTest.cs


注:本文中的Altaxo.Calc.LinearAlgebra.DoubleVector.GetDotProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。