Example #1
0
        public static Lijst operator ^(Lijst term1, Complex term2)
        {
            Lijst result = new Lijst();

            result.Items.AddRange(term1.Items.Select(T => term2 ^ T));
            return(result);
        }
Example #2
0
        public static Lijst operator /(Lijst term1, Lijst term2)
        {
            if (term1.Items.Count != term2.Items.Count)
            {
                throw new Exception("Lijst / Lijst: De dimensies zijn niet gelijk");
            }
            Lijst result = new Lijst();

            //for (int i = 0; i < term1.Items.Count; i++)
            //    result.Items.Add(term1.Items[i] + term2.Items[i]);
            return(result);
        }
Example #3
0
        public static Lijst operator ^(Lijst term1, Lijst term2)
        {
            if (term1.Items.Count != term2.Items.Count)
            {
                throw new Exception("Lijst ^ Lijst: De lijsten zijn niet even lang");
            }
            Lijst result = new Lijst();

            for (int i = 0; i < term1.Items.Count; i++)
            {
                result.Items.Add(term1.Items[i] ^ term2.Items[i]);
            }
            return(result);
        }
Example #4
0
        public static Term operator -(Term term1)
        {
            switch (term1.term_type)
            {
            case enTerm_type.Complex:
                Complex cpx = (Complex)term1;
                return(new Complex(Complex.bepaling.Real_Imag, -cpx.Real, -cpx.Imaginary));

            case enTerm_type.Lijst:
                Lijst lst    = (Lijst)term1;
                Lijst result = new Lijst();
                result.Items.AddRange(lst.Items.Select(T => (Complex)(-T)));
                return(result);

            case enTerm_type.Matrix:
                Matrix mtr     = (Matrix)term1;
                Matrix result2 = new Matrix();
                result2.Items.AddRange(mtr.Items.Select(T => T.Select(U => (Complex)(-U)).ToList()));
                return(result2);

            default:
                throw new Exception("Type van term1 niet gekend");
            }
        }
Example #5
0
        public static Term operator +(Term term1, Term term2)
        {
            switch (term1.term_type)
            {
            case enTerm_type.Complex:
                Complex cpx1 = (Complex)term1;
                switch (term2.term_type)
                {
                case enTerm_type.Complex:
                    Complex cpx2 = (Complex)term2;
                    return(new Complex(Complex.bepaling.Real_Imag, cpx1.Real + cpx2.Real, cpx1.Imaginary + cpx2.Imaginary));

                case enTerm_type.Lijst:
                    Lijst lst2   = (Lijst)term2;
                    Lijst result = new Lijst();
                    result.Items.AddRange(lst2.Items.Select(T => (Complex)(term1 + T)));
                    return(result);

                case enTerm_type.Matrix:
                    Matrix mtr2    = (Matrix)term2;
                    Matrix result2 = new Matrix();
                    result2.Items.AddRange(mtr2.Items.Select(T => T.Select(U => (Complex)(U + term1)).ToList()).ToArray());
                    return(result2);
                }
                break;

            case enTerm_type.Lijst:
                Lijst lst1 = (Lijst)term1;
                switch (term2.term_type)
                {
                case enTerm_type.Complex:
                    Complex cpx2   = (Complex)term2;
                    Lijst   result = new Lijst();
                    result.Items.AddRange(lst1.Items.Select(T => new Complex(Complex.bepaling.Real_Imag, cpx2.Real + T.Real, cpx2.Imaginary + T.Imaginary)));
                    return(result);

                case enTerm_type.Lijst:
                    Lijst lst2 = (Lijst)term2;
                    if (lst1.Items.Count != lst2.Items.Count)
                    {
                        throw new Exception("Lijst + Lijst: De lijsten zijn niet even lang");
                    }
                    Lijst result3 = new Lijst();
                    for (int i = 0; i < result3.Items.Count; i++)
                    {
                        result3.Items.Add((Complex)(lst1.Items[i] + lst2.Items[i]));
                    }
                    return(result3);

                case enTerm_type.Matrix:
                    throw new Exception("Lijst + Matrix: Kan lijst en matrix niet optellen");

                default:
                    throw new Exception("Type van term2 niet gekend");
                }

            case enTerm_type.Matrix:
                Matrix mtr1 = (Matrix)term1;
                switch (term2.term_type)
                {
                case enTerm_type.Complex:
                    return(term2 + term1);

                case enTerm_type.Lijst:
                    throw new Exception("Matrix + Lijst: Kan matrix en lijst niet optellen");

                case enTerm_type.Matrix:
                    Matrix mtr2 = (Matrix)term2;
                    if (mtr1.Dimensie != mtr2.Dimensie)
                    {
                        throw new Exception("Matrix + Matrix: De dimensies zijn niet gelijk");
                    }
                    Matrix result = new Matrix();
                    for (int i = 0; i < mtr1.Dimensie.X; i++)
                    {
                        result.Items.Add(new List <Complex>());
                        for (int j = 0; j < mtr1.Dimensie.Y; j++)
                        {
                            result.Items[i].Add((Complex)(mtr1.Items[i][j] + mtr2.Items[i][j]));
                        }
                    }
                    return(result);

                default:
                    throw new Exception("Type van term2 niet gekend");
                }

            default:
                throw new Exception("Type van term1 niet gekend");
            }
            return(null);
        }
Example #6
0
        public static Term operator *(Term term1, Term term2)
        {
            switch (term1.term_type)
            {
            case enTerm_type.Complex:
                Complex cpx1 = (Complex)term1;
                switch (term2.term_type)
                {
                case enTerm_type.Complex:
                    Complex cpx2 = (Complex)term2;
                    return(new Complex(Complex.bepaling.Modul_Arg, cpx1.Modulus * cpx2.Modulus, cpx1.Argument + cpx2.Argument));

                case enTerm_type.Lijst:
                    Lijst lst2   = (Lijst)term2;
                    Lijst result = new Lijst();
                    result.Items.AddRange(lst2.Items.Select(T => (Complex)(cpx1 * T)));
                    return(result);

                case enTerm_type.Matrix:
                    Matrix mtr2    = (Matrix)term2;
                    Matrix result2 = new Matrix();
                    result2.Items.AddRange(mtr2.Items.Select(T => T.Select(U => (Complex)(U * term1)).ToList()));
                    return(result2);

                default:
                    throw new Exception("Type van term2 niet gekend");
                }

            case enTerm_type.Lijst:
                Lijst lst1 = (Lijst)term1;
                switch (term2.term_type)
                {
                case enTerm_type.Complex:
                    Complex cpx2   = (Complex)term2;
                    Lijst   result = new Lijst();
                    result.Items.AddRange(lst1.Items.Select(T => (Complex)(cpx2 * T)));
                    return(result);

                case enTerm_type.Lijst:
                    Lijst lst2 = (Lijst)term2;
                    if (lst1.Items.Count != lst2.Items.Count)
                    {
                        throw new Exception("Lijst * Lijst: De lijsten zijn niet even lang");
                    }
                    Lijst result2 = new Lijst();
                    for (int i = 0; i < lst1.Items.Count; i++)
                    {
                        result2.Items.Add((Complex)(lst1.Items[i] * lst2.Items[i]));
                    }
                    return(result2);

                case enTerm_type.Matrix:
                    throw new Exception("Lijst * Matrix: Kan lijst en matrix niet vermenigvuldigen");

                default:
                    throw new Exception("Type van term2 niet gekend");
                }

            case enTerm_type.Matrix:
                break;
            }
            return(null);
        }