public Matrix timesTriangular (Matrix B)
   {
      if (B.m != n)
         throw new IllegalArgumentException("Matrix inner dimensions must agree.");

      Matrix X = new Matrix(m,B.n);
      double[][] c = X.getArray();
      double[][] b;
      double s = 0;
      double[] Arowi;
      double[] Browj;

      b = B.getArray();
      //multiply with each row of A
      for (int i = 0; i < m; i++)
      {
        Arowi = A[i];

        //for all columns of B
        for (int j = 0; j < B.n; j++)
        {
          s = 0;
          Browj = b[j];
          //since B being triangular, this loop uses k <= j
          for (int k = 0; k <= j; k++)
          {
            s += Arowi[k] * Browj[k];
          }
          c[i][j] = s;
        }
      }
      return X;
   }