Mercurial > hg > octave-lyh
changeset 1321:64819a909ed7
[project @ 1995-08-22 05:39:43 by jwe]
author | jwe |
---|---|
date | Tue, 22 Aug 1995 05:41:48 +0000 |
parents | c9aecc02c6d4 |
children | 24fee1f1a577 |
files | liboctave/Array.cc liboctave/CColVector.cc liboctave/CMatrix.cc liboctave/CmplxLU.cc liboctave/CollocWt.cc liboctave/DASSL.cc liboctave/FEGrid.h liboctave/LSODE.cc liboctave/LinConst.h liboctave/NLEqn.cc liboctave/NPSOL.cc liboctave/QPSOL.cc liboctave/dColVector.cc liboctave/dMatrix.cc liboctave/dbleLU.cc liboctave/idx-vector.cc src/Map.cc src/oct-hist.cc src/pt-const.cc src/pt-exp-base.cc src/pt-misc.cc src/utils.cc src/xpow.cc |
diffstat | 23 files changed, 144 insertions(+), 187 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -569,21 +569,19 @@ int min_r = old_d1 < r ? old_d1 : r; int min_c = old_d2 < c ? old_d2 : c; - int i, j; - if (old_data && old_len > 0) { - for (j = 0; j < min_c; j++) - for (i = 0; i < min_r; i++) + for (int j = 0; j < min_c; j++) + for (int i = 0; i < min_r; i++) xelem (i, j) = old_data[old_d1*j+i]; } - for (j = 0; j < min_c; j++) - for (i = min_r; i < r; i++) + for (int j = 0; j < min_c; j++) + for (int i = min_r; i < r; i++) xelem (i, j) = val; - for (j = min_c; j < c; j++) - for (i = 0; i < r; i++) + for (int j = min_c; j < c; j++) + for (int i = 0; i < r; i++) xelem (i, j) = val; if (--old_rep->count <= 0)
--- a/liboctave/CColVector.cc +++ b/liboctave/CColVector.cc @@ -631,7 +631,7 @@ for (int i = 0; i < a_len; i++) result.elem (i) = a.elem (i) * m.elem (i, i); - for (i = a_len; i < nr; i++) + for (int i = a_len; i < nr; i++) result.elem (i) = 0.0; return result; @@ -658,7 +658,7 @@ for (int i = 0; i < a_len; i++) result.elem (i) = a.elem (i) * m.elem (i, i); - for (i = a_len; i < nr; i++) + for (int i = a_len; i < nr; i++) result.elem (i) = 0.0; return result; @@ -685,7 +685,7 @@ for (int i = 0; i < a_len; i++) result.elem (i) = a.elem (i) * m.elem (i, i); - for (i = a_len; i < nr; i++) + for (int i = a_len; i < nr; i++) result.elem (i) = 0.0; return result;
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -908,7 +908,7 @@ for (int j = 0; j < nsamples; j++) F77_FCN (cfftb, CFFTB) (npts, &tmp_data[npts*j], wsave); - for (j = 0; j < npts*nsamples; j++) + for (int j = 0; j < npts*nsamples; j++) tmp_data[j] = tmp_data[j] / (double) npts; delete [] wsave; @@ -952,14 +952,14 @@ F77_FCN (cffti, CFFTI) (npts, wsave); - for (j = 0; j < nsamples; j++) + for (int j = 0; j < nsamples; j++) { for (int i = 0; i < npts; i++) row[i] = tmp_data[i*nr + j]; F77_FCN (cfftf, CFFTF) (npts, row, wsave); - for (i = 0; i < npts; i++) + for (int i = 0; i < npts; i++) tmp_data[i*nr + j] = row[i]; } @@ -997,7 +997,7 @@ delete [] wsave; - for (j = 0; j < npts*nsamples; j++) + for (int j = 0; j < npts*nsamples; j++) tmp_data[j] = tmp_data[j] / (double) npts; npts = nc; @@ -1008,14 +1008,14 @@ F77_FCN (cffti, CFFTI) (npts, wsave); - for (j = 0; j < nsamples; j++) + for (int j = 0; j < nsamples; j++) { for (int i = 0; i < npts; i++) row[i] = tmp_data[i*nr + j]; F77_FCN (cfftb, CFFTB) (npts, row, wsave); - for (i = 0; i < npts; i++) + for (int i = 0; i < npts; i++) tmp_data[i*nr + j] = row[i] / (double) npts; } @@ -1263,9 +1263,8 @@ int nrr = m > n ? m : n; ComplexMatrix result (nrr, nrhs); - int i, j; - for (j = 0; j < nrhs; j++) - for (i = 0; i < m; i++) + for (int j = 0; j < nrhs; j++) + for (int i = 0; i < m; i++) result.elem (i, j) = b.elem (i, j); Complex *presult = result.fortran_vec (); @@ -1289,8 +1288,8 @@ rcond, rank, work, lwork, rwork, info); ComplexMatrix retval (n, nrhs); - for (j = 0; j < nrhs; j++) - for (i = 0; i < n; i++) + for (int j = 0; j < nrhs; j++) + for (int i = 0; i < n; i++) retval.elem (i, j) = result.elem (i, j); delete [] tmp_data; @@ -1337,8 +1336,7 @@ int nrr = m > n ? m : n; ComplexColumnVector result (nrr); - int i; - for (i = 0; i < m; i++) + for (int i = 0; i < m; i++) result.elem (i) = b.elem (i); Complex *presult = result.fortran_vec (); @@ -1362,7 +1360,7 @@ rcond, rank, work, lwork, rwork, info); ComplexColumnVector retval (n); - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) retval.elem (i) = result.elem (i); delete [] tmp_data;
--- a/liboctave/CmplxLU.cc +++ b/liboctave/CmplxLU.cc @@ -63,15 +63,13 @@ ComplexMatrix A_fact (tmp_data, n, n); - int i; - - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { ipvt[i] -= 1; pvt[i] = i; } - for (i = 0; i < n - 1; i++) + for (int i = 0; i < n - 1; i++) { int k = ipvt[i]; if (k != i) @@ -86,17 +84,15 @@ u.resize (n, n, 0.0); p.resize (n, n, 0.0); - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { p.elem (i, pvt[i]) = 1.0; - int j; - l.elem (i, i) = 1.0; - for (j = 0; j < i; j++) + for (int j = 0; j < i; j++) l.elem (i, j) = A_fact.elem (i, j); - for (j = i; j < n; j++) + for (int j = i; j < n; j++) u.elem (i, j) = A_fact.elem (i, j); }
--- a/liboctave/CollocWt.cc +++ b/liboctave/CollocWt.cc @@ -285,29 +285,28 @@ dif1, dif2, dif3, pr); int id; - int i, j; // First derivative weights. id = 1; - for (i = 1; i <= nt; i++) + for (int i = 1; i <= nt; i++) { F77_FCN (dfopr, DFOPR) (nt, n, inc_left, inc_right, i, id, dif1, dif2, dif3, pr, vect); - for (j = 0; j < nt; j++) + for (int j = 0; j < nt; j++) A (i-1, j) = vect[j]; } // Second derivative weights. id = 2; - for (i = 1; i <= nt; i++) + for (int i = 1; i <= nt; i++) { F77_FCN (dfopr, DFOPR) (nt, n, inc_left, inc_right, i, id, dif1, dif2, dif3, pr, vect); - for (j = 0; j < nt; j++) + for (int j = 0; j < nt; j++) B (i-1, j) = vect[j]; } @@ -315,7 +314,7 @@ id = 3; double *pq = q.fortran_vec (); - F77_FCN (dfopr, DFOPR) (nt, n, inc_left, inc_right, i, id, dif1, + F77_FCN (dfopr, DFOPR) (nt, n, inc_left, inc_right, id, id, dif1, dif2, dif3, pr, pq); delete [] dif1;
--- a/liboctave/DASSL.cc +++ b/liboctave/DASSL.cc @@ -216,7 +216,7 @@ ires = -2; else { - for (i = 0; i < nn; i++) + for (int i = 0; i < nn; i++) delta [i] = tmp_delta.elem (i); } @@ -380,7 +380,7 @@ if (integration_error) return retval; - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { retval.elem (j, i) = x_next.elem (i); xdot_out.elem (j, i) = xdot.elem (i); @@ -469,7 +469,7 @@ if (save_output) { - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { retval.elem (i_out-1, i) = x_next.elem (i); xdot_out.elem (i_out-1, i) = xdot.elem (i);
--- a/liboctave/FEGrid.h +++ b/liboctave/FEGrid.h @@ -38,53 +38,37 @@ class FEGrid { +private: + + void error (const char* msg) const; + void nel_error (void) const; + + void check_grid (void) const; + public: - FEGrid (void); - FEGrid (const Vector& elbnds); + FEGrid (void) {} + FEGrid (const Vector& elbnds) { elem = elbnds; check_grid (); } FEGrid (int nel, double width); FEGrid (int nel, double left, double right); - int in_bounds (double x) const; - int element (double x) const; - double left (void) const; - double right (void) const; + double left (void) const { return elem.elem (0); } + double right (void) const { return elem.elem (elem.capacity () - 1); } - Vector element_boundaries (void) const; + int in_bounds (double x) const + { return (x >= left () && x <= right ()); } + + Vector element_boundaries (void) const { return elem; } friend ostream& operator << (ostream&, const FEGrid&); protected: Vector elem; - -private: - - void error (const char* msg) const; - void nel_error (void) const; - - void check_grid (void) const; }; -inline FEGrid::FEGrid (void) {} - -inline FEGrid::FEGrid (const Vector& elbnds) - { elem = elbnds; check_grid (); } - -inline int FEGrid::in_bounds (double x) const - { return (x >= left () && x <= right ()); } - -inline double FEGrid::left (void) const - { return elem.elem (0); } - -inline double FEGrid::right (void) const - { return elem.elem (elem.capacity () - 1); } - -inline Vector FEGrid::element_boundaries (void) const - { return elem; } - #endif /*
--- a/liboctave/LSODE.cc +++ b/liboctave/LSODE.cc @@ -339,7 +339,7 @@ if (integration_error) return retval; - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) retval.elem (j, i) = x_next.elem (i); } } @@ -421,7 +421,7 @@ if (save_output) { - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) retval.elem (i_out-1, i) = x_next.elem (i); }
--- a/liboctave/LinConst.h +++ b/liboctave/LinConst.h @@ -45,25 +45,48 @@ { public: - LinConst (void); - LinConst (int nclin, int nx); + LinConst (void) : Bounds () {} + LinConst (int nc, int n) : Bounds (nc), A (nb, n) {} + + LinConst (int eq, int ineq, int n) + : Bounds (eq+ineq), A (nb, n) {} - LinConst (int nclin_eq, int nclin_ineq, int nx); - - LinConst (const Vector& lb, const Matrix& A, const Vector& ub); + LinConst (const Vector& l, const Matrix& amat, const Vector& u) + : Bounds (l, u), A (amat) + { + if (nb != amat.rows ()) + error ("inconsistent sizes for constraint matrix and bounds vectors"); + } LinConst (const Matrix& A_eq, const Vector& b_eq, const Matrix& A_ineq, const Vector& b_ineq); - LinConst (const LinConst& a); + LinConst (const LinConst& a) + : Bounds (a.lb, a.ub), A (a.constraint_matrix ()) {} - LinConst& operator = (const LinConst& a); + LinConst& operator = (const LinConst& a) + { + nb = a.nb; + lb = a.lb; + A = a.A; + ub = a.ub; + + return *this; + } LinConst& resize (int nclin, int n); - Matrix constraint_matrix (void) const; + Matrix constraint_matrix (void) const { return A; } - LinConst& set_constraint_matrix (const Matrix& A); + LinConst& set_constraint_matrix (const Matrix& amat) + { + if (lb.capacity () != amat.rows ()) + error ("inconsistent size for new linear constraint matrix"); + + A = amat; + + return *this; + } Matrix eq_constraint_matrix (void) const; Matrix ineq_constraint_matrix (void) const; @@ -83,52 +106,6 @@ }; -inline LinConst::LinConst (void) : Bounds () {} - -inline LinConst::LinConst (int nc, int n) : Bounds (nc), A (nb, n) {} - -inline LinConst::LinConst (int eq, int ineq, int n) - : Bounds (eq+ineq), A (nb, n) {} - -inline LinConst::LinConst (const Vector& l, const Matrix& amat, - const Vector& u) - : Bounds (l, u), A (amat) -{ - if (nb != amat.rows ()) - error ("inconsistent sizes for constraint matrix and bounds vectors"); -} - -inline LinConst::LinConst (const LinConst& a) - : Bounds (a.lb, a.ub), A (a.constraint_matrix ()) {} - -inline LinConst& -LinConst::operator = (const LinConst& a) -{ - nb = a.nb; - lb = a.lb; - A = a.A; - ub = a.ub; - - return *this; -} - -inline Matrix -LinConst::constraint_matrix (void) const -{ - return A; -} - -inline LinConst& -LinConst::set_constraint_matrix (const Matrix& amat) -{ - if (lb.capacity () != amat.rows ()) - error ("inconsistent size for new linear constraint matrix"); - - A = amat; - - return *this; -} - #endif /*
--- a/liboctave/NLEqn.cc +++ b/liboctave/NLEqn.cc @@ -157,7 +157,7 @@ *iflag = -1; else { - for (i = 0; i < nn; i++) + for (int i = 0; i < nn; i++) fvec[i] = tmp_f.elem (i); } @@ -185,7 +185,7 @@ *iflag = -1; else { - for (i = 0; i < nn; i++) + for (int i = 0; i < nn; i++) fvec[i] = tmp_f.elem (i); } } @@ -201,7 +201,7 @@ { int ld = *ldfjac; for (int j = 0; j < nn; j++) - for (i = 0; i < nn; i++) + for (int i = 0; i < nn; i++) fjac[j*ld+i] = tmp_fj.elem (i, j); } } @@ -257,7 +257,7 @@ { retval.resize (n); - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) retval.elem (i) = px[i]; }
--- a/liboctave/NPSOL.cc +++ b/liboctave/NPSOL.cc @@ -107,7 +107,7 @@ mode = -1; else { - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) objgrd[i] = tmp_grad.elem (i); } } @@ -135,7 +135,7 @@ } else { - for (i = 0; i < ncnln; i++) + for (int i = 0; i < ncnln; i++) cons[i] = tmp_c.elem (i); } @@ -151,7 +151,7 @@ { int ld = nrowj; for (int j = 0; j < n; j++) - for (i = 0; i < ncnln; i++) + for (int i = 0; i < ncnln; i++) cjac[i+j*ld] = tmp_jac (i, j); } } @@ -241,7 +241,7 @@ cup[i+n] = lc.upper_bound (i); } - for (i = 0; i < ncnln; i++) + for (int i = 0; i < ncnln; i++) { clow[i+n+nclin] = nlc.lower_bound (i); cup[i+n+nclin] = nlc.upper_bound (i);
--- a/liboctave/QPSOL.cc +++ b/liboctave/QPSOL.cc @@ -78,8 +78,6 @@ Vector QPSOL::minimize (double& objf, int& inform, Vector& lambda) { - int i; - int n = x.capacity (); int itmax = (iteration_limit () < 0) ? 50 * n : iteration_limit (); @@ -103,7 +101,7 @@ if (bnds.size () > 0) { - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { pbl[i] = bnds.lower_bound (i); pbu[i] = bnds.upper_bound (i); @@ -111,14 +109,14 @@ } else { - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { pbl[i] = -bigbnd; pbu[i] = bigbnd; } } - for (i = 0; i < nclin; i++) + for (int i = 0; i < nclin; i++) { pbl[i+n] = lc.lower_bound (i); pbu[i+n] = lc.upper_bound (i); @@ -128,7 +126,7 @@ double *featol = new double [nctotl]; double tmp = feasibility_tolerance (); - for (i = 0; i < nctotl; i++) + for (int i = 0; i < nctotl; i++) featol[i] = tmp; double *ph = H.fortran_vec ();
--- a/liboctave/dColVector.cc +++ b/liboctave/dColVector.cc @@ -259,7 +259,7 @@ for (int i = 0; i < a_len; i++) result.elem (i) = a.elem (i) * m.elem (i, i); - for (i = a_len; i < nr; i++) + for (int i = a_len; i < nr; i++) result.elem (i) = 0.0; return result;
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -636,7 +636,7 @@ for (int j = 0; j < nsamples; j++) F77_FCN (cfftb, CFFTB) (npts, &tmp_data[npts*j], wsave); - for (j = 0; j < npts*nsamples; j++) + for (int j = 0; j < npts*nsamples; j++) tmp_data[j] = tmp_data[j] / (double) npts; delete [] wsave; @@ -680,14 +680,14 @@ F77_FCN (cffti, CFFTI) (npts, wsave); - for (j = 0; j < nsamples; j++) + for (int j = 0; j < nsamples; j++) { for (int i = 0; i < npts; i++) row[i] = tmp_data[i*nr + j]; F77_FCN (cfftf, CFFTF) (npts, row, wsave); - for (i = 0; i < npts; i++) + for (int i = 0; i < npts; i++) tmp_data[i*nr + j] = row[i]; } @@ -725,7 +725,7 @@ delete [] wsave; - for (j = 0; j < npts*nsamples; j++) + for (int j = 0; j < npts*nsamples; j++) tmp_data[j] = tmp_data[j] / (double) npts; npts = nc; @@ -736,14 +736,14 @@ F77_FCN (cffti, CFFTI) (npts, wsave); - for (j = 0; j < nsamples; j++) + for (int j = 0; j < nsamples; j++) { for (int i = 0; i < npts; i++) row[i] = tmp_data[i*nr + j]; F77_FCN (cfftb, CFFTB) (npts, row, wsave); - for (i = 0; i < npts; i++) + for (int i = 0; i < npts; i++) tmp_data[i*nr + j] = row[i] / (double) npts; } @@ -1010,9 +1010,8 @@ int nrr = m > n ? m : n; Matrix result (nrr, nrhs); - int i, j; - for (j = 0; j < nrhs; j++) - for (i = 0; i < m; i++) + for (int j = 0; j < nrhs; j++) + for (int i = 0; i < m; i++) result.elem (i, j) = b.elem (i, j); double *presult = result.fortran_vec (); @@ -1032,8 +1031,8 @@ rcond, rank, work, lwork, info); Matrix retval (n, nrhs); - for (j = 0; j < nrhs; j++) - for (i = 0; i < n; i++) + for (int j = 0; j < nrhs; j++) + for (int i = 0; i < n; i++) retval.elem (i, j) = result.elem (i, j); delete [] tmp_data; @@ -1098,8 +1097,7 @@ int nrr = m > n ? m : n; ColumnVector result (nrr); - int i; - for (i = 0; i < m; i++) + for (int i = 0; i < m; i++) result.elem (i) = b.elem (i); double *presult = result.fortran_vec (); @@ -1119,7 +1117,7 @@ rcond, rank, work, lwork, info); ColumnVector retval (n); - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) retval.elem (i) = result.elem (i); delete [] tmp_data;
--- a/liboctave/dbleLU.cc +++ b/liboctave/dbleLU.cc @@ -63,15 +63,13 @@ Matrix A_fact (tmp_data, n, n); - int i; - - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { ipvt[i] -= 1; pvt[i] = i; } - for (i = 0; i < n - 1; i++) + for (int i = 0; i < n - 1; i++) { int k = ipvt[i]; if (k != i) @@ -86,17 +84,15 @@ u.resize (n, n, 0.0); p.resize (n, n, 0.0); - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { p.elem (i, pvt[i]) = 1.0; - int j; - l.elem (i, i) = 1.0; - for (j = 0; j < i; j++) + for (int j = 0; j < i; j++) l.elem (i, j) = A_fact.elem (i, j); - for (j = i; j < n; j++) + for (int j = i; j < n; j++) u.elem (i, j) = A_fact.elem (i, j); }
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -258,7 +258,7 @@ min_val = max_val = data[0]; - i = 0; + int i = 0; do { if (data[i] > max_val)
--- a/src/Map.cc +++ b/src/Map.cc @@ -55,7 +55,9 @@ Pix Map<C>::seek (const char *item) const { - for (Pix i = first (); i != 0 && strcmp (key (i), item) != 0; next (i)) + Pix i = 0; + + for (i = first (); i != 0 && strcmp (key (i), item) != 0; next (i)) ; // Skip items until match found. return i; @@ -168,7 +170,8 @@ { unsigned int h = hash (item) % size; - for (CHNode<C> *t = tab[h]; goodCHptr (t); t = t->tl) + CHNode<C> *t = 0; + for (t = tab[h]; goodCHptr (t); t = t->tl) if (strcmp (item, t->hd) == 0) return t->cont; @@ -261,7 +264,9 @@ for (unsigned int i = 0; i < size; ++i) { - for (CHNode<C> *p = tab[i]; goodCHptr (p); p = p->tl) + CHNode<C> *p = 0; + + for (p = tab[i]; goodCHptr (p); p = p->tl) ++n; v &= CHptr_to_index (p) == i + 1;
--- a/src/oct-hist.cc +++ b/src/oct-hist.cc @@ -259,7 +259,9 @@ if (hlist) { - for (int i = 0; hlist[i]; i++) + int i = 0; + + for (i = 0; hlist[i]; i++) ; // Do nothing. if (limit < 0) @@ -365,7 +367,9 @@ if (! hlist) return; - for (int i = 0; hlist[i]; i++) + int i = 0; + + for (i = 0; hlist[i]; i++) ; // Count 'em. i--;
--- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -79,7 +79,9 @@ int block_size = tc_newlist_grow_size * sizeof (tree_constant); tc_newlist = (tree_constant *) new char [block_size]; - for (int i = 0; i < tc_newlist_grow_size - 1; i++) + int i = 0; + + for (i = 0; i < tc_newlist_grow_size - 1; i++) tc_newlist[i].freeptr = &tc_newlist[i+1]; tc_newlist[i].freeptr = 0; @@ -815,7 +817,9 @@ int block_size = tc_rep_newlist_grow_size * sizeof (TC_REP); tc_rep_newlist = (TC_REP *) new char [block_size]; - for (int i = 0; i < tc_rep_newlist_grow_size - 1; i++) + int i = 0; + + for (i = 0; i < tc_rep_newlist_grow_size - 1; i++) tc_rep_newlist[i].freeptr = &tc_rep_newlist[i+1]; tc_rep_newlist[i].freeptr = 0;
--- a/src/pt-exp-base.cc +++ b/src/pt-exp-base.cc @@ -413,7 +413,7 @@ // Compute size of result matrix, and check to see that the dimensions // of all the elements will match up properly. - for (i = 0; i < len; i++) + for (int i = 0; i < len; i++) { dir direct = list[i].direction; @@ -490,7 +490,7 @@ else m.resize (row_total, col_total, 0.0); - for (i = 0; i < len; i++) + for (int i = 0; i < len; i++) { tree_constant tmp = list[i].elem;
--- a/src/pt-misc.cc +++ b/src/pt-misc.cc @@ -368,7 +368,7 @@ if (vr_list) { - for (p = vr_list->first (); p != 0; vr_list->next (p)) + for (Pix p = vr_list->first (); p != 0; vr_list->next (p)) { retval(i) = vr_list->operator () (p); i++;
--- a/src/utils.cc +++ b/src/utils.cc @@ -590,7 +590,8 @@ int max_name_length = 0; int total_names = 0; - for (char **names = list; *names; names++) + char **names = 0; + for (names = list; *names; names++) { total_names++; int name_length = strlen (*names);
--- a/src/xpow.cc +++ b/src/xpow.cc @@ -530,9 +530,8 @@ assert (nr == b.rows () && nc == b.columns ()); int convert_to_complex = 0; - int i; for (int j = 0; j < nc; j++) - for (i = 0; i < nr; i++) + for (int i = 0; i < nr; i++) { double atmp = a.elem (i, j); double btmp = b.elem (i, j); @@ -549,8 +548,8 @@ { ComplexMatrix complex_result (nr, nc); - for (j = 0; j < nc; j++) - for (i = 0; i < nr; i++) + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) { Complex atmp (a.elem (i, j)); Complex btmp (b.elem (i, j)); @@ -562,8 +561,8 @@ { Matrix result (nr, nc); - for (j = 0; j < nc; j++) - for (i = 0; i < nr; i++) + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) result.elem (i, j) = pow (a.elem (i, j), b.elem (i, j)); return tree_constant (result);