Commit 66c70fc8 authored by Chuanren Wu's avatar Chuanren Wu

Initial commit

parents
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Windows template
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
### C template
# Object files
*.o
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
### Vim template
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
### C++ template
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
project(GyroDevice)
cmake_minimum_required(VERSION 2.8)
#find_package(Boost COMPONENTS unit_test_framework)
#include_directories(SYSTEM ${Boost_INCLUDE_DIR})
set(BUILD_TEST ON)
find_package(GTest QUIET)
if (GTEST_FOUND)
enable_testing()
include_directories(${GTEST_INCLUDE_DIRS})
else ()
message("Module Google Test cannot be found\nTests are disabled")
set(BUILD_TEST OFF)
endif ()
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"
OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel"
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /W4 /EHsc")
endif()
add_library(bc STATIC
src/bc.h
src/bc.cc
)
# set_target_properties(geo PROPERTIES CXX_VISIBILITY_PRESET hidden)
if (BUILD_TEST)
enable_testing()
macro(TEST_REGISTER)
set(_test_name ${ARGV0})
string(TOLOWER "${_test_name}" _test_exec_tail)
set(_test_exec "test_${_test_exec_tail}")
list(APPEND unit_tests ${_test_exec})
set(_list_var "${ARGN}")
list(REMOVE_AT _list_var 0)
add_test(${_test_name} ${_test_exec})
add_executable(${_test_exec} ${_list_var})
target_compile_definitions(${_test_exec} PRIVATE
BOOST_TEST_DYN_LINK
BOOST_TEST_MODULE=${_test_name}
)
target_link_libraries(${_test_exec} ${GTEST_BOTH_LIBRARIES})
endmacro()
macro(TEST_LINK_LIBRARY)
set(_test_name ${ARGV0})
string(TOLOWER "${_test_name}" _test_exec_tail)
set(_test_exec "test_${_test_exec_tail}")
set(_list_var "${ARGN}")
list(REMOVE_AT _list_var 0)
target_link_libraries(${_test_exec} ${_list_var})
endmacro()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS ${unit_tests})
################## Coverage ###################
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo Coverage CACHE TYPE INTERNAL FORCE )
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
find_program(GCOV gcov)
find_program(LCOV lcov)
find_program(GENHTML genhtml)
add_custom_target(coverage
COMMAND ${LCOV} -z -d .
COMMAND ${CMAKE_CTEST_COMMAND}
COMMAND ${LCOV} -d . -c -o coverage_all.txt
COMMAND ${LCOV} -r coverage_all.txt 'test/*' '/usr/*' -o coverage_src.txt
COMMAND ${GENHTML} --demangle-cpp -o coverage_report coverage_src.txt
COMMAND ${CMAKE_COMMAND} -E remove coverage_all.txt coverage_src.txt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS ${unit_tests}
)
endif()
endif(BUILD_TEST)
#################### tests ####################
if (BUILD_TEST)
TEST_REGISTER(TestBC test/test-bc.cc)
TEST_LINK_LIBRARY(TestBC bc)
endif(BUILD_TEST)
Ariadne Boundary Constraints
========
#include "bc.h"
#include <set>
#include <map>
#include <vector>
#include <cassert>
#include <algorithm>
inline int clamp1(int x)
{
return x > 0 ? x : 1;
}
struct ConstraintExt
{
ConstraintExt() = default;
ConstraintExt(const ConstraintExt &c) = default;
ConstraintExt(ConstraintExt &&c) = default;
ConstraintExt(const Constraint &c)
: plus(c.plus()), minus(c.minus()), extra(0) {}
ConstraintExt &operator=(const Constraint &c);
ConstraintExt &operator=(const ConstraintExt &c) = default;
ConstraintExt &operator=(ConstraintExt &&c) = default;
std::set<int> plus;
std::set<int> minus;
int extra;
};
ConstraintExt &ConstraintExt::operator=(const Constraint &c)
{
ConstraintExt e(c);
std::swap(*this, e);
return *this;
}
std::vector<int> discretizeImpl(
double sl,
const std::vector<double> &vl,
const std::vector<Constraint> &vc
)
{
assert(!vl.empty());
std::vector<int> res(vl.size());
std::fill(res.begin(), res.end(), -1989);
std::map<int, double> lm;
for (int i = 0; i < static_cast<int>(lm.size()); ++i) {
lm[i] = vl[i];
}
std::vector<ConstraintExt> ve(vc.size());
std::copy(vc.begin(), vc.end(), ve.begin());
// TODO
}
#include <set>
#include <vector>
class Constraint
{
public:
void plus(int i) { plus_.insert(i); }
void minus(int i) { minus_.insert(i); }
std::set<int> const &plus() const { return plus_; }
std::set<int> const &minus() const { return minus_; }
private:
std::set<int> plus_;
std::set<int> minus_;
};
#define RELAX_FACTOR 0.1
std::vector<int> discretizeImpl(
double,
const std::vector<double> &,
const std::vector<Constraint> &
);
#include <gtest/gtest.h>
TEST(BC, Base)
{
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment