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


C# Complex.Abs方法代码示例

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


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

示例1: CalculatGivensRotation

        public static Matrix CalculatGivensRotation(Complex a, Complex b)
        {
            Complex c, s, r;

            r = ComplexMath.Sqrt(a.Conjugate() * a + b.Conjugate() * b);

            if (b == 0) {
                c = 1;
                s = 0;
            } else if (a == 0) {
                c = 0;
                s = ComplexMath.Sign(b.Conjugate());
            } else {
                c = a.Abs() / r;
                s = ComplexMath.Sign(a) * b.Conjugate() / r;
            }

            Matrix givensRot = new Matrix(2);
            givensRot[0, 0] = c;
            givensRot[0, 1] = s;
            givensRot[1, 0] = -s.Conjugate();
            givensRot[1, 1] = c;

            return givensRot;
        }
开发者ID:DonDoff,项目名称:Maths,代码行数:25,代码来源:MatrixMath.cs

示例2: RowEchelon

 /// <summary>
 ///   RowEchelon
 /// </summary>
 /// <returns> </returns>
 public Matrix RowEchelon()
 {
     var echelon = Elements;
     var rows = (int) Rows;
     var cols = (int) Cols;
     var row = 0;
     var col = 0;
     for (; row < rows; )
     {
         var maxPivot = new Complex(0); //echelon[row, col]
         //First Leftmost Max Column
         var pivotRow = row;
         for (var i = row; i < rows; ++i)
         {
             var pivot = echelon[i, col];
             if (!(pivot.Abs() > maxPivot.Abs())) continue;
             pivotRow = i;
             maxPivot = pivot;
         }
         if (maxPivot == 0)
         {
             ++col;
             if (col == cols) break;
             continue;
         }
         //Interchange rows
         if (row != pivotRow)
         {
             var tmpRow = new Complex[cols];
             for (var j = 0; j < cols; ++j) tmpRow[j] = echelon[row, j];
             for (var j = 0; j < cols; ++j) echelon[row, j] = echelon[pivotRow, j];
             for (var j = 0; j < cols; ++j) echelon[pivotRow, j] = tmpRow[j];
         }
         //Leading 1
         for (var j = col; j < cols; ++j) echelon[row, j] /= maxPivot;
         //Leading 0
         for (var i = row + 1; i < rows; ++i)
         {
             var multiple = echelon[i, col];
             for (var j = col; j < cols; ++j) echelon[i, j] -= multiple * echelon[row, j];
         }
         ++row;
         ++col;
     }
     return new Matrix(echelon);
 }
开发者ID:erashid,项目名称:Extensions,代码行数:50,代码来源:Matrix.cs

示例3: ReduceRowEchelon

 /// <summary>
 ///   Reduce RowEchelon
 /// </summary>
 /// <returns> </returns>
 public Matrix ReduceRowEchelon()
 {
     var rechelon = RowEchelon().Elements;
     var rows = (int) Rows;
     var cols = (int) Cols;
     for (var row = rows - 1; row >= 0; --row)
     {
         var col = 0;
         var nonzero = new Complex(0);
         //First Leftmost Nonzero Column (Leading 1)
         for (; col < cols; ++col)
         {
             nonzero = rechelon[row, col];
             if (Math.Abs(nonzero.Abs() - 0) > EPSILON) break;
         }
         if (nonzero == 0) continue;
         //Trailing 0
         for (var i = row - 1; i >= 0; --i)
         {
             var multiple = rechelon[i, col];
             for (uint j = 0; j < cols; ++j) rechelon[i, j] -= multiple * rechelon[row, j];
         }
     }
     return new Matrix(rechelon);
 }
开发者ID:erashid,项目名称:Extensions,代码行数:29,代码来源:Matrix.cs


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