Skip to content

Commit

Permalink
[capd] minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
godardma committed Jan 7, 2025
1 parent 80fbd84 commit fc79237
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 122 deletions.
2 changes: 0 additions & 2 deletions examples/05_capd_solver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ int main()
DefaultView::set_axes(axis(0,{-2,1.5}),axis(1,{-2,3}));

for (float t=0.;t<20.;t+=0.05)
{
DefaultView::draw_box(to_codac(solution(t)));
}

DefaultView::draw_box(to_codac(c),Color::green());
DefaultView::draw_box(to_codac(result),Color::red());
Expand Down
8 changes: 0 additions & 8 deletions include/codac-capd.h

This file was deleted.

8 changes: 0 additions & 8 deletions include/codac2-capd.h

This file was deleted.

75 changes: 0 additions & 75 deletions include/codac2_capd.h

This file was deleted.

3 changes: 0 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
set(CODAC_CXX_FLAGS \"\")
")


#if(WITH_PYTHON)
#
# file(APPEND ${CODAC_CMAKE_CONFIG_FILE} "
Expand All @@ -94,7 +93,6 @@
#
#endif()


if(WITH_CAPD)

file(APPEND ${CODAC_CMAKE_CONFIG_FILE} "
Expand All @@ -114,7 +112,6 @@

endif()


install(FILES ${CODAC_CMAKE_CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_CMAKE})


Expand Down
18 changes: 4 additions & 14 deletions src/capd/codac2_capd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ namespace codac2
{
capd::Interval to_capd(const Interval &x)
{
capd::Interval y(x.lb(), x.ub());
return y;
return {x.lb(), x.ub()};
}

Interval to_codac(const capd::Interval &x)
{
Interval y(x.leftBound(), x.rightBound());
return y;
return {x.leftBound(), x.rightBound()};
}

capd::IVector to_capd(const IntervalVector &x)
Expand All @@ -51,26 +49,18 @@ namespace codac2
capd::IMatrix to_capd(const IntervalMatrix &x)
{
capd::IMatrix y(x.rows(), x.cols());
for (Index i = 0; i < (Index)x.rows(); i++)
{
for (Index j = 0; j < (Index)x.cols(); j++)
{
for (Index i = 0; i < x.rows(); i++)
for (Index j = 0; j < x.cols(); j++)
y[i][j] = to_capd(x(i, j));
}
}
return y;
}

IntervalMatrix to_codac(const capd::IMatrix &x)
{
IntervalMatrix y(x.numberOfRows(), x.numberOfColumns());
for (Index i = 0; i < (Index)x.numberOfRows(); i++)
{
for (Index j = 0; j < (Index)x.numberOfColumns(); j++)
{
y(i, j) = to_codac(x[i][j]);
}
}
return y;
}

Expand Down
24 changes: 12 additions & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ list(APPEND SRC_TESTS # listing files without extension
graphics/styles/codac2_tests_Color
)

set(CODAC_LIBRARIES ${PROJECT_NAME}-core)

# CAPD test
if (WITH_CAPD)
list(APPEND SRC_TESTS
capd/codac2_tests_capd
)
set(CODAC_LIBRARIES ${CODAC_LIBRARIES} ${PROJECT_NAME}-capd capd::capd)
endif()

foreach(SRC_TEST ${SRC_TESTS})
string(REPLACE "/" "_" TEST_NAME ${SRC_TEST})
string(REPLACE "codac2_tests_" "" TEST_NAME ${TEST_NAME})
Expand All @@ -93,7 +103,7 @@ foreach(SRC_TEST ${SRC_TESTS})
add_executable(${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_TEST}.cpp)
set(CODAC_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/../include)
target_include_directories(${TEST_NAME} SYSTEM PUBLIC ${CODAC_HEADERS_DIR})
target_link_libraries(${TEST_NAME} PUBLIC Ibex::ibex ${PROJECT_NAME}-core PRIVATE Catch2::Catch2WithMain)
target_link_libraries(${TEST_NAME} PUBLIC Ibex::ibex ${CODAC_LIBRARIES} PRIVATE Catch2::Catch2WithMain)
add_dependencies(check ${TEST_NAME})
add_test(NAME ${TEST_NAME}_cpp COMMAND ${TEST_NAME})

Expand All @@ -102,14 +112,4 @@ foreach(SRC_TEST ${SRC_TESTS})
add_test(NAME ${TEST_NAME}_py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_TEST}.py)
endif()

endforeach()

# CAPD test
if (WITH_CAPD)
add_executable(capd_tests capd/codac2_tests_capd.cpp)
set(CODAC_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/../include)
target_include_directories(capd_tests SYSTEM PUBLIC ${CODAC_HEADERS_DIR})
target_link_libraries(capd_tests PUBLIC Ibex::ibex capd::capd ${PROJECT_NAME}-core ${PROJECT_NAME}-capd PRIVATE Catch2::Catch2WithMain)
add_dependencies(check capd_tests)
add_test(NAME capd_tests_cpp COMMAND capd_tests)
endif()
endforeach()
19 changes: 19 additions & 0 deletions tests/capd/codac2_tests_capd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python

# Codac tests
# ----------------------------------------------------------------------------
# \date 2024
# \author Maël Godard
# \copyright Copyright 2024 Codac Team
# \license GNU Lesser General Public License (LGPL)

import unittest
from codac import *

class TestCAPD(unittest.TestCase):

def tests_capd(self):
self.assertTrue(True)

if __name__ == '__main__':
unittest.main()

0 comments on commit fc79237

Please sign in to comment.