當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。