> Ok. For example:
>
> 1. I create a matrix -> a=[1 2 3;4 5 6];
> 2. I pass the matrix to an *.oct function
> 3. In oct function I get the pointer to the data -> double*
> data="">
> 4. Do something...
> Is the correct working way with normal matrices?
>
Yes, but it will make a copy, and you need to return the modified
matrix as a return value, otherwise the argument will not be modified.
If you need only to read the matrix data, query data () which gives
you a const pointer.
Well, for read data I'll use the data() method, no problem. But, for example, if I need to solve a triangular system Ax=b with various b and I want to store the solutions in the same input b for save memory, one possibility is to use the data() method with a const_cast<double*>, for obtain permission for write. If I pass b from octave as a normal matrix, data() and const_cast should work, I suppose.
Not sure I understand exactly, but you matrix_value called on a
diagonal matrix object will convert it to a full one.
The diagonal data will, of course, be copied.