Mercurial > hg > octave-thorsten
comparison liboctave/Array2-idx.h @ 2589:49ae0d992eea
[project @ 1996-12-13 08:41:43 by jwe]
author | jwe |
---|---|
date | Fri, 13 Dec 1996 08:41:55 +0000 |
parents | e57847e2de87 |
children | 00b2eff19bf5 |
comparison
equal
deleted
inserted
replaced
2588:ccd72573a0cf | 2589:49ae0d992eea |
---|---|
332 } | 332 } |
333 } | 333 } |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 #define MAYBE_RESIZE_LHS \ | |
338 do \ | |
339 { \ | |
340 if (liboctave_rre_flag) \ | |
341 { \ | |
342 int max_row_idx = idx_i_is_colon ? rhs_nr : idx_i.max () + 1; \ | |
343 int max_col_idx = idx_j_is_colon ? rhs_nc : idx_j.max () + 1; \ | |
344 \ | |
345 int new_nr = max_row_idx > lhs_nr ? max_row_idx : lhs_nr; \ | |
346 int new_nc = max_col_idx > lhs_nc ? max_col_idx : lhs_nc; \ | |
347 \ | |
348 lhs.resize (new_nr, new_nc, 0.0); \ | |
349 } \ | |
350 } \ | |
351 while (0) | |
352 | |
337 template <class LT, class RT> | 353 template <class LT, class RT> |
338 int | 354 int |
339 assign (Array2<LT>& lhs, const Array2<RT>& rhs) | 355 assign (Array2<LT>& lhs, const Array2<RT>& rhs) |
340 { | 356 { |
341 int retval = 1; | 357 int retval = 1; |
376 { | 392 { |
377 lhs.maybe_delete_elements (idx_i, idx_j); | 393 lhs.maybe_delete_elements (idx_i, idx_j); |
378 } | 394 } |
379 else | 395 else |
380 { | 396 { |
381 if (liboctave_rre_flag) | |
382 { | |
383 int max_row_idx = idx_i_is_colon ? rhs_nr : idx_i.max () + 1; | |
384 int max_col_idx = idx_j_is_colon ? rhs_nc : idx_j.max () + 1; | |
385 | |
386 int new_nr = max_row_idx > lhs_nr ? max_row_idx : lhs_nr; | |
387 int new_nc = max_col_idx > lhs_nc ? max_col_idx : lhs_nc; | |
388 | |
389 lhs.resize (new_nr, new_nc, 0.0); | |
390 } | |
391 | |
392 if (rhs_nr == 1 && rhs_nc == 1 && n > 0 && m > 0) | 397 if (rhs_nr == 1 && rhs_nc == 1 && n > 0 && m > 0) |
393 { | 398 { |
399 MAYBE_RESIZE_LHS; | |
400 | |
394 RT scalar = rhs.elem (0, 0); | 401 RT scalar = rhs.elem (0, 0); |
395 | 402 |
396 for (int j = 0; j < m; j++) | 403 for (int j = 0; j < m; j++) |
397 { | 404 { |
398 int jj = idx_j.elem (j); | 405 int jj = idx_j.elem (j); |
403 } | 410 } |
404 } | 411 } |
405 } | 412 } |
406 else if (n == rhs_nr && m == rhs_nc) | 413 else if (n == rhs_nr && m == rhs_nc) |
407 { | 414 { |
415 MAYBE_RESIZE_LHS; | |
416 | |
408 for (int j = 0; j < m; j++) | 417 for (int j = 0; j < m; j++) |
409 { | 418 { |
410 int jj = idx_j.elem (j); | 419 int jj = idx_j.elem (j); |
411 for (int i = 0; i < n; i++) | 420 for (int i = 0; i < n; i++) |
412 { | 421 { |