Mercurial > hg > octave-lyh
comparison liboctave/RowVector.cc @ 161:21b599370728
[project @ 1993-10-16 17:20:32 by jwe]
author | jwe |
---|---|
date | Sat, 16 Oct 1993 17:21:25 +0000 |
parents | d2d19bd98f60 |
children | 1a48a1b91489 |
comparison
equal
deleted
inserted
replaced
160:be50d501b2a7 | 161:21b599370728 |
---|---|
239 { | 239 { |
240 return RowVector (divide (data, len, s), len); | 240 return RowVector (divide (data, len, s), len); |
241 } | 241 } |
242 | 242 |
243 ComplexRowVector | 243 ComplexRowVector |
244 RowVector::operator + (Complex s) const | 244 RowVector::operator + (const Complex& s) const |
245 { | 245 { |
246 return ComplexRowVector (add (data, len, s), len); | 246 return ComplexRowVector (add (data, len, s), len); |
247 } | 247 } |
248 | 248 |
249 ComplexRowVector | 249 ComplexRowVector |
250 RowVector::operator - (Complex s) const | 250 RowVector::operator - (const Complex& s) const |
251 { | 251 { |
252 return ComplexRowVector (subtract (data, len, s), len); | 252 return ComplexRowVector (subtract (data, len, s), len); |
253 } | 253 } |
254 | 254 |
255 ComplexRowVector | 255 ComplexRowVector |
256 RowVector::operator * (Complex s) const | 256 RowVector::operator * (const Complex& s) const |
257 { | 257 { |
258 return ComplexRowVector (multiply (data, len, s), len); | 258 return ComplexRowVector (multiply (data, len, s), len); |
259 } | 259 } |
260 | 260 |
261 ComplexRowVector | 261 ComplexRowVector |
262 RowVector::operator / (Complex s) const | 262 RowVector::operator / (const Complex& s) const |
263 { | 263 { |
264 return ComplexRowVector (divide (data, len, s), len); | 264 return ComplexRowVector (divide (data, len, s), len); |
265 } | 265 } |
266 | 266 |
267 // scalar by row vector -> row vector operations | 267 // scalar by row vector -> row vector operations |
564 } | 564 } |
565 else | 565 else |
566 data = (Complex *) NULL; | 566 data = (Complex *) NULL; |
567 } | 567 } |
568 | 568 |
569 ComplexRowVector::ComplexRowVector (int n, Complex val) | 569 ComplexRowVector::ComplexRowVector (int n, const Complex& val) |
570 { | 570 { |
571 if (n < 0) | 571 if (n < 0) |
572 FAIL; | 572 FAIL; |
573 | 573 |
574 len = n; | 574 len = n; |
610 len = 1; | 610 len = 1; |
611 data = new Complex [1]; | 611 data = new Complex [1]; |
612 data[0] = a; | 612 data[0] = a; |
613 } | 613 } |
614 | 614 |
615 ComplexRowVector::ComplexRowVector (Complex a) | 615 ComplexRowVector::ComplexRowVector (const Complex& a) |
616 { | 616 { |
617 len = 1; | 617 len = 1; |
618 data = new Complex [1]; | 618 data = new Complex [1]; |
619 data[0] = Complex (a); | 619 data[0] = Complex (a); |
620 } | 620 } |
686 | 686 |
687 return *this; | 687 return *this; |
688 } | 688 } |
689 | 689 |
690 ComplexRowVector& | 690 ComplexRowVector& |
691 ComplexRowVector::resize (int n, Complex val) | 691 ComplexRowVector::resize (int n, const Complex& val) |
692 { | 692 { |
693 int old_len = len; | 693 int old_len = len; |
694 resize (n); | 694 resize (n); |
695 for (int i = old_len; i < len; i++) | 695 for (int i = old_len; i < len; i++) |
696 data[i] = val; | 696 data[i] = val; |
747 copy (data, len, val); | 747 copy (data, len, val); |
748 return *this; | 748 return *this; |
749 } | 749 } |
750 | 750 |
751 ComplexRowVector& | 751 ComplexRowVector& |
752 ComplexRowVector::fill (Complex val) | 752 ComplexRowVector::fill (const Complex& val) |
753 { | 753 { |
754 if (len > 0) | 754 if (len > 0) |
755 copy (data, len, val); | 755 copy (data, len, val); |
756 return *this; | 756 return *this; |
757 } | 757 } |
769 | 769 |
770 return *this; | 770 return *this; |
771 } | 771 } |
772 | 772 |
773 ComplexRowVector& | 773 ComplexRowVector& |
774 ComplexRowVector::fill (Complex val, int c1, int c2) | 774 ComplexRowVector::fill (const Complex& val, int c1, int c2) |
775 { | 775 { |
776 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) | 776 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) |
777 FAIL; | 777 FAIL; |
778 | 778 |
779 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } | 779 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } |
885 { | 885 { |
886 return ComplexRowVector (divide (data, len, s), len); | 886 return ComplexRowVector (divide (data, len, s), len); |
887 } | 887 } |
888 | 888 |
889 ComplexRowVector | 889 ComplexRowVector |
890 ComplexRowVector::operator + (Complex s) const | 890 ComplexRowVector::operator + (const Complex& s) const |
891 { | 891 { |
892 return ComplexRowVector (add (data, len, s), len); | 892 return ComplexRowVector (add (data, len, s), len); |
893 } | 893 } |
894 | 894 |
895 ComplexRowVector | 895 ComplexRowVector |
896 ComplexRowVector::operator - (Complex s) const | 896 ComplexRowVector::operator - (const Complex& s) const |
897 { | 897 { |
898 return ComplexRowVector (subtract (data, len, s), len); | 898 return ComplexRowVector (subtract (data, len, s), len); |
899 } | 899 } |
900 | 900 |
901 ComplexRowVector | 901 ComplexRowVector |
902 ComplexRowVector::operator * (Complex s) const | 902 ComplexRowVector::operator * (const Complex& s) const |
903 { | 903 { |
904 return ComplexRowVector (multiply (data, len, s), len); | 904 return ComplexRowVector (multiply (data, len, s), len); |
905 } | 905 } |
906 | 906 |
907 ComplexRowVector | 907 ComplexRowVector |
908 ComplexRowVector::operator / (Complex s) const | 908 ComplexRowVector::operator / (const Complex& s) const |
909 { | 909 { |
910 return ComplexRowVector (divide (data, len, s), len); | 910 return ComplexRowVector (divide (data, len, s), len); |
911 } | 911 } |
912 | 912 |
913 // scalar by row vector -> row vector operations | 913 // scalar by row vector -> row vector operations |
935 { | 935 { |
936 return ComplexRowVector (divide (s, a.data, a.len), a.len); | 936 return ComplexRowVector (divide (s, a.data, a.len), a.len); |
937 } | 937 } |
938 | 938 |
939 ComplexRowVector | 939 ComplexRowVector |
940 operator + (Complex s, const ComplexRowVector& a) | 940 operator + (const Complex& s, const ComplexRowVector& a) |
941 { | 941 { |
942 return ComplexRowVector (add (a.data, a.len, s), a.len); | 942 return ComplexRowVector (add (a.data, a.len, s), a.len); |
943 } | 943 } |
944 | 944 |
945 ComplexRowVector | 945 ComplexRowVector |
946 operator - (Complex s, const ComplexRowVector& a) | 946 operator - (const Complex& s, const ComplexRowVector& a) |
947 { | 947 { |
948 return ComplexRowVector (subtract (s, a.data, a.len), a.len); | 948 return ComplexRowVector (subtract (s, a.data, a.len), a.len); |
949 } | 949 } |
950 | 950 |
951 ComplexRowVector | 951 ComplexRowVector |
952 operator * (Complex s, const ComplexRowVector& a) | 952 operator * (const Complex& s, const ComplexRowVector& a) |
953 { | 953 { |
954 return ComplexRowVector (multiply (a.data, a.len, s), a.len); | 954 return ComplexRowVector (multiply (a.data, a.len, s), a.len); |
955 } | 955 } |
956 | 956 |
957 ComplexRowVector | 957 ComplexRowVector |
958 operator / (Complex s, const ComplexRowVector& a) | 958 operator / (const Complex& s, const ComplexRowVector& a) |
959 { | 959 { |
960 return ComplexRowVector (divide (s, a.data, a.len), a.len); | 960 return ComplexRowVector (divide (s, a.data, a.len), a.len); |
961 } | 961 } |
962 | 962 |
963 // row vector by column vector -> scalar | 963 // row vector by column vector -> scalar |