コード例 #1
0
            /// <inheritdoc/>
            public FieldMatrix <U> getInverse()
            {
                int             m        = pivot.Length;
                U               one      = field.getOne();
                FieldMatrix <U> identity = new Array2DRowFieldMatrix <U>(field, m, m);

                for (int i = 0; i < m; ++i)
                {
                    identity.setEntry(i, i, one);
                }
                return(solve(identity));
            }
コード例 #2
0
        /// <summary>
        /// Compute the outer product.
        /// </summary>
        /// <param name="v">vector with which outer product should be computed</param>
        /// <returns>the matrix outer product between instance and v</returns>
        public FieldMatrix <T> outerProduct(ArrayFieldVector <T> v)
        {
            int             m    = data.Length;
            int             n    = v.data.Length;
            FieldMatrix <T> outp = new Array2DRowFieldMatrix <T>(field, m, n);

            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    outp.setEntry(i, j, data[i].multiply(v.data[j]));
                }
            }
            return(outp);
        }
コード例 #3
0
 /// <inheritdoc/>
 public FieldMatrix <T> outerProduct(FieldVector <T> v)
 {
     try
     {
         return(outerProduct((ArrayFieldVector <T>)v));
     }
     catch (InvalidCastException)
     {
         int             m    = data.Length;
         int             n    = v.getDimension();
         FieldMatrix <T> outp = new Array2DRowFieldMatrix <T>(field, m, n);
         for (int i = 0; i < m; i++)
         {
             for (int j = 0; j < n; j++)
             {
                 outp.setEntry(i, j, data[i].multiply(v.getEntry(j)));
             }
         }
         return(outp);
     }
 }