public MatrixEquation <double> GenerateEquation()
        {
            IMatrixDataType <double>[][] rawA, rawB;

            rawA = new IMatrixDataType <double> [NOfEquasions][];
            rawB = new IMatrixDataType <double> [NOfEquasions][];

            for (int i = 0; i < NOfEquasions; i++)
            {
                rawA[i] = new IMatrixDataType <double> [NOfEquasions];
                rawB[i] = new IMatrixDataType <double> [1];
            }

            // wektor B ma same 0 i 1 na ostatnim miejscu
            for (int i = 0; i < NOfEquasions - 1; i++)
            {
                rawB[i][0] = MatrixDouble.ZERO;
            }
            rawB[NOfEquasions - 1][0] = MatrixDouble.ONE;

            // wypełnianie macierzy A
            for (int i = 0; i < NOfEquasions; i++)
            {
                for (int j = 0; j < NOfEquasions; j++)
                {
                    rawA[i][j] = GenerateValue(i, j);
                }
            }

            return(new MatrixEquation <double>(new Matrix <double>(rawA), null, new Matrix <double>(rawB)));
        }
        public Matrix <T> Multiply(Matrix <T> factor)
        {
            //mnoży przez siebie 2 macierze

            int newRowCount = this.RowCount;
            int newColCount = factor.ColCount;

            IMatrixDataType <T>[][] raw = new IMatrixDataType <T> [newRowCount][];
            for (int i = 0; i < this.RowCount; i++)
            {
                raw[i] = new IMatrixDataType <T> [newColCount];
            }

            for (int i = 0; i < newRowCount; i++)     //wiersze
            {
                for (int j = 0; j < newColCount; j++) //kolumny
                {
                    IMatrixDataType <T> res = this.ValueMatrix[i][0].Multiply(factor.ValueMatrix[0][j]);
                    for (int k = 1; k < this.ColCount; k++)
                    {
                        res = res.Add(this.ValueMatrix[i][k].Multiply(factor.ValueMatrix[k][j]));
                    }

                    raw[i][j] = res;
                }
            }

            return(new Matrix <T>(raw));
        }
        public static IMatrixDataType <T>[] SubtractRows(IMatrixDataType <T>[] row1, IMatrixDataType <T>[] row2)
        {
            //odejmuje 2 wiersz od pierwszego
            IMatrixDataType <T>[] newRow = new IMatrixDataType <T> [row1.Length];

            for (int i = 0; i < newRow.Length; i++)
            {
                newRow[i] = row1[i].Subtract(row2[i]);
            }

            return(newRow);
        }
        public static IMatrixDataType <T>[] MultiplyRow(IMatrixDataType <T>[] row, IMatrixDataType <T> factor)
        {
            //mnoży wiersz przez skalar
            IMatrixDataType <T>[] newRow = new IMatrixDataType <T> [row.Length];

            for (int i = 0; i < newRow.Length; i++)
            {
                newRow[i] = row[i].Multiply(factor);
            }

            return(newRow);
        }
        public static IMatrixDataType <T>[] AddRows(IMatrixDataType <T>[] row1, IMatrixDataType <T>[] row2)
        {
            //dodaje do siebie 2 wiersze
            IMatrixDataType <T>[] newRow = new IMatrixDataType <T> [row1.Length];

            for (int i = 0; i < newRow.Length; i++)
            {
                newRow[i] = row1[i].Add(row2[i]);
            }

            return(newRow);
        }
        public Matrix(IMatrixDataType <T>[][] raw)
        {
            this.RowCount = raw.Length;
            this.ColCount = raw[0].Length;

            ValueMatrix = new IMatrixDataType <T> [this.RowCount][];
            for (int i = 0; i < this.RowCount; i++)
            {
                ValueMatrix[i] = new IMatrixDataType <T> [this.ColCount];
            }

            for (int i = 0; i < this.RowCount; i++)
            {
                for (int j = 0; j < this.ColCount; j++)
                {
                    this.ValueMatrix[i][j] = raw[i][j];
                }
            }
        }
 public IMatrixDataType <float> Multiply(IMatrixDataType <float> number)
 {
     return(new MatrixFloat(GetValue() * number.GetValue()));
 }
Example #8
0
 public IMatrixDataType <double> Add(IMatrixDataType <double> number)
 {
     return(new MatrixDouble(GetValue() + number.GetValue()));
 }
Example #9
0
 public IMatrixDataType <BigIntFraction> Subtract(IMatrixDataType <BigIntFraction> number)
 {
     return(new MatrixBigIntFraction(GetValue().Subtract(number.GetValue())));
 }
 public IMatrixDataType <float> Divide(IMatrixDataType <float> number)
 {
     return(new MatrixFloat(GetValue() / number.GetValue()));
 }
Example #11
0
 public IMatrixDataType <double> Divide(IMatrixDataType <double> number)
 {
     return(new MatrixDouble(GetValue() / number.GetValue()));
 }
Example #12
0
 public int CompareTo(IMatrixDataType <double> number)
 {
     return(GetValue().CompareTo(number.GetValue()));
 }
Example #13
0
 public IMatrixDataType <double> Multiply(IMatrixDataType <double> number)
 {
     return(new MatrixDouble(GetValue() * number.GetValue()));
 }
 public IMatrixDataType <float> Subtract(IMatrixDataType <float> number)
 {
     return(new MatrixFloat(GetValue() - number.GetValue()));
 }
Example #15
0
 public IMatrixDataType <BigIntFraction> Multiply(IMatrixDataType <BigIntFraction> number)
 {
     return(new MatrixBigIntFraction(GetValue().Multiply(number.GetValue())));
 }
Example #16
0
 public int CompareTo(IMatrixDataType <BigIntFraction> number)
 {
     return(BigIntFraction.Compare(GetValue(), number.GetValue()));
 }
Example #17
0
 public IMatrixDataType <BigIntFraction> Divide(IMatrixDataType <BigIntFraction> number)
 {
     return(new MatrixBigIntFraction(this.GetValue().Divide(number.GetValue())));
 }
Example #18
0
 public IMatrixDataType <double> Subtract(IMatrixDataType <double> number)
 {
     return(new MatrixDouble(GetValue() - number.GetValue()));
 }
 public IMatrixDataType <float> Add(IMatrixDataType <float> number)
 {
     return(new MatrixFloat(GetValue() + number.GetValue()));
 }