docs: public static INDArray mpow(INDArray in, int n, boolean dup) {
          Preconditions.checkState(in.isMatrix() && in.isSquare(), "Input must be a square matrix: got input with shape %s", in.shape());
          if (n == 0) {
              if (dup)
                  return Nd4j.eye(in.rows());
              else
                  return in.assign(Nd4j.eye(in.rows()));
          }
          INDArray temp;
          if (n < 0) {
              temp = InvertMatrix.invert(in, !dup);
              n = -n;
          } else
              temp = in.dup();
          INDArray result = temp.dup();
          if (n < 4) {
              for (int i = 1; i < n; i++) {
                  result.mmuli(temp);
              }
              if (dup)
                  return result;
              else
                  return in.assign(result);
          } else {
              // lets try to optimize by squaring itself a bunch of times
              int squares = (int) (Math.log(n) / Math.log(2.0));
              for (int i = 0; i < squares; i++)
                  result = result.mmul(result);
              int diff = (int) Math.round(n - Math.pow(2.0, squares));
              for (int i = 0; i < diff; i++)
                  result.mmuli(temp);
              if (dup)
                  return result;
              else
                  return in.assign(result);
          }
      }