lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Mar 17, 2011 at 17:08, Francesco Abbate <francesco.bbt@gmail.com> wrote:
>
> Probably the distinction between matrix and view is done in GSL just
> to enforce the clarity and readability in the code but I'm not
> entirely sure that it is actually a good idea.
>

In GSL, the difference between matrix and matrix_view is the ownership
semantics. matrix_veiw does not own a data block (owner flag is always
0) and cannot deallocate a matrix. It is used when you want to
temporarily work with sub-matrixes or treat a matrix as a vector or
vice versa. From the GSL documentation:

    " The new matrix view is only a view of the block underlying the
     existing matrix, M.  The block containing the elements of M is not
     owned by the new matrix view.  When the view goes out of scope the
     original matrix M and its block will continue to exist.  The
     original memory can only be deallocated by freeing the original
     matrix.  Of course, the original matrix should not be deallocated
     while the view is still in use."

--Leo--