def sqrtm(A, disp=True, blocksize=<NUM_LIT:64>):
A = np.asarray(A)<EOL>if len(A.shape) != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if blocksize < <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>keep_it_real = np.isrealobj(A)<EOL>if keep_it_real:<EOL><INDENT>T, Z = schur(A)<EOL>if not np.array_equal(T, np.triu(T)):<EOL><INDENT>T, Z = rsf2csf(T,Z)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>T, Z = schur(A, output='<STR_LIT>')<EOL><DEDENT>failflag = False<EOL>try:<EOL><INDENT>R = _sqrtm_triu(T, blocksize=blocksize)<EOL>ZH = np.conjugate(Z).T<EOL>X = Z.dot(R).dot(ZH)<EOL><DEDENT>except SqrtmError as e:<EOL><INDENT>failflag = True<EOL>X = np.empty_like(A)<EOL>X.fill(np.nan)<EOL><DEDENT>if disp:<EOL><INDENT>nzeig = np.any(np.diag(T) == <NUM_LIT:0>)<EOL>if nzeig:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>elif failflag:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>return X<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>arg2 = norm(X.dot(X) - A,'<STR_LIT>')**<NUM_LIT:2> / norm(A,'<STR_LIT>')<EOL><DEDENT>except ValueError:<EOL><INDENT>arg2 = np.inf<EOL><DEDENT>return X, arg2<EOL><DEDENT>
Matrix square root.

Parameters
----------
A : (N, N) array_like
    Matrix whose square root to evaluate
disp : bool, optional
    Print warning if error in the result is estimated large
    instead of returning estimated error. (Default: True)
blocksize : integer, optional
    If the blocksize is not degenerate with respect to the
    size of the input array, then use a blocked algorithm. (Default: 64)

Returns
-------
sqrtm : (N, N) ndarray
    Value of the sqrt function at `A`

errest : float
    (if disp == False)

    Frobenius norm of the estimated error, ||err||_F / ||A||_F

References
----------
.. [1] Edvin Deadman, Nicholas J. Higham, Rui Ralha (2013)
       "Blocked Schur Algorithms for Computing the Matrix Square Root,
       Lecture Notes in Computer Science, 7782. pp. 171-182.

Examples
--------
>>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
>>> r = sqrtm(a)
>>> r
array([[ 0.75592895,  1.13389342],
       [ 0.37796447,  1.88982237]])
>>> r.dot(r)
array([[ 1.,  3.],
       [ 1.,  4.]])