mirror of
https://github.com/rumata-ap/MatrixExtension_SMathStudio.git
synced 2026-01-12 03:49:47 +03:00
edit
This commit is contained in:
@@ -63,11 +63,11 @@ namespace MatrixExtensions
|
|||||||
FunctionSections.MatricesAndVectors, true,
|
FunctionSections.MatricesAndVectors, true,
|
||||||
new ArgumentInfo(ArgumentSections.Matrix)),
|
new ArgumentInfo(ArgumentSections.Matrix)),
|
||||||
|
|
||||||
new TermInfo("listDistinct", TermType.Function,
|
//new TermInfo("listDistinct", TermType.Function,
|
||||||
"Возвращает вектор или вектор-строку уникальных значений, содержащихся в ('матрица'), а" +
|
//"Возвращает вектор или вектор-строку уникальных значений, содержащихся в ('матрица'), а" +
|
||||||
" ('число') указывает на вид возвращаемого вектора: 0 - вектор; 1 - вектор-строка.",
|
//" ('число') указывает на вид возвращаемого вектора: 0 - вектор; 1 - вектор-строка.",
|
||||||
FunctionSections.MatricesAndVectors, true,
|
//FunctionSections.MatricesAndVectors, true,
|
||||||
new ArgumentInfo(ArgumentSections.Matrix), new ArgumentInfo(ArgumentSections.RealNumber)),
|
//new ArgumentInfo(ArgumentSections.Matrix), new ArgumentInfo(ArgumentSections.RealNumber)),
|
||||||
|
|
||||||
new TermInfo("listAdd", TermType.Function,
|
new TermInfo("listAdd", TermType.Function,
|
||||||
"Добавление нового значения ('аргумент') в конец вектора ('вектор').",
|
"Добавление нового значения ('аргумент') в конец вектора ('вектор').",
|
||||||
@@ -224,37 +224,27 @@ namespace MatrixExtensions
|
|||||||
Entry arg1 = Computation.Preprocessing(value.Items[0], context);
|
Entry arg1 = Computation.Preprocessing(value.Items[0], context);
|
||||||
Entry arg2 = Computation.Preprocessing(value.Items[1], context);
|
Entry arg2 = Computation.Preprocessing(value.Items[1], context);
|
||||||
|
|
||||||
List<string> v = new List<string>(Utilites.EntryMatrix2ArrStr(arg1));
|
TNumber tmp, tmp1;
|
||||||
List<string> vector = new List<string>(3);
|
TMatrix m;
|
||||||
TNumber tmp;
|
try
|
||||||
TNumber tmp1 = Computation.NumericCalculation(arg2, context);
|
|
||||||
if (v.Count > 2)
|
|
||||||
{
|
{
|
||||||
tmp = Computation.NumericCalculation(arg1, context);
|
tmp = Computation.NumericCalculation(arg1, context);
|
||||||
vector = new List<string>(Utilites.EntryMatrix2ArrStr(tmp.obj));
|
tmp1 = Computation.NumericCalculation(arg2, context);
|
||||||
vector.RemoveAt(vector.Count - 1);
|
TNumber count = tmp.Rows();
|
||||||
vector.RemoveAt(vector.Count - 1);
|
m = tmp.Stack(new TNumber[] { new TNumber(0, 1) });
|
||||||
vector.Add(tmp1.obj.ToString());
|
m[count.ToInt32(), 0] = tmp1;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (v.Count == 2)
|
catch
|
||||||
{
|
{
|
||||||
vector.Add(tmp1.obj.ToString());
|
tmp1 = Computation.NumericCalculation(arg2, context);
|
||||||
//vector.Add(v[0]);
|
m = new TMatrix(0);
|
||||||
//vector.Add(v[1]);
|
m[0, 0] = tmp1;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
List<Term> answer = new List<Term>();
|
|
||||||
foreach (string item in vector)
|
|
||||||
{
|
|
||||||
answer.AddRange(TermsConverter.ToTerms(item));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
answer.AddRange(TermsConverter.ToTerms(vector.Count.ToString()));
|
List<Term> answer = new List<Term>(m.ToTerms());
|
||||||
answer.AddRange(TermsConverter.ToTerms(1.ToString()));
|
|
||||||
answer.Add(new Term(Functions.Mat, TermType.Function, 2 + vector.Count));
|
|
||||||
|
|
||||||
result = Entry.Create(answer.ToArray());
|
result = Entry.Create(answer.ToArray());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,43 +276,43 @@ namespace MatrixExtensions
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.Type == TermType.Function && value.ArgsCount == 2 && value.Text == "listDistinct")
|
//if (value.Type == TermType.Function && value.ArgsCount == 2 && value.Text == "listDistinct")
|
||||||
{
|
//{
|
||||||
Entry arg1 = Computation.Preprocessing(value.Items[0], context);
|
// Entry arg1 = Computation.Preprocessing(value.Items[0], context);
|
||||||
Entry arg2 = Computation.Preprocessing(value.Items[1], context);
|
// Entry arg2 = Computation.Preprocessing(value.Items[1], context);
|
||||||
|
|
||||||
int dir = Utilites.Entry2Int(arg2);
|
// int dir = Utilites.Entry2Int(arg2);
|
||||||
TNumber tmp = Computation.NumericCalculation(arg1, context);
|
// TNumber tmp = Computation.NumericCalculation(arg1, context);
|
||||||
|
|
||||||
List<string> vector = new List<string>(Utilites.EntryMatrix2ArrStr(tmp.obj));
|
// List<string> vector = new List<string>(Utilites.EntryMatrix2ArrStr(tmp.obj));
|
||||||
vector.RemoveAt(vector.Count - 1);
|
// vector.RemoveAt(vector.Count - 1);
|
||||||
vector.RemoveAt(vector.Count - 1);
|
// vector.RemoveAt(vector.Count - 1);
|
||||||
List<string> distinct = vector.Distinct().ToList();
|
// List<string> distinct = vector.Distinct().ToList();
|
||||||
|
|
||||||
//string res = "null";
|
// //string res = "null";
|
||||||
|
|
||||||
List<Term> answer = new List<Term>();
|
// List<Term> answer = new List<Term>();
|
||||||
foreach (string item in distinct)
|
// foreach (string item in distinct)
|
||||||
{
|
// {
|
||||||
answer.AddRange(TermsConverter.ToTerms(item));
|
// answer.AddRange(TermsConverter.ToTerms(item));
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (dir==0)
|
// if (dir==0)
|
||||||
{
|
// {
|
||||||
answer.AddRange(TermsConverter.ToTerms(distinct.Count.ToString()));
|
// answer.AddRange(TermsConverter.ToTerms(distinct.Count.ToString()));
|
||||||
answer.AddRange(TermsConverter.ToTerms(1.ToString()));
|
// answer.AddRange(TermsConverter.ToTerms(1.ToString()));
|
||||||
answer.Add(new Term(Functions.Mat, TermType.Function, 2 + distinct.Count));
|
// answer.Add(new Term(Functions.Mat, TermType.Function, 2 + distinct.Count));
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
answer.AddRange(TermsConverter.ToTerms(1.ToString()));
|
// answer.AddRange(TermsConverter.ToTerms(1.ToString()));
|
||||||
answer.AddRange(TermsConverter.ToTerms(distinct.Count.ToString()));
|
// answer.AddRange(TermsConverter.ToTerms(distinct.Count.ToString()));
|
||||||
answer.Add(new Term(Functions.Mat, TermType.Function, 2 + distinct.Count));
|
// answer.Add(new Term(Functions.Mat, TermType.Function, 2 + distinct.Count));
|
||||||
}
|
// }
|
||||||
|
|
||||||
result = Entry.Create(answer.ToArray());
|
// result = Entry.Create(answer.ToArray());
|
||||||
return true;
|
// return true;
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (value.Type == TermType.Function && value.ArgsCount == 2 && value.Text == "listRemoveAt")
|
if (value.Type == TermType.Function && value.ArgsCount == 2 && value.Text == "listRemoveAt")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user