diff --git a/.gitignore b/.gitignore index 51858600e..5dfa79291 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vscode/ -.DS_Store \ No newline at end of file +.DS_Store +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..d92bdd13c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.12) + +project("Boost.uBLAS.Test" + DESCRIPTION "Boost.uBLAS is part of the Boost C++ Libraries. It is directed towards scientific computing on the level of basic linear and multilinear algebra operations with tensors, matrices and vectors." + HOMEPAGE_URL "https://github.com/boostorg/ublas") + + +option(BUILD_EXAMPLES "Build the examples directory" ON) +option(BUILD_TENSOR_TEST "Build Tensor Unit Tests" ON) +option(BUILD_BENCHMARKS "Build Benchmarks Directory" ON) + +set(BOOST_HEADERS_DIR "" CACHE PATH "Directory of include files generated by b2 headers") + +if(BOOST_HEADERS_DIR STREQUAL "") + message(STATUS "No Boost Headers specified, Looking for System installed headers") + find_package(Boost COMPONENTS unit_test_framework REQUIRED) + set(BOOST_HEADERS_DIR ${Boost_INCLUDE_DIRS} CACHE PATH "System Boost Installation include Directory" FORCE) + message(STATUS "Using Boost headers at : ${BOOST_HEADERS_DIR}. Use -DBOOST_HEADER_DIR= to overwrite") +endif() + +set(UBLAS_HEADER_DIR ${CMAKE_SOURCE_DIR}/include) + +if(BUILD_EXAMPLES) + message(STATUS "Examples will be build. You will have to run them manually") + add_subdirectory(examples/tensor) +endif() + +if(BUILD_TENSOR_TEST) + message(STATUS "Tensor Unit Tests will be build. Use ctest to run the tests") + add_subdirectory(test/tensor) +endif() + +if(BUILD_BENCHMARKS) + message(STATUS "Benchmarks will be build. You will have to run them manually") + add_subdirectory(benchmarks) +endif() diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt new file mode 100644 index 000000000..6b024db35 --- /dev/null +++ b/benchmarks/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.12) + +project("Boost.uBLAS.Benchmark" + DESCRIPTION "Boost.uBLAS.Benchmark is part of the Boost C++ Libraries. It is directed towards benchmarking various operations within Boost.uBLAS" + HOMEPAGE_URL "https://github.com/boostorg/ublas") + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include_directories(SYSTEM ${BOOST_HEADERS_DIR}) +include_directories(${UBLAS_HEADER_DIR}) + +# If you decide to use any other Boost library that requires linkage +# you should add them to the list of components in the below line. +# To link call `link_libraries()`. This library will be linked to all targets. +# To link to specific target, use `target_link_libraries( )` after +# you have created the target with `add_executable( )` + +find_package(Boost COMPONENTS program_options REQUIRED) +link_libraries(${Boost_PROGRAM_OPTIONS_LIBRARY}) + +# Add new benchmarks here. + +add_executable(add add.cpp) +add_executable(mm_prod mm_prod.cpp) +add_executable(mv_prod mv_prod.cpp) +add_executable(inner_prod inner_prod.cpp) +add_executable(outer_prod outer_prod.cpp) + +# Add a reference to benchamark here. +add_executable(add_ref reference/add.cpp) +add_executable(mm_prod_ref reference/mm_prod.cpp) +add_executable(mv_prod_ref reference/mv_prod.cpp) +add_executable(inner_prod_ref reference/inner_prod.cpp) +add_executable(outer_prod_ref reference/outer_prod.cpp) + diff --git a/examples/tensor/CMakeLists.txt b/examples/tensor/CMakeLists.txt new file mode 100644 index 000000000..593105c5e --- /dev/null +++ b/examples/tensor/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.12) + +project("Boost.uBLAS.Examples" + DESCRIPTION "Boost.uBLAS.Examples is part of the Boost C++ Libraries. It is directed towards showing different use cases and examples to get started with various operations within Boost.uBLAS" + HOMEPAGE_URL "https://github.com/boostorg/ublas") + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include_directories(SYSTEM ${BOOST_HEADERS_DIR}) +include_directories(${UBLAS_HEADER_DIR}) + +# Add a new example here. Use spaces and respect my beautiful alignment. + +add_executable(construction_access construction_access.cpp) +add_executable(simple_expressions simple_expressions.cpp) +add_executable(dynamic_prod_expressions dynamic_prod_expressions.cpp) +add_executable(fixed_rank_prod_expressions fixed_rank_prod_expressions.cpp) +add_executable(static_prod_expressions static_prod_expressions.cpp) +add_executable(fixed_rank_tensor fixed_rank_tensor.cpp) +add_executable(static_tensor static_tensor.cpp) +add_executable(einstein_notation einstein_notation.cpp) +add_executable(tensor_construction tensor_construction.cpp) + diff --git a/test/tensor/CMakeLists.txt b/test/tensor/CMakeLists.txt new file mode 100644 index 000000000..f4ae141f4 --- /dev/null +++ b/test/tensor/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.12) + +project("Boost.uBLAS.TensorTest" + DESCRIPTION "Boost.uBLAS.TensorTest is part of the Boost C++ Libraries. It is directed towards testing Boost.uBLAS.Tensor various operations within Boost.uBLAS" + HOMEPAGE_URL "https://github.com/boostorg/ublas") + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include_directories(SYSTEM ${BOOST_HEADERS_DIR}) +include_directories(${UBLAS_HEADER_DIR}) + +add_executable( + test_tensor + test_tensor.cpp + test_strides.cpp + test_expression.cpp + test_operators_comparison.cpp + test_operators_arithmetic.cpp + test_multiplication.cpp + test_multi_index_utility.cpp + test_multi_index.cpp + test_extents.cpp + test_expression_evaluation.cpp + test_einstein_notation.cpp + test_algorithms.cpp + test_tensor_matrix_vector.cpp + test_functions.cpp) + +add_executable( + test_static_tensor + test_static_tensor.cpp + test_static_extents.cpp + test_static_strides.cpp + test_static_operators_arithmetic.cpp + test_static_operators_comparison.cpp + test_static_expression_evaluation.cpp + test_static_tensor_matrix_vector.cpp + test_static_functions.cpp) + +add_executable( + test_fixed_rank_tensor + test_fixed_rank_tensor.cpp + test_fixed_rank_extents.cpp + test_fixed_rank_strides.cpp + test_fixed_rank_operators_arithmetic.cpp + test_fixed_rank_operators_comparison.cpp + test_fixed_rank_expression_evaluation.cpp + test_fixed_rank_tensor_matrix_vector.cpp + test_fixed_rank_functions.cpp) + +find_package(Boost COMPONENTS unit_test_framework REQUIRED) + +target_link_libraries(test_tensor ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(test_static_tensor ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(test_fixed_rank_tensor ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + +enable_testing() + +add_test(NAME TensorTests COMMAND test_tensor) +add_test(NAME TensorFixedRank COMMAND test_fixed_rank_tensor) +add_test(NAME TensorStatic COMMAND test_static_tensor)