[Top][All Lists]

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

Re: Get pointer to data in Matrix classes [possible solution]

From: José Luis García Pallero
Subject: Re: Get pointer to data in Matrix classes [possible solution]
Date: Thu, 12 Mar 2009 12:47:09 +0100

> 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.

Ok, my ideas about diagonal matrices are now clear.

José Luis García Pallero
/ / \
Use Debian GNU/Linux and enjoy!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]