comparison src/sparse-xpow.cc @ 14861:f7afecdd87ef

maint: Use Octave coding conventions for cuddling parentheses in src/ directory * bitfcns.cc, comment-list.cc, data.cc, defun.cc, error.cc, gl-render.cc, graphics.cc, graphics.in.h, load-path.cc, load-path.h, load-save.cc, ls-hdf5.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-ascii.cc, mappers.cc, mex.cc, oct-map.cc, oct-obj.cc, ov-base-int.cc, ov-base-mat.h, ov-base-sparse.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-cell.cc, ov-class.cc, ov-complex.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.cc, ov.cc, pr-output.cc, procstream.h, sighandlers.cc, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc, symtab.cc, syscalls.cc, sysdep.cc, txt-eng-ft.cc, variables.cc, zfstream.cc, zfstream.h: Use Octave coding conventions for cuddling parentheses.
author Rik <octave@nomad.inbox5.com>
date Sat, 14 Jul 2012 06:22:56 -0700
parents 72c96de7a403
children
comparison
equal deleted inserted replaced
14860:e027f98403c3 14861:f7afecdd87ef
248 for (octave_idx_type j = 0; j < nc; j++) 248 for (octave_idx_type j = 0; j < nc; j++)
249 { 249 {
250 for (octave_idx_type i = 0; i < nr; i++) 250 for (octave_idx_type i = 0; i < nr; i++)
251 { 251 {
252 octave_quit (); 252 octave_quit ();
253 result (i, j) = std::pow (atmp, b(i,j)); 253 result(i, j) = std::pow (atmp, b(i,j));
254 } 254 }
255 } 255 }
256 256
257 retval = result; 257 retval = result;
258 } 258 }
263 for (octave_idx_type j = 0; j < nc; j++) 263 for (octave_idx_type j = 0; j < nc; j++)
264 { 264 {
265 for (octave_idx_type i = 0; i < nr; i++) 265 for (octave_idx_type i = 0; i < nr; i++)
266 { 266 {
267 octave_quit (); 267 octave_quit ();
268 result (i, j) = std::pow (a, b(i,j)); 268 result(i, j) = std::pow (a, b(i,j));
269 } 269 }
270 } 270 }
271 271
272 retval = result; 272 retval = result;
273 } 273 }
288 for (octave_idx_type j = 0; j < nc; j++) 288 for (octave_idx_type j = 0; j < nc; j++)
289 { 289 {
290 for (octave_idx_type i = 0; i < nr; i++) 290 for (octave_idx_type i = 0; i < nr; i++)
291 { 291 {
292 octave_quit (); 292 octave_quit ();
293 result (i, j) = std::pow (atmp, b(i,j)); 293 result(i, j) = std::pow (atmp, b(i,j));
294 } 294 }
295 } 295 }
296 296
297 return result; 297 return result;
298 } 298 }
321 // FIXME -- avoid apparent GNU libm bug by 321 // FIXME -- avoid apparent GNU libm bug by
322 // converting A and B to complex instead of just A. 322 // converting A and B to complex instead of just A.
323 Complex btmp (b); 323 Complex btmp (b);
324 324
325 for (octave_idx_type j = 0; j < nc; j++) 325 for (octave_idx_type j = 0; j < nc; j++)
326 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 326 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
327 { 327 {
328 octave_quit (); 328 octave_quit ();
329 329
330 Complex atmp (a.data (i)); 330 Complex atmp (a.data (i));
331 331
332 result (a.ridx(i), j) = std::pow (atmp, btmp); 332 result(a.ridx (i), j) = std::pow (atmp, btmp);
333 } 333 }
334 334
335 retval = octave_value (result); 335 retval = octave_value (result);
336 } 336 }
337 else 337 else
338 { 338 {
339 Matrix result (nr, nc, (std::pow (0.0, b))); 339 Matrix result (nr, nc, (std::pow (0.0, b)));
340 340
341 for (octave_idx_type j = 0; j < nc; j++) 341 for (octave_idx_type j = 0; j < nc; j++)
342 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 342 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
343 { 343 {
344 octave_quit (); 344 octave_quit ();
345 result (a.ridx(i), j) = std::pow (a.data (i), b); 345 result(a.ridx (i), j) = std::pow (a.data (i), b);
346 } 346 }
347 347
348 retval = octave_value (result); 348 retval = octave_value (result);
349 } 349 }
350 } 350 }
405 return octave_value (); 405 return octave_value ();
406 } 406 }
407 407
408 int convert_to_complex = 0; 408 int convert_to_complex = 0;
409 for (octave_idx_type j = 0; j < nc; j++) 409 for (octave_idx_type j = 0; j < nc; j++)
410 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 410 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
411 { 411 {
412 if (a.data(i) < 0.0) 412 if (a.data(i) < 0.0)
413 { 413 {
414 double btmp = b (a.ridx(i), j); 414 double btmp = b (a.ridx (i), j);
415 if (static_cast<int> (btmp) != btmp) 415 if (static_cast<int> (btmp) != btmp)
416 { 416 {
417 convert_to_complex = 1; 417 convert_to_complex = 1;
418 goto done; 418 goto done;
419 } 419 }
427 // allocate a full matrix filled for the 0.^0 case and shrink it later 427 // allocate a full matrix filled for the 0.^0 case and shrink it later
428 // as needed 428 // as needed
429 429
430 if (convert_to_complex) 430 if (convert_to_complex)
431 { 431 {
432 SparseComplexMatrix complex_result (nr, nc, Complex(1.0, 0.0)); 432 SparseComplexMatrix complex_result (nr, nc, Complex (1.0, 0.0));
433 433
434 for (octave_idx_type j = 0; j < nc; j++) 434 for (octave_idx_type j = 0; j < nc; j++)
435 { 435 {
436 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 436 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
437 { 437 {
438 octave_quit (); 438 octave_quit ();
439 complex_result.xelem(a.ridx(i), j) = 439 complex_result.xelem (a.ridx (i), j) =
440 std::pow (Complex(a.data(i)), Complex(b(a.ridx(i), j))); 440 std::pow (Complex (a.data (i)), Complex (b(a.ridx (i), j)));
441 } 441 }
442 } 442 }
443 complex_result.maybe_compress (true); 443 complex_result.maybe_compress (true);
444 retval = complex_result; 444 retval = complex_result;
445 } 445 }
447 { 447 {
448 SparseMatrix result (nr, nc, 1.0); 448 SparseMatrix result (nr, nc, 1.0);
449 449
450 for (octave_idx_type j = 0; j < nc; j++) 450 for (octave_idx_type j = 0; j < nc; j++)
451 { 451 {
452 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 452 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
453 { 453 {
454 octave_quit (); 454 octave_quit ();
455 result.xelem(a.ridx(i), j) = std::pow (a.data(i), 455 result.xelem (a.ridx (i), j) = std::pow (a.data (i),
456 b (a.ridx(i), j)); 456 b(a.ridx (i), j));
457 } 457 }
458 } 458 }
459 result.maybe_compress (true); 459 result.maybe_compress (true);
460 retval = result; 460 retval = result;
461 } 461 }
505 { 505 {
506 gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc); 506 gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc);
507 return octave_value (); 507 return octave_value ();
508 } 508 }
509 509
510 SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0)); 510 SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0));
511 for (octave_idx_type j = 0; j < nc; j++) 511 for (octave_idx_type j = 0; j < nc; j++)
512 { 512 {
513 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 513 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
514 { 514 {
515 octave_quit (); 515 octave_quit ();
516 result.xelem(a.ridx(i), j) = std::pow (a.data(i), b (a.ridx(i), j)); 516 result.xelem (a.ridx(i), j) = std::pow (a.data (i), b(a.ridx (i), j));
517 } 517 }
518 } 518 }
519 519
520 result.maybe_compress (true); 520 result.maybe_compress (true);
521 521
579 ComplexMatrix result (nr, nc, Complex (std::pow (0.0, b))); 579 ComplexMatrix result (nr, nc, Complex (std::pow (0.0, b)));
580 580
581 if (xisint (b)) 581 if (xisint (b))
582 { 582 {
583 for (octave_idx_type j = 0; j < nc; j++) 583 for (octave_idx_type j = 0; j < nc; j++)
584 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 584 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
585 { 585 {
586 octave_quit (); 586 octave_quit ();
587 result (a.ridx(i), j) = 587 result (a.ridx (i), j) =
588 std::pow (a.data (i), static_cast<int> (b)); 588 std::pow (a.data (i), static_cast<int> (b));
589 } 589 }
590 } 590 }
591 else 591 else
592 { 592 {
593 for (octave_idx_type j = 0; j < nc; j++) 593 for (octave_idx_type j = 0; j < nc; j++)
594 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 594 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
595 { 595 {
596 octave_quit (); 596 octave_quit ();
597 result (a.ridx(i), j) = std::pow (a.data (i), b); 597 result (a.ridx (i), j) = std::pow (a.data (i), b);
598 } 598 }
599 } 599 }
600 600
601 retval = result; 601 retval = result;
602 } 602 }
645 { 645 {
646 gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc); 646 gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc);
647 return octave_value (); 647 return octave_value ();
648 } 648 }
649 649
650 SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0)); 650 SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0));
651 for (octave_idx_type j = 0; j < nc; j++) 651 for (octave_idx_type j = 0; j < nc; j++)
652 { 652 {
653 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 653 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
654 { 654 {
655 octave_quit (); 655 octave_quit ();
656 double btmp = b (a.ridx(i), j); 656 double btmp = b(a.ridx (i), j);
657 Complex tmp; 657 Complex tmp;
658 658
659 if (xisint (btmp)) 659 if (xisint (btmp))
660 result.xelem(a.ridx(i), j) = std::pow (a.data (i), 660 result.xelem (a.ridx (i), j) = std::pow (a.data (i),
661 static_cast<int> (btmp)); 661 static_cast<int> (btmp));
662 else 662 else
663 result.xelem(a.ridx(i), j) = std::pow (a.data (i), btmp); 663 result.xelem (a.ridx (i), j) = std::pow (a.data (i), btmp);
664 } 664 }
665 } 665 }
666 666
667 result.maybe_compress (true); 667 result.maybe_compress (true);
668 668
713 { 713 {
714 gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc); 714 gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc);
715 return octave_value (); 715 return octave_value ();
716 } 716 }
717 717
718 SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0)); 718 SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0));
719 for (octave_idx_type j = 0; j < nc; j++) 719 for (octave_idx_type j = 0; j < nc; j++)
720 { 720 {
721 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 721 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
722 { 722 {
723 octave_quit (); 723 octave_quit ();
724 result.xelem(a.ridx(i), j) = std::pow (a.data (i), b (a.ridx(i), j)); 724 result.xelem (a.ridx (i), j) = std::pow (a.data (i), b(a.ridx (i), j));
725 } 725 }
726 } 726 }
727 result.maybe_compress (true); 727 result.maybe_compress (true);
728 728
729 return result; 729 return result;