diff liboctave/numeric/sparse-chol.cc @ 31607:aac27ad79be6 stable

maint: Re-indent code after switch to using namespace macros. * build-env.h, build-env.in.cc, Cell.h, __betainc__.cc, __eigs__.cc, __ftp__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __magick_read__.cc, __pchip_deriv__.cc, amd.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, dasrt.cc, data.cc, debug.cc, defaults.cc, defaults.h, det.cc, display.cc, display.h, dlmread.cc, dynamic-ld.cc, dynamic-ld.h, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, gsvd.cc, gtk-manager.cc, gtk-manager.h, help.cc, help.h, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-hdf5.cc, ls-mat4.cc, ls-mat5.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mexproto.h, mxarray.h, mxtypes.in.h, oct-errno.in.cc, oct-hdf5-types.cc, oct-hist.cc, oct-hist.h, oct-map.cc, oct-map.h, oct-opengl.h, oct-prcstrm.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, octave-default-image.h, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-output.cc, psi.cc, qr.cc, quadcc.cc, rand.cc, regexp.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xpow.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfns.cc, svd.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, __delaunayn__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audioread.cc, convhulln.cc, gzip.cc, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.h, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-intx.h, ov-java.cc, ov-lazy-idx.cc, ov-legacy-range.cc, ov-magic-int.cc, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.h, octave.cc, octave.h, op-b-sbm.cc, op-bm-sbm.cc, op-cs-scm.cc, op-fm-fcm.cc, op-fs-fcm.cc, op-s-scm.cc, op-scm-cs.cc, op-scm-s.cc, op-sm-cs.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, oct-lvalue.cc, oct-lvalue.h, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h: Re-indent code after switch to using namespace macros.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 18:02:15 -0800
parents e88a07dec498
children 597f3ee61a48
line wrap: on
line diff
--- a/liboctave/numeric/sparse-chol.cc	Thu Dec 01 14:23:45 2022 -0800
+++ b/liboctave/numeric/sparse-chol.cc	Thu Dec 01 18:02:15 2022 -0800
@@ -45,528 +45,528 @@
 
 OCTAVE_BEGIN_NAMESPACE(math)
 
-    template <typename chol_type>
-    class sparse_chol<chol_type>::sparse_chol_rep
-    {
-    public:
+template <typename chol_type>
+class sparse_chol<chol_type>::sparse_chol_rep
+{
+public:
 
-      sparse_chol_rep (void)
-        : m_is_pd (false), m_minor_p (0), m_perm (), m_rcond (0)
+  sparse_chol_rep (void)
+    : m_is_pd (false), m_minor_p (0), m_perm (), m_rcond (0)
 #if defined (HAVE_CHOLMOD)
-        , m_L (nullptr), m_common ()
+    , m_L (nullptr), m_common ()
 #endif
-      { }
+  { }
 
-      sparse_chol_rep (const chol_type& a, bool natural, bool force)
-        : m_is_pd (false), m_minor_p (0), m_perm (), m_rcond (0)
+  sparse_chol_rep (const chol_type& a, bool natural, bool force)
+    : m_is_pd (false), m_minor_p (0), m_perm (), m_rcond (0)
 #if defined (HAVE_CHOLMOD)
-        , m_L (nullptr), m_common ()
+    , m_L (nullptr), m_common ()
 #endif
-      {
-        init (a, natural, force);
-      }
+  {
+    init (a, natural, force);
+  }
 
-      sparse_chol_rep (const chol_type& a, octave_idx_type& info,
-                       bool natural, bool force)
-        : m_is_pd (false), m_minor_p (0), m_perm (), m_rcond (0)
+  sparse_chol_rep (const chol_type& a, octave_idx_type& info,
+                   bool natural, bool force)
+    : m_is_pd (false), m_minor_p (0), m_perm (), m_rcond (0)
 #if defined (HAVE_CHOLMOD)
-        , m_L (nullptr), m_common ()
+    , m_L (nullptr), m_common ()
 #endif
-      {
-        info = init (a, natural, force);
-      }
+  {
+    info = init (a, natural, force);
+  }
 
-      // No copying!
+  // No copying!
 
-      sparse_chol_rep (const sparse_chol_rep&) = delete;
+  sparse_chol_rep (const sparse_chol_rep&) = delete;
 
-      sparse_chol_rep& operator = (const sparse_chol_rep&) = delete;
+  sparse_chol_rep& operator = (const sparse_chol_rep&) = delete;
 
-      ~sparse_chol_rep (void)
-      {
+  ~sparse_chol_rep (void)
+  {
 #if defined (HAVE_CHOLMOD)
-        if (m_L)
-          CHOLMOD_NAME (free_sparse) (&m_L, &m_common);
+    if (m_L)
+      CHOLMOD_NAME (free_sparse) (&m_L, &m_common);
 
-        CHOLMOD_NAME(finish) (&m_common);
+    CHOLMOD_NAME(finish) (&m_common);
 #endif
-      }
+  }
 
 #if defined (HAVE_CHOLMOD)
-      cholmod_sparse * L (void) const
-      {
-        return m_L;
-      }
+  cholmod_sparse * L (void) const
+  {
+    return m_L;
+  }
 #endif
 
-      octave_idx_type P (void) const
-      {
+  octave_idx_type P (void) const
+  {
 #if defined (HAVE_CHOLMOD)
-        return (m_minor_p == static_cast<octave_idx_type> (m_L->ncol) ?
-                0 : m_minor_p + 1);
+    return (m_minor_p == static_cast<octave_idx_type> (m_L->ncol) ?
+            0 : m_minor_p + 1);
 #else
-        return 0;
+    return 0;
 #endif
-      }
+  }
 
-      RowVector perm (void) const { return m_perm + 1; }
+  RowVector perm (void) const { return m_perm + 1; }
 
-      SparseMatrix Q (void) const;
+  SparseMatrix Q (void) const;
 
-      bool is_positive_definite (void) const { return m_is_pd; }
+  bool is_positive_definite (void) const { return m_is_pd; }
 
-      double rcond (void) const { return m_rcond; }
+  double rcond (void) const { return m_rcond; }
 
-    private:
+private:
 
-      bool m_is_pd;
+  bool m_is_pd;
 
-      octave_idx_type m_minor_p;
+  octave_idx_type m_minor_p;
 
-      RowVector m_perm;
+  RowVector m_perm;
 
-      double m_rcond;
+  double m_rcond;
 
 #if defined (HAVE_CHOLMOD)
-      cholmod_sparse *m_L;
+  cholmod_sparse *m_L;
 
-      cholmod_common m_common;
+  cholmod_common m_common;
 
-      void drop_zeros (const cholmod_sparse *S);
+  void drop_zeros (const cholmod_sparse *S);
 #endif
 
-      octave_idx_type init (const chol_type& a, bool natural, bool force);
-    };
+  octave_idx_type init (const chol_type& a, bool natural, bool force);
+};
 
 #if defined (HAVE_CHOLMOD)
 
-    // Can't use CHOLMOD_NAME(drop)(0.0, S, cm) because it doesn't treat
-    // complex matrices.
+// Can't use CHOLMOD_NAME(drop)(0.0, S, cm) because it doesn't treat
+// complex matrices.
 
-    template <typename chol_type>
-    void
-    sparse_chol<chol_type>::sparse_chol_rep::drop_zeros (const cholmod_sparse *S)
+template <typename chol_type>
+void
+sparse_chol<chol_type>::sparse_chol_rep::drop_zeros (const cholmod_sparse *S)
+{
+  if (! S)
+    return;
+
+  octave_idx_type *Sp = static_cast<octave_idx_type *>(S->p);
+  octave_idx_type *Si = static_cast<octave_idx_type *>(S->i);
+  chol_elt *Sx = static_cast<chol_elt *>(S->x);
+
+  octave_idx_type pdest = 0;
+  octave_idx_type ncol = S->ncol;
+
+  for (octave_idx_type k = 0; k < ncol; k++)
     {
-      if (! S)
-        return;
+      octave_idx_type p = Sp[k];
+      octave_idx_type pend = Sp[k+1];
+      Sp[k] = pdest;
 
-      octave_idx_type *Sp = static_cast<octave_idx_type *>(S->p);
-      octave_idx_type *Si = static_cast<octave_idx_type *>(S->i);
-      chol_elt *Sx = static_cast<chol_elt *>(S->x);
-
-      octave_idx_type pdest = 0;
-      octave_idx_type ncol = S->ncol;
-
-      for (octave_idx_type k = 0; k < ncol; k++)
+      for (; p < pend; p++)
         {
-          octave_idx_type p = Sp[k];
-          octave_idx_type pend = Sp[k+1];
-          Sp[k] = pdest;
-
-          for (; p < pend; p++)
-            {
-              chol_elt sik = Sx[p];
+          chol_elt sik = Sx[p];
 
-              if (CHOLMOD_IS_NONZERO (sik))
+          if (CHOLMOD_IS_NONZERO (sik))
+            {
+              if (p != pdest)
                 {
-                  if (p != pdest)
-                    {
-                      Si[pdest] = Si[p];
-                      Sx[pdest] = sik;
-                    }
+                  Si[pdest] = Si[p];
+                  Sx[pdest] = sik;
+                }
 
-                  pdest++;
-                }
+              pdest++;
             }
         }
-
-      Sp[ncol] = pdest;
     }
 
-    // Must provide a specialization for this function.
-    template <typename T>
-    int
-    get_xtype (void);
+  Sp[ncol] = pdest;
+}
+
+// Must provide a specialization for this function.
+template <typename T>
+int
+get_xtype (void);
 
-    template <>
-    inline int
-    get_xtype<double> (void)
-    {
-      return CHOLMOD_REAL;
-    }
+template <>
+inline int
+get_xtype<double> (void)
+{
+  return CHOLMOD_REAL;
+}
 
-    template <>
-    inline int
-    get_xtype<Complex> (void)
-    {
-      return CHOLMOD_COMPLEX;
-    }
+template <>
+inline int
+get_xtype<Complex> (void)
+{
+  return CHOLMOD_COMPLEX;
+}
 
 #endif
 
-    template <typename chol_type>
-    octave_idx_type
-    sparse_chol<chol_type>::sparse_chol_rep::init (const chol_type& a,
-                                                   bool natural, bool force)
-    {
-      volatile octave_idx_type info = 0;
+template <typename chol_type>
+octave_idx_type
+sparse_chol<chol_type>::sparse_chol_rep::init (const chol_type& a,
+    bool natural, bool force)
+{
+  volatile octave_idx_type info = 0;
 
 #if defined (HAVE_CHOLMOD)
 
-      octave_idx_type a_nr = a.rows ();
-      octave_idx_type a_nc = a.cols ();
+  octave_idx_type a_nr = a.rows ();
+  octave_idx_type a_nc = a.cols ();
+
+  if (a_nr != a_nc)
+    (*current_liboctave_error_handler)
+      ("sparse_chol requires square matrix");
+
+  cholmod_common *cm = &m_common;
+
+  // Setup initial parameters
+
+  CHOLMOD_NAME(start) (cm);
+  cm->prefer_zomplex = false;
+
+  double spu = sparse_params::get_key ("spumoni");
 
-      if (a_nr != a_nc)
-        (*current_liboctave_error_handler)
-          ("sparse_chol requires square matrix");
+  if (spu == 0.)
+    {
+      cm->print = -1;
+      SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, nullptr);
+    }
+  else
+    {
+      cm->print = static_cast<int> (spu) + 2;
+      SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
+                               &SparseCholPrint);
+    }
+
+  cm->error_handler = &SparseCholError;
 
-      cholmod_common *cm = &m_common;
+  SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide,
+                            divcomplex);
+
+  SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
 
-      // Setup initial parameters
+  cm->final_asis = false;
+  cm->final_super = false;
+  cm->final_ll = true;
+  cm->final_pack = true;
+  cm->final_monotonic = true;
+  cm->final_resymbol = false;
+
+  cholmod_sparse A;
+  cholmod_sparse *ac = &A;
+  double dummy;
+
+  ac->nrow = a_nr;
+  ac->ncol = a_nc;
 
-      CHOLMOD_NAME(start) (cm);
-      cm->prefer_zomplex = false;
+  ac->p = a.cidx ();
+  ac->i = a.ridx ();
+  ac->nzmax = a.nnz ();
+  ac->packed = true;
+  ac->sorted = true;
+  ac->nz = nullptr;
+#if defined (OCTAVE_ENABLE_64)
+  ac->itype = CHOLMOD_LONG;
+#else
+  ac->itype = CHOLMOD_INT;
+#endif
+  ac->dtype = CHOLMOD_DOUBLE;
+  ac->stype = 1;
+  ac->xtype = get_xtype<chol_elt> ();
+
+  if (a_nr < 1)
+    ac->x = &dummy;
+  else
+    ac->x = a.data ();
 
-      double spu = sparse_params::get_key ("spumoni");
+  // use natural ordering if no q output parameter
+  if (natural)
+    {
+      cm->nmethods = 1;
+      cm->method[0].ordering = CHOLMOD_NATURAL;
+      cm->postorder = false;
+    }
+
+  cholmod_factor *Lfactor = CHOLMOD_NAME(analyze) (ac, cm);
+  CHOLMOD_NAME(factorize) (ac, Lfactor, cm);
 
-      if (spu == 0.)
+  m_is_pd = cm->status == CHOLMOD_OK;
+  info = (m_is_pd ? 0 : cm->status);
+
+  if (m_is_pd || force)
+    {
+      m_rcond = CHOLMOD_NAME(rcond) (Lfactor, cm);
+
+      m_minor_p = Lfactor->minor;
+
+      m_L = CHOLMOD_NAME(factor_to_sparse) (Lfactor, cm);
+
+      if (m_minor_p > 0 && m_minor_p < a_nr)
         {
-          cm->print = -1;
-          SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, nullptr);
-        }
-      else
-        {
-          cm->print = static_cast<int> (spu) + 2;
-          SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
-                                   &SparseCholPrint);
+          std::size_t n1 = a_nr + 1;
+          m_L->p = CHOLMOD_NAME(realloc) (m_minor_p+1,
+                                          sizeof(octave_idx_type),
+                                          m_L->p, &n1, cm);
+
+          CHOLMOD_NAME(reallocate_sparse)
+          (static_cast<octave_idx_type *>(m_L->p)[m_minor_p],
+           m_L, cm);
+
+          m_L->ncol = m_minor_p;
         }
 
-      cm->error_handler = &SparseCholError;
-
-      SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide,
-                                divcomplex);
-
-      SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
-
-      cm->final_asis = false;
-      cm->final_super = false;
-      cm->final_ll = true;
-      cm->final_pack = true;
-      cm->final_monotonic = true;
-      cm->final_resymbol = false;
-
-      cholmod_sparse A;
-      cholmod_sparse *ac = &A;
-      double dummy;
-
-      ac->nrow = a_nr;
-      ac->ncol = a_nc;
+      drop_zeros (m_L);
 
-      ac->p = a.cidx ();
-      ac->i = a.ridx ();
-      ac->nzmax = a.nnz ();
-      ac->packed = true;
-      ac->sorted = true;
-      ac->nz = nullptr;
-#if defined (OCTAVE_ENABLE_64)
-      ac->itype = CHOLMOD_LONG;
-#else
-      ac->itype = CHOLMOD_INT;
-#endif
-      ac->dtype = CHOLMOD_DOUBLE;
-      ac->stype = 1;
-      ac->xtype = get_xtype<chol_elt> ();
-
-      if (a_nr < 1)
-        ac->x = &dummy;
-      else
-        ac->x = a.data ();
-
-      // use natural ordering if no q output parameter
-      if (natural)
+      if (! natural)
         {
-          cm->nmethods = 1;
-          cm->method[0].ordering = CHOLMOD_NATURAL;
-          cm->postorder = false;
+          m_perm.resize (a_nr);
+          for (octave_idx_type i = 0; i < a_nr; i++)
+            m_perm(i) = static_cast<octave_idx_type *>(Lfactor->Perm)[i];
         }
-
-      cholmod_factor *Lfactor = CHOLMOD_NAME(analyze) (ac, cm);
-      CHOLMOD_NAME(factorize) (ac, Lfactor, cm);
-
-      m_is_pd = cm->status == CHOLMOD_OK;
-      info = (m_is_pd ? 0 : cm->status);
-
-      if (m_is_pd || force)
-        {
-          m_rcond = CHOLMOD_NAME(rcond) (Lfactor, cm);
-
-          m_minor_p = Lfactor->minor;
-
-          m_L = CHOLMOD_NAME(factor_to_sparse) (Lfactor, cm);
+    }
 
-          if (m_minor_p > 0 && m_minor_p < a_nr)
-            {
-              std::size_t n1 = a_nr + 1;
-              m_L->p = CHOLMOD_NAME(realloc) (m_minor_p+1,
-                                              sizeof(octave_idx_type),
-                                              m_L->p, &n1, cm);
-
-              CHOLMOD_NAME(reallocate_sparse)
-                (static_cast<octave_idx_type *>(m_L->p)[m_minor_p],
-                 m_L, cm);
-
-              m_L->ncol = m_minor_p;
-            }
-
-          drop_zeros (m_L);
+  // NAME used to prefix statistics report from print_common
+  static char blank_name[] = " ";
 
-          if (! natural)
-            {
-              m_perm.resize (a_nr);
-              for (octave_idx_type i = 0; i < a_nr; i++)
-                m_perm(i) = static_cast<octave_idx_type *>(Lfactor->Perm)[i];
-            }
-        }
+  CHOLMOD_NAME(print_common) (blank_name, cm);
+  CHOLMOD_NAME(free_factor) (&Lfactor, cm);
 
-      // NAME used to prefix statistics report from print_common
-      static char blank_name[] = " ";
-
-      CHOLMOD_NAME(print_common) (blank_name, cm);
-      CHOLMOD_NAME(free_factor) (&Lfactor, cm);
-
-      return info;
+  return info;
 
 #else
 
-      octave_unused_parameter (a);
-      octave_unused_parameter (natural);
-      octave_unused_parameter (force);
+  octave_unused_parameter (a);
+  octave_unused_parameter (natural);
+  octave_unused_parameter (force);
 
-      (*current_liboctave_error_handler)
-        ("support for CHOLMOD was unavailable or disabled when liboctave was built");
+  (*current_liboctave_error_handler)
+    ("support for CHOLMOD was unavailable or disabled when liboctave was built");
 
-      return info;
+  return info;
 
 #endif
+}
+
+template <typename chol_type>
+SparseMatrix
+sparse_chol<chol_type>::sparse_chol_rep::Q (void) const
+{
+#if defined (HAVE_CHOLMOD)
+
+  octave_idx_type n = m_L->nrow;
+  SparseMatrix p (n, n, n);
+
+  for (octave_idx_type i = 0; i < n; i++)
+    {
+      p.xcidx (i) = i;
+      p.xridx (i) = static_cast<octave_idx_type> (m_perm (i));
+      p.xdata (i) = 1;
     }
 
-    template <typename chol_type>
-    SparseMatrix
-    sparse_chol<chol_type>::sparse_chol_rep::Q (void) const
-    {
-#if defined (HAVE_CHOLMOD)
-
-      octave_idx_type n = m_L->nrow;
-      SparseMatrix p (n, n, n);
+  p.xcidx (n) = n;
 
-      for (octave_idx_type i = 0; i < n; i++)
-        {
-          p.xcidx (i) = i;
-          p.xridx (i) = static_cast<octave_idx_type> (m_perm (i));
-          p.xdata (i) = 1;
-        }
-
-      p.xcidx (n) = n;
-
-      return p;
+  return p;
 
 #else
 
-      return SparseMatrix ();
+  return SparseMatrix ();
 
 #endif
+}
+
+template <typename chol_type>
+sparse_chol<chol_type>::sparse_chol (void)
+  : m_rep (new typename sparse_chol<chol_type>::sparse_chol_rep ())
+{ }
+
+template <typename chol_type>
+sparse_chol<chol_type>::sparse_chol (const chol_type& a, bool natural,
+                                     bool force)
+  : m_rep (new typename
+           sparse_chol<chol_type>::sparse_chol_rep (a, natural, force))
+{ }
+
+template <typename chol_type>
+sparse_chol<chol_type>::sparse_chol (const chol_type& a,
+                                     octave_idx_type& info,
+                                     bool natural, bool force)
+  : m_rep (new typename
+           sparse_chol<chol_type>::sparse_chol_rep (a, info, natural, force))
+{ }
+
+template <typename chol_type>
+sparse_chol<chol_type>::sparse_chol (const chol_type& a,
+                                     octave_idx_type& info,
+                                     bool natural)
+  : m_rep (new typename
+           sparse_chol<chol_type>::sparse_chol_rep (a, info, natural, false))
+{ }
+
+template <typename chol_type>
+sparse_chol<chol_type>::sparse_chol (const chol_type& a,
+                                     octave_idx_type& info)
+  : m_rep (new typename
+           sparse_chol<chol_type>::sparse_chol_rep (a, info, false, false))
+{ }
+
+template <typename chol_type>
+chol_type
+sparse_chol<chol_type>::L (void) const
+{
+#if defined (HAVE_CHOLMOD)
+
+  cholmod_sparse *m = m_rep->L ();
+
+  octave_idx_type nc = m->ncol;
+  octave_idx_type nnz = m->nzmax;
+
+  chol_type ret (m->nrow, nc, nnz);
+
+  for (octave_idx_type j = 0; j < nc+1; j++)
+    ret.xcidx (j) = static_cast<octave_idx_type *>(m->p)[j];
+
+  for (octave_idx_type i = 0; i < nnz; i++)
+    {
+      ret.xridx (i) = static_cast<octave_idx_type *>(m->i)[i];
+      ret.xdata (i) = static_cast<chol_elt *>(m->x)[i];
     }
 
-    template <typename chol_type>
-    sparse_chol<chol_type>::sparse_chol (void)
-      : m_rep (new typename sparse_chol<chol_type>::sparse_chol_rep ())
-    { }
-
-    template <typename chol_type>
-    sparse_chol<chol_type>::sparse_chol (const chol_type& a, bool natural,
-                                         bool force)
-      : m_rep (new typename
-               sparse_chol<chol_type>::sparse_chol_rep (a, natural, force))
-    { }
-
-    template <typename chol_type>
-    sparse_chol<chol_type>::sparse_chol (const chol_type& a,
-                                         octave_idx_type& info,
-                                         bool natural, bool force)
-      : m_rep (new typename
-               sparse_chol<chol_type>::sparse_chol_rep (a, info, natural, force))
-    { }
-
-    template <typename chol_type>
-    sparse_chol<chol_type>::sparse_chol (const chol_type& a,
-                                         octave_idx_type& info,
-                                         bool natural)
-      : m_rep (new typename
-               sparse_chol<chol_type>::sparse_chol_rep (a, info, natural, false))
-    { }
-
-    template <typename chol_type>
-    sparse_chol<chol_type>::sparse_chol (const chol_type& a,
-                                         octave_idx_type& info)
-      : m_rep (new typename
-               sparse_chol<chol_type>::sparse_chol_rep (a, info, false, false))
-    { }
-
-    template <typename chol_type>
-    chol_type
-    sparse_chol<chol_type>::L (void) const
-    {
-#if defined (HAVE_CHOLMOD)
-
-      cholmod_sparse *m = m_rep->L ();
-
-      octave_idx_type nc = m->ncol;
-      octave_idx_type nnz = m->nzmax;
-
-      chol_type ret (m->nrow, nc, nnz);
-
-      for (octave_idx_type j = 0; j < nc+1; j++)
-        ret.xcidx (j) = static_cast<octave_idx_type *>(m->p)[j];
-
-      for (octave_idx_type i = 0; i < nnz; i++)
-        {
-          ret.xridx (i) = static_cast<octave_idx_type *>(m->i)[i];
-          ret.xdata (i) = static_cast<chol_elt *>(m->x)[i];
-        }
-
-      return ret;
+  return ret;
 
 #else
 
-      return chol_type ();
+  return chol_type ();
 
 #endif
-    }
+}
 
-    template <typename chol_type>
-    octave_idx_type
-    sparse_chol<chol_type>::P (void) const
-    {
-      return m_rep->P ();
-    }
+template <typename chol_type>
+octave_idx_type
+sparse_chol<chol_type>::P (void) const
+{
+  return m_rep->P ();
+}
 
-    template <typename chol_type>
-    RowVector
-    sparse_chol<chol_type>::perm (void) const
-    {
-      return m_rep->perm ();
-    }
+template <typename chol_type>
+RowVector
+sparse_chol<chol_type>::perm (void) const
+{
+  return m_rep->perm ();
+}
 
-    template <typename chol_type>
-    SparseMatrix
-    sparse_chol<chol_type>::Q (void) const
-    {
-      return m_rep->Q ();
-    }
+template <typename chol_type>
+SparseMatrix
+sparse_chol<chol_type>::Q (void) const
+{
+  return m_rep->Q ();
+}
 
-    template <typename chol_type>
-    bool
-    sparse_chol<chol_type>::is_positive_definite (void) const
-    {
-      return m_rep->is_positive_definite ();
-    }
+template <typename chol_type>
+bool
+sparse_chol<chol_type>::is_positive_definite (void) const
+{
+  return m_rep->is_positive_definite ();
+}
 
-    template <typename chol_type>
-    double
-    sparse_chol<chol_type>::rcond (void) const
-    {
-      return m_rep->rcond ();
-    }
+template <typename chol_type>
+double
+sparse_chol<chol_type>::rcond (void) const
+{
+  return m_rep->rcond ();
+}
 
-    template <typename chol_type>
-    chol_type
-    sparse_chol<chol_type>::inverse (void) const
-    {
-      chol_type retval;
+template <typename chol_type>
+chol_type
+sparse_chol<chol_type>::inverse (void) const
+{
+  chol_type retval;
 
 #if defined (HAVE_CHOLMOD)
 
-      cholmod_sparse *m = m_rep->L ();
-      octave_idx_type n = m->ncol;
-      RowVector m_perm = m_rep->perm ();
-      double rcond2;
-      octave_idx_type info;
-      MatrixType mattype (MatrixType::Upper);
-      chol_type linv = L ().hermitian ().inverse (mattype, info, rcond2, 1, 0);
+  cholmod_sparse *m = m_rep->L ();
+  octave_idx_type n = m->ncol;
+  RowVector m_perm = m_rep->perm ();
+  double rcond2;
+  octave_idx_type info;
+  MatrixType mattype (MatrixType::Upper);
+  chol_type linv = L ().hermitian ().inverse (mattype, info, rcond2, 1, 0);
 
-      if (m_perm.numel () == n)
-        {
-          SparseMatrix Qc = Q ();
+  if (m_perm.numel () == n)
+    {
+      SparseMatrix Qc = Q ();
 
-          retval = Qc * linv * linv.hermitian () * Qc.transpose ();
-        }
-      else
-        retval = linv * linv.hermitian ();
+      retval = Qc * linv * linv.hermitian () * Qc.transpose ();
+    }
+  else
+    retval = linv * linv.hermitian ();
 
 #endif
 
-      return retval;
-    }
+  return retval;
+}
 
-    template <typename chol_type>
-    chol_type
-    chol2inv (const chol_type& r)
-    {
-      octave_idx_type r_nr = r.rows ();
-      octave_idx_type r_nc = r.cols ();
-      chol_type retval;
+template <typename chol_type>
+chol_type
+chol2inv (const chol_type& r)
+{
+  octave_idx_type r_nr = r.rows ();
+  octave_idx_type r_nc = r.cols ();
+  chol_type retval;
 
-      if (r_nr != r_nc)
-        (*current_liboctave_error_handler) ("U must be a square matrix");
+  if (r_nr != r_nc)
+    (*current_liboctave_error_handler) ("U must be a square matrix");
 
-      MatrixType mattype (r);
-      int typ = mattype.type (false);
-      double rcond;
-      octave_idx_type info;
-      chol_type rtra, multip;
+  MatrixType mattype (r);
+  int typ = mattype.type (false);
+  double rcond;
+  octave_idx_type info;
+  chol_type rtra, multip;
 
-      if (typ == MatrixType::Upper)
-        {
-          rtra = r.transpose ();
-          multip = (rtra*r);
-        }
-      else if (typ == MatrixType::Lower)
-        {
-          rtra = r.transpose ();
-          multip = (r*rtra);
-        }
-      else
-        (*current_liboctave_error_handler) ("U must be a triangular matrix");
+  if (typ == MatrixType::Upper)
+    {
+      rtra = r.transpose ();
+      multip = (rtra*r);
+    }
+  else if (typ == MatrixType::Lower)
+    {
+      rtra = r.transpose ();
+      multip = (r*rtra);
+    }
+  else
+    (*current_liboctave_error_handler) ("U must be a triangular matrix");
 
-      MatrixType mattypenew (multip);
-      retval = multip.inverse (mattypenew, info, rcond, true, false);
-      return retval;
-    }
+  MatrixType mattypenew (multip);
+  retval = multip.inverse (mattypenew, info, rcond, true, false);
+  return retval;
+}
 
-    // SparseComplexMatrix specialization (the value for the NATURAL
-    // parameter in the sparse_chol<T>::sparse_chol_rep constructor is
-    // different from the default).
+// SparseComplexMatrix specialization (the value for the NATURAL
+// parameter in the sparse_chol<T>::sparse_chol_rep constructor is
+// different from the default).
 
-    template <>
-    OCTAVE_API
-    sparse_chol<SparseComplexMatrix>::sparse_chol (const SparseComplexMatrix& a,
-                                                   octave_idx_type& info)
-      : m_rep (new sparse_chol<SparseComplexMatrix>::sparse_chol_rep (a, info,
-                                                                      true,
-                                                                      false))
-    { }
+template <>
+OCTAVE_API
+sparse_chol<SparseComplexMatrix>::sparse_chol (const SparseComplexMatrix& a,
+    octave_idx_type& info)
+  : m_rep (new sparse_chol<SparseComplexMatrix>::sparse_chol_rep (a, info,
+           true,
+           false))
+{ }
 
-    // Instantiations we need.
+// Instantiations we need.
 
-    template class OCTAVE_API sparse_chol<SparseMatrix>;
+template class OCTAVE_API sparse_chol<SparseMatrix>;
 
-    template class sparse_chol<SparseComplexMatrix>;
+template class sparse_chol<SparseComplexMatrix>;
 
-    template OCTAVE_API SparseMatrix
-    chol2inv<SparseMatrix> (const SparseMatrix& r);
+template OCTAVE_API SparseMatrix
+chol2inv<SparseMatrix> (const SparseMatrix& r);
 
-    template OCTAVE_API SparseComplexMatrix
-    chol2inv<SparseComplexMatrix> (const SparseComplexMatrix& r);
+template OCTAVE_API SparseComplexMatrix
+chol2inv<SparseComplexMatrix> (const SparseComplexMatrix& r);
 
 OCTAVE_END_NAMESPACE(math)
 OCTAVE_END_NAMESPACE(octave)