Mercurial > forge
comparison main/fixed/src/fixedColVector.cc @ 9481:d84d2fea3c90 octave-forge
Re-enable compilation of fixed package
author | jordigh |
---|---|
date | Wed, 22 Feb 2012 22:07:33 +0000 |
parents | f8d77845533f |
children |
comparison
equal
deleted
inserted
replaced
9480:954f2f00d782 | 9481:d84d2fea3c90 |
---|---|
39 | 39 |
40 // Fixed Point Column Vector class | 40 // Fixed Point Column Vector class |
41 | 41 |
42 FixedColumnVector::FixedColumnVector (const MArray<int> &is, | 42 FixedColumnVector::FixedColumnVector (const MArray<int> &is, |
43 const MArray<int> &ds) | 43 const MArray<int> &ds) |
44 : MArray<FixedPoint> (is.length()) | 44 : MArray<FixedPoint> (dim_vector (is.length(), 1)) |
45 { | 45 { |
46 if (length() != ds.length()) { | 46 if (length() != ds.length()) { |
47 (*current_liboctave_error_handler) ("vector size mismatch"); | 47 (*current_liboctave_error_handler) ("vector size mismatch"); |
48 return; | 48 return; |
49 } | 49 } |
52 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i)); | 52 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i)); |
53 } | 53 } |
54 | 54 |
55 FixedColumnVector::FixedColumnVector (const ColumnVector &is, | 55 FixedColumnVector::FixedColumnVector (const ColumnVector &is, |
56 const ColumnVector &ds) | 56 const ColumnVector &ds) |
57 : MArray<FixedPoint> (is.length()) | 57 : MArray<FixedPoint> (dim_vector (is.length(), 1)) |
58 { | 58 { |
59 if (length() != ds.length()) { | 59 if (length() != ds.length()) { |
60 (*current_liboctave_error_handler) ("vector size mismatch"); | 60 (*current_liboctave_error_handler) ("vector size mismatch"); |
61 return; | 61 return; |
62 } | 62 } |
64 for (int i = 0; i < length (); i++) | 64 for (int i = 0; i < length (); i++) |
65 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i)); | 65 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i)); |
66 } | 66 } |
67 | 67 |
68 FixedColumnVector::FixedColumnVector (const MArray<int> &is, | 68 FixedColumnVector::FixedColumnVector (const MArray<int> &is, |
69 const MArray<int> &ds, const FixedColumnVector& a) | 69 const MArray<int> &ds, |
70 : MArray<FixedPoint> (a.length()) | 70 const FixedColumnVector& a) |
71 : MArray<FixedPoint> (dim_vector (a.length(), 1)) | |
71 { | 72 { |
72 if ((length() != is.length()) || (length() != ds.length())) { | 73 if ((length() != is.length()) || (length() != ds.length())) { |
73 (*current_liboctave_error_handler) ("vector size mismatch"); | 74 (*current_liboctave_error_handler) ("vector size mismatch"); |
74 return; | 75 return; |
75 } | 76 } |
78 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), | 79 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
79 a.elem (i)); | 80 a.elem (i)); |
80 } | 81 } |
81 | 82 |
82 FixedColumnVector::FixedColumnVector (const ColumnVector &is, | 83 FixedColumnVector::FixedColumnVector (const ColumnVector &is, |
83 const ColumnVector &ds, const FixedColumnVector& a) | 84 const ColumnVector &ds, |
84 : MArray<FixedPoint> (a.length()) | 85 const FixedColumnVector& a) |
86 : MArray<FixedPoint> (dim_vector (a.length(), 1)) | |
85 { | 87 { |
86 if ((length() != is.length()) || (length() != ds.length())) { | 88 if ((length() != is.length()) || (length() != ds.length())) { |
87 (*current_liboctave_error_handler) ("vector size mismatch"); | 89 (*current_liboctave_error_handler) ("vector size mismatch"); |
88 return; | 90 return; |
89 } | 91 } |
93 a.elem (i)); | 95 a.elem (i)); |
94 } | 96 } |
95 | 97 |
96 FixedColumnVector::FixedColumnVector (unsigned int is, unsigned int ds, | 98 FixedColumnVector::FixedColumnVector (unsigned int is, unsigned int ds, |
97 const FixedColumnVector& a) | 99 const FixedColumnVector& a) |
98 : MArray<FixedPoint> (a.length()) | 100 : MArray<FixedPoint> (dim_vector (a.length(), 1)) |
99 { | 101 { |
100 for (int i = 0; i < length (); i++) | 102 for (int i = 0; i < length (); i++) |
101 elem (i) = FixedPoint(is, ds, a.elem (i)); | 103 elem (i) = FixedPoint(is, ds, a.elem (i)); |
102 } | 104 } |
103 | 105 |
104 FixedColumnVector::FixedColumnVector (const MArray<int> &is, | 106 FixedColumnVector::FixedColumnVector (const MArray<int> &is, |
105 const MArray<int> &ds, const ColumnVector& a) | 107 const MArray<int> &ds, |
106 : MArray<FixedPoint> (a.length()) | 108 const ColumnVector& a) |
109 : MArray<FixedPoint> (dim_vector (a.length(), 1)) | |
107 { | 110 { |
108 if ((length() != is.length()) || (length() != ds.length())) { | 111 if ((length() != is.length()) || (length() != ds.length())) { |
109 (*current_liboctave_error_handler) ("vector size mismatch"); | 112 (*current_liboctave_error_handler) ("vector size mismatch"); |
110 return; | 113 return; |
111 } | 114 } |
114 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), | 117 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
115 a.elem (i)); | 118 a.elem (i)); |
116 } | 119 } |
117 | 120 |
118 FixedColumnVector::FixedColumnVector (const ColumnVector &is, | 121 FixedColumnVector::FixedColumnVector (const ColumnVector &is, |
119 const ColumnVector &ds, const ColumnVector& a) | 122 const ColumnVector &ds, |
120 : MArray<FixedPoint> (a.length()) | 123 const ColumnVector& a) |
124 : MArray<FixedPoint> (dim_vector (a.length(), 1)) | |
121 { | 125 { |
122 if ((length() != is.length()) || (length() != ds.length())) { | 126 if ((length() != is.length()) || (length() != ds.length())) { |
123 (*current_liboctave_error_handler) ("vector size mismatch"); | 127 (*current_liboctave_error_handler) ("vector size mismatch"); |
124 return; | 128 return; |
125 } | 129 } |
129 a.elem (i)); | 133 a.elem (i)); |
130 } | 134 } |
131 | 135 |
132 FixedColumnVector::FixedColumnVector (unsigned int is, unsigned int ds, | 136 FixedColumnVector::FixedColumnVector (unsigned int is, unsigned int ds, |
133 const ColumnVector& a) | 137 const ColumnVector& a) |
134 : MArray<FixedPoint> (a.length()) | 138 : MArray<FixedPoint> (dim_vector (a.length(), 1)) |
135 { | 139 { |
136 for (int i = 0; i < length (); i++) | 140 for (int i = 0; i < length (); i++) |
137 elem (i) = FixedPoint(is, ds, a.elem (i)); | 141 elem (i) = FixedPoint(is, ds, a.elem (i)); |
138 } | 142 } |
139 | 143 |
140 FixedColumnVector::FixedColumnVector (const MArray<int> &is, | 144 FixedColumnVector::FixedColumnVector (const MArray<int> &is, |
141 const MArray<int> &ds, const ColumnVector& a, | 145 const MArray<int> &ds, |
146 const ColumnVector& a, | |
142 const ColumnVector& b) | 147 const ColumnVector& b) |
143 : MArray<FixedPoint> (a.length()) | 148 : MArray<FixedPoint> (dim_vector (a.length(), 1)) |
144 { | 149 { |
145 if ((length() != b.length()) || (length() != is.length()) || | 150 if ((length() != b.length()) || (length() != is.length()) || |
146 (length() != ds.length())) { | 151 (length() != ds.length())) { |
147 (*current_liboctave_error_handler) ("vector size mismatch"); | 152 (*current_liboctave_error_handler) ("vector size mismatch"); |
148 return; | 153 return; |
153 (unsigned int)a.elem (i), | 158 (unsigned int)a.elem (i), |
154 (unsigned int)b.elem (i)); | 159 (unsigned int)b.elem (i)); |
155 } | 160 } |
156 | 161 |
157 FixedColumnVector::FixedColumnVector (const ColumnVector &is, | 162 FixedColumnVector::FixedColumnVector (const ColumnVector &is, |
158 const ColumnVector &ds, const ColumnVector& a, | 163 const ColumnVector &ds, |
164 const ColumnVector& a, | |
159 const ColumnVector& b) | 165 const ColumnVector& b) |
160 : MArray<FixedPoint> (a.length()) | 166 : MArray<FixedPoint> (dim_vector (a.length(), 1)) |
161 { | 167 { |
162 if ((length() != b.length()) || (length() != is.length()) || | 168 if ((length() != b.length()) || (length() != is.length()) || |
163 (length() != ds.length())) { | 169 (length() != ds.length())) { |
164 (*current_liboctave_error_handler) ("vector size mismatch"); | 170 (*current_liboctave_error_handler) ("vector size mismatch"); |
165 return; | 171 return; |
169 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), | 175 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
170 (unsigned int)a.elem (i), | 176 (unsigned int)a.elem (i), |
171 (unsigned int)b.elem (i)); | 177 (unsigned int)b.elem (i)); |
172 } | 178 } |
173 | 179 |
174 FixedColumnVector::FixedColumnVector (unsigned int is, unsigned int ds, | 180 FixedColumnVector::FixedColumnVector (unsigned int is, |
175 const ColumnVector& a, const ColumnVector& b) | 181 unsigned int ds, |
176 : MArray<FixedPoint> (a.length()) | 182 const ColumnVector& a, |
183 const ColumnVector& b) | |
184 : MArray<FixedPoint> (dim_vector (a.length(), 1)) | |
177 { | 185 { |
178 if (length() != b.length()) { | 186 if (length() != b.length()) { |
179 (*current_liboctave_error_handler) ("vector size mismatch"); | 187 (*current_liboctave_error_handler) ("vector size mismatch"); |
180 return; | 188 return; |
181 } | 189 } |
444 | 452 |
445 if (nc != a_len) | 453 if (nc != a_len) |
446 gripe_nonconformant ("operator *", nr, nc, a_len, 1); | 454 gripe_nonconformant ("operator *", nr, nc, a_len, 1); |
447 else | 455 else |
448 { | 456 { |
449 retval.resize (nr, FixedPoint()); | 457 retval.resize (nr, FixedPoint()); |
450 if (nr != 0 && nc != 0) | 458 if (nr != 0 && nc != 0) |
451 for (int i = 0; i < nc; i++) | 459 for (int i = 0; i < nc; i++) |
452 for (int j = 0; j < nr; j++) | 460 for (int j = 0; j < nr; j++) |
453 retval.elem (j) += a.elem(i) * m.elem(j,i); | 461 retval.elem (j) += a.elem(i) * m.elem(j,i); |
454 } | 462 } |
549 int a_len = a.length (); | 557 int a_len = a.length (); |
550 int b_len = b.length (); | 558 int b_len = b.length (); |
551 | 559 |
552 if (a_len == 1) | 560 if (a_len == 1) |
553 { | 561 { |
554 retval.resize(b_len); | 562 retval.resize(b_len); |
555 FixedPoint ad = a(0); | 563 FixedPoint ad = a(0); |
556 for (int i = 0; i < b_len; i++) | 564 for (int i = 0; i < b_len; i++) |
557 retval(i) = pow(ad, b(i)); | 565 retval(i) = pow(ad, b(i)); |
558 } | 566 } |
559 else if (b_len == 1) | 567 else if (b_len == 1) |
560 { | 568 { |
561 retval.resize(a_len); | 569 retval.resize(a_len); |
562 FixedPoint bd = b(0); | 570 FixedPoint bd = b(0); |
563 for (int i = 0; i < a_len; i++) | 571 for (int i = 0; i < a_len; i++) |
564 retval(i) = pow(a(i), bd); | 572 retval(i) = pow(a(i), bd); |
565 } | 573 } |
566 else if (a_len == b_len) | 574 else if (a_len == b_len) |
567 { | 575 { |
568 retval.resize(a_len); | 576 retval.resize(a_len, 1); |
569 for (int i = 0; i < a_len; i++) | 577 for (int i = 0; i < a_len; i++) |
570 retval(i) = pow(a(i), b(i)); | 578 retval(i) = pow(a(i), b(i)); |
571 } | 579 } |
572 else | 580 else |
573 gripe_nonconformant ("operator .^", a_len, b_len); | 581 gripe_nonconformant ("operator .^", a_len, b_len); |