public static UnitVector operator*(ElementaryMatrix em, UnitVector uv)
        {
            UnitVector retVal = new UnitVector(0);

            retVal.Clear();

            // Elementary Matrix private default constructor called from implicit method. It is a value.
            if (em.Name == "E" && em.Rows == 1 && em.Columns == 1)
            {
                return(em[0, 0] * uv);
            }

            if (uv.Order != em.Rows)
            {
                throw new Exception("Vector length must be same as number of columns and rows of matrix");
            }

            for (int rowCount = 0; rowCount < em.Rows; rowCount++)
            {
                int SumOfRow = 0;
                for (int colCount = 0; colCount < em.Columns; colCount++)
                {
                    SumOfRow += (em.InternalRep[rowCount, colCount] * uv[colCount]);
                }

                retVal.Add(SumOfRow);
            }

            return(retVal);
        }
Beispiel #2
0
        public static UnitVector operator*(UnitVector uv, int value)
        {
            UnitVector uvOut = new UnitVector(0);

            uvOut.Clear();
            for (int vectCount = 0; vectCount < uv.Count; vectCount++)
            {
                uvOut.Add(uv[vectCount] * value);
            }
            return(uvOut);
        }
        public static UnitVector operator*(UnitVector uv, ElementaryMatrix em)
        {
            UnitVector retVal = new UnitVector(0);

            retVal.Clear();
            if (uv.Order != em.Rows)
            {
                throw new Exception("Vector length must be same as number of columns and rows of matrix");
            }

            for (int rowCount = 0; rowCount < em.Rows; rowCount++)
            {
                int SumOfRow = 0;
                for (int colCount = 0; colCount < em.Columns; colCount++)
                {
                    SumOfRow += (em.InternalRep[rowCount, colCount] * uv[colCount]);
                }

                retVal.Add(SumOfRow);
            }

            return(retVal);
        }