Esempio n. 1
0
            protected override TOperatorReturn OperatorMultiply(int dist)
            {
                var result = new TOperatorReturn()
                {
                    Vec = (int[])Vec.Clone(), Dim = Dim
                };

                for (int i = 0; i < result.Dim; i++)
                {
                    result[i] *= dist;
                }
                return(result);
            }
Esempio n. 2
0
            // only when we will use the operator we should implement its logic
            protected override TOperatorReturn OperatorSubtract(VectorOfInt <TSelf, TDim, TOperatorReturn> dist)
            {
                var result = new TOperatorReturn()
                {
                    Vec = (int[])Vec.Clone(), Dim = Dim
                };

                for (int i = 0; i < result.Dim; i++)
                {
                    result[i] -= dist[i];
                }
                return(result);
            }
Esempio n. 3
0
            protected override TOperatorReturn OperatorAdd(VectorOfInt <TSelf, TDim, TOperatorReturn> dist)
            {
                // if we type {Vec = Vec} this will pass Vec value by reference so , but we just need a copy
                // we need to persist the actual value
                var result = new TOperatorReturn()
                {
                    Vec = (int[])Vec.Clone(), Dim = Dim
                };

                for (int i = 0; i < result.Dim; i++)
                {
                    result[i] += dist[i];
                }
                return(result);
            }
Esempio n. 4
0
        private void Fill()
        {
            var prevMat    = A.Clone();
            var prevSumVec = Z.Clone();

            for (int column = 0; column <= A.VariablesCount; column++)
            {
                A[resolvingRow, column] /= resolvingElemValue;
            }

            for (int row = 0; row <= A.RowsCount; row++)
            {
                for (int column = 0; column <= A.VariablesCount; column++)
                {
                    if (row == A.RowsCount)
                    {
                        if (column != 0)
                        {
                            double a = resolvingElemValue * prevSumVec[column];
                            double b = (column != 0 ? prevMat[resolvingRow, column] : -prevMat[resolvingRow, column]) * prevSumVec[resolvingColumn];

                            double sub = a - b;
                            Z[column] = sub / resolvingElemValue;
                        }
                    }
                    else if (row != resolvingRow)
                    {
                        double a = resolvingElemValue * (column != 0 ? prevMat[row, column] : -prevMat[row, column]);
                        double b = (column != 0 ? prevMat[resolvingRow, column] : -prevMat[resolvingRow, column]) * prevMat[row, resolvingColumn];

                        double sub = a - b;
                        A[row, column] = (column != 0 ? sub / resolvingElemValue : -sub / resolvingElemValue);
                    }
                }
            }

            basSum = (basSum * resolvingElemValue - prevSumVec[resolvingColumn]) / resolvingElemValue;
        }