コード例 #1
0
        public Vec Clone()
        {
            var array  = VariablesList.ToArray();
            var result = new Vec(array);

            result.Sign = Sign;

            return(result);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }