LSLib.LS.Matrix.Duplicate C# (CSharp) Méthode

Duplicate() public méthode

public Duplicate ( ) : Matrix
Résultat Matrix
        public Matrix Duplicate()                   // Function returns the copy of this matrix
        {
            Matrix matrix = new Matrix(rows, cols);
            for (int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i, j] = mat[i, j];
            return matrix;
        }

Usage Example

Exemple #1
0
        public static Matrix Power(Matrix m, int pow)           // Power matrix to exponent
        {
            if (pow == 0)
            {
                return(IdentityMatrix(m.rows, m.cols));
            }
            if (pow == 1)
            {
                return(m.Duplicate());
            }
            if (pow == -1)
            {
                return(m.Invert());
            }

            Matrix x;

            if (pow < 0)
            {
                x = m.Invert(); pow *= -1;
            }
            else
            {
                x = m.Duplicate();
            }

            Matrix ret = IdentityMatrix(m.rows, m.cols);

            while (pow != 0)
            {
                if ((pow & 1) == 1)
                {
                    ret *= x;
                }
                x    *= x;
                pow >>= 1;
            }
            return(ret);
        }
All Usage Examples Of LSLib.LS.Matrix::Duplicate