GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-sparse.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2005-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_oct_sparse_h)
27#define octave_oct_sparse_h 1
28
29#include "octave-config.h"
30
31#include <limits>
32
33#if defined (HAVE_CHOLMOD)
34# include "dSparse.h"
35# include "CSparse.h"
36#endif
37
38#if defined (HAVE_SUITESPARSE_AMD_H)
39# include <suitesparse/amd.h>
40#elif defined (HAVE_AMD_AMD_H)
41# include <amd/amd.h>
42#elif defined (HAVE_AMD_H)
43# include <amd.h>
44#endif
45
46#if defined (HAVE_SUITESPARSE_CCOLAMD_H)
47# include <suitesparse/ccolamd.h>
48#elif defined (HAVE_CCOLAMD_CCOLAMD_H)
49# include <ccolamd/ccolamd.h>
50#elif defined (HAVE_CCOLAMD_H)
51# include <ccolamd.h>
52#endif
53
54#if defined (HAVE_SUITESPARSE_CHOLMOD_H)
55# include <suitesparse/cholmod.h>
56#elif defined (HAVE_CHOLMOD_CHOLMOD_H)
57# include <cholmod/cholmod.h>
58#elif defined (HAVE_CHOLMOD_H)
59# include <cholmod.h>
60#endif
61
62#if defined (HAVE_SUITESPARSE_COLAMD_H)
63# include <suitesparse/colamd.h>
64#elif defined (HAVE_COLAMD_COLAMD_H)
65# include <colamd/colamd.h>
66#elif defined (HAVE_COLAMD_H)
67# include <colamd.h>
68#endif
69
70#if defined (HAVE_SUITESPARSE_CS_H)
71# include <suitesparse/cs.h>
72#elif defined (HAVE_CXSPARSE_CS_H)
73# include <cxsparse/cs.h>
74#elif defined (HAVE_CS_H)
75# include <cs.h>
76#endif
77
78#if defined (HAVE_SUITESPARSE_UMFPACK_H)
79# include <suitesparse/umfpack.h>
80#elif defined (HAVE_UMFPACK_UMFPACK_H)
81# include <umfpack/umfpack.h>
82#elif defined (HAVE_UMFPACK_H)
83# include <umfpack.h>
84#endif
85
86#if defined (HAVE_SUITESPARSE_SUITESPARSEQR_HPP)
87# include <suitesparse/SuiteSparseQR.hpp>
88#elif defined (HAVE_SUITESPARSEQR_HPP)
89# include <SuiteSparseQR.hpp>
90#endif
91
92// Cope with new SuiteSparse versions
93
94#if defined (SUITESPARSE_VERSION)
95# if (SUITESPARSE_VERSION >= SUITESPARSE_VER_CODE (4, 3))
96# define SUITESPARSE_NAME(name) SuiteSparse_ ## name
97# define SUITESPARSE_ASSIGN_FPTR(f_name, f_var, f_assign) (SuiteSparse_config.f_name = f_assign)
98# define SUITESPARSE_ASSIGN_FPTR2(f_name, f_var, f_assign) (SuiteSparse_config.f_name = SUITESPARSE_NAME (f_assign))
99# else
100# define SUITESPARSE_ASSIGN_FPTR(f_name, f_var, f_assign) (f_var = f_assign)
101# define SUITESPARSE_ASSIGN_FPTR2(f_name, f_var, f_assign) (f_var = CHOLMOD_NAME (f_assign))
102# endif
103#endif
104
105// Function names depend on integer type.
106
107#if defined (HAVE_AMD)
108# if defined (OCTAVE_ENABLE_64)
109# define AMD_NAME(name) amd_l ## name
110# else
111# define AMD_NAME(name) amd ## name
112# endif
113#endif
114
115#if defined (HAVE_CCOLAMD)
116# if defined (OCTAVE_ENABLE_64)
117# define CCOLAMD_NAME(name) ccolamd_l ## name
118# define CSYMAMD_NAME(name) csymamd_l ## name
119# else
120# define CCOLAMD_NAME(name) ccolamd ## name
121# define CSYMAMD_NAME(name) csymamd ## name
122# endif
123#endif
124
125#if defined (HAVE_CHOLMOD)
126# if defined (OCTAVE_ENABLE_64)
127# define CHOLMOD_NAME(name) cholmod_l_ ## name
128# else
129# define CHOLMOD_NAME(name) cholmod_ ## name
130# endif
131#endif
132
133#if defined (HAVE_COLAMD)
134# if defined (OCTAVE_ENABLE_64)
135# define COLAMD_NAME(name) colamd_l ## name
136# define SYMAMD_NAME(name) symamd_l ## name
137# else
138# define COLAMD_NAME(name) colamd ## name
139# define SYMAMD_NAME(name) symamd ## name
140# endif
141#endif
142
143#if defined (HAVE_CXSPARSE)
144# if defined (OCTAVE_ENABLE_64)
145# define CXSPARSE_DNAME(name) cs_dl ## name
146# define CXSPARSE_ZNAME(name) cs_cl ## name
147# else
148# define CXSPARSE_DNAME(name) cs_di ## name
149# define CXSPARSE_ZNAME(name) cs_ci ## name
150# endif
151#endif
152
153#if defined (HAVE_UMFPACK)
154# if defined (OCTAVE_ENABLE_64)
155# define UMFPACK_DNAME(name) umfpack_dl_ ## name
156# define UMFPACK_ZNAME(name) umfpack_zl_ ## name
157# else
158# define UMFPACK_DNAME(name) umfpack_di_ ## name
159# define UMFPACK_ZNAME(name) umfpack_zi_ ## name
160# endif
161#endif
162
163#if (defined (HAVE_AMD) || defined (HAVE_CCOLAMD) \
164 || defined (HAVE_CHOLMOD) || defined (HAVE_COLAMD) \
165 || defined (HAVE_CXSPARSE) || defined (HAVE_SPQR) \
166 || defined (HAVE_UMFPACK))
167
168namespace octave
169{
170# if defined (OCTAVE_ENABLE_64)
171 typedef SuiteSparse_long suitesparse_integer;
172# else
174# endif
175
178
179 extern const OCTAVE_API suitesparse_integer *
181
184
185 extern const OCTAVE_API octave_idx_type *
187
188 inline octave_idx_type
189 from_suitesparse_long (SuiteSparse_long x)
190 {
193 (*current_liboctave_error_handler)
194 ("integer dimension or index out of range for Octave's indexing type");
195
196 return static_cast<octave_idx_type> (x);
197 }
198
199 inline octave_idx_type
200 from_size_t (std::size_t x)
201 {
202 // std::size_t is guaranteed to be unsigned
204 (*current_liboctave_error_handler)
205 ("integer dimension or index out of range for Octave's index type");
206
207 return static_cast<octave_idx_type> (x);
208 }
209}
210
211#endif
212#endif
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:207
F77_RET_T const F77_DBLE * x
#define OCTAVE_API
Definition: main.in.cc:55
octave_idx_type * to_octave_idx_type_ptr(suitesparse_integer *i)
Definition: oct-sparse.cc:67
octave_idx_type from_suitesparse_long(SuiteSparse_long x)
Definition: oct-sparse.h:189
octave_idx_type from_size_t(std::size_t x)
Definition: oct-sparse.h:200
int suitesparse_integer
Definition: oct-sparse.h:173
suitesparse_integer * to_suitesparse_intptr(octave_idx_type *i)
Definition: oct-sparse.cc:51