Example #1
0
        // [X] = ([A]*)t
        public static MyComplexBandMatrix matrix_ConjugateTranspose(MyComplexBandMatrix matA)
        {
            MyComplexBandMatrix matX = new MyComplexBandMatrix(matA);

            matX.ConjugateTranspose();
            return(matX);
        }
Example #2
0
        // [X] = alpha * [A]
        public static MyComplexBandMatrix product(Complex alpha, MyComplexBandMatrix matA)
        {
            MyComplexBandMatrix matX = new MyComplexBandMatrix(matA.RowSize, matA.SubdiaSize, matA.SuperdiaSize);

            for (int i = 0; i < matA.RowSize; i++)
            {
                for (int j = 0; j < matA.ColumnSize; j++)
                {
                    matX[i, j] = alpha * matA[i, j];
                }
            }
            return(matX);
        }
Example #3
0
        public static MyComplexBandMatrix matrix_FromBuffer(Complex[] mat_, int nRowCol, int nSubdia, int nSuperdia, bool copyFlg = true)
        {
            MyComplexBandMatrix mat = null;

            if (copyFlg)
            {
                mat = new MyComplexBandMatrix(mat_, nRowCol, nSubdia, nSuperdia);
            }
            else
            {
                mat       = new MyComplexBandMatrix(nRowCol, nSubdia, nSuperdia);
                mat._body = mat_;
            }
            return(mat);
        }
Example #4
0
 public static Complex[] matrix_ToBuffer(MyComplexBandMatrix mat, bool copyFlg = true)
 {
     Complex[] mat_ = null;
     if (copyFlg)
     {
         int size = mat._rsize * mat._csize;
         mat_ = new Complex[size];
         mat._body.CopyTo(mat_, 0);
     }
     else
     {
         mat_ = mat._body;
     }
     return(mat_);
 }
Example #5
0
        // {x} = [A]{v}
        public static Complex[] product(MyComplexBandMatrix matA, Complex[] vec)
        {
            System.Diagnostics.Debug.Assert(matA.ColumnSize == vec.Length);
            //BUGFIX
            //Complex[] retVec = new Complex[vec.Length];
            Complex[] retVec = new Complex[matA.RowSize];

            for (int i = 0; i < matA.RowSize; i++)
            {
                retVec[i] = new Complex(0.0, 0.0);
                for (int k = 0; k < matA.ColumnSize; k++)
                {
                    retVec[i] += matA[i, k] * vec[k];
                }
            }
            return(retVec);
        }
Example #6
0
        // [X] = [A] - [B]
        public static MyComplexBandMatrix minus(MyComplexBandMatrix matA, MyComplexBandMatrix matB)
        {
            System.Diagnostics.Debug.Assert(matA.RowSize == matB.RowSize);
            System.Diagnostics.Debug.Assert(matA.ColumnSize == matB.ColumnSize);
            int rowcolSize   = matA.RowSize;
            int subdiaSize   = matA.SubdiaSize >= matB.SubdiaSize ? matA.SubdiaSize : matB.SubdiaSize;
            int superdiaSize = matA.SuperdiaSize >= matB.SuperdiaSize ? matA.SuperdiaSize : matB.SuperdiaSize;

            MyComplexBandMatrix matX = new MyComplexBandMatrix(rowcolSize, subdiaSize, superdiaSize);

            for (int i = 0; i < matA.RowSize; i++)
            {
                for (int j = 0; j < matA.ColumnSize; j++)
                {
                    matX[i, j] = matA[i, j] - matB[i, j];
                }
            }
            return(matX);
        }
Example #7
0
 // [X] = ([A]*)t
 public static MyComplexBandMatrix matrix_ConjugateTranspose(MyComplexBandMatrix matA)
 {
     MyComplexBandMatrix matX = new MyComplexBandMatrix(matA);
     matX.ConjugateTranspose();
     return matX;
 }
Example #8
0
        // [X] = [A] + [B]
        public static MyComplexBandMatrix plus(MyComplexBandMatrix matA, MyComplexBandMatrix matB)
        {
            System.Diagnostics.Debug.Assert(matA.RowSize == matB.RowSize);
            System.Diagnostics.Debug.Assert(matA.ColumnSize == matB.ColumnSize);
            int rowcolSize = matA.RowSize;
            int subdiaSize = matA.SubdiaSize >= matB.SubdiaSize ? matA.SubdiaSize : matB.SubdiaSize;
            int superdiaSize = matA.SuperdiaSize >= matB.SuperdiaSize ? matA.SuperdiaSize : matB.SuperdiaSize;

            MyComplexBandMatrix matX = new MyComplexBandMatrix(rowcolSize, subdiaSize, superdiaSize);
            for (int i = 0; i < matA.RowSize; i++)
            {
                for (int j = 0; j < matA.ColumnSize; j++)
                {
                    matX[i, j] = matA[i, j] + matB[i, j];
                }
            }
            return matX;
        }
Example #9
0
 public static Complex[] matrix_ToBuffer(MyComplexBandMatrix mat, bool copyFlg = true)
 {
     Complex[] mat_ = null;
     if (copyFlg)
     {
         int size = mat._rsize * mat._csize;
         mat_ = new Complex[size];
         mat._body.CopyTo(mat_, 0);
     }
     else
     {
         mat_ = mat._body;
     }
     return mat_;
 }
Example #10
0
 public static MyComplexBandMatrix matrix_FromBuffer(Complex[] mat_, int nRowCol, int nSubdia, int nSuperdia, bool copyFlg = true)
 {
     MyComplexBandMatrix mat = null;
     if (copyFlg)
     {
         mat = new MyComplexBandMatrix(mat_, nRowCol, nSubdia, nSuperdia);
     }
     else
     {
         mat = new MyComplexBandMatrix(nRowCol, nSubdia, nSuperdia);
         mat._body = mat_;
     }
     return mat;
 }
 /// <summary>
 /// �w�肳�ꂽ�s���R�s�[���āC�V�����s���쐬����D
 /// </summary>
 /// <param name="m">�R�s�[�����s��</param>
 public MyComplexBandMatrix(MyComplexBandMatrix m)
 {
     CopyFrom(m);
 }
        /// <summary>
        /// �]�u����D(�x�[�X�N���X��I/F�̃I�[�o�[���C�h)
        /// </summary>
        /// <returns>�]�u��̎��g�ւ̎Q��</returns>
        public override MyComplexMatrix Transpose()
        {
            //return base.Transpose();

            int rowcolSize = this._rowcolSize;
            int subdiaSize = 0;
            int superdiaSize = 0;
            // �]�u���subdiaSize, superdiaSize��擾����
            // r��c������ւ���Ă��邱�Ƃɒ���
            for (int r = 0; r < rowcolSize; r++)
            {
                if (r < rowcolSize - 1)
                {
                    int cnt = 0;
                    for (int c = rowcolSize - 1; c >= r + 1; c--)
                    {
                        // ��O�v�f�����‚������甲����
                        if (Math.Abs(this[c, r].Real) >= Constants.PrecisionLowerLimit || Math.Abs(this[c, r].Imaginary) >= Constants.PrecisionLowerLimit)
                        {
                            cnt = c - r;
                            break;
                        }
                    }
                    if (cnt > subdiaSize)
                    {
                        subdiaSize = cnt;
                    }
                }
                if (r > 0)
                {
                    int cnt = 0;
                    for (int c = 0; c <= r - 1; c++)
                    {
                        // ��O�v�f�����‚������甲����
                        if (Math.Abs(this[c, r].Real) >= Constants.PrecisionLowerLimit || Math.Abs(this[c, r].Imaginary) >= Constants.PrecisionLowerLimit)
                        {
                            cnt = r - c;
                            break;
                        }
                    }
                    if (cnt > superdiaSize)
                    {
                        superdiaSize = cnt;
                    }
                }
            }

            MyComplexBandMatrix t = new MyComplexBandMatrix(rowcolSize, subdiaSize, superdiaSize);
            for (int r = 0; r < this._rsize; ++r)
            {
                for (int c = 0; c < this._csize; ++c)
                {
                    //t[c, r] = this[r, c];
                    //t._body[c + r * this._csize] = this._body[r + c * this._rsize];
                    //t._body[(c - r) + t._subdiaSize + t._superdiaSize + r * t._rsize] = this._body[(r - c) + this._subdiaSize + this._superdiaSize + c * this._rsize];
                    t._body[(c - r) + t._subdiaSize + t._superdiaSize + r * t._rsize].Real = this._body[(r - c) + this._subdiaSize + this._superdiaSize + c * this._rsize].Real;
                    t._body[(c - r) + t._subdiaSize + t._superdiaSize + r * t._rsize].Imaginary = this._body[(r - c) + this._subdiaSize + this._superdiaSize + c * this._rsize].Imaginary;
                }
            }

            this.Clear();
            this._body = t._body;
            this._rsize = t._rsize;
            this._csize = t._csize;
            this._rowcolSize = t._rowcolSize;
            this._subdiaSize = t._subdiaSize;
            this._superdiaSize = t._superdiaSize;

            return this;
        }
Example #13
0
        /// <summary>
        /// 複素共役転置する.(ベースクラスのI/Fのオーバーライド)
        /// </summary>
        /// <returns>転置後の自身への参照</returns>
        public override MyComplexMatrix ConjugateTranspose()
        {
            //return base.ConjugateTranspose();

            int rowcolSize   = this._rowcolSize;
            int subdiaSize   = 0;
            int superdiaSize = 0;

            // 転置後のsubdiaSize, superdiaSizeを取得する
            // rとcが入れ替わっていることに注意
            for (int r = 0; r < rowcolSize; r++)
            {
                if (r < rowcolSize - 1)
                {
                    int cnt = 0;
                    for (int c = rowcolSize - 1; c >= r + 1; c--)
                    {
                        // 非0要素が見つかったら抜ける
                        if (Math.Abs(this[c, r].Real) >= Constants.PrecisionLowerLimit || Math.Abs(this[c, r].Imaginary) >= Constants.PrecisionLowerLimit)
                        {
                            cnt = c - r;
                            break;
                        }
                    }
                    if (cnt > subdiaSize)
                    {
                        subdiaSize = cnt;
                    }
                }
                if (r > 0)
                {
                    int cnt = 0;
                    for (int c = 0; c <= r - 1; c++)
                    {
                        // 非0要素が見つかったら抜ける
                        if (Math.Abs(this[c, r].Real) >= Constants.PrecisionLowerLimit || Math.Abs(this[c, r].Imaginary) >= Constants.PrecisionLowerLimit)
                        {
                            cnt = r - c;
                            break;
                        }
                    }
                    if (cnt > superdiaSize)
                    {
                        superdiaSize = cnt;
                    }
                }
            }

            MyComplexBandMatrix t = new MyComplexBandMatrix(rowcolSize, subdiaSize, superdiaSize);

            for (int r = 0; r < this._rsize; ++r)
            {
                for (int c = 0; c < this._csize; ++c)
                {
                    //t[c, r] = Complex.Conjugate(this[r, c]);
                    //t._body[(c - r) + t._subdiaSize + t._superdiaSize + r * t._rsize] = Complex.Conjugate(this._body[(r - c + this._subdiaSize + this._superdiaSize + c * this._rsize]);
                    t._body[(c - r) + t._subdiaSize + t._superdiaSize + r * t._rsize].Real      = this._body[(r - c) + this._subdiaSize + this._superdiaSize + c * this._rsize].Real;
                    t._body[(c - r) + t._subdiaSize + t._superdiaSize + r * t._rsize].Imaginary = -this._body[(r - c) + this._subdiaSize + this._superdiaSize + c * this._rsize].Imaginary;
                }
            }

            this.Clear();
            this._body         = t._body;
            this._rsize        = t._rsize;
            this._csize        = t._csize;
            this._rowcolSize   = t._rowcolSize;
            this._subdiaSize   = t._subdiaSize;
            this._superdiaSize = t._superdiaSize;

            return(this);
        }
Example #14
0
 /// <summary>
 /// 指定された行列をコピーして,新しい行列を作成する.
 /// </summary>
 /// <param name="m">コピーされる行列</param>
 public MyComplexBandMatrix(MyComplexBandMatrix m)
 {
     CopyFrom(m);
 }
Example #15
0
        // {x} = [A]{v}
        public static Complex[] product(MyComplexBandMatrix matA, Complex[] vec)
        {
            System.Diagnostics.Debug.Assert(matA.ColumnSize == vec.Length);
            //BUGFIX
            //Complex[] retVec = new Complex[vec.Length];
            Complex[] retVec = new Complex[matA.RowSize];

            for (int i = 0; i < matA.RowSize; i++)
            {
                retVec[i] = new Complex(0.0, 0.0);
                for (int k = 0; k < matA.ColumnSize; k++)
                {
                    retVec[i] += matA[i, k] * vec[k];
                }
            }
            return retVec;
        }
 /// <summary>
 /// �w�肳�ꂽ�s���R�s�[����D
 /// </summary>
 /// <param name="m">�R�s�[�����s��</param>
 /// <returns>�R�s�[��̎��g�ւ̎Q��</returns>
 public virtual MyComplexBandMatrix CopyFrom(MyComplexBandMatrix m)
 {
     return CopyFrom(m._body, m._rowcolSize, m._subdiaSize, m._superdiaSize);
 }
Example #17
0
 // [X] = alpha * [A]
 public static MyComplexBandMatrix product(Complex alpha, MyComplexBandMatrix matA)
 {
     MyComplexBandMatrix matX = new MyComplexBandMatrix(matA.RowSize, matA.SubdiaSize, matA.SuperdiaSize);
     for (int i = 0; i < matA.RowSize; i++)
     {
         for (int j = 0; j < matA.ColumnSize; j++)
         {
             matX[i, j] = alpha * matA[i, j];
         }
     }
     return matX;
 }
Example #18
0
 /// <summary>
 /// 指定された行列をコピーする.
 /// </summary>
 /// <param name="m">コピーされる行列</param>
 /// <returns>コピー後の自身への参照</returns>
 public virtual MyComplexBandMatrix CopyFrom(MyComplexBandMatrix m)
 {
     return(CopyFrom(m._body, m._rowcolSize, m._subdiaSize, m._superdiaSize));
 }