/// <summary>
        /// Matrix ^ scalar
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public QsMatrix PowerScalar(QsScalar value)
        {
            QsMatrix Total = (QsMatrix)this.Identity; //first get the identity matrix of this matrix.

            int count = Qs.IntegerFromQsValue(value);

            if (count > 0)
            {
                for (int i = 1; i <= count; i++)
                {
                    Total = Total.MultiplyMatrix(this);
                }
            }
            else if (count == 0)
            {
                return(Total);   //which id identity already
            }
            else
            {
                count = Math.Abs(count);
                for (int i = 1; i <= count; i++)
                {
                    Total = Total.MultiplyMatrix(this.Inverse);    //multiply the inverses many times
                }
            }

            return(Total);
        }
Ejemplo n.º 2
0
        public override QsValue RightShiftOperation(QsValue times)
        {
            int itimes = Qs.IntegerFromQsValue((QsScalar)times);

            if (itimes > this.Text.Length)
            {
                itimes = itimes % this.Text.Length;
            }

            // 1 2 3 4 5 >> 2  == 4 5 1 2 3

            StringBuilder vec = new StringBuilder(this.Text.Length);

            for (int i = this.Text.Length - itimes; i < this.Text.Length; i++)
            {
                vec.Append(this.Text[i]);
            }

            for (int i = 0; i < (this.Text.Length - itimes); i++)
            {
                vec.Append(this.Text[i]);
            }


            return(new QsText(vec.ToString()));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// QsValue ^x QsValue
        /// Power of multiple cross product operations
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        virtual public QsValue PowerCrossOperation(QsValue value)
        {
            QsValue Total = this.Identity;

            int count = Qs.IntegerFromQsValue((QsScalar)value);

            for (int i = 1; i <= count; i++)
            {
                Total = Total.CrossProductOperation(this);
            }

            return(Total);
        }
Ejemplo n.º 4
0
        public override QsValue LeftShiftOperation(QsValue vl)
        {
            QsValue times;

            if (vl is QsReference)
            {
                times = ((QsReference)vl).ContentValue;
            }
            else
            {
                times = vl;
            }

            int itimes = Qs.IntegerFromQsValue((QsScalar)times);

            int c = InitialValues.Count();

            if (itimes > c)
            {
                itimes = itimes % c;
            }


            QsTupleValue[] NewValues = new QsTupleValue[c];

            int ix = 0;

            for (int i = itimes; i < c; i++)
            {
                NewValues[ix] = InitialValues[i];
                ix++;
            }

            for (int i = 0; i < itimes; i++)
            {
                NewValues[ix] = InitialValues[i];
                ix++;
            }

            return(new QsFlowingTuple(NewValues));
        }
Ejemplo n.º 5
0
        public override QsValue RightShiftOperation(QsValue vl)
        {
            QsValue times;

            if (vl is QsReference)
            {
                times = ((QsReference)vl).ContentValue;
            }
            else
            {
                times = vl;
            }


            int itimes = Qs.IntegerFromQsValue((QsScalar)times);

            if (itimes > this.Count)
            {
                itimes = itimes % this.Count;
            }

            // 1 2 3 4 5 >> 2  == 4 5 1 2 3

            QsVector vec = new QsVector(this.Count);

            for (int i = this.Count - itimes; i < this.Count; i++)
            {
                vec.AddComponent(this[i]);
            }

            for (int i = 0; i < (this.Count - itimes); i++)
            {
                vec.AddComponent(this[i]);
            }


            return(vec);
        }