public RealVector this[string ColumnsOrRows]
        {
            get
            {
                RealVector retVal = new RealVector();
                if (ColumnsOrRows.Length != 2 && ColumnsOrRows.IndexOf(".") == -1)
                {
                    throw new Exception("Bad indexer. Should by .j or i. with i or j being numeric such as .1 or 2.");
                }

                RowOrColumn rc = new RowOrColumn();
                try
                {
                    if (ColumnsOrRows[0] == '.') // Column
                    {
                        rc.rowColumn = RowColumn.Column;
                        rc.Val       = int.Parse(ColumnsOrRows[1].ToString()) - 1;
                    }
                    else // Row
                    {
                        rc.rowColumn = RowColumn.Row;
                        rc.Val       = int.Parse(ColumnsOrRows[0].ToString()) - 1;
                    }
                }
                catch
                {
                    throw new Exception("Bad indexer. Should by .j or i. with i or j being numeric such as .1 or 2.");
                }
                retVal               = this[rc];
                retVal.FullRep       = this.Name + "_" + ColumnsOrRows + @"\;=\;" + retVal.ToLatex();
                retVal.IsRowOrColumn = rc.rowColumn;
                return(retVal);
            }
        }
        public RealVector this[RowOrColumn rc]
        {
            get
            {
                RealVector retVal = new RealVector();

                if (rc.rowColumn == RowColumn.Column)
                {
                    retVal = this[rc.Val];
                }
                else
                {
                    for (int rowCount = 0; rowCount < Columns; rowCount++)
                    {
                        retVal.Add(InternalRep[rc.Val, rowCount]);
                    }
                }
                return(retVal);
            }
            set
            {
                if (rc.rowColumn == RowColumn.Column)
                {
                    this[rc.Val] = value;
                }
                else
                {
                    for (int colcount = 0; colcount < Columns; colcount++)
                    {
                        InternalRep[rc.Val, colcount] = value[colcount];
                    }
                }
            }
        }
        public SquareRealMatrix Transpose()
        {
            SquareRealMatrix retVal = new SquareRealMatrix(this.Rows, this.Columns);
            RowOrColumn      rc     = new RowOrColumn();

            rc.rowColumn = RowColumn.Row;
            rc.Val       = 0;
            for (int rowCount = 0; rowCount < Rows; rowCount++)
            {
                RealVector rv = this[rowCount];
                rc.Val     = rowCount;
                retVal[rc] = rv;
            }

            return(retVal);
        }
Example #4
0
        public SymbolMatrix ReName(List <string> newSymbols)
        {
            SymbolMatrix flipper = new SymbolMatrix(this.Rows, this.Columns);
            RowOrColumn  rc      = new RowOrColumn();

            rc.rowColumn = RowColumn.Row;
            rc.Val       = 0;

            SymbolVector oldSymbols = this[rc];

            for (int rowCount = 0; rowCount < Rows; rowCount++)
            {
                for (int colCount = 0; colCount < Columns; colCount++)
                {
                    int    ind = oldSymbols.FindIndex(f => f.Expression == this[rowCount, colCount].Expression);
                    Symbol sym = new Symbol(newSymbols[ind]);
                    sym.IsExpression            = true;
                    flipper[rowCount, colCount] = sym;
                }
            }
            return(flipper);
        }