From 1d9d32cfd46e7c33ad54d29abbc16f70ba204e77 Mon Sep 17 00:00:00 2001 From: dnave Date: Thu, 12 Jul 2018 01:54:29 -0400 Subject: [PATCH] Implemented writable_vector::fill() and writable_matrix::fill() convenience functions. - Bumped CML to version 2.1.2. - Added CMake commands to create a project folder structure containing the CML headers. This is currently tested with Visual Studio 2013+. Closes #16 --- CML.cmake | 399 +++++++++++++++++++++ CMake/CMLTestMacros.cmake | 8 +- CMakeLists.txt | 4 +- cml/matrix/writable_matrix.h | 8 + cml/matrix/writable_matrix.tpp | 17 +- cml/vector/writable_vector.h | 8 + cml/vector/writable_vector.tpp | 16 + cml/version.h | 4 +- ignore-me.cpp | 0 tests/main/CMakeLists.txt | 3 +- tests/matrix/dynamic_allocated_matrix1.cpp | 10 + tests/matrix/dynamic_external_matrix1.cpp | 11 + tests/matrix/fixed_compiled_matrix1.cpp | 10 + tests/matrix/fixed_external_matrix1.cpp | 11 + tests/vector/dynamic_allocated_vector1.cpp | 9 + tests/vector/dynamic_external_vector1.cpp | 9 + tests/vector/fixed_compiled_vector1.cpp | 8 + tests/vector/fixed_external_vector1.cpp | 9 + 18 files changed, 532 insertions(+), 12 deletions(-) create mode 100644 CML.cmake create mode 100644 ignore-me.cpp diff --git a/CML.cmake b/CML.cmake new file mode 100644 index 0000000..4f17cec --- /dev/null +++ b/CML.cmake @@ -0,0 +1,399 @@ +# -*- cmake -*- ----------------------------------------------------------- +# @@COPYRIGHT@@ +#*------------------------------------------------------------------------- + +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") + set(_header_group "Header Files\\") +else() + set(_header_group) +endif() + +set(main_HEADERS + cml/cml.h + cml/matrix.h + cml/quaternion.h + cml/types.h + cml/util.h + cml/vector.h + cml/version.h + ) +source_group("${_header_group}" FILES ${main_HEADERS}) + +set(common_HEADERS + cml/common/array_size_of.h + cml/common/basis_tags.h + cml/common/compiler.h + cml/common/exception.h + cml/common/layout_tags.h + cml/common/memory_tags.h + cml/common/promotion.h + cml/common/size_tags.h + cml/common/storage_tags.h + cml/common/temporary.h + cml/common/traits.h + cml/common/type_util.h + ) +source_group("${_header_group}common" FILES ${common_HEADERS}) + +set(common_mpl_HEADERS + cml/common/mpl/are_convertible.h + cml/common/mpl/are_same.h + cml/common/mpl/enable_if_arithmetic.h + cml/common/mpl/enable_if_array.h + cml/common/mpl/enable_if_convertible.h + cml/common/mpl/enable_if_pointer.h + cml/common/mpl/enable_if_reshapeable.h + cml/common/mpl/enable_if_same.h + cml/common/mpl/enable_if_t.h + cml/common/mpl/if_t.h + cml/common/mpl/int_c.h + cml/common/mpl/is_reshapeable.h + cml/common/mpl/is_same_pair.h + cml/common/mpl/is_statically_polymorphic.h + cml/common/mpl/item_at.h + cml/common/mpl/plus_c.h + cml/common/mpl/rebind.h + cml/common/mpl/type_map.h + cml/common/mpl/type_table.h + ) +source_group("${_header_group}common\\mpl" FILES ${common_mpl_HEADERS}) + +set(scalar_HEADERS + cml/scalar/binary_ops.h + cml/scalar/constants.h + cml/scalar/functions.h + cml/scalar/promotion.h + cml/scalar/traits.h + cml/scalar/unary_ops.h + ) +source_group("${_header_group}scalar" FILES ${scalar_HEADERS}) + +set(storage_HEADERS + cml/storage/allocated_selector.h + cml/storage/any_selector.h + cml/storage/compiled_selector.h + cml/storage/external_selector.h + cml/storage/promotion.h + cml/storage/resize.h + cml/storage/selectors.h + cml/storage/type_util.h + ) +source_group("${_header_group}storage" FILES ${storage_HEADERS}) + +set(vector_HEADERS + cml/vector/binary_node.h + cml/vector/binary_node.tpp + cml/vector/binary_ops.h + cml/vector/comparison.h + cml/vector/comparison.tpp + cml/vector/cross.h + cml/vector/cross_node.h + cml/vector/cross_node.tpp + cml/vector/cross_ops.h + cml/vector/dot.h + cml/vector/dot.tpp + cml/vector/dynamic.h + cml/vector/dynamic_allocated.h + cml/vector/dynamic_allocated.tpp + cml/vector/dynamic_const_external.h + cml/vector/dynamic_const_external.tpp + cml/vector/dynamic_external.h + cml/vector/dynamic_external.tpp + cml/vector/external.h + cml/vector/fixed.h + cml/vector/fixed_compiled.h + cml/vector/fixed_compiled.tpp + cml/vector/fixed_const_external.h + cml/vector/fixed_const_external.tpp + cml/vector/fixed_external.h + cml/vector/fixed_external.tpp + cml/vector/functions.h + cml/vector/functions.tpp + cml/vector/fwd.h + cml/vector/hadamard_product.h + cml/vector/ops.h + cml/vector/outer_product.h + cml/vector/outer_product_node.h + cml/vector/outer_product_node.tpp + cml/vector/outer_product_ops.h + cml/vector/perp_dot.h + cml/vector/perp_dot.tpp + cml/vector/products.h + cml/vector/promotion.h + cml/vector/readable_vector.h + cml/vector/readable_vector.tpp + cml/vector/scalar_node.h + cml/vector/scalar_node.tpp + cml/vector/scalar_ops.h + cml/vector/size_checking.h + cml/vector/size_checking.tpp + cml/vector/subvector.h + cml/vector/subvector_node.h + cml/vector/subvector_node.tpp + cml/vector/subvector_ops.h + cml/vector/subvector_ops.tpp + cml/vector/temporary.h + cml/vector/traits.h + cml/vector/triple_product.h + cml/vector/triple_product.tpp + cml/vector/types.h + cml/vector/type_util.h + cml/vector/unary_node.h + cml/vector/unary_node.tpp + cml/vector/unary_ops.h + cml/vector/vector.h + cml/vector/writable_vector.h + cml/vector/writable_vector.tpp + ) +source_group("${_header_group}vector" FILES ${vector_HEADERS}) + +set(vector_detail_HEADERS + cml/vector/detail/check_or_resize.h + cml/vector/detail/combined_size_of.h + cml/vector/detail/resize.h + ) +source_group("${_header_group}vector\\detail" FILES ${vector_detail_HEADERS}) + +set(matrix_HEADERS + cml/matrix/array_size_of.h + cml/matrix/basis.h + cml/matrix/basis_node.h + cml/matrix/basis_node.tpp + cml/matrix/basis_ops.h + cml/matrix/binary_node.h + cml/matrix/binary_node.tpp + cml/matrix/binary_ops.h + cml/matrix/col_node.h + cml/matrix/col_node.tpp + cml/matrix/col_ops.h + cml/matrix/comparison.h + cml/matrix/comparison.tpp + cml/matrix/determinant.h + cml/matrix/determinant.tpp + cml/matrix/dynamic.h + cml/matrix/dynamic_allocated.h + cml/matrix/dynamic_allocated.tpp + cml/matrix/dynamic_external.h + cml/matrix/dynamic_external.tpp + cml/matrix/external.h + cml/matrix/fixed.h + cml/matrix/fixed_compiled.h + cml/matrix/fixed_compiled.tpp + cml/matrix/fixed_external.h + cml/matrix/fixed_external.tpp + cml/matrix/functions.h + cml/matrix/fwd.h + cml/matrix/hadamard_product.h + cml/matrix/inverse.h + cml/matrix/lu.h + cml/matrix/lu.tpp + cml/matrix/matrix.h + cml/matrix/matrix_product.h + cml/matrix/matrix_product.tpp + cml/matrix/ops.h + cml/matrix/promotion.h + cml/matrix/readable_matrix.h + cml/matrix/readable_matrix.tpp + cml/matrix/row_col.h + cml/matrix/row_node.h + cml/matrix/row_node.tpp + cml/matrix/row_ops.h + cml/matrix/scalar_node.h + cml/matrix/scalar_node.tpp + cml/matrix/scalar_ops.h + cml/matrix/size_checking.h + cml/matrix/size_checking.tpp + cml/matrix/temporary.h + cml/matrix/trace.h + cml/matrix/trace.tpp + cml/matrix/traits.h + cml/matrix/transpose.h + cml/matrix/transpose_node.h + cml/matrix/transpose_node.tpp + cml/matrix/transpose_ops.h + cml/matrix/types.h + cml/matrix/type_util.h + cml/matrix/unary_node.h + cml/matrix/unary_node.tpp + cml/matrix/unary_ops.h + cml/matrix/vector_product.h + cml/matrix/vector_product.tpp + cml/matrix/writable_matrix.h + cml/matrix/writable_matrix.tpp + ) +source_group("${_header_group}matrix" FILES ${matrix_HEADERS}) + +set(matrix_detail_HEADERS + cml/matrix/detail/apply.h + cml/matrix/detail/check_or_resize.h + cml/matrix/detail/copy.h + cml/matrix/detail/determinant.h + cml/matrix/detail/determinant.tpp + cml/matrix/detail/generate.h + cml/matrix/detail/get.h + cml/matrix/detail/inverse.h + cml/matrix/detail/lu.h + cml/matrix/detail/lu.tpp + cml/matrix/detail/resize.h + cml/matrix/detail/transpose.h + ) +source_group("${_header_group}matrix\\detail" FILES ${matrix_detail_HEADERS}) + +set(quaternion_HEADERS + cml/quaternion/binary_node.h + cml/quaternion/binary_node.tpp + cml/quaternion/binary_ops.h + cml/quaternion/comparison.h + cml/quaternion/comparison.tpp + cml/quaternion/conjugate.h + cml/quaternion/conjugate_node.h + cml/quaternion/conjugate_node.tpp + cml/quaternion/conjugate_ops.h + cml/quaternion/conjugate_ops.tpp + cml/quaternion/cross_tags.h + cml/quaternion/dot.h + cml/quaternion/dot.tpp + cml/quaternion/fixed.h + cml/quaternion/fixed_compiled.h + cml/quaternion/fixed_compiled.tpp + cml/quaternion/functions.h + cml/quaternion/functions.tpp + cml/quaternion/fwd.h + cml/quaternion/imaginary.h + cml/quaternion/imaginary_node.h + cml/quaternion/imaginary_node.tpp + cml/quaternion/imaginary_ops.h + cml/quaternion/imaginary_ops.tpp + cml/quaternion/inverse.h + cml/quaternion/inverse_node.h + cml/quaternion/inverse_node.tpp + cml/quaternion/inverse_ops.h + cml/quaternion/inverse_ops.tpp + cml/quaternion/ops.h + cml/quaternion/order_tags.h + cml/quaternion/product.h + cml/quaternion/product.tpp + cml/quaternion/promotion.h + cml/quaternion/quaternion.h + cml/quaternion/readable_quaternion.h + cml/quaternion/readable_quaternion.tpp + cml/quaternion/scalar_node.h + cml/quaternion/scalar_node.tpp + cml/quaternion/scalar_ops.h + cml/quaternion/size_checking.h + cml/quaternion/temporary.h + cml/quaternion/traits.h + cml/quaternion/types.h + cml/quaternion/type_util.h + cml/quaternion/unary_node.h + cml/quaternion/unary_node.tpp + cml/quaternion/unary_ops.h + cml/quaternion/writable_quaternion.h + cml/quaternion/writable_quaternion.tpp + ) +source_group("${_header_group}quaternion" FILES ${quaternion_HEADERS}) + +set(mathlib_HEADERS + cml/mathlib/axis_order.h + cml/mathlib/constants.h + cml/mathlib/coordinate_conversion.h + cml/mathlib/coordinate_conversion.tpp + cml/mathlib/euler_order.h + cml/mathlib/frustum.h + cml/mathlib/frustum.tpp + cml/mathlib/mathlib.h + cml/mathlib/random_unit.h + cml/mathlib/random_unit.tpp + ) +source_group("${_header_group}mathlib" FILES ${mathlib_HEADERS}) + +set(mathlib_vector_HEADERS + cml/mathlib/vector/angle.h + cml/mathlib/vector/angle.tpp + cml/mathlib/vector/generators.h + cml/mathlib/vector/misc.h + cml/mathlib/vector/misc.tpp + cml/mathlib/vector/orthonormal.h + cml/mathlib/vector/orthonormal.tpp + cml/mathlib/vector/products.h + cml/mathlib/vector/rotation.h + cml/mathlib/vector/rotation.tpp + cml/mathlib/vector/transform.h + cml/mathlib/vector/transform.tpp + ) +source_group("${_header_group}mathlib\\vector" FILES ${mathlib_vector_HEADERS}) + +set(mathlib_matrix_HEADERS + cml/mathlib/matrix/basis.h + cml/mathlib/matrix/basis.tpp + cml/mathlib/matrix/concat.h + cml/mathlib/matrix/concat.tpp + cml/mathlib/matrix/generators.h + cml/mathlib/matrix/invert.h + cml/mathlib/matrix/invert.tpp + cml/mathlib/matrix/misc.h + cml/mathlib/matrix/misc.tpp + cml/mathlib/matrix/projection.h + cml/mathlib/matrix/projection.tpp + cml/mathlib/matrix/rotation.h + cml/mathlib/matrix/rotation.tpp + cml/mathlib/matrix/scale.h + cml/mathlib/matrix/scale.tpp + cml/mathlib/matrix/size_checking.h + cml/mathlib/matrix/size_checking.tpp + cml/mathlib/matrix/temporary.h + cml/mathlib/matrix/transform.h + cml/mathlib/matrix/transform.tpp + cml/mathlib/matrix/translation.h + cml/mathlib/matrix/translation.tpp + ) +source_group("${_header_group}mathlib\\matrix" FILES ${mathlib_matrix_HEADERS}) + +set(mathlib_quaternion_HEADERS + cml/mathlib/quaternion/basis.h + cml/mathlib/quaternion/basis.tpp + cml/mathlib/quaternion/rotation.h + cml/mathlib/quaternion/rotation.tpp + ) +source_group("${_header_group}mathlib\\quaternion" + FILES ${mathlib_quaternion_HEADERS}) + +set(util_HEADERS + cml/util/matrix_print.h + cml/util/matrix_print.tpp + cml/util/quaternion_print.h + cml/util/quaternion_print.tpp + cml/util/vector_hash.h + cml/util/vector_print.h + cml/util/vector_print.tpp + ) +source_group("${_header_group}\\util" FILES ${util_HEADERS}) + +set(all_headers + ${main_HEADERS} + ${common_HEADERS} + ${common_mpl_HEADERS} + ${scalar_HEADERS} + ${storage_HEADERS} + ${matrix_HEADERS} + ${matrix_detail_HEADERS} + ${quaternion_HEADERS} + ${util_HEADERS} + ${vector_HEADERS} + ${vector_detail_HEADERS} + ${mathlib_HEADERS} + ${mathlib_vector_HEADERS} + ${mathlib_matrix_HEADERS} + ${mathlib_quaternion_HEADERS} + ) + +add_library(cml STATIC ${all_headers} ignore-me.cpp) +target_include_directories(cml + PUBLIC $ + ) + +source_group("_" FILES ignore-me.cpp) +set_target_properties(cml PROPERTIES EXCLUDE_FROM_ALL TRUE) + +# -------------------------------------------------------------------------- +# vim:ft=cmake diff --git a/CMake/CMLTestMacros.cmake b/CMake/CMLTestMacros.cmake index e1e118d..cba1a63 100644 --- a/CMake/CMLTestMacros.cmake +++ b/CMake/CMLTestMacros.cmake @@ -10,11 +10,11 @@ macro(CML_ADD_TEST ) # Define the executable name: - set(ExecName "${_Name}_test") + set(ExecName "${_Name}") # Define the test name: if(DEFINED CML_CURRENT_TEST_GROUP) - set(TestName "CML:${CML_CURRENT_TEST_GROUP}:${_Name}_test") + set(TestName "CML:${CML_CURRENT_TEST_GROUP}:${_Name}") else() message(FATAL_ERROR "CML_CURRENT_TEST_GROUP must be defined") endif() @@ -22,8 +22,8 @@ macro(CML_ADD_TEST # Setup the build target: add_executable(${ExecName} ${_Name}.cpp) set_target_properties(${ExecName} PROPERTIES - FOLDER "CML-Projects/CML-Tests/${CML_CURRENT_TEST_GROUP}") - target_link_libraries(${ExecName} cml_test_main) + FOLDER "CML-Tests/${CML_CURRENT_TEST_GROUP}") + target_link_libraries(${ExecName} cml cml_test_main) # Setup the test: add_test(NAME ${TestName} COMMAND ${ExecName}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8675939..387aecb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,9 +123,6 @@ option(CML_BUILD_TESTING "Build CML tests" OFF) ## PATH CONFIGURATION ## -# Include directories: -include_directories(${CML_ROOT}) - # Output paths: set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CML_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CML_BINARY_DIR}/lib) @@ -133,6 +130,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CML_BINARY_DIR}/lib) ## Build subdirectories: +include(CML.cmake) # Build tests if requested: if(CML_BUILD_TESTING) diff --git a/cml/matrix/writable_matrix.h b/cml/matrix/writable_matrix.h index 8678f92..54442e3 100644 --- a/cml/matrix/writable_matrix.h +++ b/cml/matrix/writable_matrix.h @@ -163,6 +163,14 @@ class writable_matrix DerivedT&& random(const_reference low, const_reference high) &&; #endif + /** Set all elements to a specific value. */ + DerivedT& fill(const_reference v) __CML_REF; + +#ifdef CML_HAS_RVALUE_REFERENCE_FROM_THIS + /** Set all elements of a temporary to a specific value. */ + DerivedT&& fill(const_reference v) &&; +#endif + /** Set the matrix to its inverse. * * @throws non_square_matrix_error at run-time if the matrix is diff --git a/cml/matrix/writable_matrix.tpp b/cml/matrix/writable_matrix.tpp index a657d29..4afcf92 100644 --- a/cml/matrix/writable_matrix.tpp +++ b/cml/matrix/writable_matrix.tpp @@ -176,7 +176,6 @@ writable_matrix
::identity() && } #endif - template DT& writable_matrix
::random( const_reference low, const_reference high @@ -203,6 +202,22 @@ writable_matrix
::random(const_reference low, const_reference high) && } #endif +template DT& +writable_matrix
::fill(const_reference v) __CML_REF +{ + detail::generate(*this, [&v](int,int) { return v; }, layout_tag()); + return this->actual(); +} + +#ifdef CML_HAS_RVALUE_REFERENCE_FROM_THIS +template DT&& +writable_matrix
::fill(const_reference v) && +{ + this->fill(v); + return (DT&&) *this; +} +#endif + template DT& writable_matrix
::inverse() __CML_REF { diff --git a/cml/vector/writable_vector.h b/cml/vector/writable_vector.h index 4f91a4b..e93df9f 100644 --- a/cml/vector/writable_vector.h +++ b/cml/vector/writable_vector.h @@ -172,6 +172,14 @@ class writable_vector DerivedT&& random(const_reference low, const_reference high) &&; #endif + /** Set all elements to a specific value. */ + DerivedT& fill(const_reference v) __CML_REF; + +#ifdef CML_HAS_RVALUE_REFERENCE_FROM_THIS + /** Set all elements of a temporary to a specific value. */ + DerivedT&& fill(const_reference v) &&; +#endif + public: diff --git a/cml/vector/writable_vector.tpp b/cml/vector/writable_vector.tpp index d16e6b8..f648011 100644 --- a/cml/vector/writable_vector.tpp +++ b/cml/vector/writable_vector.tpp @@ -210,6 +210,22 @@ writable_vector
::random(const_reference low, const_reference high) && } #endif +template DT& +writable_vector
::fill(const_reference v) __CML_REF +{ + for(int i = 0; i < this->size(); ++ i) this->put(i, v); + return this->actual(); +} + +#ifdef CML_HAS_RVALUE_REFERENCE_FROM_THIS +template DT&& +writable_vector
::fill(const_reference v) && +{ + this->fill(v); + return (DT&&) *this; +} +#endif + template template auto writable_vector
::set(const E0& e0, const Es&... eN) __CML_REF -> enable_if_t::value, DT&> diff --git a/cml/version.h b/cml/version.h index 6c6aea5..3d4cdf9 100644 --- a/cml/version.h +++ b/cml/version.h @@ -10,10 +10,10 @@ #define cml_version_h /* Current CML version: */ -#define CML_VERSION 200101U +#define CML_VERSION 200102U /* Current CML version as a string: */ -#define CML_VERSION_STRING "2.1.1" +#define CML_VERSION_STRING "2.1.2" #endif diff --git a/ignore-me.cpp b/ignore-me.cpp new file mode 100644 index 0000000..e69de29 diff --git a/tests/main/CMakeLists.txt b/tests/main/CMakeLists.txt index 07579c7..7582173 100644 --- a/tests/main/CMakeLists.txt +++ b/tests/main/CMakeLists.txt @@ -9,8 +9,7 @@ target_include_directories(cml_test_main PUBLIC ${CMAKE_CURRENT_LIST_DIR} PRIVATE ${CML_ROOT} ) -set_target_properties(cml_test_main - PROPERTIES FOLDER "CML-Projects/CML-Tests/TestMain") +set_target_properties(cml_test_main PROPERTIES FOLDER "CML-Tests") # -------------------------------------------------------------------------- # vim:ft=cmake diff --git a/tests/matrix/dynamic_allocated_matrix1.cpp b/tests/matrix/dynamic_allocated_matrix1.cpp index 531aafd..e1f326b 100644 --- a/tests/matrix/dynamic_allocated_matrix1.cpp +++ b/tests/matrix/dynamic_allocated_matrix1.cpp @@ -360,6 +360,16 @@ CATCH_TEST_CASE("list_assign2") CATCH_CHECK(M(2,3) == 0.); } +CATCH_TEST_CASE("fill1") +{ + cml::matrixd M(5,5); + M.fill(1.); + CATCH_REQUIRE(M.rows() == 5); + CATCH_REQUIRE(M.cols() == 5); + CATCH_CHECK(M.data()[0] == 1.); + CATCH_CHECK(M(4,4) == 1.); +} + CATCH_TEST_CASE("size_check1") { cml::matrixd M(3,4); diff --git a/tests/matrix/dynamic_external_matrix1.cpp b/tests/matrix/dynamic_external_matrix1.cpp index 82d15e7..9c841ed 100644 --- a/tests/matrix/dynamic_external_matrix1.cpp +++ b/tests/matrix/dynamic_external_matrix1.cpp @@ -244,6 +244,17 @@ CATCH_TEST_CASE("list_assign2") CATCH_CHECK(M(2,3) == 0.); } +CATCH_TEST_CASE("fill1") +{ + double data[5*5]; + cml::externalmnd_c M(data, 5,5); + M.fill(1.); + CATCH_REQUIRE(M.rows() == 5); + CATCH_REQUIRE(M.cols() == 5); + CATCH_CHECK(M.data()[0] == 1.); + CATCH_CHECK(M(4,4) == 1.); +} + CATCH_TEST_CASE("resize1") { double data[3*4]; diff --git a/tests/matrix/fixed_compiled_matrix1.cpp b/tests/matrix/fixed_compiled_matrix1.cpp index 41ff1a8..086609f 100644 --- a/tests/matrix/fixed_compiled_matrix1.cpp +++ b/tests/matrix/fixed_compiled_matrix1.cpp @@ -434,6 +434,16 @@ CATCH_TEST_CASE("list_assign2") CATCH_CHECK(M(2,3) == 0.); } +CATCH_TEST_CASE("fill1") +{ + cml::matrix34d_c M; + M.fill(1.); + CATCH_REQUIRE(M.rows() == 3); + CATCH_REQUIRE(M.cols() == 4); + CATCH_CHECK(M.data()[0] == 1.); + CATCH_CHECK(M(2,3) == 1.); +} + CATCH_TEST_CASE("size_check1") { cml::matrix34d M; diff --git a/tests/matrix/fixed_external_matrix1.cpp b/tests/matrix/fixed_external_matrix1.cpp index 49f4d1d..84c61bc 100644 --- a/tests/matrix/fixed_external_matrix1.cpp +++ b/tests/matrix/fixed_external_matrix1.cpp @@ -244,6 +244,17 @@ CATCH_TEST_CASE("list_assign2") CATCH_CHECK(M(2,3) == 0.); } +CATCH_TEST_CASE("fill1") +{ + double data[3*4]; + cml::external34d_c M(data); + M.fill(1.); + CATCH_REQUIRE(M.rows() == 3); + CATCH_REQUIRE(M.cols() == 4); + CATCH_CHECK(M.data()[0] == 1.); + CATCH_CHECK(M(2,3) == 1.); +} + CATCH_TEST_CASE("size_check1") { double data[3*4]; diff --git a/tests/vector/dynamic_allocated_vector1.cpp b/tests/vector/dynamic_allocated_vector1.cpp index 4be8a7f..7f2db03 100644 --- a/tests/vector/dynamic_allocated_vector1.cpp +++ b/tests/vector/dynamic_allocated_vector1.cpp @@ -164,6 +164,15 @@ CATCH_TEST_CASE("list_temp_construct") CATCH_CHECK(v[0] == 1.); } +CATCH_TEST_CASE("fill1") +{ + cml::vectord v(5); + v.fill(1.); + CATCH_REQUIRE(v.size() == 5); + CATCH_CHECK(v.data()[0] == 1.); + CATCH_CHECK(v[4] == 1.); +} + CATCH_TEST_CASE("write1") { cml::vectord v(3); diff --git a/tests/vector/dynamic_external_vector1.cpp b/tests/vector/dynamic_external_vector1.cpp index 0b19143..5523597 100644 --- a/tests/vector/dynamic_external_vector1.cpp +++ b/tests/vector/dynamic_external_vector1.cpp @@ -42,6 +42,15 @@ CATCH_TEST_CASE("list_assign") CATCH_CHECK(v[0] == 1.); } +CATCH_TEST_CASE("fill1") { + double av[5]; + cml::externalnd v(av, 5); + v.fill(1.); + CATCH_REQUIRE(v.size() == 5); + CATCH_CHECK(v.data()[0] == 1.); + CATCH_CHECK(v[4] == 1.); +} + CATCH_TEST_CASE("write1") { double data[] = { 1., 2., 3. }; diff --git a/tests/vector/fixed_compiled_vector1.cpp b/tests/vector/fixed_compiled_vector1.cpp index 8093362..f54b6e8 100644 --- a/tests/vector/fixed_compiled_vector1.cpp +++ b/tests/vector/fixed_compiled_vector1.cpp @@ -172,6 +172,14 @@ CATCH_TEST_CASE("list_assign") CATCH_CHECK(v[0] == 1.); } +CATCH_TEST_CASE("fill1") { + cml::vector3d v; + v.fill(1.); + CATCH_REQUIRE(v.size() == 3); + CATCH_CHECK(v.data()[0] == 1.); + CATCH_CHECK(v[2] == 1.); +} + CATCH_TEST_CASE("write1") { cml::vector3d v; diff --git a/tests/vector/fixed_external_vector1.cpp b/tests/vector/fixed_external_vector1.cpp index 88392ea..f32345e 100644 --- a/tests/vector/fixed_external_vector1.cpp +++ b/tests/vector/fixed_external_vector1.cpp @@ -42,6 +42,15 @@ CATCH_TEST_CASE("list_assign") CATCH_CHECK(v[0] == 1.); } +CATCH_TEST_CASE("fill1") { + double av[3]; + cml::external3d v(av); + v.fill(1.); + CATCH_REQUIRE(v.size() == 3); + CATCH_CHECK(v.data()[0] == 1.); + CATCH_CHECK(v[2] == 1.); +} + CATCH_TEST_CASE("write1") { double data[] = { 1., 2., 3. };