Menu

Matrix row or column as vector

2013-04-02
2013-06-12
  • Peter Burka

    Peter Burka - 2013-04-02

    It's time for my daily question :)

    I'd like to be able to treat a row or column of a matrix as a vector. I can use matrix_range to slice a 1*n or n*1 submatrix from the matrix, but a 1*n matrix isn't quite the same as a vector in ViennaCL. In particular, I can't use the element_prod() function with a matrix.

    Is there any way to convert a 1*n matrix_range into a vector or to slice a vector from a matrix? Alternatively, is there any way to compute the element_prod() of two 1*n matrices?

     
  • Karl Rupp

    Karl Rupp - 2013-04-02

    Hi,

    haha, no problem, just go ahead. Every user request is valuable for us because it gives us hints on what needs to be improved. The row-/column-extraction is one such thing. We plan to add this piece of functionality in 1.5.0, the current release 1.4.1 is not capable of extracting these 'as a vector'. The only workaround for the moment is to use a custom OpenCL kernel, or, if you are using OpenCL and only need the first row/column of a matrix, to pass the OpenCL handle to the constructor of the vector. Alternatively, you could use the viennacl-dev repository soon, where this feature will be available in about two weeks.

    Unfortunately I can't give you a better answer this time…

    Best regards,
    Karli

     

Log in to post a comment.