Esempio n. 1
0
        public static PermutationMatrix operator *(PermutationMatrix a, PermutationMatrix b)
        {
            PermutationMatrix ret = new PermutationMatrix(a.Rows, a.Columns);

            for (int i = 0; i < ret.Rows; i++)
            {
                for (int j = 0; j < ret.Columns; j++)
                {
                    for (int k = 0; k < ret.Columns; k++)
                    {
                        ret.InternalRep[i, j] += a.InternalRep[i, k] * b.InternalRep[k, j];
                    }
                }
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(a.ToLatex());
            sb.Append(b.ToLatex());
            sb.Append(" = ");
            sb.Append(ret.ToLatex());

            ret.FullRep = sb.ToString();


            return(ret);
        }
Esempio n. 2
0
        public Permutation(int[] TR, int[] BR)
        {
            TopRow    = TR;
            BottomRow = BR;

            IsIdentity       = BR.SequenceEqual(TR);
            ElementName      = string.Join("", BR);
            ElementNameValue = long.Parse(ElementName);
            Matrix           = new PermutationMatrix(this);
        }
Esempio n. 3
0
        public PermutationMatrix Transpose()
        {
            PermutationMatrix ret = new PermutationMatrix(this.Rows, this.Columns);

            for (int i = 0; i < this.Columns; i++)
            {
                for (int j = 0; j < this.Rows; j++)
                {
                    ret.InternalRep[j, i] = this.InternalRep[i, j];
                }
            }
            return(ret);
        }
Esempio n. 4
0
        public PermutationMatrix Inverse()
        {
            PermutationMatrix ret = this.Transpose();
            StringBuilder     sb  = new StringBuilder();

            sb.Append(this.ToLatex() + "^{-1}");
            sb.Append(" = ");
            sb.Append(ret.ToLatex());

            ret.FullRep = sb.ToString();

            return(ret);
        }