comparison liboctave/dRowVector.cc @ 2386:4fc9fd1424a9

[project @ 1996-10-12 18:31:34 by jwe]
author jwe
date Sat, 12 Oct 1996 18:38:10 +0000
parents 1b57120c997b
children a5a300c61159
comparison
equal deleted inserted replaced
2385:170053c0f75e 2386:4fc9fd1424a9
51 const double*, const int&); 51 const double*, const int&);
52 } 52 }
53 53
54 // Row Vector class. 54 // Row Vector class.
55 55
56 int 56 bool
57 RowVector::operator == (const RowVector& a) const 57 RowVector::operator == (const RowVector& a) const
58 { 58 {
59 int len = length (); 59 int len = length ();
60 if (len != a.length ()) 60 if (len != a.length ())
61 return 0; 61 return 0;
62 return equal (data (), a.data (), len); 62 return equal (data (), a.data (), len);
63 } 63 }
64 64
65 int 65 bool
66 RowVector::operator != (const RowVector& a) const 66 RowVector::operator != (const RowVector& a) const
67 { 67 {
68 return !(*this == a); 68 return !(*this == a);
69 } 69 }
70 70
168 168
169 RowVector& 169 RowVector&
170 RowVector::operator += (const RowVector& a) 170 RowVector::operator += (const RowVector& a)
171 { 171 {
172 int len = length (); 172 int len = length ();
173 if (len != a.length ()) 173
174 { 174 int a_len = a.length ();
175 (*current_liboctave_error_handler) 175
176 ("nonconformant vector += operation attempted"); 176 if (len != a_len)
177 {
178 gripe_nonconformant ("operator +=", len, a_len);
177 return *this; 179 return *this;
178 } 180 }
179 181
180 if (len == 0) 182 if (len == 0)
181 return *this; 183 return *this;
188 190
189 RowVector& 191 RowVector&
190 RowVector::operator -= (const RowVector& a) 192 RowVector::operator -= (const RowVector& a)
191 { 193 {
192 int len = length (); 194 int len = length ();
193 if (len != a.length ()) 195
194 { 196 int a_len = a.length ();
195 (*current_liboctave_error_handler) 197
196 ("nonconformant vector -= operation attempted"); 198 if (len != a_len)
199 {
200 gripe_nonconformant ("operator -=", len, a_len);
197 return *this; 201 return *this;
198 } 202 }
199 203
200 if (len == 0) 204 if (len == 0)
201 return *this; 205 return *this;
213 { 217 {
214 RowVector retval; 218 RowVector retval;
215 219
216 int len = v.length (); 220 int len = v.length ();
217 221
218 if (a.rows () != len) 222 int a_nr = a.rows ();
219 (*current_liboctave_error_handler) 223 int a_nc = a.cols ();
220 ("nonconformant vector multiplication attempted"); 224
225 if (a_nr != len)
226 gripe_nonconformant ("operator *", 1, len, a_nr, a_nc);
221 else 227 else
222 { 228 {
223 int a_nr = a.rows (); 229 int a_nr = a.rows ();
224 int a_nc = a.cols (); 230 int a_nc = a.cols ();
225 231
364 { 370 {
365 double retval = 0.0; 371 double retval = 0.0;
366 372
367 int len = v.length (); 373 int len = v.length ();
368 374
369 if (len != a.length ()) 375 int a_len = a.length ();
370 (*current_liboctave_error_handler) 376
371 ("nonconformant vector multiplication attempted"); 377 if (len != a_len)
378 gripe_nonconformant ("operator *", len, a_len);
372 else if (len != 0) 379 else if (len != 0)
373 retval = F77_FCN (ddot, DDOT) (len, v.data (), 1, a.data (), 1); 380 retval = F77_FCN (ddot, DDOT) (len, v.data (), 1, a.data (), 1);
374 381
375 return retval; 382 return retval;
376 } 383 }