Beispiel #1
0
        public Vec Clone()
        {
            var array  = VariablesList.ToArray();
            var result = new Vec(array);

            result.Sign = Sign;

            return(result);
        }
Beispiel #2
0
        public Vec ReplaceVarWithVec(Vec vec, int basicVarNumber)
        {
            Vec result = new Vec(VariablesList.ToArray());

            result.Sign = Sign;

            result = result.AddFunc(vec.Mul(result[basicVarNumber]));
            result[basicVarNumber] = 0;

            return(result);
        }
Beispiel #3
0
        public Vec AddFunc(Vec vec)
        {
            Vec result = new Vec(VariablesList.ToArray());

            result.Sign = Sign;

            for (int i = 0; i <= VariablesCount; i++)
            {
                result[i] += vec[i];
            }

            return(result);
        }
Beispiel #4
0
        public Vec Mul(double ratio)
        {
            Vec result = new Vec(VariablesList.ToArray());

            result.Sign = Sign;

            for (int i = 0; i <= VariablesCount; i++)
            {
                result[i] *= ratio;
            }

            return(result);
        }
Beispiel #5
0
        public Vec GetTagretFunc(IList <Vec> vecList, IList <int> basicVarNumbers)
        {
            if (basicVarNumbers == null)
            {
                return(null);
            }

            Vec target = new Vec(VariablesList.ToArray());

            target.Sign = Sign;

            for (int i = 0; i < vecList.Count; i++)
            {
                var limit = vecList[i].Solve(basicVarNumbers[i]);
                target = target.ReplaceVarWithVec(limit, basicVarNumbers[i]);
            }

            return(target);
        }
Beispiel #6
0
        public Vec Solve(int varNum)
        {
            double ratio = 1 / this[varNum];

            Vec result = new Vec(VariablesList.ToArray());

            result.Sign = Sign;

            for (int i = 0; i <= VariablesCount; i++)
            {
                if (i == varNum)
                {
                    result[i] = 0;
                    continue;
                }

                result[i] *= -ratio;
            }

            return(result);
        }