SuperSCS  1.3.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
glbopts.h
Go to the documentation of this file.
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2017 Pantelis Sopasakis (https://alphaville.github.io),
5  * Krina Menounou (https://www.linkedin.com/in/krinamenounou),
6  * Panagiotis Patrinos (http://homes.esat.kuleuven.be/~ppatrino)
7  * Copyright (c) 2012 Brendan O'Donoghue (bodonoghue85@gmail.com)
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to deal
11  * in the Software without restriction, including without limitation the rights
12  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in all
17  * copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  * SOFTWARE.
26  *
27  */
28 #ifndef SCS_GLB_H_GUARD
29 #define SCS_GLB_H_GUARD
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include <math.h>
36 
37 #ifdef RESTRICT
38 #undef RESTRICT
39 #endif
40 
41 #if(defined _WIN32 || defined _WIN64 || defined _WINDLL)
42 #define RESTRICT
43 #else
44 #define RESTRICT __restrict
45 #endif
46 
47  /* redefine printfs and memory allocators as needed */
48 #ifdef MATLAB_MEX_FILE
49 #include "mex.h"
50 #define scs_printf mexPrintf
51 #define scs_free_ mxFree
52 #define scs_malloc_ mxMalloc
53 #define scs_calloc_ mxCalloc
54 #elif defined PYTHON
55 #include <Python.h>
56 #include <stdlib.h>
57 #define scs_printf(...) \
58  { \
59  PyGILState_STATE gilstate = PyGILState_Ensure(); \
60  PySys_WriteStdout(__VA_ARGS__); \
61  PyGILState_Release(gilstate); \
62  }
63 #define scs_free_ free
64 #define scs_malloc_ malloc
65 #define scs_calloc_ calloc
66 #elif(defined(USING_R))
67 #include <stdlib.h>
68 #include <stdio.h>
69 #include <R_ext/Print.h> /* Rprintf etc */
70 #define scs_printf Rprintf
71 #define scs_free_ free
72 #define scs_malloc_ malloc
73 #define scs_calloc_ calloc
74 #else
75 #include <stdio.h>
76 #include <stdlib.h>
77 #define scs_printf printf
78 #define scs_free_ free
79 #define scs_malloc_ malloc
80 #define scs_calloc_ calloc
81 #endif
82 
83 #define scs_free(x) if ((x)!=NULL) { scs_free_(x); x = SCS_NULL; }
84 #define scs_malloc(x) (((x) > 0) ? scs_malloc_(x) : SCS_NULL)
85 #define scs_calloc(x, y) scs_calloc_(x, y)
86 
87 #ifdef DLONG
88 #ifdef _WIN64
89  typedef __int64 scs_int;
90  /* #define scs_int __int64 */
91 #else
92  typedef long scs_int;
93  /* #define scs_int long */
94 #endif
95 #else
96  typedef int scs_int;
97 #endif
98 
99 #ifndef FLOAT
100  typedef double scs_float;
101 #ifndef NAN
102 #define NAN ((scs_float)0x7ff8000000000000)
103 #endif
104 #ifndef INFINITY
105 #define INFINITY NAN
106 #endif
107 #else
108  typedef float scs_float;
109 #ifndef NAN
110 #define NAN ((float)0x7fc00000)
111 #endif
112 #ifndef INFINITY
113 #define INFINITY NAN
114 #endif
115 #endif
116 
117 #define SCS_NULL 0
118 
119 #ifndef MAX
120 
123 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
124 #endif
125 
126 #ifndef MIN
127 
130 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
131 #endif
132 
133 #ifndef ABS
134 
137 #define ABS(x) (((x) < 0) ? -(x) : (x))
138 #endif
139 
140 #ifndef SGN
141 
144 #define SGN(x) (((x) >= 0) ? 1.0 : -1.0)
145 #endif
146 
147 #ifndef POWF
148 #ifdef FLOAT
149 #define POWF powf
150 #else
151 #define POWF pow
152 #endif
153 #endif
154 
155 #ifndef SQRTF
156 #ifdef FLOAT
157 #define SQRTF sqrtf
158 #else
159 #define SQRTF sqrt
160 #endif
161 #endif
162 
163 
170  typedef struct scs_data ScsData;
174  typedef struct scs_settings ScsSettings;
178  typedef struct scs_solution ScsSolution;
182  typedef struct scs_info ScsInfo;
186  typedef struct scs_scaling ScsScaling;
190  typedef struct scs_work ScsWork;
196  typedef struct scs_cone ScsCone;
201 
207  typedef
208  enum direction_enum {
225  }
227 
228 #ifdef __cplusplus
229 }
230 #endif
231 #endif
Definition: glbopts.h:212
Terminating information.
Definition: scs.h:539
enum direction_enum ScsDirectionType
Direction computation method (in SuperSCS)
direction_enum
Direction computation method (in SuperSCS)
Definition: glbopts.h:207
Definition: glbopts.h:224
Definition: glbopts.h:216
int scs_int
Definition: glbopts.h:96
Cone structure.
Definition: cones.h:48
double scs_float
Definition: glbopts.h:100
struct containing problem data
Definition: scs.h:254
Workspace for SCS.
Definition: scs.h:75
Definition: glbopts.h:220
Memory for the computation of directions (Broyden and Anderson's methods).
Definition: scs.h:60
Settings structure.
Definition: scs.h:290
Normalization variables.
Definition: scs.h:571
Primal-dual solution arrays.
Definition: scs.h:518