BoostConfig =========== .. cpp:class:: numpy::BoostConfig numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use BoostConfig BoostConfig obj; // ... operations ... Indexing / Selection -------------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``Backend get_default_backend()`` - Backend - BOOST_CONFIG.H:92 - :ref:`View ` Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``Backend resolve_backend(Backendrequested = Backend::AUTO)`` - Backend - BOOST_CONFIG.H:93 - :ref:`View ` * - ``void set_default_backend(Backendbackend)`` - void - BOOST_CONFIG.H:91 - :ref:`View ` * - ``bool should_use_boost(Backendrequested = Backend::AUTO)`` - bool - BOOST_CONFIG.H:94 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-boostconfig-get_default_backend-0: .. dropdown:: get_default_backend (np_test_1_all.cpp:25367) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 25357 :emphasize-lines: 11 // std::cout << "[OK] BoostInfo tests passed" << std::endl; } void test_boost_config() { std::cout << "========= Testing BoostConfig ==================="; using namespace numpy::boost_lib; // Test default backend Backend default_backend = BoostConfig::get_default_backend(); // std::cout << "Default backend: " // << (default_backend == Backend::AUTO ? "AUTO" : // default_backend == Backend::BOOST ? "BOOST" : "STANDARD") // << std::endl; // Test backend resolution Backend resolved_auto = BoostConfig::resolve_backend(Backend::AUTO); // std::cout << "Resolved AUTO backend: " // << (resolved_auto == Backend::BOOST ? "BOOST" : "STANDARD") // << std::endl; .. _example-boostconfig-resolve_backend-1: .. dropdown:: resolve_backend (np_test_1_all.cpp:25374) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 25364 :emphasize-lines: 11 using namespace numpy::boost_lib; // Test default backend Backend default_backend = BoostConfig::get_default_backend(); // std::cout << "Default backend: " // << (default_backend == Backend::AUTO ? "AUTO" : // default_backend == Backend::BOOST ? "BOOST" : "STANDARD") // << std::endl; // Test backend resolution Backend resolved_auto = BoostConfig::resolve_backend(Backend::AUTO); // std::cout << "Resolved AUTO backend: " // << (resolved_auto == Backend::BOOST ? "BOOST" : "STANDARD") // << std::endl; // Test should_use_boost bool use_boost = BoostConfig::should_use_boost(Backend::AUTO); // std::cout << "Should use Boost (AUTO): " << (use_boost ? "Yes" : "No") << std::endl; // Verify consistency if (BoostInfo::is_runtime_available()) { .. _example-boostconfig-set_default_backend-2: .. dropdown:: set_default_backend (np_test_1_all.cpp:25414) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 25404 :emphasize-lines: 11 // Test forced STANDARD backend bool use_standard = BoostConfig::should_use_boost(Backend::STANDARD); if (use_standard) { throw std::runtime_error("Forced STANDARD backend not working"); } // std::cout << "[OK] Forced STANDARD backend works" << std::endl; // Test backend setting Backend original = BoostConfig::get_default_backend(); BoostConfig::set_default_backend(Backend::STANDARD); if (BoostConfig::get_default_backend() != Backend::STANDARD) { throw std::runtime_error("Backend setting not working"); } BoostConfig::set_default_backend(original); // Restore // std::cout << "[OK] Backend setting works" << std::endl; // std::cout << "[OK] BoostConfig tests passed" << std::endl; } #if BOOST_ENABLED .. _example-boostconfig-should_use_boost-3: .. dropdown:: should_use_boost (np_test_1_all.cpp:25380) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 25370 :emphasize-lines: 11 // default_backend == Backend::BOOST ? "BOOST" : "STANDARD") // << std::endl; // Test backend resolution Backend resolved_auto = BoostConfig::resolve_backend(Backend::AUTO); // std::cout << "Resolved AUTO backend: " // << (resolved_auto == Backend::BOOST ? "BOOST" : "STANDARD") // << std::endl; // Test should_use_boost bool use_boost = BoostConfig::should_use_boost(Backend::AUTO); // std::cout << "Should use Boost (AUTO): " << (use_boost ? "Yes" : "No") << std::endl; // Verify consistency if (BoostInfo::is_runtime_available()) { // If Boost is available, AUTO should resolve to BOOST if (resolved_auto != Backend::BOOST) { throw std::runtime_error("Backend resolution incorrect when Boost available"); } if (!use_boost) { throw std::runtime_error("should_use_boost incorrect when Boost available");