A colleague has some Matlab code we'd like to explore porting to Octave. The code in question makes use of Matlabs '@' directories and operator overloading. We don't mind using C++ instead. The harder it is, the longer it will take, that's all. Could someone tell us what would be involved?
We have worked through http://octave.sourceforge.net/coda/. It was very helpful, but of course it doesn't take us quite where we want to go. (Less helpful was http://www.gnu.org/software/octave/doc/interpreter/User_002ddefined-Data-Types.html#User_002ddefined-Data-Types, except in the negative sense.) Features we'd like to (re-)implement: 1. Methods for data structures. I realize this is inside-out for Octave. 2. Operator overloading. The second is the more important. It would seem that function handles would help with #1, except there's no notion of a "this" pointer. I'm encouraged by finding function overloading; it would seem like a relatively short step from there. The rest of this message is an explanation as to why we consider this feature valuable. Please forgive me if it's already available and we missed it. Thanks for any help. --jkl == begin rationale == Why do we want to do this, and why should you care? Smarter objects are easier to deal with. In our case, we have very sparse matrices with some special properties: 1. They know the type of data they represent, and refuse to be multiplied if the types are multipliable. 2. They self-conform i.e., if their dimensions are inappropriate, zeros are appended. (This works for our application.) 3. They are more efficient on the Y axis. Memory allocation in Matlab's sparse matrix implementation is sensitive to the magnitude of the Y index values. Our matrices share a dictionary that compresses the Y dimension without affecting the outcome. Consider two matrices: a = 1 2 3 4 5 6 b = 9 8 7 6 Of course this fails: octave-3.0.1:39> a * b error: operator *: nonconformant arguments (op1 is 2x3, op2 is 2x2) error: evaluating binary operator `*' near line 39, column 3 because what's actually meant (here) by "b" is c = 9 8 7 6 0 0 octave-3.0.1:39> a * c ans = 23 20 71 62 Using our current Matlab objects, we can do: result = a * b; To do the same with Octave using procedures would entail (notionally): # define functions "multipliable" and "conform", then: if multipliable(a, b) result = a.data * conform(b, size(a.data, 2)); else error( "type %s not multipliable by type %s", a.type, b.type ); endif But that's not self-checking, so we really need to define that logic in a function, and have the user call: result = useful_mult(a, b); which is not very appealing. == end rationale == ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Octave-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/octave-dev
