• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# LinearAlgebra.ComplexDoubleVector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ComplexDoubleVector类属于Altaxo.Calc.LinearAlgebra命名空间,在下文中一共展示了ComplexDoubleVector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CtorDimensions

 public void CtorDimensions()
 {
   ComplexDoubleVector test = new ComplexDoubleVector(2);
   
   Assert.AreEqual(test.Length, 2);
   Assert.AreEqual(test[0],new Complex(0));
   Assert.AreEqual(test[1],new Complex(0));
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:8,代码来源:ComplexDoubleVectorTest.cs


示例2: CtorInitialValues

 public void CtorInitialValues()
 {
   ComplexDoubleVector test = new ComplexDoubleVector(2, new Complex(1,-1));
   
   Assert.AreEqual(test.Length, 2);
   Assert.AreEqual(test[0],new Complex(1,-1));
   Assert.AreEqual(test[1],new Complex(1,-1));
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:8,代码来源:ComplexDoubleVectorTest.cs


示例3: InternalCompute

    /// <summary>Performs the QR factorization.</summary>
    protected override void InternalCompute() 
    {
      int m = matrix.Rows;
      int n = matrix.Columns;
#if MANAGED
      int minmn = m < n ? m : n;
      r_ = new ComplexDoubleMatrix(matrix); // create a copy
      ComplexDoubleVector[] u = new ComplexDoubleVector[minmn];
      for (int i = 0; i < minmn; i++) 
      {
        u[i] = Householder.GenerateColumn(r_, i, m - 1, i);
        Householder.UA(u[i], r_, i, m - 1, i + 1, n - 1);
      }
      q_ = ComplexDoubleMatrix.CreateIdentity(m);
      for (int i = minmn - 1; i >= 0; i--) 
      {
        Householder.UA(u[i], q_, i, m - 1, i, m - 1);
      }
#else
      qr = ComplexDoubleMatrix.ToLinearComplexArray(matrix);
      jpvt = new int[n];
      jpvt[0] = 1;
      Lapack.Geqp3.Compute(m, n, qr, m, jpvt, out tau);
      r_ = new ComplexDoubleMatrix(m, n);
      // Populate R

      for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
          if (i <= j) {
            r_.data[j * m + i] = qr[(jpvt[j]-1) * m + i];
          }
          else {
            r_.data[j * m + i] = Complex.Zero;
          }
        }
      }

      q_ = new ComplexDoubleMatrix(m, m);
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
          if (j < n)
            q_.data[j * m + i] = qr[j * m + i];
          else
            q_.data[j * m + i] = Complex.Zero;
        }
      }
      if( m < n ){
        Lapack.Ungqr.Compute(m, m, m, q_.data, m, tau);
      } else{
        Lapack.Ungqr.Compute(m, m, n, q_.data, m, tau);
      }
#endif
      for (int i = 0; i < m; i++) 
      {
        if (q_[i, i] == 0)
          isFullRank = false;
      }
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:59,代码来源:ComplexDoubleQRDecomp.cs


示例4: CurrentException2

		public void CurrentException2()
		{
			ComplexDoubleVector test = new ComplexDoubleVector(new Complex[2] { 1, 2 });
			IEnumerator enumerator = test.GetEnumerator();
			enumerator.MoveNext();
			enumerator.MoveNext();
			enumerator.MoveNext();
			object value = enumerator.Current;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:9,代码来源:ComplexDoubleVectorEnumeratorTest.cs


示例5: CtorArray

 public void CtorArray()
 {
   double[] testvector = new double[2]{0,1};
   
   ComplexDoubleVector test = new ComplexDoubleVector(testvector);
   Assert.AreEqual(test.Length,testvector.Length);
   Assert.AreEqual(test[0],new Complex(testvector[0]));
   Assert.AreEqual(test[1],new Complex(testvector[1]));
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:9,代码来源:ComplexDoubleVectorTest.cs


示例6: GenerateColumn

		public static ComplexDoubleVector GenerateColumn(IComplexDoubleMatrix A, int r1, int r2, int c)
		{
			int ru = r2 - r1 + 1;
			ComplexDoubleVector u = new ComplexDoubleVector(r2 - r1 + 1);

			for (int i = r1; i <= r2; i++)
			{
				u[i - r1] = A[i, c];
				A[i, c] = Complex.Zero;
			}

			double norm = u.GetNorm();

			if (r1 == r2 || norm == 0)
			{
				A[r1, c] = new Complex(-u[0]);
				u[0] = System.Math.Sqrt(2);
				return u;
			}

			Complex scale = new Complex(1 / norm, 0);

			Complex t = Complex.Zero;
			Complex t1 = Complex.Zero;
			if (u[0].Real != 0 || u[0].Imag != 0)
			{
				t = u[0];
				t1 = ComplexMath.Conjugate(u[0]);
				t = ComplexMath.Absolute(t);
				t = t1 / t;
				scale = scale * t;
			}
			A[r1, c] = -Complex.One / scale;

			for (int i = 0; i < ru; i++)
			{
				u[i] = u[i] * scale;
			}

			u[0] = new Complex(u[0].Real + 1, 0);
			double s = System.Math.Sqrt(1 / u[0].Real);

			for (int i = 0; i < ru; i++)
			{
				u[i] = new Complex(s * u[i].Real, s * u[i].Imag);
			}
			return u;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:48,代码来源:HouseHolder.cs


示例7: Current

		public void Current()
		{
			ComplexDoubleVector test = new ComplexDoubleVector(new Complex[2] { 1, 2 });
			IEnumerator enumerator = test.GetEnumerator();
			bool movenextresult;

			movenextresult = enumerator.MoveNext();
			Assert.IsTrue(movenextresult);
			Assert.AreEqual(enumerator.Current, test[0]);

			movenextresult = enumerator.MoveNext();
			Assert.IsTrue(movenextresult);
			Assert.AreEqual(enumerator.Current, test[1]);

			movenextresult = enumerator.MoveNext();
			Assert.IsFalse(movenextresult);
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:17,代码来源:ComplexDoubleVectorEnumeratorTest.cs


示例8: ICollection

 public void ICollection()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new Complex[4]{0,1,2,3});
   Complex[] b = new Complex[5];
   
   Assert.AreEqual(a.Count,a.Length);
   
   a.CopyTo(b,1);
   Assert.AreEqual(b[0],(Complex)0);
   Assert.AreEqual(b[1],(Complex)0); 
   Assert.AreEqual(b[2],(Complex)1);
   Assert.AreEqual(b[3],(Complex)2);
   Assert.AreEqual(b[4],(Complex)3); 
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:14,代码来源:ComplexDoubleVectorTest.cs


示例9: GetEnumerator

 public void GetEnumerator()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new Complex[4]{0,1,2,3});
   IEnumerator dve = a.GetEnumerator();
   Complex b;
   bool c;
   
   c = dve.MoveNext();
   b = (Complex)dve.Current;
   Assert.AreEqual(c,true);
   Assert.AreEqual(b,(Complex)0);
   
   c = dve.MoveNext();
   b = (Complex)dve.Current;
   Assert.AreEqual(c,true);
   Assert.AreEqual(b,(Complex)1);
   
   c = dve.MoveNext();
   b = (Complex)dve.Current;
   Assert.AreEqual(c,true);
   Assert.AreEqual(b,(Complex)2);
   
   c = dve.MoveNext();
   b = (Complex)dve.Current;
   Assert.AreEqual(c,true);
   Assert.AreEqual(b,(Complex)3);
   
   c = dve.MoveNext();
   Assert.AreEqual(c,false);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:30,代码来源:ComplexDoubleVectorTest.cs


示例10: Clone

 public void Clone()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new double[4]{0,1,2,3});
   ComplexDoubleVector b = a.Clone();
   
   Assert.AreEqual(a[0],b[0]);
   Assert.AreEqual(a[1],b[1]);
   Assert.AreEqual(a[2],b[2]);
   Assert.AreEqual(a[3],b[3]);
   
   a=a*2;
   
   Assert.AreEqual(a[0],b[0]*2);
   Assert.AreEqual(a[1],b[1]*2);
   Assert.AreEqual(a[2],b[2]*2);
   Assert.AreEqual(a[3],b[3]*2);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:17,代码来源:ComplexDoubleVectorTest.cs


示例11: GetEnumeratorException

 public void GetEnumeratorException()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new Complex[4]{0,1,2,3});
   IEnumerator dve = a.GetEnumerator();
   
   Complex b = (Complex)dve.Current;
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:ComplexDoubleVectorTest.cs


示例12: GetSum

 public void GetSum()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new double[4]{0,1,2,3});
   ComplexDoubleVector b = new ComplexDoubleVector(new double[4]{4,5,6,7});
   
   Assert.AreEqual(a.GetSum(),(Complex)6);
   Assert.AreEqual(a.GetSumMagnitudes(),6);
   
   Assert.AreEqual(b.GetSum(),(Complex)22);
   Assert.AreEqual(b.GetSumMagnitudes(),22);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:11,代码来源:ComplexDoubleVectorTest.cs


示例13: Divide

 public void Divide()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new double[4]{0,1,2,3});
   ComplexDoubleVector c = new ComplexDoubleVector(a);
   ComplexDoubleVector d = new ComplexDoubleVector(a);
   double scal = -4;
     
   c = a/scal;
   d = ComplexDoubleVector.Divide(a,scal);
     
   Assert.AreEqual(c[0],a[0]/scal);
   Assert.AreEqual(c[1],a[1]/scal);
   Assert.AreEqual(c[2],a[2]/scal);
   Assert.AreEqual(c[3],a[3]/scal);  
   
   Assert.AreEqual(d[0],a[0]/scal);
   Assert.AreEqual(d[1],a[1]/scal);
   Assert.AreEqual(d[2],a[2]/scal);
   Assert.AreEqual(d[3],a[3]/scal);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:20,代码来源:ComplexDoubleVectorTest.cs


示例14: YuleWalker

    /// <summary>
    /// Solve the Yule-Walker equations for a symmetric square Toeplitz system
    /// </summary>
    /// <param name="R">The left-most column of the Toeplitz matrix.</param>
    /// <returns>The solution vector.</returns>
    /// <exception cref="ArgumentNullException">
    /// <B>R</B> is a null reference.
    /// </exception>
    /// <exception cref="ArgumentOutOfRangeException">
    /// The length of <B>R</B> must be greater than one.
    /// </exception>
    /// <exception cref="SingularMatrixException">
    /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
    /// </exception>
    /// <remarks>
    /// This member is used to solve the Yule-Walker system <B>AX</B> = -<B>a</B>,
    /// where <B>A</B> is a symmetric square Toeplitz matrix, constructed
    /// from the elements <B>R[0]</B>, ..., <B>R[N-2]</B> and
    /// the vector <B>a</B> is constructed from the elements
    /// <B>R[1]</B>, ..., <B>R[N-1]</B>.
    /// <para>
    /// Durbin's algorithm is used to solve the linear system. It requires
    /// approximately the <b>N</b> squared FLOPS to calculate the
    /// solution (<b>N</b> is the matrix order).
    /// </para>
    /// </remarks>
    public static ComplexDoubleVector YuleWalker(IROComplexDoubleVector R)
    {

      ComplexDoubleVector a;

      // check parameters
      if (R == null)
      {
        throw new System.ArgumentNullException("R");
      }
      else if (R.Length < 2)
      {
        throw new System.ArgumentOutOfRangeException("R", "The length of R must be greater than 1.");
      }
      else
      {

        int N = R.Length - 1;
        a = new ComplexDoubleVector(N);             // prediction coefficients
        ComplexDoubleVector Z = new ComplexDoubleVector(N);   // temporary storage vector
        Complex e;                    // predictor error
        Complex inner;                  // inner product
        Complex g;                    // reflection coefficient
        int i, j, l;

        // setup first order solution
        e = R[0];
        if (e == Complex.Zero)
        {
          throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
        }
        g = -R[1] / R[0];
        a[0] = g;

        // calculate solution for successive orders
        for (i = 1; i < N; i++)
        {

          e *= (Complex.One - g * g);
          if (e == Complex.Zero)
          {
            throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
          }

          // calculate inner product
          inner = R[i + 1];
          for (j = 0, l = i; j < i; j++, l--)
          {
            inner += a[j] * R[l];
          }

          // update prediction coefficients
          g = -(inner / e);
          for (j = 0, l = i - 1; j < i; j++, l--)
          {
            Z[j] = a[j] + g * a[l];
          }

          // copy vector
          for (j = 0; j < i; j++)
          {
            a[j] = Z[j];
          }

          a[i] = g;

        }
      }

      return a;
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:97,代码来源:ComplexDoubleSymmetricLevinson.cs


示例15: Solve

    /// <overloads>
    /// Solve a symmetric square Toeplitz system.
    /// </overloads>
    /// <summary>
    /// Solve a symmetric square Toeplitz system with a right-side vector.
    /// </summary>
    /// <param name="Y">The right-hand side of the system.</param>
    /// <returns>The solution vector.</returns>
    /// <exception cref="ArgumentNullException">
    /// Parameter <B>Y</B> is a null reference.
    /// </exception>
    /// <exception cref="RankException">
    /// The length of <B>Y</B> is not equal to the number of rows in the Toeplitz matrix.
    /// </exception>
    /// <exception cref="SingularMatrixException">
    /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
    /// </exception>
    /// <remarks>
    /// This member solves the linear system <B>TX</B> = <B>Y</B>, where <B>T</B> is
    /// the symmetric square Toeplitz matrix, <B>X</B> is the unknown solution vector
    /// and <B>Y</B> is a known vector.
    /// <para>
    /// The class implicitly decomposes the inverse Toeplitz matrix into a <b>UDL</b> factorisation
    /// using the Levinson algorithm, and then calculates the solution vector.
    /// </para>
    /// </remarks>
    public ComplexDoubleVector Solve(IROComplexDoubleVector Y)
    {
      ComplexDoubleVector X;

      // check parameters
      if (Y == null)
      {
        throw new System.ArgumentNullException("Y");
      }
      else if (m_Order != Y.Length)
      {
        throw new RankException("The length of Y is not equal to the number of rows in the Toeplitz matrix.");
      }

      Compute();

      if (m_IsSingular == true)
      {
        throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
      }

      int i, j, l;      // index/loop variables
      Complex Inner;      // inner product
      Complex G;        // scaling constant
      Complex[] A;        // reference to current order coefficients

      // allocate memory for solution
      X = new ComplexDoubleVector(m_Order);

      // setup zero order solution
      X[0] = Y[0] / m_LeftColumn[0];

      // solve systems of increasing order
      for (i = 1; i < m_Order; i++)
      {
        // calculate inner product
        Inner = Y[i];
        for (j = 0, l = i; j < i; j++, l--)
        {
          Inner -= X[j] * m_LeftColumn[l];
        }
        // get the current predictor coefficients row
        A = m_LowerTriangle[i];

        // update the solution vector
        G = Inner * m_Diagonal[i];
        for (j = 0; j <= i; j++)
        {
          X[j] += G * A[j];
        }

      }

      return X;
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:81,代码来源:ComplexDoubleSymmetricLevinson.cs


示例16: Add

 public void Add()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new double[4]{0,1,2,3});
   ComplexDoubleVector b = new ComplexDoubleVector(new double[4]{4,5,6,7});
   ComplexDoubleVector c = new ComplexDoubleVector(a.Length);
   ComplexDoubleVector d = new ComplexDoubleVector(b.Length);
   
   c = a+b;
   d = ComplexDoubleVector.Add(a,b);
   
   Assert.AreEqual(c[0],a[0]+b[0]);
   Assert.AreEqual(c[1],a[1]+b[1]);
   Assert.AreEqual(c[2],a[2]+b[2]);
   Assert.AreEqual(c[3],a[3]+b[3]);
   
   Assert.AreEqual(d[0],c[0]);
   Assert.AreEqual(d[1],c[1]);
   Assert.AreEqual(d[2],c[2]);
   Assert.AreEqual(d[3],c[3]);
   
   a.Add(b);
   
   Assert.AreEqual(c[0],a[0]);
   Assert.AreEqual(c[1],a[1]);
   Assert.AreEqual(c[2],a[2]);
   Assert.AreEqual(c[3],a[3]);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:27,代码来源:ComplexDoubleVectorTest.cs


示例17: CtorCopy

 public void CtorCopy()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new double[2]{0,1});
   ComplexDoubleVector b = new ComplexDoubleVector(a);
   
   Assert.AreEqual(b.Length,a.Length);
   Assert.AreEqual(b[0],a[0]);
   Assert.AreEqual(b[1],a[1]);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:9,代码来源:ComplexDoubleVectorTest.cs


示例18: Subtract

 public void Subtract()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new double[4]{0,1,2,3});
   ComplexDoubleVector b = new ComplexDoubleVector(new double[4]{4,5,6,7});
   ComplexDoubleVector c = new ComplexDoubleVector(a.Length);
   ComplexDoubleVector d = new ComplexDoubleVector(b.Length);
   
   c = a-b;
   d = ComplexDoubleVector.Subtract(a,b);
   
   Assert.AreEqual(c[0],a[0]-b[0]);
   Assert.AreEqual(c[1],a[1]-b[1]);
   Assert.AreEqual(c[2],a[2]-b[2]);
   Assert.AreEqual(c[3],a[3]-b[3]);
   
   Assert.AreEqual(d[0],c[0]);
   Assert.AreEqual(d[1],c[1]);
   Assert.AreEqual(d[2],c[2]);
   Assert.AreEqual(d[3],c[3]);
   
   a.Subtract(b);
   
   Assert.AreEqual(c[0],a[0]);
   Assert.AreEqual(c[1],a[1]);
   Assert.AreEqual(c[2],a[2]);
   Assert.AreEqual(c[3],a[3]);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:27,代码来源:ComplexDoubleVectorTest.cs


示例19: Negate

 public void Negate()
 {
   double[] vec = new double[4]{0,1,2,3};
   ComplexDoubleVector a = new ComplexDoubleVector(vec);
   ComplexDoubleVector b = -a;
   
   a = ComplexDoubleVector.Negate(a);
   
   Assert.AreEqual(-(Complex)vec[0],a[0]);
   Assert.AreEqual(-(Complex)vec[1],a[1]);
   Assert.AreEqual(-(Complex)vec[2],a[2]);
   Assert.AreEqual(-(Complex)vec[3],a[3]);
   
   Assert.AreEqual(-(Complex)vec[0],b[0]);
   Assert.AreEqual(-(Complex)vec[1],b[1]);
   Assert.AreEqual(-(Complex)vec[2],b[2]);
   Assert.AreEqual(-(Complex)vec[3],b[3]);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:18,代码来源:ComplexDoubleVectorTest.cs


示例20: Axpy

 public void Axpy()
 {
   ComplexDoubleVector a = new ComplexDoubleVector(new double[4]{0,1,2,3});
   Double scal = 3;
   ComplexDoubleVector b = new ComplexDoubleVector(4);
   
   b.Axpy(scal,a);
   a.Scale(scal);
   
   Assert.AreEqual(a[0],b[0]);
   Assert.AreEqual(a[1],b[1]);
   Assert.AreEqual(a[2],b[2]);
   Assert.AreEqual(a[3],b[3]);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:14,代码来源:ComplexDoubleVectorTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LinearAlgebra.ComplexFloatVector类代码示例发布时间:2022-05-24
下一篇:
C# Calc.ComplexFloat类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap