Registered Member
|
Hi All,
I'm hoping to use Eigen to help speed up some computations in Matlab. In particular, I'm writing a mex function [Z,Mu] = MyMexFunction( X ); that takes in a matrix X, and returns two new matrices, Z and Mu. These matrices will be very big in some cases. X has size N x D, with N = tens of thousands and D = hundreds Z has size N x 1 Mu has size K x D I'm hoping to get input on what exactly the "best practice" is to allocate the new memory for Z,Mu so that it will play nice with Matlab. So far, I'm using Matlab's provided mex utilities to do the allocating, and then using Eigen's Map interface so the matrices are accessible to Eigen. Here's my skeleton of code for the relevant mex function:
The code above runs fine. But I'm just curious if I should be using the matlab allocation function (mxCreateDoubleMatrix) or if it would be better to use Eigen's allocation and then somehow get Matlab to read that in without copying all the data. Thoughts? Also, in what cases is it best to use the "aligned" in "Map<ArrayXXd,Aligned>" . I don't seem to see a speed-up either way. Would I be better off specifying a stride as well? Thanks! |
Moderator
|
Using MatLab's allocator should be fine. For large matrices, the 'Aligned' flag does not help much because actual alignement is determined at runtime.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]