# File lib/linalg/dmatrix/fit.rb, line 32
      def self.fit(a, b)
         raise DimensionError unless a.vsize == b.vsize
         b_in = b

         trans = Char.new("N")
         m = XInteger.new(a.vsize)
         n = XInteger.new(a.hsize)
         nrhs = XInteger.new(b.hsize)
         a = a.clone
         lda = XInteger.new(a.vsize)
         b = DMatrix.new(Math.max(m.value, n.value),
                         nrhs.value).replace_minor(0, 0, b_in)
         ldb = XInteger.new(b.vsize)
         work = DReal.new # query
         lwork = XInteger.new(-1) # query
         info = XInteger.new
         
         # query
         Lapack.dgels(trans,
                      m,
                      n,
                      nrhs,
                      a,
                      lda,
                      b,
                      ldb,
                      work,
                      lwork,
                      info)
         
         raise Diverged unless info.value == 0
         lwork = XInteger.new(work.value.to_i)
         work = DData.new(lwork.value)
         
         Lapack.dgels(trans,
                      m,
                      n,
                      nrhs,
                      a,
                      lda,
                      b,
                      ldb,
                      work,
                      lwork,
                      info)
         
         raise Diverged unless info.value == 0

         x = b.minor(0, 0, n.value, nrhs.value)
         if block_given?
            yield x
         else
            x
         end
      end