Skip to content

Commit

Permalink
updates to installation process, nested headers, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
akielaries committed Jan 3, 2023
1 parent d8c81c0 commit 6232b29
Show file tree
Hide file tree
Showing 23 changed files with 2,050 additions and 1,994 deletions.
3,584 changes: 1,792 additions & 1,792 deletions .coverage/lcov.info

Large diffs are not rendered by default.

262 changes: 131 additions & 131 deletions .coverage/lcov.xml

Large diffs are not rendered by default.

31 changes: 17 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ endif()

include(GNUInstallDirs)


############################################################
# Run tests specified in Makefile
############################################################
enable_testing()

#add_subdirectory(tests)

add_custom_target(TESTS COMMAND make run-tests
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
)

############################################################
# Create a library
############################################################
Expand All @@ -38,29 +50,20 @@ target_include_directories(${PROJECT_NAME} PUBLIC
PRIVATE modules
)

# headers to declare as public
set(OPM_INCLUDES
${PROJECT_SOURCE_DIR}/include/arithmetic/arith.hpp
${PROJECT_SOURCE_DIR}/include/calculus/deriv.hpp
${PROJECT_SOURCE_DIR}/include/linalg/lao.hpp
${PROJECT_SOURCE_DIR}/include/ml/linreg.hpp
${PROJECT_SOURCE_DIR}/include/number_theory/cipher.hpp
${PROJECT_SOURCE_DIR}/include/number_theory/rc4.hpp
${PROJECT_SOURCE_DIR}/include/number_theory/primes.hpp
)

set_target_properties(${PROJECT_NAME}
PROPERTIES
PUBLIC_HEADER "${OPM_INCLUDES}"
VERSION ${PROJECT_VERSION}
)

install(TARGETS ${PROJECT_NAME} EXPORT openMTPKConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/openMTPK"
)

# install include directory to /usr/local/include/openMTPK
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/openMTPK"
)

install(EXPORT openMTPKConfig DESTINATION share/openMTPK/cmake)
Expand Down
30 changes: 30 additions & 0 deletions include/arithmetic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @file
*
* @brief openMTPK ARITHMETIC MODULE
*
* @details This file serves as the core Arithmetic module housing the
* basic operations and operations based on/using arithmetic.
*/
#ifndef LINALG_HPP
#define LINALG_HPP


/**
* @brief \b Arithmetic \b Basics
* @details Basics of Arithmetic
*/
#define ARITHMETIC_BASICS
#include "arithmetic/arith_base.hpp"
/*****************************************************************************/

/**
* @brief \b Arithmetic \b Operations
* @details Encompasses Arithmetic related operations
*/
#define ARITHMETIC_OPERATIONS
#include "arithmetic/arith_ops.hpp"
/*****************************************************************************/

#endif

30 changes: 2 additions & 28 deletions include/arithmetic/arith.hpp → include/arithmetic/arith_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Definitions for basic arithmetic operations
*/

#ifndef ARITH_HPP
#define ARITH_HPP
#ifndef ARITH_BASE_HPP
#define ARITH_BASE_HPP
#include <vector>
#include <iostream>
#include <stdio.h>
Expand Down Expand Up @@ -97,33 +97,7 @@ class Arith {
inline auto exp(Z z, Zy... zy) {
return z *= exp(zy...);
}
};

/**
* @brief Arithmetic Basics Class based on Arithmetic operations
*/
class Basics {

public:
/**
* @brief Find greatest power of 2 itegers
*
* @param[in] n : integer 1
* @param[in] p : integer 2
*
* @return result : (int)
*/
int greatest_power(int n, int p);

/**
* @brief Find Greatest Common Divisor of 2 integers
*
* @param[in] x : integer 1
* @param[in] y : integer 2
*
* @return result : (int)
*/
int op_gcd(int x, int y);
};

} // namespace
Expand Down
48 changes: 48 additions & 0 deletions include/arithmetic/arith_ops.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* @file
* @author Akiel Aries
*
* Definitions for basic arithmetic operations
*/

#ifndef ARITH_OPS_HPP
#define ARITH_OPS_HPP
#include <vector>
#include <iostream>
#include <stdio.h>
#include <algorithm>


namespace mtpk {

/**
* @brief Arithmetic Basics Class based on Arithmetic operations
*/
class Basics {

public:
/**
* @brief Find greatest power of 2 itegers
*
* @param[in] n : integer 1
* @param[in] p : integer 2
*
* @return result : (int)
*/
int greatest_power(int n, int p);

/**
* @brief Find Greatest Common Divisor of 2 integers
*
* @param[in] x : integer 1
* @param[in] y : integer 2
*
* @return result : (int)
*/
int op_gcd(int x, int y);
};

} // namespace

#endif

2 changes: 1 addition & 1 deletion include/linalg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* @details Encompasses Vector and Scalar operations
*/
#define MATRIX
#include "linalg/vector.hpp"
#include "linalg/vectors.hpp"
/*****************************************************************************/

#endif
Expand Down
2 changes: 1 addition & 1 deletion include/ml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*/
#define CLASSIFICATION
#include "ml/bayes_clf.hpp"
#include "ml/nearest_neighbors.hpp"
#include "ml/nearest_neighbor.hpp"
// #include "ml/decision_tree"
// #include "ml/rand_forest"
// #include "ml/support_vector"
Expand Down
2 changes: 1 addition & 1 deletion include/ml/mlp_network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define MLP_NETWORK_HPP
#include <vector>
#include <stdio.h>
#include "../linalg/lao.hpp"
#include "../linalg.hpp"


namespace mtpk {
Expand Down
2 changes: 1 addition & 1 deletion modules/arithmetic/arith.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* stubbed out implementation file for arithmetic operations
*/
#include "../../include/arithmetic/arith.hpp"
#include "../../include/arithmetic/arith_ops.hpp"


int mtpk::Basics::greatest_power(int n, int p) {
Expand Down
3 changes: 2 additions & 1 deletion modules/linalg/lao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <fstream>
#include <stdio.h>
#include <vector>
#include "../../include/linalg/lao.hpp"
#include "../../include/linalg/vectors.hpp"
#include "../../include/linalg/matrix.hpp"


int mtpk::Vectors::add(int a, int b) {
Expand Down
3 changes: 2 additions & 1 deletion modules/number_theory/primes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <iostream>
#include <stdio.h>
#include "../../include/number_theory/primes.hpp"
#include "../../include/arithmetic/arith.hpp"
#include "../../include/arithmetic/arith_base.hpp"
#include "../../include/arithmetic/arith_ops.hpp"


// declare Basics and Primality class objects
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp/arithmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <stdio.h>
#include <vector>
#include <cassert>
#include <openMTPK/arith.hpp>
#include <openMTPK/arithmetic.hpp>


int main(){
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp/cipher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdio.h>
#include <string>
#include <vector>
#include <openMTPK/cipher.hpp>
#include <openMTPK/number_theory/cipher.hpp>


int main() {
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp/deriv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>
#include <vector>
#include <cassert>
#include <openMTPK/deriv.hpp>
#include <openMTPK/calculus/deriv.hpp>


int main() {
Expand Down
9 changes: 4 additions & 5 deletions samples/cpp/linalg_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include <stdio.h>
#include <vector>
#include <cassert>
#include <openMTPK/vectors.hpp>
#include <openMTPK/matrix.hpp>
#include <openMTPK/linalg.hpp>


int main() {
Expand All @@ -23,10 +22,10 @@ int main() {
std::cout << "Sum = " << x << std::endl;


auto MTX = mtx<float>::randn(2, 2);
MTX.print_mtx();
//auto MTX = mtx<float>::randn(2, 2);
//MTX.print_mtx();

(MTX-MTX).print_mtx();
//(MTX-MTX).print_mtx();



Expand Down
4 changes: 2 additions & 2 deletions samples/cpp/primes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*
*/
#include <iostream>
#include <openMTPK/primes.hpp>
#include <openMTPK/number_theory/primes.hpp>

int main() {
std::cout << "BASIC NUMBER THEORY OPERATIONS\n" << std::endl;
// declare primality class object
Primality p;
mtpk::Primality p;

std::cout << "<--------- IS IT PRIME? --------->\n";
int a = 9;
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp/rc4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>
#include <vector>
#include <time.h>
#include <openMTPK/rc4.hpp>
#include <openMTPK/number_theory/rc4.hpp>


int main() {
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp/reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
#include <iostream>
#include <stdio.h>
#include <openMTPK/linreg.hpp>
#include <openMTPK/ml/linreg.hpp>


int main() {
Expand Down
16 changes: 8 additions & 8 deletions tests/arith/t_arith.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Testing Arithmetic Operations
*/
#include "../../include/arithmetic/arith.hpp"
#include "../../include/arithmetic.hpp"
#include <limits.h>
#include <gtest/gtest.h>

Expand All @@ -11,7 +11,7 @@ using ::testing::DoubleLE;


namespace {
Arith ar;
mtpk::Arith ar;

// test case, test name
TEST(arith_test, add_positive) {
Expand All @@ -36,7 +36,7 @@ namespace {
}

namespace {
Basics ba;
mtpk::Basics ba;

// greatest power
TEST(basics, greatest_pow) {
Expand All @@ -46,11 +46,11 @@ namespace {

// greatest common divisor
TEST(basics, greatest_common_divisor) {
EXPECT_EQ(2, ba.rm_gcd(2, 4));
EXPECT_EQ(6, ba.rm_gcd(2198466, 96096));
EXPECT_EQ(11, ba.rm_gcd(66, 11));
EXPECT_EQ(8, ba.rm_gcd(232, 96));
EXPECT_EQ(10, ba.rm_gcd(1703210, 20320));
EXPECT_EQ(2, ba.op_gcd(2, 4));
EXPECT_EQ(6, ba.op_gcd(2198466, 96096));
EXPECT_EQ(11, ba.op_gcd(66, 11));
EXPECT_EQ(8, ba.op_gcd(232, 96));
EXPECT_EQ(10, ba.op_gcd(1703210, 20320));
}
}
/*
Expand Down
2 changes: 1 addition & 1 deletion tests/calc/t_calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using ::testing::DoubleLE;


namespace {
calculus calc;
mtpk::Calculus calc;

// Test Derivative Operations
TEST(deriv_test, deriv_at_val) {
Expand Down
2 changes: 1 addition & 1 deletion tests/linalg/t_linalg.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Testing Linear Algebra Operations
*/
#include "../../include/linalg/lao.hpp"
#include "../../include/linalg.hpp"
#include <string>
#include <limits.h>
#include <gtest/gtest.h>
Expand Down
2 changes: 1 addition & 1 deletion tests/number_theory/t_primes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace {
// declare primality class object
Primality p;
mtpk::Primality p;

TEST(prime_test, is_prime) {
int is_prime_0 = 2;
Expand Down

0 comments on commit 6232b29

Please sign in to comment.