private static VectorL <T> Mul(VectorL <T> v, T c) { var res = new VectorL <T>(v); res.Mul(c); return(res); }
private static VectorL <T> Subtract(VectorL <T> a, VectorL <T> b) { var res = new VectorL <T>(a); res.Subtract(b); return(res); }
private static VectorL <T> Sum(VectorL <T> a, VectorL <T> b) { var res = new VectorL <T>(a); res.Add(b); return(res); }
public void Subtract(VectorL <T> v) { if (Size != v.Size) { throw new DifferentSizeException($"{Size} != {v.Size}"); } for (var i = 0; i < Size; i++) { _vec[i] -= (dynamic)v._vec[i]; } }
public T ScalarMul(VectorL <T> v) { if (Size != v.Size) { throw new DifferentSizeException($"{Size} != {v.Size}"); } var res = new T(); for (var i = 0; i < Size; i++) { res += (dynamic)_vec[i] * v._vec[i]; } return(res); }
public int CompareTo(VectorL <T> other) { var t = new VectorL <T>(this); t -= other; switch (t) { case VectorL <ComplexL> vector: for (int i = 0; i < vector.Size; i++) { if (!(Math.Abs(vector._vec[i].Abs) > double.Epsilon)) { continue; } if (vector._vec[i].Abs > 0) { return(1); } return(-1); } break; default: for (int i = 0; i < t.Size; i++) { if (Math.Abs((dynamic)t._vec[i]) < double.Epsilon) { continue; } if ((dynamic)t._vec[i] < 0) { return(-1); } return(1); } break; } return(0); }
public VectorL(VectorL <T> v) { _vec = new List <T>(v._vec); }
protected bool Equals(VectorL <T> other) { return(Equals(_vec, other._vec)); }
static void Main(string[] args) { if (true) { var c = new ComplexL(-1, 0); c.DivideByZeroEvent += PrintEvent; c.DivideByZeroEvent += PrintEventWithArgs; var c2 = new ComplexL(0, 0); // Console.WriteLine($"c2 arg = {c2.Arg}"); // Console.WriteLine(c / c2); foreach (var complexL in c.Root(2)) { Console.WriteLine(complexL); } } // int[] a = {1, 2, 3}; // var b = new[] {1, 2, 3}; // var v = new VectorL<int>(new int[]{1234, 2}); if (!true) { // var doubleArr_1 = new double[4] { 3.0, 2.0, 1.0, 1.0 }; // var doubleArr_2 = new double[4] { 3.0, 3.0, 1.0, 2.0 }; // var doubleArr_3 = new double[4] { 1.0, 2.0, 1.0, 2.0 }; var basis = new[] { new VectorL <double>(3.0, 2.0, 1.0, 1.0), new VectorL <double>(3.0, 3.0, 1.0, 2.0), new VectorL <double>(1.0, 2.0, 1.0, 2.0) }; foreach (var v in VectorL <double> .Orthogonality(basis)) { Console.WriteLine(v); } } if (!true) { var basis = new[] { new VectorL <ComplexL>(ComplexL.One, ComplexL.Zero, ComplexL.Zero), new VectorL <ComplexL>(ComplexL.Zero, ComplexL.One, ComplexL.Zero), new VectorL <ComplexL>(ComplexL.Zero, ComplexL.Zero, ComplexL.One), }; var newBasis = VectorL <ComplexL> .Orthogonality(basis); newBasis.ForEach(Console.WriteLine); Console.WriteLine($"Vec length = {newBasis[0].Abs()}"); } if (!true) { VectorL <int> a = new VectorL <int>(3, 2, 2), b = new VectorL <int>(3, 2, 2); Console.WriteLine(a == b); } if (false) { var v = new VectorL <int>(); Console.WriteLine(v); } // var v1 = new VectorL<ComplexL>(ComplexL.One, ComplexL.Zero, ComplexL.Zero); // Console.WriteLine(v1.Abs()); }