Skip to content

Commit

Permalink
Merge 1252c65 into 2f1447f
Browse files Browse the repository at this point in the history
  • Loading branch information
goulart-paul committed Jul 19, 2018
2 parents 2f1447f + 1252c65 commit 835951b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 51 deletions.
23 changes: 19 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Options
# ----------------------------------------------
# Use floats instead of doubles
option (DFLOAT "Use float numbers instead of doubles" OFF)
set(DFLOAT OFF CACHE BOOL "Use float numbers instead of doubles")
message(STATUS "Floats are ${DFLOAT}")

# Use long integers for indexing
option (DLONG "Use long integers (64bit) for indexing" ON)
set(DLONG ON CACHE BOOL "Use long integers (64bit) for indexing")
if (NOT (CMAKE_SIZEOF_VOID_P EQUAL 8))
message(STATUS "Disabling long integers (64bit) on 32bit machine")
set(DLONG OFF)
Expand Down Expand Up @@ -50,8 +50,22 @@ endif (NOT MSVC)

# Generate header file with the global options
# ---------------------------------------------
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/qdldl_configure.h.in
${CMAKE_CURRENT_SOURCE_DIR}/include/qdldl_configure.h

# numeric types
if(DFLOAT)
set(QDLDL_FLOAT_TYPE "float")
else()
set(QDLDL_FLOAT_TYPE "double")
endif()

if(DLONG)
set(QDLDL_INT_TYPE "long long")
else()
set(QDLDL_INT_TYPE "int")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/qdldl_types.h.in
${CMAKE_CURRENT_SOURCE_DIR}/include/qdldl_types.h
NEWLINE_STYLE LF)


Expand All @@ -65,6 +79,7 @@ set(
set(
qdldl_headers
include/qdldl.h
include/qdldl_types.h
)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ QDLDL uses its own internal types for integers, floats and booleans (`QDLDL_int,
- `DFLOAT` (default false): uses float numbers instead of doubles
- `DLONG` (default true): uses long integers for indexing (for large matrices)

Note that the `QDLDL_bool` type is defined as the standard `bool` type for C standards >= C99. Before the `bool` type was not defined and for earlier standards QDLDL sets `QDLDL_bool = QDLDL_int`.
Note that the `QDLDL_bool` type is defined as the standard `_Bool` type for C standards >= C99. In earlier C standards the `_Bool` type was not defined and QDLDL sets `QDLDL_bool = QDLDL_int`.


## Linking QDLDL
Expand Down
18 changes: 0 additions & 18 deletions configure/qdldl_configure.h.in

This file was deleted.

24 changes: 24 additions & 0 deletions configure/qdldl_types.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef QDLDL_TYPES_H
# define QDLDL_TYPES_H

# ifdef __cplusplus
extern "C" {
# endif /* ifdef __cplusplus */

// QDLDL integer and float types

typedef @QDLDL_INT_TYPE@ QDLDL_int; /* for indices */
typedef @QDLDL_FLOAT_TYPE@ QDLDL_float; /* for numerical values */

// Use bool for logical type if available
#if __STDC_VERSION__ >= 199901L
typedef _Bool QDLDL_bool;
#else
typedef int QDLDL_bool;
#endif

# ifdef __cplusplus
}
# endif /* ifdef __cplusplus */

#endif /* ifndef OSQP_CONFIGURE_H */
2 changes: 1 addition & 1 deletion include/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
qdldl_configure.h
qdldl_types.h
30 changes: 3 additions & 27 deletions include/qdldl.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
#ifndef QDLDL_H
# define QDLDL_H

// Include qdldl configure options
#include "qdldl_configure.h"

// Custom types
// Integers
# ifdef DLONG // long integers
typedef long long QDLDL_int; /* for indices */
# else // standard integers
typedef int QDLDL_int; /* for indices */
# endif /* ifdef DLONG */

// Doubles
# ifndef DFLOAT // Doubles
typedef double QDLDL_float; /* for numerical values */
# else // Floats
typedef float QDLDL_float; /* for numerical values */
# endif /* ifndef DFLOAT */

// Define bool if standard > C89
#if __STDC_VERSION__ >= 199901L
#include <stdbool.h>
typedef bool QDLDL_bool;
#else
typedef QDLDL_int QDLDL_bool;
#endif
#define QDLDL_H

// Include qdldl type options
#include "qdldl_types.h"

# ifdef __cplusplus
extern "C" {
Expand Down

0 comments on commit 835951b

Please sign in to comment.