'copyAtoB' : DLL function with matrix

Hello,

 

I try to use the dll example copyAtoB using matrix 10 * 10:

 

//load the shared library into GAUSS
dlibrary ECOS;

//size of vectors
nelems = 10;

//Fill in 'A' with random normal numbers
A = rndn(nelems, 10);

//Pre-allocate 'B' to be the same size as 'A'
B = zeros(nelems, 10);
//Call your C function
dllcall copyAtoB(A, B, nelems);

 

How can I modify the c funtion to have the expected results? I tried double pointer but without sucess.

thanks

3 Answers



0



a matrix n x n is avector 1 x n^2

qam

0


0



Assuming you used the C code from the accepted answer in this post, based on your GAUSS code above, I would expect that when B comes back from the dllcall it contains the first 10 numbers from A and the rest zeros.

In C you operate on an element at a time, so the nelems input to copyAtoB needs to be equal to the total number of elements in each matrix. For example, this should work:

//load the shared library into GAUSS
dlibrary ECOS;

//size of vectors
nrows = 10;
ncols = 10;
total_elems = nrows * ncols;

//Fill in 'A' with random normal numbers
A = rndn(nrows, ncols);

//Pre-allocate 'B' to be the same size as 'A'
B = zeros(nrows, ncols);

//Call your C function
dllcall copyAtoB(A, B, total_elems);

aptech

1,773


0



you are right. thanks a lot

qam

0

Your Answer

3 Answers

0

a matrix n x n is avector 1 x n^2

0

Assuming you used the C code from the accepted answer in this post, based on your GAUSS code above, I would expect that when B comes back from the dllcall it contains the first 10 numbers from A and the rest zeros.

In C you operate on an element at a time, so the nelems input to copyAtoB needs to be equal to the total number of elements in each matrix. For example, this should work:

//load the shared library into GAUSS
dlibrary ECOS;

//size of vectors
nrows = 10;
ncols = 10;
total_elems = nrows * ncols;

//Fill in 'A' with random normal numbers
A = rndn(nrows, ncols);

//Pre-allocate 'B' to be the same size as 'A'
B = zeros(nrows, ncols);

//Call your C function
dllcall copyAtoB(A, B, total_elems);
0

you are right. thanks a lot


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.