#define CUDATOOLS_IMPLEMENTATION #include #include int main() { CudaTools::Array arr = CudaTools::Array::constant(0); arr.reshape({4, 5, 5}); // Creates a three dimensional array. arr[0][0][0] = 1; // Axis by axis indexing. arr[{1, 0, 0}] = 100; // Specific 'coordinate' indexing. std::cout << arr << "\n"; CudaTools::Array arrRange = CudaTools::Array::range(18); auto arrSlice = arr.slice({{1, 2}, {1, 4}, {1, 4}}). // Takes a slice of the center. std::cout << "Before Copy:\n" << arrSlice << "\n"; arrSlice = arrRange; // Copies arrRange into arrSlice. (Does NOT replace!) std::cout << "After Copy:\n" << arrSlice << "\n"; std::cout << "Modified: \n" << arr << "\n"; // The original array is modified, since a slice does not copy. CudaTools::Array newArr = arr.copy(); // Copies the original Array. for (auto it = newArr.begin(); it != newArr.end(); ++it) { // Iterate through the array. *it = 1; } std::cout << "Modified New Array:\n" << newArr << "\n"; std::cout << "Old Array:\n" << arr << "\n"; // The original array was not modified after a copy. return 0; }