Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
klu2_free_symbolic.hpp
1 /* ========================================================================== */
2 /* === KLU_free_symbolic ==================================================== */
3 /* ========================================================================== */
4 // @HEADER
5 // ***********************************************************************
6 //
7 // KLU2: A Direct Linear Solver package
8 // Copyright 2011 Sandia Corporation
9 //
10 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the
11 // U.S. Government retains certain rights in this software.
12 //
13 // This library is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License as
15 // published by the Free Software Foundation; either version 2.1 of the
16 // License, or (at your option) any later version.
17 //
18 // This library is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
26 // USA
27 // Questions? Contact Mike A. Heroux (maherou@sandia.gov)
28 //
29 // KLU2 is derived work from KLU, licensed under LGPL, and copyrighted by
30 // University of Florida. The Authors of KLU are Timothy A. Davis and
31 // Eka Palamadai. See Doc/KLU_README.txt for the licensing and copyright
32 // information for KLU.
33 //
34 // ***********************************************************************
35 // @HEADER
36 
37 /* Free the KLU Symbolic object. */
38 
39 #ifndef KLU2_FREE_SYMBOLIC_HPP
40 #define KLU2_FREE_SYMBOLIC_HPP
41 
42 #include "klu2_internal.h"
43 #include "klu2_memory.hpp"
44 
45 template <typename Entry, typename Int>
46 Int KLU_free_symbolic
47 (
48  KLU_symbolic<Entry, Int> **SymbolicHandle,
49  KLU_common<Entry, Int> *Common
50 )
51 {
52  KLU_symbolic<Entry, Int> *Symbolic ;
53  Int n ;
54  if (Common == NULL)
55  {
56  return (FALSE) ;
57  }
58  if (SymbolicHandle == NULL || *SymbolicHandle == NULL)
59  {
60  return (TRUE) ;
61  }
62  Symbolic = *SymbolicHandle ;
63  n = Symbolic->n ;
64  KLU_free (Symbolic->P, n, sizeof (Int), Common) ;
65  KLU_free (Symbolic->Q, n, sizeof (Int), Common) ;
66  KLU_free (Symbolic->R, n+1, sizeof (Int), Common) ;
67  KLU_free (Symbolic->Lnz, n, sizeof (double), Common) ; /* TODO: Entry ?? */
68  KLU_free (Symbolic, 1, sizeof (KLU_symbolic<Entry, Int>), Common) ;
69  *SymbolicHandle = NULL ;
70  return (TRUE) ;
71 }
72 
73 #endif