Copying a portion of a Matrix

Hi all,

can I copy a portion of a matrix, i.e. a generic minor of a matrix?
For instance, say A the N1xN2 float matrix, i would like to select its MxM minor that contains the element Aij (with j and i given) as its first element and to copy it in a different data structure, say B a matrix MxM.

Is there a special copy command that allows to do it in few lines, avoiding for cycles?

Thanks for any suggestions.

Bye,

P.

I don’t see how you can avoid doing M copy operations in that situation.

I was thinking about to use an cudaArray 2D structure. It seems that you can copy a sub-array with one command line…naturally MxM copying operations must be accomplished to perform the transfer, but it is managed by the library and trasparent to the developer.

Is it possible?

I am not sure that will help you. cudaArrays are intended for use with textures. You can’t use them directly inside a kernel, only via a texture reference, and they are read-only.

You could use cublasSetMatrix or call directly cudaMemcpy2D ( that is what cublasSetMatrix uses under the hood).