From bug-octave-request at bevo dot che dot wisc dot edu Tue Oct 31 14:09:22 2000 Subject: vector transpose speedup From: "John W. Eaton" To: Paul Kienzle Cc: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 31 Oct 2000 14:09:02 -0600 On 5-Oct-2000, Paul Kienzle wrote: | To: bug-octave at bevo dot che dot wisc dot edu | Cc: pkienzle | Subject: vector transpose speedup | | Bug report for Octave 2.1.31 configured for %OCTAVE_CANONICAL_HOST_TYPE% | | Description: | ----------- | | x' does not need to copy the matrix if it is nx1 or 1xn | | Repeat-By: | --------- | | Fix: | --- | | *** Array2.cc 2000/10/05 09:33:32 1.1 | --- Array2.cc 2000/10/04 19:17:18 | *************** | *** 220,233 **** | Array2 | Array2::transpose (void) const | { | - Array2 result (d2, d1); | | ! if (d1 > 0 && d2 > 0) | ! for (int j = 0; j < d2; j++) | ! for (int i = 0; i < d1; i++) | ! result.elem (j, i) = elem (i, j); | | ! return result; | } | | /* | --- 220,241 ---- | Array2 | Array2::transpose (void) const | { | | ! if (d1 > 1 && d2 > 1) | ! { | ! Array2 result (d2, d1); | | ! for (int j = 0; j < d2; j++) | ! for (int i = 0; i < d1; i++) | ! result.xelem (j, i) = xelem (i, j); | ! | ! return result; | ! } | ! else | ! { | ! // Fast transpose for vectors and empty matrices | ! return Array2 (*this, d2, d1); | ! } | } | | /* I applied this patch. I left in both changes from elem to xelem, though it does not matter for the RHS since they are the same for const objects. jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------