/// <summary>
        /// Do symbolic and numeric factorization.
        /// </summary>
        protected virtual int DoFactorize()
        {
            A = CreateSparse(matrix, handles);

            if (NativeMethods.cholmod_check_sparse(ref A, ref common) != 1)
            {
                return(-1);
            }

            Lp = NativeMethods.cholmod_analyze(ref A, ref common);

            L = (CholmodFactor)Marshal.PtrToStructure(Lp, typeof(CholmodFactor));

            return(NativeMethods.cholmod_factorize(ref A, ref L, ref common));
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                InteropHelper.Free(handles);
            }

            if (Lp != IntPtr.Zero)
            {
                NativeMethods.cholmod_free_factor(ref Lp, ref common);

                NativeMethods.cholmod_finish(ref common);

                L = default(CholmodFactor);
            }
        }