def METHOD_NAME(svd_impl_name, use_fortran):
  import scitbx.linalg
  svd_impl = getattr(scitbx.linalg, "lapack_%s" % svd_impl_name)
  from scitbx.array_family import flex
  from scitbx import matrix
  from libtbx.test_utils import approx_equal
  #
  for diag in [0, 1]:
    for n in range(1, 11):
      a = flex.double(flex.grid(n,n), 0)
      for i in range(n):
        a[(i,i)] = diag
      a_inp = a.deep_copy()
      svd = svd_impl(a=a, use_fortran=use_fortran)
      if (svd is None):
        if (not use_fortran):
          print("Skipping tests: lapack_%s not available." % svd_impl_name)
        return
      assert svd.info == 0
      assert approx_equal(svd.s, [diag]*n)
      assert svd.u.all() == (n,n)
      assert svd.vt.all() == (n,n)
  mt = flex.mersenne_twister(seed=0)
  for m in range(1,11):
    for n in range(1,11):
      a = matrix.rec(elems=tuple(mt.random_double(m*n)*4-2), n=(m,n))
      svd = svd_impl(
        a=a.transpose().as_flex_double_matrix(), use_fortran=use_fortran)
      assert svd.info == 0
      sigma = matrix.diag(svd.s) # min(m,n) x min(m,n)
      # FORTRAN layout, so transpose
      u  = matrix.rec(svd.u ,  svd.u.all()).transpose()
      vt = matrix.rec(svd.vt, svd.vt.all()).transpose()
      assert approx_equal(u * sigma * vt, a)
  #
  a = matrix.rec(elems=[
     0.47,  0.10, -0.21,
    -0.21, -0.03, 0.35], n=(3,2))
  svd = svd_impl(
    a=a.transpose().as_flex_double_matrix(), use_fortran=use_fortran)
  assert svd.info == 0
  assert approx_equal(svd.s, [0.55981345199567534, 0.35931726783538481])
  # again remember column-major storage
  assert approx_equal(svd.u, [
    0.81402078804155853, -0.5136261274467826, 0.27121644094748704,
    -0.42424674329757839, -0.20684171439391938, 0.88160717215094342])
  assert approx_equal(svd.vt, [
    0.8615633693608673, -0.50765003750177129,
    0.50765003750177129, 0.8615633693608673])