code: function lu_custom(A) {
      // Outer product LU decomposition with partial pivoting
      // Ref: Algo 3.4.1 Golub and Van Loan
      if (A.shape.length != 2) {
          throw new Error('Input is not a Matrix (2D)');
      }
      if (A.shape[0] !== A.shape[1]) {
          throw new Error('Input is not a Square Matrix');
      }
      var n = A.shape[0];
      var perm = new common_1.NDArray({ shape: [n] });
      for (var i = 0; i < n; i++) {
          perm.set(i, i);
      }
      function recordPermutation(ri, rj) {
          var tmp = perm.get(ri);
          perm.set(ri, perm.get(rj));
          perm.set(rj, tmp);
      }
      for (var k = 0; k < n - 1; k++) {
          // Find the maximum absolute entry in k'th column
          var ipivot = 0;
          var pivot = -Infinity;
          for (var i = k; i < n; i++) {
              var val = Math.abs(A.get(i, k)); // TODO:Complex
              if (val > pivot) {
                  pivot = val;
                  ipivot = i;
              }
          }
          // Swap rows k and ipivot
          A.swaprows(k, ipivot);
          recordPermutation(k, ipivot);
          if (common_1.iszero(pivot)) {
              throw new Error('Can\'t perform LU decomp. 0 on diagonal');
          }
          for (var i = k + 1; i < n; i++) {
              A.set(i, k, A.get(i, k) / pivot); // TODO:Complex
          }
          for (var i = k + 1; i < n; i++) {
              for (var j = n - 1; j > k; j--) {
                  // TODO:Complex
                  A.set(i, j, A.get(i, j) - A.get(i, k) * A.get(k, j));
              }
          }
      }
      return perm;
  }
docs: @hidden
  Perform LU decomposition
  
  $$ A = P L U $$