diff --git a/include/clad/Differentiator/Array.h b/include/clad/Differentiator/Array.h index d5ee05b68..bceab2656 100644 --- a/include/clad/Differentiator/Array.h +++ b/include/clad/Differentiator/Array.h @@ -51,6 +51,12 @@ template class array { CUDA_HOST_DEVICE array(const array& arr) : array(arr.m_arr, arr.m_size) {} + template + CUDA_HOST_DEVICE array(const array& arr) + : m_arr(new T[arr.size()]), m_size(arr.size()) { + (*this) = arr; + } + CUDA_HOST_DEVICE array(std::size_t size, const clad::array& arr) : m_arr(new T[size]), m_size(size) { for (std::size_t i = 0; i < size; ++i) diff --git a/test/Misc/CladArray.C b/test/Misc/CladArray.C index 7cb9f39c8..ad370c01b 100644 --- a/test/Misc/CladArray.C +++ b/test/Misc/CladArray.C @@ -113,6 +113,16 @@ int main() { //CHECK-EXEC: 1 : 4 //CHECK-EXEC: 2 : 5 + // clad::array --> clad::array + clad::array type_conv_arr = clad_arr; + + for (int i = 0; i < 3; i++) { + printf("%d : %.2Lf\n", i, type_conv_arr[i]); + } + //CHECK-EXEC: 0 : 1.00 + //CHECK-EXEC: 1 : 2.00 + //CHECK-EXEC: 2 : 3.00 + test_arr -= arr_ref; for (int i = 0; i < 3; i++) { printf("%d : %d\n", i, test_arr[i]);