|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using FormulaEditor;
using DataPerformer.Interfaces;
namespace DataPerformer
{
/// <summary>
/// Multidimensional dynamical parameter
/// </summary>
public class DynamicalParameter
{
/// <summary>
/// Strig of parameters labels
/// </summary>
private string labels = "";
/// <summary>
/// List of parameters
/// </summary>
private ArrayList parameters = new ArrayList();
/// <summary>
/// Error message of undefined parameter
/// </summary>
public static readonly string UndefinedParameter = "Undefined parameter";
/// <summary>
/// Error message of undefined parameters
/// </summary>
public static readonly string UndefinedParameters = "Undefined parameters";
/// <summary>
/// Constructor
/// </summary>
public DynamicalParameter()
{
}
/// <summary>
/// Adds measurement
/// </summary>
/// <param name="c">Measurement label</param>
/// <param name="m">Measurement</param>
public void Add(char c, IMeasure m)
{
if (labels.IndexOf(c) >= 0)
{
throw new Exception("Double parameter '" + c + "'");
}
labels += c;
parameters.Add(m);
}
/// <summary>
/// Replaces measure
/// </summary>
/// <param name="c">Letter of measure</param>
/// <param name="measure">New value of measure</param>
public void Replace(char c, IMeasure measure)
{
int k = labels.IndexOf(c);
ArrayList p = new ArrayList();
for (int i = 0; i < k; i++)
{
p.Add(parameters[i]);
}
p.Add(measure);
for (int i = k; i < parameters.Count; i++)
{
p.Add(parameters[i]);
}
parameters = p;
p = null;
}
/// <summary>
/// Gets measurement
/// </summary>
public IMeasure this[char c]
{
get
{
int n = labels.IndexOf(c);
if (n < 0)
{
throw new Exception(UndefinedParameter);
}
return parameters[n] as IMeasure;
}
}
/// <summary>
/// Sets formula argument
/// </summary>
/// <param name="arg"></param>
public void Set(ElementaryObjectArgument arg)
{
foreach (char c in labels)
{
arg[c] = this[c].Parameter();
}
}
/// <summary>
/// String of parameter variables
/// </summary>
public string Variables
{
get
{
return labels;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:
1) Noncommutative geometry
http://front.math.ucdavis.edu/author/P.Ivankov
2) Literary work (Russian only)
http://zhurnal.lib.ru/editors/3/3d_m/
3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1