NULAPACK
NUmerical Linear Algebra PACKage
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/*
2 * ====================================================================
3 * N U L A P A C K
4 * U U L A P A C K
5 * L L L A P A C K
6 * A A A A P A C K
7 * P P P P P A C K
8 * A A A A A A C K
9 * C C C C C C C K
10 * K K K K K K K K
11 *
12 * This file is part of NULAPACK - NUmerical Linear Algebra PACKage
13 *
14 * Copyright (C) 2025 Saud Zahir
15 *
16 * NULAPACK is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * NULAPACK is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with NULAPACK. If not, see <https://www.gnu.org/licenses/>.
28 * ====================================================================
29 */
30
31#ifndef FORTRAN_TYPES_H
32#define FORTRAN_TYPES_H
33
34#include <stdint.h>
35#include <inttypes.h>
36
37#ifdef __cplusplus
38 #include <complex>
39 typedef std::complex<float> complex_float;
40 typedef std::complex<double> complex_double;
41#else
42 #include <complex.h>
43 typedef float _Complex complex_float;
44 typedef double _Complex complex_double;
45#endif
46
47// Accessors for real/imaginary parts
48#ifndef complex_float_real
49 #define complex_float_real(z) (crealf(z))
50#endif
51#ifndef complex_float_imag
52 #define complex_float_imag(z) (cimagf(z))
53#endif
54#ifndef complex_double_real
55 #define complex_double_real(z) (creal(z))
56#endif
57#ifndef complex_double_imag
58 #define complex_double_imag(z) (cimag(z))
59#endif
60
61// Integer type — default is 32-bit, override with -DFORTRAN_ILP64 if needed
62#ifdef FORTRAN_ILP64
63 typedef int64_t fortran_int;
64 #define FORTRAN_IFMT PRId64
65#else
66 typedef int32_t fortran_int;
67 #define FORTRAN_IFMT PRId32
68#endif
69
71
72// Fortran-style type aliases
73typedef float fortran_real;
74typedef double fortran_double;
77
78// Aliases matching traditional Fortran naming
79#define REAL fortran_real
80#define DOUBLE fortran_double
81#define COMPLEX fortran_complex
82#define DOUBLE_COMPLEX fortran_double_complex
83#define INTEGER fortran_int
84#define LOGICAL fortran_logical
85
86// Optional: function pointer types for selector functions
87typedef LOGICAL (*SELECT_REAL_2)(const REAL*, const REAL*);
88typedef LOGICAL (*SELECT_REAL_3)(const REAL*, const REAL*, const REAL*);
89typedef LOGICAL (*SELECT_DOUBLE_2)(const DOUBLE*, const DOUBLE*);
90typedef LOGICAL (*SELECT_DOUBLE_3)(const DOUBLE*, const DOUBLE*, const DOUBLE*);
91typedef LOGICAL (*SELECT_COMPLEX_1)(const COMPLEX*);
92typedef LOGICAL (*SELECT_COMPLEX_2)(const COMPLEX*, const COMPLEX*);
95
96#define SUBROUTINE inline void
97
98#ifdef __cplusplus
99 #define fortran extern "C" void
100#else
101 #define fortran extern void
102#endif
103
104#endif
fortran_logical(* SELECT_COMPLEX_1)(const fortran_complex *)
Definition types.h:91
std::complex< double > complex_double
Definition types.h:40
std::complex< float > complex_float
Definition types.h:39
float fortran_real
Definition types.h:73
#define REAL
Definition types.h:79
fortran_logical(* SELECT_REAL_3)(const fortran_real *, const fortran_real *, const fortran_real *)
Definition types.h:88
fortran_logical(* SELECT_DOUBLE_3)(const fortran_double *, const fortran_double *, const fortran_double *)
Definition types.h:90
#define DOUBLE_COMPLEX
Definition types.h:82
#define LOGICAL
Definition types.h:84
fortran_logical(* SELECT_COMPLEX_2)(const fortran_complex *, const fortran_complex *)
Definition types.h:92
#define DOUBLE
Definition types.h:80
double fortran_double
Definition types.h:74
#define COMPLEX
Definition types.h:81
fortran_logical(* SELECT_DOUBLE_2)(const fortran_double *, const fortran_double *)
Definition types.h:89
fortran_logical(* SELECT_DOUBLE_COMPLEX_1)(const fortran_double_complex *)
Definition types.h:93
complex_float fortran_complex
Definition types.h:75
complex_double fortran_double_complex
Definition types.h:76
int32_t fortran_int
Definition types.h:66
fortran_logical(* SELECT_DOUBLE_COMPLEX_2)(const fortran_double_complex *, const fortran_double_complex *)
Definition types.h:94
fortran_int fortran_logical
Definition types.h:70
fortran_logical(* SELECT_REAL_2)(const fortran_real *, const fortran_real *)
Definition types.h:87