From 917ad98379862a7ca5cd6313b0de64b3b52c5dc2 Mon Sep 17 00:00:00 2001 From: montaquila Date: Sat, 7 Jan 2023 22:46:50 -0700 Subject: [PATCH] updates to Python API. Including Derivatives + Matrix and Vector operations --- MANIFEST.in | 1 + Python/openmtpk/Makefile | 10 +++++++--- Python/openmtpk/openmtpk.i | 20 +++++++++++++++++--- setup.py | 5 +++++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 96428da5a..7f624a660 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,7 @@ include *x86_64-linux-gnu.so include *.md include LICENSE global-exclude *.cxx +global-exclude __pycache__ recursive-include modules *.cpp recursive-include include *.hpp diff --git a/Python/openmtpk/Makefile b/Python/openmtpk/Makefile index f6c9b2d3c..43b8c382d 100644 --- a/Python/openmtpk/Makefile +++ b/Python/openmtpk/Makefile @@ -32,10 +32,13 @@ run-swig: ############################################################################## primes = $(MOD_DIR)/number_theory/primes.cpp arith = $(MOD_DIR)/arithmetic/arith.cpp +calc = $(MOD_DIR)/calculus/deriv.cpp +linalg = $(MOD_DIR)/linalg/lao.cpp +linreg = $(MOD_DIR)/ml/linreg.cpp cipher = $(MOD_DIR)/number_theory/cipher.cpp rc4 = $(MOD_DIR)/number_theory/rc4.cpp compile: - ${CXX} ${STD} ${CXX_DBG} -O2 -fPIC -c ${arith} ${primes} ${cipher} ${rc4} + ${CXX} ${STD} ${CXX_DBG} -O2 -fPIC -c ${arith} ${calc} ${primes} ${linalg} ${linreg} ${cipher} ${rc4} ############################################################################## # COMPILE WRAPPED SOURCE FILE @@ -55,9 +58,9 @@ endif # COMPILE SOURCE OBJECTS ############################################################################## pkgLINUX = _openmtpk.so -pkgOSX = _openmtpk.co +pkgOSX = _openmtpk.so -src_objs = arith.o primes.o cipher.o rc4.o openmtpk_wrap.o +src_objs = arith.o deriv.o lao.o linreg.o primes.o cipher.o rc4.o openmtpk_wrap.o compile-lib: # LINUX ifeq ($(OS), Linux) @@ -73,6 +76,7 @@ endif clean: rm -rf */__pycache__ rm -f *.o + rm -f *.so rm -f *.cxx rm -f openmtpk.py diff --git a/Python/openmtpk/openmtpk.i b/Python/openmtpk/openmtpk.i index d19ad9f63..392feab10 100644 --- a/Python/openmtpk/openmtpk.i +++ b/Python/openmtpk/openmtpk.i @@ -6,16 +6,30 @@ %include "std_string.i" %{ #include "../../include/arithmetic/arith_ops.hpp" + + #include "../../include/calculus/deriv.hpp" + + #include "../../include/ml/bayes_network.hpp" + #include "../../include/ml/k-foldCV.hpp" + #include "../../include/ml/linreg.hpp" + #include "../../include/ml/nearest_neighbor.hpp" + #include "../../include/number_theory/primes.hpp" #include "../../include/number_theory/rc4.hpp" #include "../../include/number_theory/cipher.hpp" %} -/* -%include "../../include/arithmetic/arith.hpp" -*/ %include "../../include/arithmetic/arith_ops.hpp" + +%include "../../include/calculus/deriv.hpp" + +%include "../../include/ml/bayes_network.hpp" +%include "../../include/ml/k-foldCV.hpp" +%include "../../include/ml/linreg.hpp" +%include "../../include/ml/nearest_neighbor.hpp" + %include "../../include/number_theory/primes.hpp" %include "../../include/number_theory/rc4.hpp" %include "../../include/number_theory/cipher.hpp" + diff --git a/setup.py b/setup.py index e007cf996..0a29a9733 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,8 @@ +""" +Main entrypoint for building the openMTPK Python API. +Leverages SWIG, setuptools, and a few other dependencies. +""" + #from setuptools import setup, find_packages import setuptools from setuptools import setup, dist