VectorizeOptions#

class numpy::VectorizeOptions#

numpy C++ class.

Example#

#include <numpy/np_ndarray.h>
using namespace numpy;

// Use VectorizeOptions
VectorizeOptions obj;
// ... operations ...

Other Methods#

Signature

Return Type

Location

Example

VectorizeOptions & withCache(boolenable_cache = true, size_tsize = 1000)

VectorizeOptions &

NP_VECTORIZE.H:48

View

VectorizeOptions & withDoc(const std::string &documentation)

VectorizeOptions &

NP_VECTORIZE.H:54

VectorizeOptions & withExcluded(const std::vector<size_t>&excl)

VectorizeOptions &

NP_VECTORIZE.H:43

View

VectorizeOptions & withSignature(const std::string &sig)

VectorizeOptions &

NP_VECTORIZE.H:38

Code Examples#

The following examples are extracted from the test suite.

withCache (np_test_1_all.cpp:15020)
15010      }
15011
15012      // Test 5: Custom vectorized function with options
15013      std::cout << "========= test_vectorize_with_options =======================";
15014
15015      auto custom_func = [](double x, double y, double scale) {
15016        return scale * (x + y);
15017        };
15018
15019      numpy::VectorizeOptions opts;
15020      opts.withExcluded({ 2 }).withCache(true, 500);
15021
15022      auto vectorized_custom = numpy::vectorize(custom_func, opts);
15023
15024      // Simplified test - just test with 2 array arguments for now
15025      numpy::NDArray<double> x({ 2 });
15026      x.setElementAt({ 0 }, 1.0);
15027      x.setElementAt({ 1 }, 2.0);
15028
15029      numpy::NDArray<double> y({ 2 });
15030      y.setElementAt({ 0 }, 3.0);
withExcluded (np_test_1_all.cpp:15020)
15010      }
15011
15012      // Test 5: Custom vectorized function with options
15013      std::cout << "========= test_vectorize_with_options =======================";
15014
15015      auto custom_func = [](double x, double y, double scale) {
15016        return scale * (x + y);
15017        };
15018
15019      numpy::VectorizeOptions opts;
15020      opts.withExcluded({ 2 }).withCache(true, 500);
15021
15022      auto vectorized_custom = numpy::vectorize(custom_func, opts);
15023
15024      // Simplified test - just test with 2 array arguments for now
15025      numpy::NDArray<double> x({ 2 });
15026      x.setElementAt({ 0 }, 1.0);
15027      x.setElementAt({ 1 }, 2.0);
15028
15029      numpy::NDArray<double> y({ 2 });
15030      y.setElementAt({ 0 }, 3.0);