Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake" CA
# ---------------------------------------------------------
project (
data
VERSION 0.0.35
VERSION 0.0.36
DESCRIPTION "functinal data structures, mathematics, cryptography, networking, wrappers, and other high-level programming constructs in c++"
LANGUAGES CXX
)
Expand Down Expand Up @@ -114,7 +114,7 @@ endif ()
# ---------------------------------------------------------

# required for pretty much everything.
find_package (Boost 1.86 COMPONENTS thread chrono log_setup log REQUIRED)
find_package (Boost 1.88 COMPONENTS thread chrono log_setup log REQUIRED)
# if we do not have boost
# * linux:
# * go to the boost website, download and extract the latest version.
Expand Down Expand Up @@ -150,9 +150,6 @@ ENDIF ()
include (FetchContent)
cmake_policy (SET CMP0135 NEW)

FetchContent_Declare (json URL https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz)
FetchContent_MakeAvailable (json)

FetchContent_Declare (ctre URL https://github.com/hanickadot/compile-time-regular-expressions/archive/refs/tags/v3.10.0.zip)
FetchContent_MakeAvailable (ctre)

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# use this command to run the docker file with tests
# docker build -f Dockerfile.test -t test .

FROM gigamonkey/gigamonkey-base-dev:v2.2.1
FROM gigamonkey/gigamonkey-base-dev:v2.3.1

WORKDIR /home/data
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gigamonkey/gigamonkey-base-dev:v2.2.1
FROM gigamonkey/gigamonkey-base-dev:v2.3.1

WORKDIR /home/data
COPY . .
Expand Down
13 changes: 13 additions & 0 deletions cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rm -rf /usr/local/include/data
rm -rf /usr/local/include/sv
rm -rf /usr/local/lib/libdata_crypto.a
rm -rf /usr/local/lib/libdata_net.a
rm -rf /usr/local/lib/libdata_numbers.a
rm -rf /usr/local/lib/libdata_hash.a
rm -rf /usr/local/lib/libdata_io.a
rm -rf /usr/local/lib/libdata_string.a
rm -rf /usr/local/include/data/version.hpp
rm -rf /usr/local/lib/cmake/data/dataTargets.cmake
rm -rf /usr/local/lib/cmake/data/dataTargets-debug.cmake
rm -rf /usr/local/lib/cmake/data/dataConfig.cmake
rm -rf /usr/local/lib/cmake/data/dataConfigVersion.cmake
38 changes: 19 additions & 19 deletions cmake/FindData.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
find_package(PkgConfig)
pkg_check_modules(PC_DATA QUIET Data)
find_package (PkgConfig)
pkg_check_modules (PC_DATA QUIET Data)

find_path(DATA_INCLUDE_DIR
find_path (DATA_INCLUDE_DIR
NAMES data.hpp
HINTS ENV DATA_INC_DIR
ENV DATA_DIR
Expand All @@ -10,22 +10,22 @@ PATH_SUFFIXES include/data
DOC "The directory containing the Data header files"
)

find_library(DATA_LIBRARY NAMES data
find_library (DATA_LIBRARY NAMES data
HINTS ENV DATA_LIB_DIR
ENV DATA_DIR
$ENV{DATA_DIR}/lib
PATH_SUFFIXES lib/data
DOC "Path to the Data library"
)

message(STATUS "${DATA_INCLUDE_DIR}")
if(DATA_INCLUDE_DIR)
file(READ "${DATA_INCLUDE_DIR}/data/version.hpp" ver)
message (STATUS "${DATA_INCLUDE_DIR}")
if (DATA_INCLUDE_DIR)
file (READ "${DATA_INCLUDE_DIR}/data/version.hpp" ver)
string(REGEX MATCH "#define DATA_VERSION \"([0-9*.]*)\"" _ ${ver})
set(DATA_VERSION ${CMAKE_MATCH_1})
endif()
set (DATA_VERSION ${CMAKE_MATCH_1})
endif ()

include(FindPackageHandleStandardArgs)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(Data
FOUND_VAR DATA_FOUND
REQUIRED_VARS
Expand All @@ -34,20 +34,20 @@ find_package_handle_standard_args(Data
VERSION_VAR DATA_VERSION
)

if(DATA_FOUND)
set(DATA_LIBRARIES ${DATA_LIBRARY})
set(DATA_INCLUDE_DIRS ${DATA_INCLUDE_DIR})
endif()
if (DATA_FOUND)
set (DATA_LIBRARIES ${DATA_LIBRARY})
set (DATA_INCLUDE_DIRS ${DATA_INCLUDE_DIR})
endif ()

if(DATA_FOUND AND NOT TARGET Data::Data)
add_library(Data::Data UNKNOWN IMPORTED)
set_target_properties(Data::Data PROPERTIES
if (DATA_FOUND AND NOT TARGET Data::Data)
add_library (Data::Data UNKNOWN IMPORTED)
set_target_properties (Data::Data PROPERTIES
IMPORTED_LOCATION "${DATA_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${DATA_INCLUDE_DIR}"
)
endif()
endif ()

mark_as_advanced(
mark_as_advanced (
DATA_INCLUDE_DIR
DATA_LIBRARY
)
91 changes: 50 additions & 41 deletions cmake/FindGMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
# GMP_LIBRARIES_DIR - directory where the GMP libraries are located
# GMP_LIBRARIES - Link these to use GMP

if (TARGET GMP::GMP)
return ()
endif ()

function (define_imported_target library headers)

function(define_imported_target library headers)
add_library(GMP::GMP UNKNOWN IMPORTED)
set_target_properties(GMP::GMP PROPERTIES
add_library (GMP::GMP UNKNOWN IMPORTED)
set_target_properties (GMP::GMP PROPERTIES
IMPORTED_LOCATION ${library}
INTERFACE_INCLUDE_DIRECTORIES ${headers}
)
INTERFACE_INCLUDE_DIRECTORIES ${headers})

set (GMP_FOUND 1 CACHE INTERNAL "GMP found" FORCE)
set (GMP_LIBRARIES ${library}
Expand All @@ -28,63 +31,69 @@ if (GMP_LIBRARIES AND GMP_INCLUDES)
return ()
endif ()

set(QUIET_ARG)
if(GMP_FIND_QUIETLY)
set(QUIET_ARG QUIET)
endif()
set (QUIET_ARG)
if (GMP_FIND_QUIETLY)
set (QUIET_ARG QUIET)
endif ()

set(REQUIRED_ARG)
if(GMP_FIND_REQUIRED)
set(REQUIRED_ARG REQUIRED)
endif()
set (REQUIRED_ARG)
if (GMP_FIND_REQUIRED)
set (REQUIRED_ARG REQUIRED)
endif ()

file(TO_CMAKE_PATH "$ENV{GMP_DIR}" _GMP_DIR)
file (TO_CMAKE_PATH "$ENV{GMP_DIR}" _GMP_DIR)

include(FindPackageHandleStandardArgs)
include (FindPackageHandleStandardArgs)

find_path(GMP_INCLUDE_DIR
NAMES gmp.h gmpxx.h
HINTS ENV GMP_INC_DIR
ENV GMP_DIR
$ENV{GMP_DIR}/include
PATH_SUFFIXES include
DOC "The directory containing the GMP header files"
)
find_path (GMP_INCLUDE_DIR
NAMES gmp.h gmpxx.h
HINTS ENV GMP_INC_DIR
ENV GMP_DIR
$ENV{GMP_DIR}/include
PATH_SUFFIXES include
DOC "The directory containing the GMP header files")

find_library(GMP_LIBRARY_RELEASE NAMES gmp libgmp-10 gmp-10 mpir
find_library (GMP_LIBRARY_RELEASE NAMES gmp libgmp-10 gmp-10 mpir
HINTS ENV GMP_LIB_DIR
ENV GMP_DIR
$ENV{GMP_DIR}/lib
PATH_SUFFIXES lib
DOC "Path to the Release GMP library"
)
DOC "Path to the Release GMP library")

find_library(GMP_LIBRARY_DEBUG NAMES gmpd gmp libgmp-10 gmp-10 mpir
find_library (GMP_LIBRARY_DEBUG NAMES gmpd gmp libgmp-10 gmp-10 mpir
HINTS ENV GMP_LIB_DIR
ENV GMP_DIR
$ENV{GMP_DIR}/include
PATH_SUFFIXES lib
DOC "Path to the Debug GMP library"
)

DOC "Path to the Debug GMP library")

if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(GMP_LIBRARIES ${GMP_LIBRARY_DEBUG})
else()
set(GMP_LIBRARIES ${GMP_LIBRARY_RELEASE})
endif()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set (GMP_LIBRARIES ${GMP_LIBRARY_DEBUG})
else ()
set (GMP_LIBRARIES ${GMP_LIBRARY_RELEASE})
endif ()

# Attempt to load a user-defined configuration for GMP if couldn't be found
if ( NOT GMP_INCLUDE_DIR OR NOT GMP_LIBRARIES)
include( GMPConfig OPTIONAL )
include ( GMPConfig OPTIONAL )
endif()

find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_INCLUDE_DIR)
if (GMP_FOUND)
define_imported_target(
"${GMP_LIBRARIES}"
"${GMP_INCLUDE_DIR}"
)
elseif(GMP_FIND_REQUIRED)
message(FATAL_ERROR "Required Gmp library not found")
endif()
"${GMP_INCLUDE_DIR}")
elseif (GMP_FIND_REQUIRED)
message (FATAL_ERROR "Required Gmp library not found")
endif ()

message(STATUS "==== Dumping GMP::GMP target properties ====")

get_property(_props TARGET GMP::GMP PROPERTY PROPERTY_NAMES)

foreach(_prop ${_props})
get_target_property(_val GMP::GMP ${_prop})
message(STATUS "${_prop} = ${_val}")
endforeach()

message(STATUS "===========================================")
18 changes: 8 additions & 10 deletions include/data/arithmetic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ namespace data {

template <typename Z, typename N = Z> concept proto_number_system =
proto_system<Z, N> && ImplicitlyConvertible<N, Z> &&
// NOTE: this clause should be uncommented, but the numbers
// don't work right ATM so we need to fix them.
//ExplicitlyConvertible<Z, N> &&
Convertible<Z, N> &&
math::hetero_abs_and_negate<N, Z>;

// here we look at types with bit operations defined on them.
Expand Down Expand Up @@ -414,11 +412,11 @@ namespace data {

template <typename X, typename Y>
concept div_algebraic_unsigned_to =
ring_algebraic_unsigned_to<X, Y> /*&&
ring_algebraic_unsigned_to<X, Y> &&
requires (const X &a) {
{ a / 1u } -> ImplicitlyConvertible<Y>;
{ 1u / a } -> ImplicitlyConvertible<Y>;
}*/;
//{ 1u / a } -> ImplicitlyConvertible<Y>;
};

template <typename X, typename Y>
concept group_algebraic_signed_big_to =
Expand Down Expand Up @@ -629,16 +627,16 @@ namespace data {
template <typename Z> concept WholeNumber =
div_number<Z> && requires (const Z &a, const Z &b) {
{ a % b };
// NOTE this should be uncommented.
//{ divmod (a, b) };
{ divmod (a, math::nonzero {b}) };
} && (Signed<Z> || Unsigned<Z>);

template <typename Z> concept Integer =
WholeNumber<Z> && RingNumber<Z> && div_number_signed<Z>;

// TODO require homo modable.
template <typename Z> concept Natural =
WholeNumber<Z> && div_number_unsigned<Z>;
WholeNumber<Z> && div_number_unsigned<Z> && requires (const Z &a, const Z &b) {
{ a % b } -> Same<Z>;
};

// now we have two types that go together as signed and unsigned versions of each other.
template <typename Z, typename N = Z> concept number_system =
Expand Down
Loading
Loading