Skip to content

Commit 92ccad1

Browse files
committed
Initial Commit
1 parent 7c1ab21 commit 92ccad1

24 files changed

+7074
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ install_manifest.txt
99
compile_commands.json
1010
CTestTestfile.cmake
1111
_deps
12+
/out
13+
/.vs

CMakeLists.txt

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
cmake_minimum_required (VERSION 3.8)
2+
3+
project (numpy_random)
4+
5+
if (MSVC)
6+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++17>)
7+
if (CMAKE_GENERATOR STREQUAL "Ninja")
8+
add_compile_options(
9+
/wd4464
10+
/wd4711
11+
/wd4820
12+
)
13+
endif()
14+
else()
15+
set(CMAKE_CXX_STANDARD 17)
16+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
17+
endif()
18+
19+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
20+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
21+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
22+
23+
function(create_target_directory_groups target_name)
24+
source_group("Other Files" REGULAR_EXPRESSION ".")
25+
26+
get_target_property(target_sources "${target_name}" SOURCES)
27+
28+
foreach(file_name IN LISTS target_sources)
29+
get_filename_component(dir_name "${file_name}" PATH)
30+
string(REPLACE "/" "\\" group_name "${dir_name}")
31+
source_group("${group_name}" FILES "${file_name}")
32+
endforeach()
33+
endfunction()
34+
35+
add_subdirectory(src)

CMakeSettings.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "x64-Debug",
5+
"generator": "Ninja",
6+
"configurationType": "Debug",
7+
"inheritEnvironments": [ "msvc_x64_x64" ],
8+
"buildRoot": "${projectDir}\\out\\build\\${name}",
9+
"installRoot": "${projectDir}\\out\\install\\${name}",
10+
"cmakeCommandArgs": "",
11+
"buildCommandArgs": "",
12+
"ctestCommandArgs": ""
13+
},
14+
{
15+
"name": "x64-Release",
16+
"generator": "Ninja",
17+
"configurationType": "Release",
18+
"buildRoot": "${projectDir}\\out\\build\\${name}",
19+
"installRoot": "${projectDir}\\out\\install\\${name}",
20+
"cmakeCommandArgs": "",
21+
"buildCommandArgs": "",
22+
"ctestCommandArgs": "",
23+
"inheritEnvironments": [ "msvc_x64_x64" ]
24+
}
25+
]
26+
}

src/CMakeLists.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
include_directories(.)
2+
3+
set_property(DIRECTORY APPEND PROPERTY
4+
COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
5+
6+
if (MSVC)
7+
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE)
8+
9+
add_definitions(-DNOMINMAX)
10+
11+
add_definitions(-DWIN32_LEAN_AND_MEAN)
12+
else()
13+
if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
14+
add_compile_options("-stdlib=libc++")
15+
endif()
16+
17+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
18+
add_definitions(-D_FILE_OFFSET_BITS=64)
19+
endif()
20+
endif()
21+
22+
add_subdirectory(numpy)
23+
add_library(numpy_random STATIC
24+
"numpy_random.cpp"
25+
"numpy_random.h"
26+
)
27+
28+
# Combine both static libraries
29+
add_library(libnumpyrandom STATIC $<TARGET_OBJECTS:numpy> $<TARGET_OBJECTS:numpy_random>)
30+
target_link_libraries(libnumpyrandom PUBLIC numpy numpy_random)
31+
32+
create_target_directory_groups(numpy_random)

src/numpy/CMakeLists.txt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
add_library(numpy STATIC
2+
"npy_common.h"
3+
"npy_math.h"
4+
"numpyconfig.h"
5+
"_numpyconfig.h"
6+
"random/bitgen.h"
7+
"random/distributions.h"
8+
"random/distributions/distributions.c"
9+
"random/distributions/logfactorial.c"
10+
"random/distributions/logfactorial.h"
11+
"random/distributions/random_hypergeometric.c"
12+
"random/distributions/random_mvhg_count.c"
13+
"random/distributions/random_mvhg_marginals.c"
14+
"random/distributions/ziggurat_constants.h"
15+
"random/legacy/legacy-distributions.c"
16+
"random/legacy/legacy-distributions.h"
17+
)
18+
19+
if (MSVC)
20+
target_compile_options(numpy PRIVATE
21+
/wd4242
22+
/wd4244
23+
/wd4245
24+
/wd4254
25+
/wd4800
26+
)
27+
else()
28+
target_compile_options(numpy PRIVATE
29+
-Wno-conversion
30+
31+
-Wno-sign-conversion
32+
33+
$<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation>
34+
)
35+
endif()
36+
37+
create_target_directory_groups(numpy)

src/numpy/LICENSE.txt

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2005-2022, NumPy Developers.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of the NumPy Developers nor the names of any
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/numpy/_numpyconfig.h

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/* copied from pyconfig.h */
2+
#define SIZEOF_SHORT 2
3+
#define SIZEOF_INT 4
4+
#define SIZEOF_LONG 4
5+
#define ALIGNOF_LONG 4
6+
#define SIZEOF_LONG_LONG 8
7+
#define SIZEOF_DOUBLE 8
8+
#define SIZEOF_FLOAT 4
9+
10+
#if defined(__APPLE__)
11+
12+
# undef SIZEOF_LONG
13+
# undef SIZEOF_PTHREAD_T
14+
# undef SIZEOF_SIZE_T
15+
# undef SIZEOF_TIME_T
16+
# undef SIZEOF_VOID_P
17+
# undef SIZEOF__BOOL
18+
# undef SIZEOF_UINTPTR_T
19+
# undef SIZEOF_PTHREAD_T
20+
# undef WORDS_BIGENDIAN
21+
# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
22+
# undef DOUBLE_IS_BIG_ENDIAN_IEEE754
23+
# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
24+
# undef HAVE_GCC_ASM_FOR_X87
25+
26+
# undef VA_LIST_IS_ARRAY
27+
# if defined(__LP64__) && defined(__x86_64__)
28+
# define VA_LIST_IS_ARRAY 1
29+
# endif
30+
31+
# undef HAVE_LARGEFILE_SUPPORT
32+
# ifndef __LP64__
33+
# define HAVE_LARGEFILE_SUPPORT 1
34+
# endif
35+
36+
# undef SIZEOF_LONG
37+
# ifdef __LP64__
38+
# define SIZEOF__BOOL 1
39+
# define SIZEOF__BOOL 1
40+
# define SIZEOF_LONG 8
41+
# define SIZEOF_PTHREAD_T 8
42+
# define SIZEOF_SIZE_T 8
43+
# define SIZEOF_TIME_T 8
44+
# define SIZEOF_VOID_P 8
45+
# define SIZEOF_UINTPTR_T 8
46+
# define SIZEOF_PTHREAD_T 8
47+
# else
48+
# ifdef __ppc__
49+
# define SIZEOF__BOOL 4
50+
# else
51+
# define SIZEOF__BOOL 1
52+
# endif
53+
# define SIZEOF_LONG 4
54+
# define SIZEOF_PTHREAD_T 4
55+
# define SIZEOF_SIZE_T 4
56+
# define SIZEOF_TIME_T 4
57+
# define SIZEOF_VOID_P 4
58+
# define SIZEOF_UINTPTR_T 4
59+
# define SIZEOF_PTHREAD_T 4
60+
# endif
61+
62+
# if defined(__LP64__)
63+
/* MacOSX 10.4 (the first release to support 64-bit code
64+
* at all) only supports 64-bit in the UNIX layer.
65+
* Therefore suppress the toolbox-glue in 64-bit mode.
66+
*/
67+
68+
/* In 64-bit mode setpgrp always has no arguments, in 32-bit
69+
* mode that depends on the compilation environment
70+
*/
71+
# undef SETPGRP_HAVE_ARG
72+
73+
# endif
74+
75+
#ifdef __BIG_ENDIAN__
76+
#define WORDS_BIGENDIAN 1
77+
#define DOUBLE_IS_BIG_ENDIAN_IEEE754
78+
#else
79+
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754
80+
#endif /* __BIG_ENDIAN */
81+
82+
#ifdef __i386__
83+
# define HAVE_GCC_ASM_FOR_X87
84+
#endif
85+
86+
/*
87+
* The definition in pyconfig.h is only valid on the OS release
88+
* where configure ran on and not necessarily for all systems where
89+
* the executable can be used on.
90+
*
91+
* Specifically: OSX 10.4 has limited supported for '%zd', while
92+
* 10.5 has full support for '%zd'. A binary built on 10.5 won't
93+
* work properly on 10.4 unless we suppress the definition
94+
* of PY_FORMAT_SIZE_T
95+
*/
96+
#undef PY_FORMAT_SIZE_T
97+
98+
99+
#endif
100+
101+
102+
#define NPY_SIZEOF_SHORT SIZEOF_SHORT
103+
#define NPY_SIZEOF_INT SIZEOF_INT
104+
#define NPY_SIZEOF_LONG SIZEOF_LONG
105+
#define NPY_SIZEOF_FLOAT 4
106+
#define NPY_SIZEOF_COMPLEX_FLOAT 8
107+
#define NPY_SIZEOF_DOUBLE 8
108+
#define NPY_SIZEOF_COMPLEX_DOUBLE 16
109+
#define NPY_SIZEOF_LONGDOUBLE 8
110+
#define NPY_SIZEOF_COMPLEX_LONGDOUBLE 16
111+
#define NPY_SIZEOF_PY_INTPTR_T 8
112+
#define NPY_SIZEOF_OFF_T 4
113+
#define NPY_SIZEOF_PY_LONG_LONG 8
114+
#define NPY_SIZEOF_LONGLONG 8
115+
#define NPY_NO_SIGNAL 1
116+
#define NPY_NO_SMP 0
117+
#define NPY_HAVE_DECL_ISNAN
118+
#define NPY_HAVE_DECL_ISINF
119+
#define NPY_HAVE_DECL_SIGNBIT
120+
#define NPY_HAVE_DECL_ISFINITE
121+
#define NPY_USE_C99_COMPLEX 1
122+
#define NPY_USE_C99_FORMATS 1
123+
#define NPY_VISIBILITY_HIDDEN
124+
#define NPY_ABI_VERSION 0x01000009
125+
#define NPY_API_VERSION 0x00000010
126+
127+
#ifndef __STDC_FORMAT_MACROS
128+
#define __STDC_FORMAT_MACROS 1
129+
#endif

0 commit comments

Comments
 (0)