IndexedArray#
-
class numpy::IndexedArray#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use IndexedArray
IndexedArray obj;
// ... operations ...
Constructors#
Signature |
Location |
Example |
|---|---|---|
|
NP_ADVANCED_INDEXING.H:59 |
Linear Algebra#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
size_t |
NP_ADVANCED_INDEXING.H:223 |
Type Handling#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
void |
NP_ADVANCED_INDEXING.H:149 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
void |
NP_ADVANCED_INDEXING.H:197 |
|
|
void |
NP_ADVANCED_INDEXING.H:233 |
|
|
void |
NP_ADVANCED_INDEXING.H:324 |
|
|
void |
NP_ADVANCED_INDEXING.H:117 |
|
|
void |
NP_ADVANCED_INDEXING.H:81 |
|
|
const std::vector<size_t>& |
NP_ADVANCED_INDEXING.H:64 |
Code Examples#
The following examples are extracted from the test suite.
shape (np_test_1_all.cpp:3751)
3741 }
3742
3743 for (size_t j = 0; j < 3; ++j) {
3744 arr3.setElementAt({0, j}, static_cast<double>((j + 1) * 100)); // [100, 200, 300]
3745 }
3746
3747 // Broadcast all arrays together
3748 std::vector<NDArray<double>> arrays = {arr1, arr2, arr3};
3749 auto broadcasted = broadcast_arrays(arrays);
3750
3751 // All should have shape (2, 3)
3752 for (const auto& arr : broadcasted) {
3753 if (!((arr.getShape() == std::vector<size_t>{2, 3}))) {
3754 std::string description = std::string("test_broadcast_arrays():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !((arr.getShape() == std::vector<size_t>{2, 3}))";
3755 std::cout << std::string("[FAIL] ") + description << std::endl;
3756 throw std::runtime_error(description);
3757 }
3758 }
3759
3760 // Check values
3761 if (!(broadcasted[0].getElementAt({0, 1}) == 2.0)) {