comparison liboctave/CDiagMatrix.cc @ 2827:2387b8694c75

[project @ 1997-03-25 23:41:28 by jwe] CDiagMatrix.h
author jwe
date Tue, 25 Mar 1997 23:41:28 +0000
parents 4fc9fd1424a9
children 8b262e771614
comparison
equal deleted inserted replaced
2826:d6867cd782c7 2827:2387b8694c75
577 577
578 return c; 578 return c;
579 } 579 }
580 580
581 ComplexDiagMatrix 581 ComplexDiagMatrix
582 operator + (const ComplexDiagMatrix& m, const DiagMatrix& a)
583 {
584 int nr = m.rows ();
585 int nc = m.cols ();
586
587 int a_nr = a.rows ();
588 int a_nc = a.cols ();
589
590 if (nr != a_nr || nc != a_nc)
591 {
592 gripe_nonconformant ("operator +", nr, nc, a_nr, a_nc);
593 return ComplexDiagMatrix ();
594 }
595
596 if (nr == 0 || nc == 0)
597 return ComplexDiagMatrix (nr, nc);
598
599 return ComplexDiagMatrix (add (m.data (), a.data (), m.length ()), nr, nc);
600 }
601
602 ComplexDiagMatrix
603 operator - (const ComplexDiagMatrix& m, const DiagMatrix& a)
604 {
605 int nr = m.rows ();
606 int nc = m.cols ();
607
608 int a_nr = a.rows ();
609 int a_nc = a.cols ();
610
611 if (nr != a_nr || nc != a_nc)
612 {
613 gripe_nonconformant ("operator -", nr, nc, a_nr, a_nc);
614 return ComplexDiagMatrix ();
615 }
616
617 if (nr == 0 || nc == 0)
618 return ComplexDiagMatrix (nr, nc);
619
620 return ComplexDiagMatrix (subtract (m.data (), a.data (), m.length ()),
621 nr, nc);
622 }
623
624 ComplexDiagMatrix
625 operator * (const ComplexDiagMatrix& a, const DiagMatrix& b) 582 operator * (const ComplexDiagMatrix& a, const DiagMatrix& b)
626 { 583 {
627 int nr_a = a.rows (); 584 int nr_a = a.rows ();
628 int nc_a = a.cols (); 585 int nc_a = a.cols ();
629 586
660 617
661 return c; 618 return c;
662 } 619 }
663 620
664 ComplexDiagMatrix 621 ComplexDiagMatrix
665 operator + (const DiagMatrix& m, const ComplexDiagMatrix& a)
666 {
667 int nr = m.rows ();
668 int nc = m.cols ();
669
670 int a_nr = a.rows ();
671 int a_nc = a.cols ();
672
673 if (nr != a_nr || nc != a_nc)
674 {
675 gripe_nonconformant ("operator +", nr, nc, a_nr, a_nc);
676 return ComplexDiagMatrix ();
677 }
678
679 if (nc == 0 || nr == 0)
680 return ComplexDiagMatrix (nr, nc);
681
682 return ComplexDiagMatrix (add (m.data (), a.data (), m.length ()), nr, nc);
683 }
684
685 ComplexDiagMatrix
686 operator - (const DiagMatrix& m, const ComplexDiagMatrix& a)
687 {
688 int nr = m.rows ();
689 int nc = m.cols ();
690
691 int a_nr = a.rows ();
692 int a_nc = a.cols ();
693
694 if (nr != a_nr || nc != a_nc)
695 {
696 gripe_nonconformant ("operator -", nr, nc, a_nr, a_nc);
697 return ComplexDiagMatrix ();
698 }
699
700 if (nc == 0 || nr == 0)
701 return ComplexDiagMatrix (nr, nc);
702
703 return ComplexDiagMatrix (subtract (m.data (), a.data (), m.length ()),
704 nr, nc);
705 }
706
707 ComplexDiagMatrix
708 operator * (const DiagMatrix& a, const ComplexDiagMatrix& b) 622 operator * (const DiagMatrix& a, const ComplexDiagMatrix& b)
709 { 623 {
710 int nr_a = a.rows (); 624 int nr_a = a.rows ();
711 int nc_a = a.cols (); 625 int nc_a = a.cols ();
712 626
740 else 654 else
741 c.elem (i, i) = a_element * b_element; 655 c.elem (i, i) = a_element * b_element;
742 } 656 }
743 657
744 return c; 658 return c;
745 }
746
747 ComplexDiagMatrix
748 product (const ComplexDiagMatrix& m, const DiagMatrix& a)
749 {
750 int nr = m.rows ();
751 int nc = m.cols ();
752
753 int a_nr = a.rows ();
754 int a_nc = a.cols ();
755
756 if (nr != a_nr || nc != a_nc)
757 {
758 gripe_nonconformant ("product", nr, nc, a_nr, a_nc);
759 return ComplexDiagMatrix ();
760 }
761
762 if (nr == 0 || nc == 0)
763 return ComplexDiagMatrix (nr, nc);
764
765 return ComplexDiagMatrix (multiply (m.data (), a.data (), m.length ()),
766 nr, nc);
767 }
768
769 ComplexDiagMatrix
770 product (const DiagMatrix& m, const ComplexDiagMatrix& a)
771 {
772 int nr = m.rows ();
773 int nc = m.cols ();
774
775 int a_nr = a.rows ();
776 int a_nc = a.cols ();
777
778 if (nr != a_nr || nc != a_nc)
779 {
780 gripe_nonconformant ("product", nr, nc, a_nr, a_nc);
781 return ComplexDiagMatrix ();
782 }
783
784 if (nc == 0 || nr == 0)
785 return ComplexDiagMatrix (nr, nc);
786
787 return ComplexDiagMatrix (multiply (m.data (), a.data (), m.length ()),
788 nr, nc);
789 } 659 }
790 660
791 // other operations 661 // other operations
792 662
793 ComplexColumnVector 663 ComplexColumnVector