1 /* 2 * ----------------------------------------------------------------- 3 * Programmer(s): Daniel Reynolds @ SMU 4 * ----------------------------------------------------------------- 5 * SUNDIALS Copyright Start 6 * Copyright (c) 2002-2019, Lawrence Livermore National Security 7 * and Southern Methodist University. 8 * All rights reserved. 9 * 10 * See the top-level LICENSE and NOTICE files for details. 11 * 12 * SPDX-License-Identifier: BSD-3-Clause 13 * SUNDIALS Copyright End 14 * ----------------------------------------------------------------- 15 * This is the header file for the LAPACK dense implementation of the 16 * SUNLINSOL module, SUNLINSOL_LINPACKDENSE. 17 * 18 * Note: 19 * - The definition of the generic SUNLinearSolver structure can 20 * be found in the header file sundials_linearsolver.h. 21 * ----------------------------------------------------------------- 22 */ 23 24 #ifndef _SUNLINSOL_LAPDENSE_H 25 #define _SUNLINSOL_LAPDENSE_H 26 27 #include <sundials/sundials_linearsolver.h> 28 #include <sundials/sundials_lapack.h> 29 #include <sundials/sundials_matrix.h> 30 #include <sundials/sundials_nvector.h> 31 #include <sunmatrix/sunmatrix_dense.h> 32 33 #ifdef __cplusplus /* wrapper to enable C++ usage */ 34 extern "C" { 35 #endif 36 37 /* Interfaces to match 'realtype' with the correct LAPACK functions */ 38 #if defined(SUNDIALS_DOUBLE_PRECISION) 39 #define xgetrf_f77 dgetrf_f77 40 #define xgetrs_f77 dgetrs_f77 41 #elif defined(SUNDIALS_SINGLE_PRECISION) 42 #define xgetrf_f77 sgetrf_f77 43 #define xgetrs_f77 sgetrs_f77 44 #else 45 #error Incompatible realtype for LAPACK; disable LAPACK and rebuild 46 #endif 47 48 /* Catch to disable LAPACK linear solvers with incompatible sunindextype */ 49 #if defined(SUNDIALS_INT32_T) 50 #else /* incompatible sunindextype for LAPACK */ 51 #error Incompatible sunindextype for LAPACK; disable LAPACK and rebuild 52 #endif 53 54 /* ----------------------------------------------- 55 * LAPACK dense implementation of SUNLinearSolver 56 * ----------------------------------------------- */ 57 58 struct _SUNLinearSolverContent_LapackDense { 59 sunindextype N; 60 sunindextype *pivots; 61 long int last_flag; 62 }; 63 64 typedef struct _SUNLinearSolverContent_LapackDense *SUNLinearSolverContent_LapackDense; 65 66 67 /* --------------------------------------------- 68 * Exported Functions for SUNLINSOL_LAPACKDENSE 69 * --------------------------------------------- */ 70 71 SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_LapackDense(N_Vector y, 72 SUNMatrix A); 73 74 /* deprecated */ 75 SUNDIALS_EXPORT SUNLinearSolver SUNLapackDense(N_Vector y, SUNMatrix A); 76 77 SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_LapackDense(SUNLinearSolver S); 78 SUNDIALS_EXPORT int SUNLinSolInitialize_LapackDense(SUNLinearSolver S); 79 SUNDIALS_EXPORT int SUNLinSolSetup_LapackDense(SUNLinearSolver S, SUNMatrix A); 80 SUNDIALS_EXPORT int SUNLinSolSolve_LapackDense(SUNLinearSolver S, SUNMatrix A, 81 N_Vector x, N_Vector b, realtype tol); 82 SUNDIALS_EXPORT long int SUNLinSolLastFlag_LapackDense(SUNLinearSolver S); 83 SUNDIALS_EXPORT int SUNLinSolSpace_LapackDense(SUNLinearSolver S, 84 long int *lenrwLS, 85 long int *leniwLS); 86 SUNDIALS_EXPORT int SUNLinSolFree_LapackDense(SUNLinearSolver S); 87 88 #ifdef __cplusplus 89 } 90 #endif 91 92 #endif 93