diff --git a/org/qmckl_blas.org b/org/qmckl_blas.org index ee878fe..b0a70fc 100644 --- a/org/qmckl_blas.org +++ b/org/qmckl_blas.org @@ -52,7 +52,10 @@ #include "config.h" #endif +#include "qmckl_memory_private_type.h" #include "qmckl_blas_private_type.h" + +#include "qmckl_memory_private_func.h" #include "qmckl_blas_private_func.h" int main() { @@ -406,6 +409,7 @@ qmckl_tensor_of_vector(const qmckl_vector vector, } assert (prod_size == vector.size); + result.order = order; result.data = vector.data; return result; @@ -604,7 +608,7 @@ qmckl_tensor qmckl_tensor_set(qmckl_tensor tensor, double value) { qmckl_vector vector = qmckl_vector_of_tensor(tensor); - for (int32_t i=0 ; i (int64_t) 0); + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = vector.size * sizeof(double); + + double* target = (double*) qmckl_malloc(context, mem_info); + if (target == NULL) { + return NULL; + } + + qmckl_exit_code rc; + rc = qmckl_double_of_vector(context, vector, target, vector.size); + assert (rc == QMCKL_SUCCESS); + if (rc != QMCKL_SUCCESS) { + rc = qmckl_free(context, target); + target = NULL; + } + + return target; +} + #+end_src + + + #+begin_src c :comments org :tangle (eval h_private_func) +double* qmckl_alloc_double_of_matrix(const qmckl_context context, + const qmckl_matrix matrix); + #+end_src + + + #+begin_src c :comments org :tangle (eval c) :exports none +double* qmckl_alloc_double_of_matrix(const qmckl_context context, + const qmckl_matrix matrix) +{ + qmckl_vector vector = qmckl_vector_of_matrix(matrix); + return qmckl_alloc_double_of_vector(context, vector); +} + #+end_src + + + #+begin_src c :comments org :tangle (eval h_private_func) +double* qmckl_alloc_double_of_tensor(const qmckl_context context, + const qmckl_tensor tensor); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :exports none +double* qmckl_alloc_double_of_tensor(const qmckl_context context, + const qmckl_tensor tensor) +{ + qmckl_vector vector = qmckl_vector_of_tensor(tensor); + return qmckl_alloc_double_of_vector(context, vector); +} + #+end_src + + + ** Tests :noexport: #+begin_src c :comments link :tangle (eval c_test) :exports none @@ -803,6 +875,8 @@ qmckl_tensor_of_double(const qmckl_context context, for (int64_t i=0 ; i