Guest User

Untitled

a guest
Aug 23rd, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. /* N-dimensional output arrays */
  2. %define TYPEMAP_OUTND(oct_type, sg_type, if_type, error_string)
  3. %typemap(out) shogun::SGNDArray<sg_type>
  4. {
  5. sg_type* array = $1.array;
  6. int32_t* dims = $1.dims;
  7. int32_t num_dims = $1.num_dims;
  8.  
  9. dim_vector vdims(1, num_dims);
  10.  
  11. int32_t n = 1;
  12. for (int32_t i = 0; i < num_dims; i++)
  13. {
  14. n *= dims[i];
  15. vdims(i) = dims[i];
  16. printf("%d ", vdims(i));
  17. }
  18. printf("\n");
  19.  
  20. oct_type mat = oct_type(dim_vector(vdims));
  21.  
  22. for (int32_t i=0; i<n; i++)
  23. {
  24. mat(i) = (if_type) array[i];
  25. printf("%f ", mat(i));
  26. }
  27. printf("\n");
  28.  
  29. $result=mat;
  30. }
  31. %enddef
Advertisement
Add Comment
Please, Sign In to add comment