Пример #1
0
        public override bool Equals(object obj)
        {
            if (!(obj is RowVector))
            {
                throw new NotSupportedException("Can not compare because their type is not same.");
            }
            if (obj == null)
            {
                return((this as object) == null);
            }
            RowVector other = obj as RowVector;

            if (this.Count != other.Count)
            {
                return(false);
            }
            else
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if (this[i] != other[i])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #2
0
        public static RowVector operator-(RowVector row1)
        {
            RowVector newRow = new RowVector(row1);

            for (int i = 0; i < newRow.Count; i++)
            {
                newRow[i] = 0 - newRow[i];
            }
            return(newRow);
        }
Пример #3
0
 public void AppendRow(RowVector row)
 {
     if (row.Count != this.ColumnsCount)
     {
         throw new NotSupportedException("The count of row which is appeded to matrix is not equal to the count of column of matrix.");
     }
     this.m_data.Add(row);
     this.m_RowsCount++;
     m_Columns.Clear();
 }
Пример #4
0
        public RowVector MultiplyWithNumber(decimal x)
        {
            RowVector newRow = new RowVector(this);

            for (int i = 0; i < newRow.Count; i++)
            {
                newRow[i] = (double)Math.Round((decimal)newRow[i] * x, 5, MidpointRounding.AwayFromZero);
            }

            return(newRow);
        }
Пример #5
0
        public RowVector Plus(RowVector row)
        {
            if (row.Count != this.m_Count)
            {
                throw new NotSupportedException("Can not plus two row because their count is not equal.");
            }
            RowVector newRow = new RowVector(this);

            for (int i = 0; i < this.Count; i++)
            {
                newRow[i] += row[i];
            }
            return(newRow);
        }
Пример #6
0
 public void InsertRow(RowVector row, int index)
 {
     if (row.Count != this.ColumnsCount)
     {
         throw new NotSupportedException("The count of row which is appeded to matrix is not equal to the count of column of matrix.");
     }
     if (index < 0 || index >= this.RowsCount)
     {
         throw new NotSupportedException("The row insertion position is beyond the boundary of the matrix.");
     }
     this.m_data.Insert(index, row);
     this.m_RowsCount++;
     m_Columns.Clear();
 }
Пример #7
0
        public RowVector MultiplyLeftWithRowVector(RowVector row)
        {
            if (row.Count != this.RowsCount)
            {
                throw new NotSupportedException("Can not multiply RowVector * Matrix because Rowvector's count is not equal with Matrix's ColumnCount.");
            }
            RowVector newRow = new RowVector();

            foreach (ColumnVector column in this.GetColumnVectors())
            {
                newRow.Append(row * column);
            }
            return(newRow);
        }
Пример #8
0
        public Matrix GetInverseMatrix()
        {
            List <RowVector> newRows = new List <RowVector>();

            for (int i = 0; i < this.RowsCount; i++)
            {
                RowVector row = new RowVector();
                for (int j = 0; j < this.ColumnsCount; j++)
                {
                    row.Append(this.GetAlgeraicComplement(i, j));
                }
                newRows.Add(row);
            }
            Matrix  newMatrix = new Matrix(newRows);
            double  module    = this.GetModule();
            decimal temp      = (decimal)1.0 / (decimal)module;

            newMatrix = newMatrix * temp;
            return(newMatrix.GetTransposeMatrix());
        }
Пример #9
0
        public RowVector MultiplyRightWithMatrix(Matrix matrix)
        {
            if (this.Count == 0)
            {
                throw new NotSupportedException("The count of row vector is zero when row vector is multiplied with matrix.");
            }
            if (matrix.RowsCount == 0)
            {
                throw new NotSupportedException("The row count of matrix is zero when row vector is multiplied with matrix.");
            }
            if (this.Count != matrix.RowsCount)
            {
                throw new NotSupportedException("The count of row vector is not equal to matrix's row count when row vector is multiplied with matrix.");
            }

            RowVector result = new RowVector();

            foreach (ColumnVector column in matrix.GetColumnVectors())
            {
                result.Append(this * column);
            }
            return(result);
        }
Пример #10
0
 public RowVector(RowVector vector)
 {
     m_data  = vector.m_data.Where(t => true).ToList();
     m_Count = vector.m_Count;
 }
Пример #11
0
 public double MultiplyLeftWithRowVector(RowVector row)
 {
     return(row * this);
 }
Пример #12
0
 public RowVector Minus(RowVector row)
 {
     return(this.Plus(-row));
 }