本文整理汇总了C#中Vector.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.ToString方法的具体用法?C# Vector.ToString怎么用?C# Vector.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Complex a1 = new Complex(2, 5);
Complex a2 = new Complex(4, 3);
Complex a3 = new Complex(1, 4);
Complex a4 = new Complex(2, 6);
Complex a5 = new Complex(2, 8);
Complex a6 = new Complex(7, 3);
Complex a7 = new Complex(4, 5);
Complex a8 = new Complex(1, 3);
Complex[] Vec = { a1, a2, a3, a4, a5, a6, a7, a8 };
Vector<Complex> Data = new Vector<Complex>(Vec);
ulong Len = Data.Length();
int Dir = 1;
Vector<Complex> NewData = Transformation.FFT_L(Data, Dir);
Console.WriteLine(NewData.ToString());
Console.WriteLine();
Transformation.FFTReOrder(Data);
Transformation.FFT_T(Data, 0, Len, Dir);
Console.WriteLine(Data.ToString());
Console.WriteLine();
Dir = -1;
NewData = Transformation.FFT_L(Data, Dir);
Transformation.FFTReOrder(Data);
Transformation.FFT_T(Data, 0, Len, Dir);
if (Dir == -1) {
for (ulong i = 0; i < Len; i++)
{
Data[i].i /= Len;
Data[i].r /= Len;
NewData[i].i /= Len;
NewData[i].r /= Len;
}
}
Console.WriteLine(NewData.ToString());
Console.WriteLine();
Console.WriteLine(Data.ToString());
Console.ReadKey();
}
示例2: Main
static void Main()
{
const double A = 0.9;
const double b = 0.6;
const double n = 0.25;
const int N = 1000;
// Initialization
SimpleKalmanFilter kf = new SimpleKalmanFilter(1, 1);
kf.Q = Matrix.Identity(kf.K.Rows) * 1e-5;
kf.R = Matrix.Identity(kf.K.Columns) * (1-1e-5);
kf.Prediction();
// Processing
Vector x_in = new Vector(kf.K.Columns);
double x_mem = 0;
Vector rnd = Vector.Random(N, new Normal(b, n));
for (Int32 ind = 0; ind < N; ++ind)
{
x_mem = A * x_mem + rnd[ind];
x_in[0] = x_mem;
Vector v_i = kf.Filter(x_in);
Console.WriteLine(x_in.ToString() + ": " + v_i.ToString());
}
}
示例3: EvalBrdf
private void EvalBrdf(out RgbSpectrum fs, ref Vector lwi, ref Vector lwo)
{
float sinthetai = SinTheta(ref lwi);
float sinthetao = SinTheta(ref lwo);
// Compute cosine term of Oren--Nayar model
float sinphii = SinPhi(ref lwi), cosphii = CosPhi(ref lwi);
float sinphio = SinPhi(ref lwo), cosphio = CosPhi(ref lwo);
float dcos = cosphii*cosphio + sinphii*sinphio;
#if VERBOSE
Assert.IsNotNaN(cosphii,"cosphii "+lwi.ToString());
Assert.IsNotNaN(cosphio, "cosphio " + lwo.ToString());
Assert.IsNotNaN(sinphii, "sinphii " + lwi.ToString());
Assert.IsNotNaN(sinphio, "sinphio " + lwo.ToString());
#endif
float maxcos = Math.Max(0f, dcos);
// Compute sine and tangent terms of Oren--Nayar model
float sinalpha, tanbeta;
if (Math.Abs(CosTheta(ref lwi)) > Math.Abs(CosTheta(ref lwo)))
{
sinalpha = sinthetao;
tanbeta = sinthetai/Math.Abs(CosTheta(ref lwi));
}
else
{
sinalpha = sinthetai;
tanbeta = sinthetao/Math.Abs(CosTheta(ref lwo));
}
fs = R*MathLab.INVPI*
(A + B*maxcos*sinalpha*tanbeta);
#if VERBOSE
if (fs.IsNegative())
{
Tracer.TraceLine("OrenNayar - f - negative");
}
if (fs.IsBlack())
{
Tracer.TraceLine("OrenNayar - f - black");
}
#endif
}
示例4: ItShouldHoldElements
public void ItShouldHoldElements()
{
Vector<byte> actual = new Vector<byte>();
actual.Add(1);
actual.Add(0);
actual.Add(1);
Vector<byte> expected = new Vector<byte>();
expected.Add(1);
expected.Add(0);
expected.Add(1);
Assert.AreEqual(expected.ToString(), actual.ToString());
}
示例5: f
public override void f(ref Vector wo, ref Vector wi, ref Normal N, ref RgbSpectrum in_fs, out RgbSpectrum fs)
{
CreateFrame(ref N);
var lwo = WorldToLocal(ref wo).Normalize();
var lwi = WorldToLocal(ref wi).Normalize();
#if VERBOSE
Assert.IsNotNaN(ref lwo, "LWO "+wo.ToString());
Assert.IsNotNaN(ref lwi, "LWI "+ wi.ToString());
#endif
EvalBrdf(out fs, ref lwi, ref lwo);
}
示例6: VectorToString
public void VectorToString()
{
Vector vector = new Vector(new double[] { 1.1, 2.2, 3.3 });
Assert.AreEqual("[ 1.1, 2.2, 3.3 ]", vector.ToString());
}
示例7: learnNetworkTest
public void learnNetworkTest()
{
int dimension = 0;
List<LearningExample> examples = new List<LearningExample>();
MLPNetwork target = null;
List<int> dimensions = new List<int>();
int iterations = 1; // Tylko jedna iteracja
try
{
target = new MLPNetwork(dimension, dimensions, null, null, examples);
}
catch (NetworkDimensionException e1)
{
Assert.AreEqual(e1.BadDimension, 0);
//dimensions.Add(3);
dimensions.Add(2);
dimensions.Add(1);
dimension = 3;
target = new MLPNetwork(dimension, dimensions, null, null, examples);
try
{
target.learnNetwork(iterations, 0.5);
}
catch (ExampleListException)
{
Vector v = new Vector(3);
v[0] = 1;
v[1] = 0.8;
v[2] = 0.3;
Perceptron p0 = target.Layers[0].Perceptrons[0];
Perceptron p1 = target.Layers[0].Perceptrons[1];
Perceptron p2 = target.Layers[1].Perceptrons[0];
p0.Weights[0] = 0.3;
p0.Weights[1] = 0.5;
p0.Weights[2] = -0.2;
p1.Weights[0] = -0.5;
p1.Weights[1] = 0.1;
p1.Weights[2] = -0.2;
p2.Weights[0] = -0.4;
p2.Weights[1] = -0.8;
p2.Weights[2] = 0.1;
Vector expected = new Vector(2);
expected[1] = 0.8;
//Console.WriteLine("Iloczyn wektorowy: " + v * p0.Weights);
//Console.WriteLine(p2.Weights.ToString());
examples.Add(new LearningExample(v, expected));
//Console.WriteLine("Wyjście pierwszego perceptronu:");
//Console.WriteLine(p0.outputFunction(v).ToString());
//Console.WriteLine("Wyjście drugiego perceptronu:");
//Console.WriteLine(p1.outputFunction(v).ToString());
Vector v0 = new Vector(3);
v0[0] = 1;
v0[1] = s(0.64);
v0[2] = s(-0.48);
target.classify(examples[0]);
v0 = round(v0);
//Console.WriteLine("Wektor po zaokrągleniu: " + v0);
// Sprawdza, czy dobrze liczone są wartości wyjściowe perceptronów
Assert.AreEqual(v0.ToString(), round(target.ClassificationExamples[0].Example).ToString());
Vector v1 = new Vector(2);
v1[0] = 1;
v1[1] = s(-0.886);
v1 = round(v1);
Assert.AreEqual(v1.ToString(), round(target.ClassificationExamples[1].Example).ToString());
Assert.AreEqual(0.292, v1[1]);
Console.WriteLine("Blad: " + target.globalError());
target.learnNetwork(1, 0.5);
Console.WriteLine("Wyjścia kolejnych warstw:");
foreach (LearningExample e in target.ClassificationExamples)
{
Console.WriteLine(round(e.Example).ToString());
}
Vector d0 = new Vector(2);
d0[1] = -0.105;
Assert.AreEqual(d0.ToString(), round(target.delty[1]).ToString());
Vector d1 = new Vector(3);
d1[1] = 0.019;
d1[2] = -0.002;
Assert.AreEqual(d1.ToString(), round(target.delty[0]).ToString());
Console.WriteLine("Wagi pierwszego perceptronu po iteracji:");
Console.WriteLine(round(p0.Weights).ToString());
//.........这里部分代码省略.........
示例8: VectorToString
public void VectorToString()
{
var v = new Vector(3, 4, 5);
Assert.AreEqual("(3, 4, 5)", v.ToString());
}
示例9: ToStringAndFromString
public void ToStringAndFromString()
{
var v = new Vector(2.23f, 3.45f, 0.59f);
string vectorAsString = v.ToString();
Assert.AreEqual(v, new Vector(vectorAsString));
}
示例10: GetCurrentValueCore
//.........这里部分代码省略.........
case AnimationType.To:
from = defaultOriginValue;
to = _keyValues[0];
validateOrigin = true;
break;
case AnimationType.By:
// According to the SMIL specification, a By animation is
// always additive. But we don't force this so that a
// user can re-use a By animation and have it replace the
// animations that precede it in the list without having
// to manually set the From value to the base value.
to = _keyValues[0];
foundation = defaultOriginValue;
validateOrigin = true;
break;
case AnimationType.FromTo:
from = _keyValues[0];
to = _keyValues[1];
if (IsAdditive)
{
foundation = defaultOriginValue;
validateOrigin = true;
}
break;
case AnimationType.FromBy:
from = _keyValues[0];
to = AnimatedTypeHelpers.AddVector(_keyValues[0], _keyValues[1]);
if (IsAdditive)
{
foundation = defaultOriginValue;
validateOrigin = true;
}
break;
default:
Debug.Fail("Unknown animation type.");
break;
}
if (validateOrigin
&& !AnimatedTypeHelpers.IsValidAnimationValueVector(defaultOriginValue))
{
throw new InvalidOperationException(
SR.Get(
SRID.Animation_Invalid_DefaultValue,
this.GetType(),
"origin",
defaultOriginValue.ToString(CultureInfo.InvariantCulture)));
}
if (validateDestination
&& !AnimatedTypeHelpers.IsValidAnimationValueVector(defaultDestinationValue))
{
throw new InvalidOperationException(
SR.Get(
SRID.Animation_Invalid_DefaultValue,
this.GetType(),
"destination",
defaultDestinationValue.ToString(CultureInfo.InvariantCulture)));
}
if (IsCumulative)
{
double currentRepeat = (double)(animationClock.CurrentIteration - 1);
if (currentRepeat > 0.0)
{
Vector accumulator = AnimatedTypeHelpers.SubtractVector(to, from);
accumulated = AnimatedTypeHelpers.ScaleVector(accumulator, currentRepeat);
}
}
// return foundation + accumulated + from + ((to - from) * progress)
return AnimatedTypeHelpers.AddVector(
foundation,
AnimatedTypeHelpers.AddVector(
accumulated,
AnimatedTypeHelpers.InterpolateVector(from, to, progress)));
}
示例11: MouseClick
internal override void MouseClick(Vector.FxVector2f location)
{
int x = (int)Math.Ceiling(location.x);
int y = (int)Math.Ceiling(location.y);
Console.WriteLine(location.ToString());
if (x >= 0 && x < Width && y >= 0 && y < Height)
{
Console.WriteLine(internalImage[x + y * Pitch]);
OnMouseClickEvent(this, location);
}
}
示例12: Test_Others
public void Test_Others()
{
Vector v1 = new Vector(1, 2, 3, 4, 5);
// �o��
Assert.That(v1.ToArray(), Is.EqualTo(new[] { 1.0, 2, 3, 4, 5 }));
string s = v1.ToString();
string csv = Vectors.ToCsv(v1);
v1 = Vector.Fill(10, 1);
Assert.AreEqual(10, v1.Size);
Assert.AreEqual(new Vector(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), v1);
v1.Flip(); // �������]
v1.Zero(); // �S�Ă̗v�f��0
Assert.AreEqual(new Vector(new Size(10)).Zero(), v1);
}
示例13: TestToString
public void TestToString()
{
var v = new Vector<string, double> {{"x", 1}, {"y", 2}};
v.ToString().ShouldEqual("2|y> 1|x> ");
}
示例14: button2_Click
private void button2_Click(object sender, EventArgs e)
{
try
{
Open = new OpenFileDialog();
Open.Filter = "Текстовые файлы (*.txt)|*txt|Все файлы (*.*)|*.*";
Open.ShowDialog();
StreamReader openfile = new StreamReader(Open.FileName, Encoding.GetEncoding(1251)); //Явно декодируем виндуузовскую кодировку
openfile.BaseStream.Position = 0; // В начало потока перейти
if ((s = openfile.ReadLine()) != null)
{
if (s.Length > 2000)
{
MessageBox.Show("Входная строка имеет длину больше 100!");
openfile.Close();
return;
}
s = s.Replace(" ", string.Empty);
s = s.Trim().Replace(" ", string.Empty);
string[] numbers = s.Split(new char[3]{ '+', 'i', ';' });
Dimension = (ulong)numbers.Length/3; //Размерность вектора
Data = new Vector<Complex>(Dimension);
for (ulong i = 0; i < Dimension; i ++)
{
Data[i] = new Complex(Convert.ToDouble(numbers[3 * i]), Convert.ToDouble(numbers[3 * i + 1]));
if (Data[i].i > 1000 || Data[i].r > 1000 || Data[i].r < -1000 || Data[i].i < -1000) {
MessageBox.Show(String.Format("Данные числа с номером {0} превышают по модулю 1000!", i));
Data = null;
textBox1.Text = "";
openfile.Close();
return;
}
}
}
else
{
MessageBox.Show("Неверный формат входных данных!");
Data = null;
textBox1.Text = "";
openfile.Close();
return;
}
if (openfile.ReadLine() != null)
{
MessageBox.Show("В файле содержится больше одной строки!");
Data = null;
textBox1.Text = "";
openfile.Close();
return;
}
openfile.Close(); //До сюда доходим только если ранее не вылетело ошибок
button1.Enabled = true;
}
catch (ArgumentOutOfRangeException)
{
MessageBox.Show("Файл не соответствет формату!");
Data = null;
textBox17.Text = "";
return;
}
catch (Exception exc) // возможные ошибки типа "Доступ к файлу запрещён"
{
MessageBox.Show(exc.Message + "\n");
Data = null;
textBox17.Text = "";
return;
}
if (Data != null) textBox17.Text = (Data.ToString());
}
示例15: GetDirection
Direction GetDirection(Vector vector)
{
foreach (KeyValuePair<Direction, Vector> pair in directions)
if (vector.Equals(pair.Value)) return pair.Key;
throw new System.Exception("Couldn't get direction for vector " + vector.ToString());
}