public IvyFEM.Lapack.ComplexMatrix CalcBoundaryMatrix( double omega, System.Numerics.Complex[] betas, System.Numerics.Complex[][] ezEVecs) { int nodeCnt = ezEVecs[0].Length; IvyFEM.Lapack.ComplexMatrix X = new Lapack.ComplexMatrix(nodeCnt, nodeCnt); int modeCnt = betas.Length; for (int iMode = 0; iMode < modeCnt; iMode++) { var beta = betas[iMode]; var ezEVec = ezEVecs[iMode]; var RyyZ = (IvyFEM.Lapack.ComplexMatrix)Ryy; var vec1 = RyyZ * ezEVec; var vec2 = RyyZ * IvyFEM.Lapack.Utils.Conjugate(ezEVec); for (int col = 0; col < nodeCnt; col++) { for (int row = 0; row < nodeCnt; row++) { System.Numerics.Complex value = (System.Numerics.Complex.ImaginaryOne / (omega * Constants.Mu0)) * beta * beta.Magnitude * vec1[col] * vec2[row]; X[row, col] += value; } } } return(X); }
public void Transpose() { ComplexMatrix t = new ComplexMatrix(ColumnLength, RowLength); for (int row = 0; row < RowLength; row++) { for (int col = 0; col < ColumnLength; col++) { t[col, row] = this[row, col]; } } Copy(t.Buffer, t.RowLength, t.ColumnLength, false); }
public static ComplexMatrix operator *(ComplexMatrix A, ComplexMatrix B) { System.Numerics.Complex[] c; int cRow; int cCol; IvyFEM.Lapack.Functions.zgemmAB(out c, out cRow, out cCol, A.Buffer, A.RowLength, A.ColumnLength, TransposeType.Nop, B.Buffer, B.RowLength, B.ColumnLength, TransposeType.Nop); bool alloc = false; ComplexMatrix C = new ComplexMatrix(c, cRow, cCol, alloc); return(C); }
public static System.Numerics.Complex DoubleDot(ComplexMatrix A, ComplexMatrix B) { System.Diagnostics.Debug.Assert(A.RowLength == B.ColumnLength); System.Diagnostics.Debug.Assert(A.ColumnLength == B.RowLength); int nRow = A.RowLength; int nCol = A.ColumnLength; System.Numerics.Complex ret = 0; for (int row = 0; row < nRow; row++) { for (int col = 0; col < nCol; col++) { ret += A[row, col] * System.Numerics.Complex.Conjugate(B[col, row]); } } return(ret); }
public static ComplexMatrix Inverse(ComplexMatrix A) { System.Diagnostics.Debug.Assert(A.RowLength == A.ColumnLength); int n = A.RowLength; ComplexMatrix workA = new ComplexMatrix(A); ComplexMatrix workB = new ComplexMatrix(n, n); workB.Identity(); // 単位行列 System.Numerics.Complex[] a = workA.Buffer; System.Numerics.Complex[] b = workB.Buffer; // [A][X] = [B] // [B]の内容が書き換えられるので、matXを新たに生成せず、Bを出力に指定している int xRow = 0; int xCol = 0; IvyFEM.Lapack.Functions.zgesv(out b, out xRow, out xCol, a, n, n, b, n, n); bool alloc = false; // 指定したバッファを使用する ComplexMatrix X = new ComplexMatrix(b, xRow, xCol, alloc); return(X); }
public ComplexMatrix(ComplexMatrix src) { Copy(src); }
public void Inverse() { ComplexMatrix ret = Inverse(this); Copy(ret.Buffer, ret.RowLength, ret.ColumnLength, false); }
public void Conjugate() { ComplexMatrix ret = Conjugate(this); Buffer = ret.Buffer; }
public void Copy(ComplexMatrix src) { Copy(src.Buffer, src.RowLength, src.ColumnLength, true); }