octave-maintainers
[Top][All Lists]
Advanced

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

Looking at Type inferencing compiler


From: John W. Eaton
Subject: Looking at Type inferencing compiler
Date: Mon, 11 Dec 2006 13:52:17 -0500

On 11-Dec-2006, David Bateman wrote:

| So the only example above that is faster than the m-file is yours!!! Do
| you or anyone else know where I'm paying the speed penalty for the
| octave in-built classes? In any case I suspect that the improvement you
| showed in the example in your thesis was largely due to the different
| matrix class that the type inferencing, though further benchmarks will
| be needed to prove that.

|     inline operator octave_value(){ 
|       Matrix m(rows,cols); for (int i = 0; i<rows; ++i) for ( int j = 0 ; 
j<cols; ++j ) m(i,j) = rep[i][j];
|       return m;
|     };

It's not clear to me whether this conversion operator is being used,
but it will be slow because the indexing operator for the Matrix class
must check the reference count each time it is called.  You can fix
that by doing

  inline operator octave_value(){ 
    Matrix m(rows,cols);
    double *mp = m.fortran_vec ();
    int k = 0;
    for (int j = 0 ; j<cols; ++j)
      for (int i = 0; i<rows; ++i)
        mp[k++] = rep[i][j];
    return m;
  }

jwe


reply via email to

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