[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Oct-file version of x>0
From: |
David Bateman |
Subject: |
Re: Oct-file version of x>0 |
Date: |
Wed, 31 May 2006 21:48:21 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.6-7.6.20060mdk (X11/20050322) |
John W. Eaton wrote:
> On 30-May-2006, Michael Kopp wrote:
>
> | > I think the best way to start is with a table that translates m-file
> | > commands into oct-file commands.
> | >
> | > The first column is the m-file command; the second column is the
> | > corresponding oct-file command; maybe a third column for comments.
> | >
> | > One table could be for matrix manipulation:
> | >
> | > x > 2
> | > mx_el_gt (x, 2)
> |
> | <Snip>
> |
> |
> | Speaking of matrix manipulation in oct-files: Is there an easy-to-use
> | equivalent to the sort function?
>
> If you start by looking at the implementation of Octave's sort
> function in src/DLD-FUNCTIONS/sort.cc, you'll see that most everything
> is defined in that file. Some of the code inside sort.cc could go in
> liboctinterp instead, so that it would be more easily used by other
> functions. Patches welcome.
>
> jwe
Why both, the main part of sort is a class octave_sort in liboctave. I
use octave_sort in a number of places in liboctave for the sparse code,
and so it is almost as easy to use octave_sort classs as the libc qsort
function. Look in the Sparse-op-defs.h (SPARSE_SPARSE_MUL) for an easy
example of the use of octave_sort, which is basically two lines. Note
that the template instantiation of the class is in sparse-sort.cc for
this example. sparse-sort.cc also contains a more complex example, where
there is a user defined comparison function to allow indexed searchs to
be performed. Check
Sparse<T>::Sparse (const Array<T>& a, const Array<octave_idx_type>& r,
const Array<octave_idx_type>& c, octave_idx_type nr,
octave_idx_type nc, bool sum_terms)
to see where this use of the sort class is useful..
D.
- Re: Oct-file version of x>0, (continued)
- Re: Oct-file version of x>0, Michael Creel, 2006/05/24
- Re: Oct-file version of x>0, Michael Kopp, 2006/05/30
- Re: Oct-file version of x>0, John W. Eaton, 2006/05/31
- Re: Oct-file version of x>0,
David Bateman <=
- Re: Oct-file version of x>0, John W. Eaton, 2006/05/31
- Re: Oct-file version of x>0, David Bateman, 2006/05/31